Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin 卡夫卡流与科特林的物化视图_Kotlin_Apache Kafka_Apache Kafka Streams - Fatal编程技术网

Kotlin 卡夫卡流与科特林的物化视图

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

要在Java中创建kafka streams状态存储,我可以执行以下操作:

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))