说明
用于测试、演示
api
fromCollection(Seq)-从Java Java.util.Collection创建数据流。集合中的所有元素必须具有相同的类型。fromCollection(Iterator)-从迭代器创建数据流。该类指定迭代器返回的元素的数据类型。fromElements(elements: _*)-从给定的对象序列创建数据流。所有对象必须具有相同的类型。fromParallelCollection(SplittableIterator)-从迭代器并行创建数据流。该类指定迭代器返回的元素的数据类型。generateSequence(from, to)-并行生成给定间隔中的数字序列。
例子
public static void main(String[] args) throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<String> ds = env.fromElements(
"hadoop hdfs",
"hadoop yarn",
"hadoop flink",
"flink yarn");
ds.print();
env.execute("test");
}