Main Content


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

Return a new RDD containing the distinct elements of an existing RDD


result = distinct(obj,numPartitions)


result = distinct(obj,numPartitions) returns a new RDD result containing the distinct elements of obj by eliminating duplicate values.

Input Arguments

expand all

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 distinct elements of the input RDD, 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);

%% distinct
inputRDD = sc.parallelize({1,2,1,2});
dRDD = inputRDD.distinct();
viewRes = dRDD.glom().collect()  %{1,2}

Version History

Introduced in R2016b