Main Content

distinct

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

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

Syntax

result = distinct(obj,numPartitions)

Description

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.

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);

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

Version History

Introduced in R2016b