How to set and get static variables from spark?

前端 未结 4 1322
孤独总比滥情好
孤独总比滥情好 2020-12-06 07:09

I have a class as this:

public class Test {
    private static String name;

    public static String getName() {
        return name;
    }

    public stati         


        
4条回答
  •  感动是毒
    2020-12-06 07:23

    The copy of your class in your driver process isn't the copy in your executors. They aren't in the same ClassLoader, or even the same JVM, or even on the same machine. Setting a static variable on the driver does nothing to the other copies, hence you find it null remotely.

提交回复
热议问题