gpt4 book ai didi

java.lang.IllegalStateException : Unable to return a default Coder in dataflow 2. X

转载 作者:搜寻专家 更新时间:2023-11-01 01:12:08 33 4
gpt4 key购买 nike

我在数据流 2.1 SDK 中有一个简单的管道。它从 pubsub 读取数据,然后对其应用 DoFn。

PCollection<MyClass> e = streamData.apply("ToE", ParDo.of(new MyDoFNClass()));

在此管道上出现以下错误:

java.lang.IllegalStateException: Unable to return a default Coder for ToEvents/ParMultiDo(MyDoFNClass).out0 [PCollection]. Correct one of the following root causes: No Coder has been manually specified; you may do so using .setCoder(). Inferring a Coder from the CoderRegistry failed: Unable to provide a Coder for com.X.X.model.MyClass.

MyDoFn 类如下:

@DefaultCoder(AvroCoder.class)

public class MyClass{

public long id;
public HashMap<String,HashSet<String>> a;

@SerializedName("a")
public Integer Id;
@SerializedName("ae")
public String ae;
}

最佳答案

找到解决方案只需要将 implements Serializable 添加到 MyClass

@DefaultCoder(AvroCoder.class)

public class MyClass implements Serializable {

public long id;
public HashMap<String,HashSet<String>> a;

@SerializedName("a")
public Integer Id;
@SerializedName("ae")
public String ae;
}

关于java.lang.IllegalStateException : Unable to return a default Coder in dataflow 2. X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47706013/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com