我正尝试使用 NestedValueProvider ,就像Google云平台文档https://cloud.google.com/dataflow/docs/templates/creating-templates提供的示例一样,但是它抛出异常:无法序列化NestedValueProvider {value = RuntimeValueProvider {propertyName = date,default = null},translator =}
@Description("Processing date")
@Validation.Required
ValueProvider<String> getDate();
void setDate(ValueProvider<String> date);
PCollectionTuple lines = this.p
.apply("ReadW2", TextIO.read().from(ValueProvider.NestedValueProvider.of(options.getDate(), new SerializableFunction<String, String>() {
@Override
public String apply(String date) {
return "gs://bucketname/" + date;
}
})))
答案 0 :(得分:0)
现在它对我有用,但是我不明白为什么。 我刚刚将匿名类转换为lambda表达式。
PCollectionTuple lines = this.p
.apply("ReadW2", TextIO.read().from(NestedValueProvider.of(options.getDate(), (SerializableFunction<String, String>) date -> gs://bucketname/" + date)))