Main Content

isEmpty

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

Determine if an RDD contains any elements

Syntax

tf = isEmpty(obj)

Description

tf = isEmpty(obj) returns a logical 1 (true) if the input RDD obj contains no elements, and a logical 0 (false) otherwise.

Input Arguments

expand all

An input RDD, specified as an RDD object.

Output Arguments

expand all

Indicates whether the input RDD is empty or not, returned as a logical value.

Examples

expand all

Check if an RDD contains any elements.

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

%% isEmpty
x = sc.parallelize({});
tf = x.map(@(x)({x,1})).isEmpty(); % tf=1
Introduced in R2016b