小编Chr*_*ian的帖子

Spark - 迭代算法的奇怪行为

我尝试用Spark编写迭代算法.该算法包含一个主循环,其中使用不同的并行性火花命令.如果在每次迭代中只使用一个spark命令,一切正常,但是当使用多个命令时,Spark的行为变得非常奇怪.主要问题是在具有2个项目的rdd上的map命令不会导致2但在许多函数调用中.

它看起来像Spark正在迭代x中执行从迭代1到迭代(x-1)的每个命令.但不仅在循环的最后一次迭代中,而且在循环的每次迭代中!

我构建了一个小例子来重现行为(使用Java 1.8和Spark 1.6.1)

首先是rdd中使用的数据结构:

public class Data implements Serializable {
    private static final long serialVersionUID = -6367920689454127925L;
    private String id;
    private Integer value;

    public Data(final String id, final Integer value) {
        super();
        this.id = id;
        this.value = value;
    }

    public String getId() {
        return this.id;
    }

    public Integer getValue() {
        return this.value;
    }

    public void setValue(final Integer value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return "Data [id=" + this.id + ", value=" + this.value …
Run Code Online (Sandbox Code Playgroud)

iteration algorithm apache-spark

4
推荐指数
1
解决办法
1713
查看次数

标签 统计

algorithm ×1

apache-spark ×1

iteration ×1