Kotlin 卡夫卡流与科特林的物化视图
要在Java中创建kafka streams状态存储,我可以执行以下操作:Kotlin 卡夫卡流与科特林的物化视图,kotlin,apache-kafka,apache-kafka-streams,Kotlin,Apache Kafka,Apache Kafka Streams,要在Java中创建kafka streams状态存储,我可以执行以下操作: final KGroupedStream<String, String> wordCounts = textLines .flatMapValues(value -> Arrays.asList(pattern.split(value.toLowerCase()))) .groupBy((key, word) -> word); wordCount
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));
我需要做什么?由于
as
在Kotlin中是一个保留字,请尝试用反勾号将as
包围起来,即
`as`
如果它对其他任何人都有用,以及Raman建议的背景标记,我必须做一些其他更改:
- 首先,泛型类型需要在
方法之后指定,而不是直接在as
类之后指定物化的
- 其次,我不得不使用
,而不是使用ByteArray
Array
wordCounts.count(Materialized.`as`<String, Long, KeyValueStore<Bytes, ByteArray>>(WORD_COUNT_STORE))
wordCounts.count(具体化.`as`(WORD\u count\u STORE))
`as`
wordCounts.count(Materialized.`as`<String, Long, KeyValueStore<Bytes, ByteArray>>(WORD_COUNT_STORE))