Main Content


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

Return the values resulting from the set difference between two RDDs


result = subtract(obj1,obj2,numPartitions)


result = subtract(obj1,obj2,numPartitions) returns elements that are the set difference of obj1 and obj2. numPartitions specifies the number of partitions to create in the resulting RDD.

Input Arguments

expand all

An input RDD, specified as a RDD object.

An input RDD, specified as a RDD object.

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

Data Types: double

Output Arguments

expand all

A pipelined RDD containing the set subtraction of the two input RDDs, returned as a RDD object.


expand all

%% Connect to Spark
sparkProp = containers.Map({'spark.executor.cores'}, {'1'});
conf = matlab.compiler.mlspark.SparkConf('AppName','myApp', ...
sc = matlab.compiler.mlspark.SparkContext(conf);

%% subtract
x = sc.parallelize({ 1,2,3 });
y = sc.parallelize({ 2,4,5 });
c = x.subtract(y,2).collect(); % {1,3}

Version History

Introduced in R2016b