Main Content


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

Return a new RDD that has exactly numPartitions partitions


result = repartition(obj,numPartitions)


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.


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

%% 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