Flink基于集合的Source
基于集合的Source,该类Source通常就是为了做测试或实验的,不用于生产环境
import org.apache.flink.streaming.api.datastream.DataStreamSource; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import java.util.Arrays; import java.util.List; public class CollectionSource { public static void main(String[] args) throws Exception{ StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); Listnums = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); DataStreamSource numStream = env.fromCollection(nums); System.out.println("fromCollection创建的DataStreamSource的并行度为:" + numStream.getParallelism()); numStream.print(); env.execute(); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)