Main Content

collectAsMap

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

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

Syntax

result = collectAsMap(obj)

Description

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.

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

% 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