Main Content

zipWithUniqueId

Class: matlab.compiler.mlspark.RDD
Package: matlab.compiler.mlspark

Zip an RDD with generated unique Long IDs

Syntax

result = zipWithUniqueId(obj)

Description

result = zipWithUniqueId(obj) zips obj with generated unique Long IDs.

Input Arguments

expand all

An input RDD, specified as a RDD object.

Output Arguments

expand all

An output pipelined RDD, returned as a RDD object.

Examples

expand all

%% 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);

%% zipWithUniqueId
x = sc.parallelize({'a','b','c','d','e'},3);
out = x.zipWithUniqueId().collect(); % {{'a',0},{'b',1},{'c',4},{'d',2},{'e',5}}
Introduced in R2016b