Main Content

zip

Class: matlab.compiler.mlspark.RDD
Namespace: matlab.compiler.mlspark

Zip one RDD with another

Syntax

result = zip(obj1,obj2)

Description

result = zip(obj1,obj2) returns a key-value pair RDD result, where the first element in the pair is from obj1 and second element is from obj2. The output RDD result has the same number of elements as obj1. Both the obj1 and the obj2 must have the same length.

Input Arguments

expand all

An input RDD, specified as a RDD object.

An input RDD, specified as a RDD object.

Output Arguments

expand all

An output RDD zipped from two input RDDs, 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);

%% zip
x = sc.parallelize({'A', 'B', 3});
y = sc.parallelize({1, 2, 'C'});
out = x.zip(y).collect(); % {{'A',1},{'B',2},{3,'C'}}}

Version History

Introduced in R2016b