Main Content

count

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

Count number of elements in an RDD

Syntax

result = count(obj)

Description

result = count(obj) counts the number of elements in obj.

Input Arguments

expand all

An input RDD to count, specified as a RDD object.

Output Arguments

expand all

The number of elements in an input RDD, returned as a scalar.

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

% count
countVal = sc.parallelize({1, 2, 3, 4, 5}).count();
disp(countVal);

Version History

Introduced in R2016b

See Also