Main Content

repartition

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

Return a new RDD that has exactly numPartitions partitions

Syntax

result = repartition(obj,numPartitions)

Description

result = repartition(obj,numPartitions) returns a new RDD result that has exactly numPartitions partitions.

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 repartitioned RDD with partitions specified by numPartitions, 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);

%% repartition
inputRDD = sc.parallelize({1,2,3,2,1},4);
outRDD1 = inputRDD.repartition(1); % {1,2,3,2,1}
viewRes = outRDD1.collect()

Version History

Introduced in R2016b