Class: matlab.compiler.mlspark.RDD Package: matlab.compiler.mlspark
Zip an RDD with its element indices
result = zipWithIndex(obj)
result = zipWithIndex(obj) zips an obj with its element indices.
result
obj
expand all
RDD
An input RDD, specified as a RDD object.
An output pipelined RDD, returned as a RDD object.
%% Connect to Spark sparkProp = containers.Map({'spark.executor.cores'}, {'1'}); conf = matlab.compiler.mlspark.SparkConf('AppName','myApp', ... 'Master','local[1]','SparkProperties',sparkProp); sc = matlab.compiler.mlspark.SparkContext(conf); %% zipWithIndex x = sc.parallelize({'a','b','c','d'},3); out = x.zipWithIndex().collect(); % {{'a',0},{'b',1},{'c',2},{'d',3}}
matlab.compiler.mlspark.RDD.zipWithUniqueId | matlab.compiler.mlspark.SparkContext.parallelize | zip
matlab.compiler.mlspark.RDD.zipWithUniqueId
matlab.compiler.mlspark.SparkContext.parallelize
zip