mirror of
https://github.com/wassname/ray.git
synced 2026-07-12 18:32:07 +08:00
[Streaming] Streaming filter transform (#6816)
* add filter transform * lint * add new line
This commit is contained in:
+3
-2
@@ -44,6 +44,7 @@ public class WordCountTest extends BaseUnitTest implements Serializable {
|
||||
collector.collect(new WordAndCount(record, 1));
|
||||
}
|
||||
})
|
||||
.filter(pair -> !pair.word.contains("world"))
|
||||
.keyBy(pair -> pair.word)
|
||||
.reduce((ReduceFunction<WordAndCount>) (oldValue, newValue) ->
|
||||
new WordAndCount(oldValue.word, oldValue.count + newValue.count))
|
||||
@@ -53,14 +54,14 @@ public class WordCountTest extends BaseUnitTest implements Serializable {
|
||||
streamingContext.execute("testWordCount");
|
||||
|
||||
// Sleep until the count for every word is computed.
|
||||
while (wordCount.size() < 3) {
|
||||
while (wordCount.size() < 2) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.warn("Got an exception while sleeping.", e);
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(wordCount, ImmutableMap.of("eagle", 3, "hello", 1, "world", 1));
|
||||
Assert.assertEquals(wordCount, ImmutableMap.of("eagle", 3, "hello", 1));
|
||||
}
|
||||
|
||||
private static class WordAndCount implements Serializable {
|
||||
|
||||
Reference in New Issue
Block a user