Main Content

cache

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

Store an RDD in memory

Syntax

cache(obj)

Description

cache(obj) stores an RDD object specified by obj in the memory of the executors across a cluster.

Input Arguments

expand all

An RDD to be cached in memory, specified as an RDD object.

Examples

expand all

Store an RDD in the memory of the executors across the cluster.

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

%% cache
myFile = sc.textFile('airlinesmall.csv');
myFile.cache();

Version History

Introduced in R2016b

See Also