Stream流的特点_只能用一次 Stream流属于管道流,只能被消费(使用)一次 第一个stream流调用完毕方法,数据就会流转到下一个stream上 而这时第一个stream流已经使用完毕,就会关闭了 所以第一个stream流就不能再调用方法了 /* IllegalStateException: stream has already been operated upon or closed */ //遍历stream流 stream.forEach(name-> System.out.pri…
区别:map mapper返回R,flatMap mapper返回Stream<R> 官网解释 1,<R>Stream<R> flatMap(Function<? super T,? extends Stream<? extends R>> mapper) Returns a stream consisting of the results of replacing each element of this stream with the co…
map将函数作用到数据集的每一个元素上,生成一个新的分布式的数据集(RDD)返回 map函数的源码: def map(self, f, preservesPartitioning=False): """ Return a new RDD by applying a function to each element of this RDD. >>> rdd = sc.parallelize(["b", "a", &quo…