Main Content


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

Pass each value in the key-value pair RDD through a flatMap method without changing the keys


result = flatMapValues(obj,func)


result = flatMapValues(obj,func) passes each value in a key-value pair RDD obj through the flatMap method without changing the keys. func represents the function to be applied by the flatMap method.

Input Arguments

expand all

An input RDD on which a transformation function is applied, specified as a RDD object.

Function to be applied to each element in the input RDD, specified as a function handle.


Data Types: function_handle

Output Arguments

expand all

An output pipelined 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);

%% flatMapValues
inRDD = sc.parallelize({ {'AA', {1,2,3}}, {'BB',3}, {'CC', {'cc',4}} });
f = @(x)(x);
out = inRDD.flatMapValues(f).collect();
% out : {{'AA',1},{'AA',2},{'AA',3},{'BB',3},{'CC','cc'},{'CC',4}}

Version History

Introduced in R2016b