Main Content

zip

R2026b

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

(To be removed) Zip one RDD with another

matlab.compiler.mlspark.RDD.zip will be removed in a future release. There is no replacement functionality. For more information, see Version History.

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

collapse all