继承时AvroCoder UnresolvedUnionException

时间:2018-03-08 20:02:52

标签: java google-cloud-dataflow avro apache-beam

我正在修改将在我的Dataflow Pipeline中使用的类。我将我的默认编码器声明为AvroCoder。 该类工作正常,直到我将继承添加到静态子类CompareEquals。现在CompareEquals延伸Comparisons 我收到这个错误......

    org.apache.avro.UnresolvedUnionException: Not in union ["null",{"type":"record","name":"Comparisons","namespace":"com.package.AttributeCompare$","fields":[]}]: com.package.AttributeCompare$CompareEquals@3688eb5b
        at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:740)
        at org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:205)
        at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:123)
        at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:75)
        at org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:159) ...

以下是类(两者都在单独的文件中相同的包):

    @DefaultCoder(AvroCoder.class)
    public class AttributeCompare extends AttributeBase {

        public static class CompareEquals extends Comparisons implements Serializable{

            @Override
            public boolean isSatisfied(Object atrC, Object attr) {
                return true;
            };
        }
    }


    @DefaultCoder(AvroCoder.class)
    public class Comparisons implements Serializable {
      public boolean isSatisfied(Object atrC, Object attr);
    }

没有extends它运行没有错误。我已经尝试将Comparisons转换为界面,但仍有同样的问题。关于从哪里去的任何建议?

0 个答案:

没有答案