Main Content

glom

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

Coalesce all elements within each partition of an RDD

Syntax

result = glom(obj)

Description

result = glom(obj) returns an RDD result created by coalescing all elements within each partition of obj.

Input Arguments

expand all

An input RDD, specified as a RDD object.

Output Arguments

expand all

A pipelined RDD containing coalesced elements within each partition of the input RDD, 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);

%% glom
inputRDD = sc.parallelize({'A','B','C','D','E','C','B'}); 
mapRDD = inputRDD.map(@(x)({x,1})); 
redRDD = mapRDD.reduceByKey(@(x,y)(x+y),3); 
out = redRDD.glom().collect() % { {{'C',2}}, {{'A',1},{'D',1}}, {{'B',2},{'E',1}} } 
% 3 cell arrays as 3 partitions were created by reduceByKey
Introduced in R2016b