Home > other > RDD. Map reference external val error & quot; The Task not serializable"
RDD. Map reference external val error & quot; The Task not serializable"
Time:09-26
Val Size=5 Val fixedLogs=RDD. Map {row=& gt; { The Size } }
Statement in the spark - shell variable val Size=5; References in the map, then an error "Task not serializable" what should I do
Thank you for the great god
CodePudding user response:
Val bcSize=sc. BroadCast (size) Val fixedLogs=RDD. Map {row=& gt; { BcSize. Value } }
CodePudding user response:
Because you RDD transform and the action of operator is performed on the executor, and you write the main method, is run on driver, so you can't cross machine across processes to visit you in the driver's size, to access, can only use radio variable, this is on each executor to create a copy of the object being broadcast,
CodePudding user response:
I can't, or an error
CodePudding user response:
I am using SQL dataFrame. RDD. Map The following code still not serialize
Val bcSize=sc. Broadcast (5) Val test=dayErrorDF. Select (" judge. * ", "fix. *"). The RDD. Map {row=& gt; BcSize. Value }