Class DataStreamUtils
- java.lang.Object
-
- org.apache.flink.streaming.api.datastream.DataStreamUtils
-
@Experimental public final class DataStreamUtils extends Object
A collection of utilities forDataStreams.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <OUT> Iterator<OUT>collect(DataStream<OUT> stream)Deprecated.Please useDataStream.executeAndCollect().static <OUT> Iterator<OUT>collect(DataStream<OUT> stream, String executionJobName)Deprecated.Please useDataStream.executeAndCollect().static <E> List<E>collectBoundedStream(DataStream<E> stream, String jobName)Deprecated.Please useDataStream.executeAndCollect().static <E> List<E>collectRecordsFromUnboundedStream(ClientAndIterator<E> client, int numElements)Deprecated.Please useDataStream.executeAndCollect().static <E> List<E>collectUnboundedStream(DataStream<E> stream, int numElements, String jobName)Deprecated.Please useDataStream.executeAndCollect().static <OUT> ClientAndIterator<OUT>collectWithClient(DataStream<OUT> stream, String jobExecutionName)Deprecated.Please useDataStream.executeAndCollect().static <T,K>
KeyedStream<T,K>reinterpretAsKeyedStream(DataStream<T> stream, org.apache.flink.api.java.functions.KeySelector<T,K> keySelector)static <T,K>
KeyedStream<T,K>reinterpretAsKeyedStream(DataStream<T> stream, org.apache.flink.api.java.functions.KeySelector<T,K> keySelector, org.apache.flink.api.common.typeinfo.TypeInformation<K> typeInfo)
-
-
-
Method Detail
-
collect
@Deprecated public static <OUT> Iterator<OUT> collect(DataStream<OUT> stream)
Deprecated.Please useDataStream.executeAndCollect().Triggers the distributed execution of the streaming dataflow and returns an iterator over the elements of the given DataStream.The DataStream application is executed in the regular distributed manner on the target environment, and the events from the stream are polled back to this application process and thread through Flink's REST API.
-
collect
@Deprecated public static <OUT> Iterator<OUT> collect(DataStream<OUT> stream, String executionJobName)
Deprecated.Please useDataStream.executeAndCollect().Triggers the distributed execution of the streaming dataflow and returns an iterator over the elements of the given DataStream.The DataStream application is executed in the regular distributed manner on the target environment, and the events from the stream are polled back to this application process and thread through Flink's REST API.
-
collectWithClient
@Deprecated public static <OUT> ClientAndIterator<OUT> collectWithClient(DataStream<OUT> stream, String jobExecutionName) throws Exception
Deprecated.Please useDataStream.executeAndCollect().Starts the execution of the program and returns an iterator to read the result of the given data stream, plus aJobClientto interact with the application execution.- Throws:
Exception
-
collectBoundedStream
@Deprecated public static <E> List<E> collectBoundedStream(DataStream<E> stream, String jobName) throws Exception
Deprecated.Please useDataStream.executeAndCollect().Collects contents the given DataStream into a list, assuming that the stream is a bounded stream.This method blocks until the job execution is complete. By the time the method returns, the job will have reached its FINISHED status.
Note that if the stream is unbounded, this method will never return and might fail with an Out-of-Memory Error because it attempts to collect an infinite stream into a list.
- Throws:
Exception- Exceptions that occur during the execution are forwarded.
-
collectUnboundedStream
@Deprecated public static <E> List<E> collectUnboundedStream(DataStream<E> stream, int numElements, String jobName) throws Exception
Deprecated.Please useDataStream.executeAndCollect().Triggers execution of the DataStream application and collects the given number of records from the stream. After the records are received, the execution is canceled.- Throws:
Exception
-
collectRecordsFromUnboundedStream
@Deprecated public static <E> List<E> collectRecordsFromUnboundedStream(ClientAndIterator<E> client, int numElements)
Deprecated.Please useDataStream.executeAndCollect().
-
reinterpretAsKeyedStream
public static <T,K> KeyedStream<T,K> reinterpretAsKeyedStream(DataStream<T> stream, org.apache.flink.api.java.functions.KeySelector<T,K> keySelector)
Reinterprets the givenDataStreamas aKeyedStream, which extracts keys with the givenKeySelector.IMPORTANT: For every partition of the base stream, the keys of events in the base stream must be partitioned exactly in the same way as if it was created through a
DataStream.keyBy(KeySelector).- Type Parameters:
T- Type of events in the data stream.K- Type of the extracted keys.- Parameters:
stream- The data stream to reinterpret. For every partition, this stream must be partitioned exactly in the same way as if it was created through aDataStream.keyBy(KeySelector).keySelector- Function that defines how keys are extracted from the data stream.- Returns:
- The reinterpretation of the
DataStreamas aKeyedStream.
-
reinterpretAsKeyedStream
public static <T,K> KeyedStream<T,K> reinterpretAsKeyedStream(DataStream<T> stream, org.apache.flink.api.java.functions.KeySelector<T,K> keySelector, org.apache.flink.api.common.typeinfo.TypeInformation<K> typeInfo)
Reinterprets the givenDataStreamas aKeyedStream, which extracts keys with the givenKeySelector.IMPORTANT: For every partition of the base stream, the keys of events in the base stream must be partitioned exactly in the same way as if it was created through a
DataStream.keyBy(KeySelector).- Type Parameters:
T- Type of events in the data stream.K- Type of the extracted keys.- Parameters:
stream- The data stream to reinterpret. For every partition, this stream must be partitioned exactly in the same way as if it was created through aDataStream.keyBy(KeySelector).keySelector- Function that defines how keys are extracted from the data stream.typeInfo- Explicit type information about the key type.- Returns:
- The reinterpretation of the
DataStreamas aKeyedStream.
-
-