Main Content

intersection

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

Return the set intersection of one RDD with another

Syntax

result = intersection(obj1,obj2)

Description

result = intersection(obj1,obj2) returns elements that are the set intersection of obj1 and obj2.

Input Arguments

expand all

An input RDD, , specified as a RDD object.

An input RDD, specified as a RDD object.

Output Arguments

expand all

A pipelined RDD containing the set intersection of 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);

%% intersection
x = sc.parallelize({'A','B','C'});
y = sc.parallelize({'B','D'});
z = sc.parallelize({'E','F'});
out1 = x.intersection(y).collect(); % {'B'}

Version History

Introduced in R2016b