-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-9243 Update the javadocs to include TimestampKeyValueStore #7848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |
| import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier; | ||
| import org.apache.kafka.streams.state.KeyValueStore; | ||
| import org.apache.kafka.streams.state.QueryableStoreType; | ||
| import org.apache.kafka.streams.state.ReadOnlyKeyValueStore; | ||
| import org.apache.kafka.streams.state.TimestampedKeyValueStore; | ||
|
|
||
| import java.util.function.Function; | ||
|
|
||
|
|
@@ -43,7 +43,7 @@ | |
| * A {@code KTable} can be transformed record by record, joined with another {@code KTable} or {@link KStream}, or | ||
| * can be re-partitioned and aggregated into a new {@code KTable}. | ||
| * <p> | ||
| * Some {@code KTable}s have an internal state (a {@link ReadOnlyKeyValueStore}) and are therefore queryable via the | ||
| * Some {@code KTable}s have an internal state (a {@link TimestampedKeyValueStore}) and are therefore queryable via the | ||
| * interactive queries API. | ||
| * For example: | ||
| * <pre>{@code | ||
|
|
@@ -53,7 +53,7 @@ | |
| * streams.start() | ||
| * ... | ||
| * final String queryableStoreName = table.queryableStoreName(); // returns null if KTable is not queryable | ||
| * ReadOnlyKeyValueStore view = streams.store(queryableStoreName, QueryableStoreTypes.keyValueStore()); | ||
| * TimestampedKeyValueStore view = streams.store(queryableStoreName, QueryableStoreTypes.keyValueStore()); | ||
| * view.get(key); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can you remove the blanks? Those would be rendered: This applies to all |
||
| *}</pre> | ||
| *<p> | ||
|
|
@@ -130,11 +130,11 @@ public interface KTable<K, V> { | |
| * Furthermore, for each record that gets dropped (i.e., does not satisfy the given predicate) a tombstone record | ||
| * is forwarded. | ||
| * <p> | ||
| * To query the local {@link KeyValueStore} it must be obtained via | ||
| * To query the local {@link TimestampedKeyValueStore} it must be obtained via | ||
| * {@link KafkaStreams#store(String, QueryableStoreType) KafkaStreams#store(...)}: | ||
| * <pre>{@code | ||
| * KafkaStreams streams = ... // filtering words | ||
| * ReadOnlyKeyValueStore<K,V> localStore = streams.store(queryableStoreName, QueryableStoreTypes.<K, V>keyValueStore()); | ||
| * TimestampedKeyValueStore<K,V> localStore = streams.store(queryableStoreName, QueryableStoreTypes.<K, V>keyValueStore()); | ||
| * K key = "some-word"; | ||
| * V valueForKey = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) | ||
| * }</pre> | ||
|
|
@@ -169,11 +169,11 @@ KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, | |
| * Furthermore, for each record that gets dropped (i.e., does not satisfy the given predicate) a tombstone record | ||
| * is forwarded. | ||
| * <p> | ||
| * To query the local {@link KeyValueStore} it must be obtained via | ||
| * To query the local {@link TimestampedKeyValueStore} it must be obtained via | ||
| * {@link KafkaStreams#store(String, QueryableStoreType) KafkaStreams#store(...)}: | ||
| * <pre>{@code | ||
| * KafkaStreams streams = ... // filtering words | ||
| * ReadOnlyKeyValueStore<K,V> localStore = streams.store(queryableStoreName, QueryableStoreTypes.<K, V>keyValueStore()); | ||
| * TimestampedKeyValueStore<K,V> localStore = streams.store(queryableStoreName, QueryableStoreTypes.<K, V>keyValueStore()); | ||
| * K key = "some-word"; | ||
| * V valueForKey = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) | ||
| * }</pre> | ||
|
|
@@ -255,11 +255,11 @@ KTable<K, V> filter(final Predicate<? super K, ? super V> predicate, | |
| * Furthermore, for each record that gets dropped (i.e., does satisfy the given predicate) a tombstone record is | ||
| * forwarded. | ||
| * <p> | ||
| * To query the local {@link KeyValueStore} it must be obtained via | ||
| * To query the local {@link TimestampedKeyValueStore} it must be obtained via | ||
| * {@link KafkaStreams#store(String, QueryableStoreType) KafkaStreams#store(...)}: | ||
| * <pre>{@code | ||
| * KafkaStreams streams = ... // filtering words | ||
| * ReadOnlyKeyValueStore<K,V> localStore = streams.store(queryableStoreName, QueryableStoreTypes.<K, V>keyValueStore()); | ||
| * TimestampedKeyValueStore<K,V> localStore = streams.store(queryableStoreName, QueryableStoreTypes.<K, V>keyValueStore()); | ||
| * K key = "some-word"; | ||
| * V valueForKey = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) | ||
| * }</pre> | ||
|
|
@@ -293,11 +293,11 @@ KTable<K, V> filterNot(final Predicate<? super K, ? super V> predicate, | |
| * Furthermore, for each record that gets dropped (i.e., does satisfy the given predicate) a tombstone record is | ||
| * forwarded. | ||
| * <p> | ||
| * To query the local {@link KeyValueStore} it must be obtained via | ||
| * To query the local {@link TimestampedKeyValueStore} it must be obtained via | ||
| * {@link KafkaStreams#store(String, QueryableStoreType) KafkaStreams#store(...)}: | ||
| * <pre>{@code | ||
| * KafkaStreams streams = ... // filtering words | ||
| * ReadOnlyKeyValueStore<K,V> localStore = streams.store(queryableStoreName, QueryableStoreTypes.<K, V>keyValueStore()); | ||
| * TimestampedKeyValueStore<K,V> localStore = streams.store(queryableStoreName, QueryableStoreTypes.<K, V>keyValueStore()); | ||
| * K key = "some-word"; | ||
| * V valueForKey = localStore.get(key); // key must be local (application state is shared over all running Kafka Streams instances) | ||
| * }</pre> | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change doesn't look quite right. It should still be a ReadOnlyKeyValueStore, but the generics are different:
ReadOnlyKeyValueStore<K, ValueAndTimestamp<V>>. Also, if the intent is to recommend using the Timestamped variant, then folks would actually have to specifyQueryableStoreTypes.timestampedKeyValueStore().There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This this top level class JavaDoc, should we also explain that it it still possible to query the store as plain key-value store only? I can imagine, that not all applications are interested in the timestamp and it would be quite convenient for them to stay with the old pattern (note, that the old pattern is not deprecated and still totally valid to use).
Thoughts?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vvcephei Thanks for the heads up. I've dug a little more and was able to confirm that streams.store returns a
ReadOnlyKeyValueStore<K, ValueAndTimestamp<V>>whenQueryableStoreTypes.timestampedKeyValueStore()is passed as the second argument. It looks like the type returned by streams.store is dependent upon the return type of the create method of that second argument, namely a TimestampedKeyValueStoreType. I'll make the necessary updates and verify that the code in the javadocs works.@mjsax You raise a good point. We can provide documentation for the two approaches; however, if we add another QueryableStoreType similar to KeyValueStore and TimestampedKeyValueStore then we've got to make more updates in many places. To remedy this, perhaps we only provide a code example of how to query at the KTable interface documentation and remove the examples in the documentation for the methods. Otherwise, we can continue to update these code snippets in the documentation throughout. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. I see your point. Maintaining the docs in many different places is quite a challenge. Curious to hear what @vvcephei thinks about this question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\cc @vvcephei Any comments?
Btw: There seems to be an overlap with https://issues.apache.org/jira/browse/KAFKA-9290 -- might be worth to resolve both issue with a single PR?