apache-kafka - Kafka Streams聚合加法器运算符问题
问题描述
这是我的 Kafka Streams 代码:
KTable<String, Long> bankTransactionsStream = streamsIn
.groupByKey()
.aggregate(
()-> 0L,
(aggKey, newValue, aggValue) -> aggValue + newValue,
Materialized.<String, String, KeyValueStore<Bytes, byte[]>>as("test-events-snapshots").withKeySerde(Serdes.String()).
withValueSerde(Serdes.String())
);
我通过键对流进行分组,然后我想聚合以将流的每个新值 ( newValue
) 添加到聚合值 ( aggValue
)。我正在关注官方的 confluent 文档,但突出显示了两个错误,它们都与提供的 VR 数据类型有关:
- 在加法器上
(aggKey, newValue, aggValue) -> aggValue + newValue
(必需类型:KTable <String,Long> 提供:KTable<String,VR> 不存在类型变量的实例,因此 Long 符合字符串推理变量 VR 具有不兼容的边界:等式约束:字符串下限:长 - 在初始化器 (
()-> 0L
) 上:必需类型:KTable <String,Long>,提供:KTable <String, VR> 不兼容的等式约束:KeyValueStore<Bytes, byte[]> 和 StateStore
我不明白为什么它假设我提供 VR 类型,有什么想法吗?
解决方案
推荐阅读
- azure - Azure Web App Bot,分析刀片不见了。停产?
- excel - Excel - 通过字符串标识符取消堆栈数据
- python - 如何使用 Keras 计算链式模型的损失?
- tensorflow - Tensorflow Hub - 获取模型的输入形状和问题域?
- blazor - Blazor - 多次创建子组件 - 当 EditForm.Model 更改时
- php - 使用实时搜索栏向 mysql 输入表单以输入外键
- python - 如何将字符串中包含数组的numpy字符串数组转换为字符串数组?
- c++ - 将指针数组的元素设置为 C++ 中的指针
- javascript - 将初始计数值设置为动态行表
- r - 有没有办法将它从上一时期特定于 R 中相同观察的值分配给变量?