Package org.apache.kafka.streams.query
Class MultiVersionedKeyQuery<K,V>
java.lang.Object
org.apache.kafka.streams.query.MultiVersionedKeyQuery<K,V>
- Type Parameters:
K
- The type of the key.V
- The type of the result returned by this query.
- All Implemented Interfaces:
Query<VersionedRecordIterator<V>>
@Evolving
public final class MultiVersionedKeyQuery<K,V>
extends Object
implements Query<VersionedRecordIterator<V>>
Interactive query for retrieving a set of records with the same specified key and different timestamps within the specified time range.
No ordering is guaranteed for the results, but the results can be sorted by timestamp (in ascending or descending order) by calling the corresponding defined methods.
-
Method Summary
Modifier and TypeMethodDescriptionfromTime()
The starting time point of the query, if specifiedSpecifies the starting time point for the key query.key()
The key that was specified for this query.The order of the returned records by timestamp.toTime()
The ending time point of the query, if specifiedSpecifies the ending time point for the key query.Specifies the order of the returned records by the query as ascending by timestamp.Specifies the order of the returned records by the query as descending by timestamp.static <K,
V> MultiVersionedKeyQuery<K, V> withKey
(K key) Creates a query that will retrieve the set of records identified bykey
if any exists (ornull
otherwise).
-
Method Details
-
withKey
Creates a query that will retrieve the set of records identified bykey
if any exists (ornull
otherwise).While the query by default returns the all the record versions of the specified
key
, setting thefromTimestamp
(by calling thefromTime(Instant)
method), and thetoTimestamp
(by calling thetoTime(Instant)
method) makes the query to return the record versions associated to the specified time range.- Type Parameters:
K
- The type of the keyV
- The type of the value that will be retrieved- Parameters:
key
- The specified key by the query- Throws:
NullPointerException
- ifkey
is null
-
fromTime
Specifies the starting time point for the key query.The key query returns all the records that are still existing in the time range starting from the timestamp
fromTime
. There can be records which have been inserted before thefromTime
and are still valid in the query specified time range (the whole time range or even partially). The key query in fact returns all the records that have NOT become tombstone at or afterfromTime
.- Parameters:
fromTime
- The starting time point IffromTime
is null, it will be considered as negative infinity, ie, no lower bound
-
toTime
Specifies the ending time point for the key query. The key query returns all the records that have timestamp <= toTime.- Parameters:
toTime
- The ending time point If @param toTime is null, will be considered as positive infinity, ie, no upper bound
-
withDescendingTimestamps
Specifies the order of the returned records by the query as descending by timestamp. -
withAscendingTimestamps
Specifies the order of the returned records by the query as ascending by timestamp. -
key
The key that was specified for this query.- Returns:
- The specified
key
of the query.
-
fromTime
The starting time point of the query, if specified- Returns:
- The specified
fromTime
of the query.
-
toTime
The ending time point of the query, if specified- Returns:
- The specified
toTime
of the query.
-
resultOrder
The order of the returned records by timestamp.- Returns:
- the order of returned records based on timestamp (can be unordered, or in ascending, or in descending order of timestamps).
-