KeyValueStore 如何允许写操作(Kafka Streams)

huangapple go评论74阅读模式
英文:

How KeyValueStore allows write operations (Kafka Streams)

问题

我正在尝试理解Kafka Stream的StateStore。我理解了一些基本概念。我查看了代码。

这是StateStore的声明:

public interface StateStore { }

其中一个扩展了StateStore的接口是KeyValueStore

这是KeyValueStore的声明:

public interface KeyValueStore<K, V> extends StateStore, ReadOnlyKeyValueStore<K, V> { }

这是ReadOnlyKeyValueStore的声明:

public interface ReadOnlyKeyValueStore<K, V> { }

我的疑问是:

public interface KeyValueStore<K, V> extends StateStore, ReadOnlyKeyValueStore<K, V> { }

KeyValueStore如何允许以下操作(摘自其Java文档):

/**

  • 支持put/get/delete和范围查询的键值存储。
  • @param 键类型
  • @param 值类型
    */

KeyValueStore扩展了ReadOnlyKeyValueStore。所以这是如何可能的?

可以有人帮助理解吗?

英文:

I am trying to understand kafka stream's Statestore. I understood some basics of it. I looked into the code.

Here is the declaration of StateStore:

public interface StateStore { }

One of the interfaces which extends StateStore is KeyValueStore.

Here is the declaration of KeyValueStore:

public interface KeyValueStore&lt;K, V&gt; extends StateStore, ReadOnlyKeyValueStore&lt;K, V&gt; { }

Here is the declaration of ReadOnlyKeyValueStore:

public interface ReadOnlyKeyValueStore&lt;K, V&gt; { }

My doubt is this:

public interface KeyValueStore&lt;K, V&gt; extends StateStore, ReadOnlyKeyValueStore&lt;K, V&gt; { }

How KeyValueStore is allowing the following operations (taken from its java-doc_):

>/**

  • A key-value store that supports put/get/delete and range queries.
    *
  • @param <K> The key type
  • @param <V> The value type
    */

KeyValueStore is extending ReadOnlyKeyValueStore. So how is it possible?

Can anyone help understand this?

答案1

得分: 2

这只是一个接口,没有明确限制写入能力的逻辑。

唯一的区别是添加了put和delete方法。通过继承只读存储接口获得了get方法。

https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/state/KeyValueStore.java#L40

英文:

It's just an interface, there's no logic that explicitly limits the ability to write.

The only difference is the addition of the put and delete method(s). The get method is obtained through inheritance of the read-only store interface

https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/state/KeyValueStore.java#L40

huangapple
  • 本文由 发表于 2020年1月3日 17:06:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/59575718.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定