java - java如何区分apache beam中KV实例中的两个键?

标签 java apache-beam

apache beam 的版本是 2.15.0

在此code ,类 Airport 用作 KV 实例的 Key,最后,计算每个 Airport 实例的 mean

c.output(KV.of(stats.airport, stats.timestamp));

但是apache beam如何在内部比较两个键并返回两个实例是否相同?如果所有类成员具有相同的值,两个实例是否被视为相同? Document没有提到两个键的比较。

如果有人能帮助我理解,我将不胜感激。

最佳答案

这实际上在 GroupByKey 转换中进行了解释 docs ,这是在 Mean 聚合的幕后完成的操作:

Two keys of type K are compared for equality not by regular Java Object.equals(java.lang.Object), but instead by first encoding each of the keys using the Coder of the keys of the input PCollection, and then comparing the encoded bytes. This admits efficient parallel evaluation. Note that this requires that the Coder of the keys be deterministic (see Coder.verifyDeterministic()). If the key Coder is not deterministic, an exception is thrown at pipeline construction time.

请注意 Mean使用Combine.PerKey这是 GroupByKey + Combine.GroupedValues 的“简写”。

关于java - java如何区分apache beam中KV实例中的两个键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57831948/

相关文章:

java - 以编程方式发送短信 - 设置过期时间

apache-flink - Apache flink 与 Apache Beam(使用 flink 运行器)

google-cloud-platform - 云数据流/光束 : Side Input Limit

google-cloud-platform - 数据流,使用客户提供的加密 key 加载文件

java - 何时使用 DropWizard bundle ?

java - 在java中将列表的列表转换为json对象

java - 我们可以做些什么来加快 XML 处理速度?

java - 使用@OrderColumn 的JPA 多重获取返回多个空值

python - 如何使用部署在 Kubernetes 上的 Flink 运行 Beam Python 管道?

apache-kafka - KafkaIO withLogAppendTime 与 withProcessingTime