Main Content

join

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

Return an RDD containing all pairs of elements with matching keys

Syntax

result = join(obj1,obj2,numPartitions)

Description

result = join(obj1,obj2,numPartitions) performs an inner join on obj1 and obj2 and returns an RDD result of key-value pairs containing all pairs of elements with matching keys in the input RDDs. obj1 and obj2 must be key-value pair RDDs. numPartitions specifies the number of partitions to create in the resulting RDD.

Input Arguments

expand all

The first input RDD to be joined, specified as a RDD object. RDD must be a key-value pair RDD.

The second input RDD to be joined, specified as a RDD object. RDD must be a key-value pair RDD.

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

Data Types: double

Output Arguments

expand all

A pipelined RDD containing all pairs of elements with matching keys in the 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);

%% join
x = sc.parallelize({ {'a',11}, {'b', {1,2,3}}, {'b','22'} ,{'c','dd'} });
y = sc.parallelize({ {'a',33}, {'b',44} , {'a',55}, {'d', 5 }});
z = x.join(y, 2);
viewRes = z.collect() % {{'b',{{1,2,3},44}},{'b',{'22',44}},{'a',{11,33}},{'a',{11,55}}}

Version History

Introduced in R2016b