pyspark.Broadcast.load#
- Broadcast.load(file)[source]#
Read a pickled representation of value from the open file or socket.
- Parameters
- file
BinaryIO
File or socket where the pickled value will be read.
- file
- Returns
- T
The object hierarchy specified therein reconstituted from the pickled representation of an object.
Examples
>>> import os >>> import tempfile
>>> b = spark.sparkContext.broadcast([1, 2, 3, 4, 5]) >>> c = spark.sparkContext.broadcast(1)
Read the pickled representation of value from the open temp file.
>>> with tempfile.TemporaryDirectory(prefix="load") as d: ... path = os.path.join(d, "test.txt") ... with open(path, "wb") as f: ... b.dump(b.value, f) ... with open(path, "rb") as f: ... c.load(f) [1, 2, 3, 4, 5]