Main Content


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

Return the key-value pairs in an RDD as a MATLAB containers.Map object


result = collectAsMap(obj)


result = collectAsMap(obj) returns the key-value pairs in obj as a MATLAB® containers.Map object.

Input Arguments

expand all

An RDD object, specified as a RDD object.

Output Arguments

expand all

The key-value pairs in an RDD, returned as a MATLAB containers.Map 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);

% Collect as Map
x = sc.parallelize({ {'a',1} ,{'b',2} });
c = x.collectAsMap() % c is a MAP with 'a','b' as keys and 1,2 as values

Version History

Introduced in R2016b