GCP 数据流抛出异常随机键太大
GCP Dataflow throws exception Shuffle key too large
我有一段代码对我的数据进行分组,但是当我输出时它抛出异常。
这个class在KV
中用作key
class CKey {
private Long id;
private Long subId;
}
这是我的 Dataflow 工作的一部分
TupleTag<CItem> itemsTuple = //...
TupleTag<CMeta> metaTuple = //...
//...
PCollection<KV<CKey, CItem>> items = null;
PCollection<KV<CKey, CMeta>> meta;
KeyedPCollectionTuple.of(itemsTuple, items).and(metaTuple, meta.next())
.apply(CoGroupByKey.create())
.apply(new CustomGroupPairsFn());
连接数据的自定义函数
class CustomGroupPairsFn extends DoFn<KV<CKey, CoGbkResult>, MyCustomObject> {
@ProcessElement
public void processElement(@Element KV<CKey, CoGbkResult> element, OutputReceiver<MyCustomObject> out) {
CoGbkResult pair = element.getValue();
Iterator<CItem> citem = pair.getAll(ITEMS).iterator();
Iterator<CMeta> cmeta = pair.getAll(METADATA).iterator();
try {
out.output(new MyCustomObject(citem.next(), cmeta));
} catch (Exception e) {
log.error("Error occurred", e);
}
}
}
try
只有1行代码,里面抛出异常,异常:
我该如何解决这个问题?
发生此错误是因为您洗牌的密钥太大。
这是什么意思?在 Dataflow 中,流式传输管道允许的最大随机播放键为 1.5 MB。你似乎有一个比那个更大的元素键。
也许您的管道在某个意外的地方有一个 GroupByKey/Shuffling 操作,因此最好能提供更多有关它的详细信息。
我有一段代码对我的数据进行分组,但是当我输出时它抛出异常。
这个class在KV
中用作keyclass CKey {
private Long id;
private Long subId;
}
这是我的 Dataflow 工作的一部分
TupleTag<CItem> itemsTuple = //...
TupleTag<CMeta> metaTuple = //...
//...
PCollection<KV<CKey, CItem>> items = null;
PCollection<KV<CKey, CMeta>> meta;
KeyedPCollectionTuple.of(itemsTuple, items).and(metaTuple, meta.next())
.apply(CoGroupByKey.create())
.apply(new CustomGroupPairsFn());
连接数据的自定义函数
class CustomGroupPairsFn extends DoFn<KV<CKey, CoGbkResult>, MyCustomObject> {
@ProcessElement
public void processElement(@Element KV<CKey, CoGbkResult> element, OutputReceiver<MyCustomObject> out) {
CoGbkResult pair = element.getValue();
Iterator<CItem> citem = pair.getAll(ITEMS).iterator();
Iterator<CMeta> cmeta = pair.getAll(METADATA).iterator();
try {
out.output(new MyCustomObject(citem.next(), cmeta));
} catch (Exception e) {
log.error("Error occurred", e);
}
}
}
try
只有1行代码,里面抛出异常,异常:
我该如何解决这个问题?
发生此错误是因为您洗牌的密钥太大。
这是什么意思?在 Dataflow 中,流式传输管道允许的最大随机播放键为 1.5 MB。你似乎有一个比那个更大的元素键。
也许您的管道在某个意外的地方有一个 GroupByKey/Shuffling 操作,因此最好能提供更多有关它的详细信息。