我正在尝试使用自定义编码器来处理 Dataflow 中的数据。我所做的是以下内容:
- 将数据从 BigQuery 导出到 avro 文件
- 使用 avro-tools-1.7.7.jar 从这些文件中的模式自动生成一个类
- 使用 Kryo 为该类编写了一个自定义编码器
- 用注释类
@DefaultCoder(MyCustomCoder.class)
- 使用注册我的编码器
p.getCoderRegistry().registerCoder(MyCustomClass.class, MyCustomCoder.class);
- 使用从 avro 文件中读取数据
PCollection<MyCustomClass> pc = p.apply(AvroIO.Read.named("Name").from("gs://bucket/path/to/*.avro").withSchema(MyCustomClass.class));
问题是,如果我的编码器中有错误,我的工作只会在洗牌步骤中失败。看起来 Dataflow 并没有使用我的自定义编码器从 avro 文件中加载数据。真的是这样吗?如果是这样,有没有办法覆盖用于加载数据的编码器?