pyspark.Broadcast.load_from_path#
- Broadcast.load_from_path(path)[source]#
Read the pickled representation of an object from the open file andreturn the reconstituted object hierarchy specified therein.
- Parameters
- pathstr
File path where reads the pickled value.
- Returns
- T
The object hierarchy specified therein reconstitutedfrom the pickled representation of an object.
Examples
>>>importos>>>importtempfile
>>>b=spark.sparkContext.broadcast([1,2,3,4,5])>>>c=spark.sparkContext.broadcast(1)
Read the pickled representation of value from temp file.
>>>withtempfile.TemporaryDirectory(prefix="load_from_path")asd:...path=os.path.join(d,"test.txt")...withopen(path,"wb")asf:...b.dump(b.value,f)...c.load_from_path(path)[1, 2, 3, 4, 5]