Main Content

cogroup

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

Group data from RDDs sharing the same key

Syntax

result = cogroup(obj1,obj2,numPartitions)

Description

result = cogroup(obj1,obj2,numPartitions) groups the data from obj1 and obj2 that share the same key.

Input Arguments

expand all

The first input RDD, specified as a RDD object.

The second input RDD, specified as a RDD object.

Number of partitions to create, specified as a scalar value.

Data Types: double

Output Arguments

expand all

An RDD containing grouped data, 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);

%% cogroup
x = sc.parallelize({ {'a',1}, {'b', 4} });
y = sc.parallelize({ {'a',2} });
z=x.cogroup(y);

Version History

Introduced in R2016b