broadcast
Class: matlab.compiler.mlspark.SparkContext
Namespace: matlab.compiler.mlspark
Broadcast a read-only variable to the cluster
Syntax
result =
broadcast(sc,value)
Description
broadcasts
a read-only variable result
=
broadcast(sc
,value
)value
to the cluster initialized
by SparkContext sc
.
Input Arguments
sc
— SparkContext to use
SparkContext
object
The SparkContext to use, specified as a SparkContext
object.
value
— Value to be broadcast
any supported data type
The value to be broadcast, specified as any supported data type.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| char
| struct
| table
| cell
| function_handle
| categorical
| string
Output Arguments
result
— Broadcast variable
Broadcast
object
Broadcast variable, returned as a broadcast object with the following properties:
id
value
path
Examples
Broadcast a Variable
Broadcast a read-only variable to 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); %% broadcast myRdd = sc.parallelize({1,2,3,4,5}); myBroadcast = sc.broadcast('Hello, World'); newRdd = myRdd.map(@(x) myBroadcast.value); countdata = newRdd.collect()
Version History
Introduced in R2016b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)