Main Content

cartesian

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

Create an RDD that is the Cartesian product of two RDDs

Syntax

result = cartesian(obj1,obj2)

Description

result = cartesian(obj1,obj2) creates a new RDD that is the Cartesian product between two RDDs, obj1 and obj2.

Input Arguments

expand all

The first input RDD, specified as a RDD object.

The second input RDD, specified as a RDD object.

Output Arguments

expand all

An RDD representing the Cartesian product of two 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);

%% cartesian
x = sc.parallelize({'A', 2, 'C'});
y = sc.parallelize({'D', 1});
out = x.cartesian(y).collect(); % {{'A','D'},{'A',1},{2,'D'},{2,1},{'C','D'},{'C',1}}
Introduced in R2016b