public class StreamCollector
extends org.junit.rules.ExternalResource
DataStream
.
public class DataStreamTest {
{@literal @}Rule
public StreamCollector collector = new StreamCollector();
public void test() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<Integer> stream = env.fromElements(1, 2, 3);
CompletableFuture<Collection<Integer>> results = collector.collect(stream);
Assert.assertThat(results.get(), hasItems(1, 2, 3));
}
}
Note: The stream collector assumes: 1) The stream is bounded. 2) All elements will fit in memory. 3) All tasks run within the same JVM.
Constructor and Description |
---|
StreamCollector() |
Modifier and Type | Method and Description |
---|---|
protected void |
after() |
protected void |
before() |
<IN> CompletableFuture<Collection<IN>> |
collect(DataStream<IN> stream) |
protected void before()
before
in class org.junit.rules.ExternalResource
public <IN> CompletableFuture<Collection<IN>> collect(DataStream<IN> stream)
protected void after()
after
in class org.junit.rules.ExternalResource
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.