pyspark.RDD.mapPartitionsWithSplit

抽样。 mapPartitionsWithSplit ( f:可调用的((int,Iterable(T]],Iterable(U]],preservesPartitioning:bool= )→pyspark.rdd.RDD(U]

返回一个新的抽样的抽样函数应用到每个分区,同时跟踪原始分区的索引。

例子

> > >抽样=sc并行化([1,2,3,4),4)> > >deff(splitIndex,迭代器):收益率splitIndex> > >抽样mapPartitionsWithSplit(f)总和()6