Class: matlab.compiler.mlspark.RDD Package: matlab.compiler.mlspark
Save RDD as a text file
saveAsTextFile(obj,path)
saveAsTextFile(obj,path) saves obj as a text file in a location specified by path.
obj
path
expand all
RDD
An input RDD, specified as a RDD object.
Directory location in which to save the text file, specified as a character vector enclosed in ''.
''
Data Types: char
char
Save an RDD as a text file by converting each RDD element to its string representation and storing it as a line of text.
%% 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); %% saveAsTextFile % May require setting HADOOP_PREFIX or HADOOP_HOME environment variables to a % valid Hadoop installation folder even if running locally. % For example: % setenv('HADOOP_PREFIX','/mathworks/AH/hub/apps_PCT/LS_Hadoop_hadoop01glnxa64/hadoop-2.5.2') inRDD = sc.parallelize({1,2,3,4,5}); inRDD.saveAsTextFile('myFile.txt');
datastore | parallelize | saveAsKeyValueDatastore | saveAsTallDatastore
datastore
parallelize
saveAsKeyValueDatastore
saveAsTallDatastore