【发布时间】:2018-11-04 05:23:48
【问题描述】:
要在 Java 中创建一个 kafka 流状态存储,我可以这样做:
final KGroupedStream<String, String> wordCounts = textLines
.flatMapValues(value -> Arrays.asList(pattern.split(value.toLowerCase())))
.groupBy((key, word) -> word);
wordCounts.count(Materialized.<String, Long, KeyValueStore<Bytes, byte[]>>as(WORD_COUNT_STORE));
我正在尝试将其转换为 Kotlin,如下所示:
val wordCounts: KGroupedStream<String, String> = textLines
.flatMapValues({value -> value.split("\\W+") })
.groupBy({ _, word -> word})
wordCounts.count(Materialized.<String, Long, KeyValueStore<Bytes, Array<Byte>>>as(WORD_COUNT_STORE))
但是,我收到以下编译器错误:
Interface KeyValueStore does not have constructors
我需要做什么?
【问题讨论】:
标签: kotlin apache-kafka apache-kafka-streams