Package org.apache.kafka.streams.query
Class VersionedKeyQuery<K,V>
java.lang.Object
org.apache.kafka.streams.query.VersionedKeyQuery<K,V>
- Type Parameters:
K- The type of the key.V- The type of the value.
- All Implemented Interfaces:
Query<VersionedRecord<V>>
@Evolving
public final class VersionedKeyQuery<K,V>
extends Object
implements Query<VersionedRecord<V>>
Interactive query for retrieving a single record from a versioned state store based on its key and timestamp.
-
Method Summary
Modifier and TypeMethodDescriptionSpecifies the timestamp for the key query.The timestamp of the query, if specified.key()The key that was specified for this query.static <K,V> VersionedKeyQuery <K, V> withKey(K key) Creates a query that will retrieve the record from a versioned state store identified bykeyif it exists (ornullotherwise).
-
Method Details
-
withKey
Creates a query that will retrieve the record from a versioned state store identified bykeyif it exists (ornullotherwise).While the query by default returns the latest value of the specified
key, setting theasOfTimestamp(by calling theasOf(Instant)method), makes the query to return the value associated to the specifiedasOfTimestamp.- Type Parameters:
K- The type of the keyV- The type of the value that will be retrieved- Parameters:
key- The key to retrieve- Throws:
NullPointerException- ifkeyis null
-
asOf
Specifies the timestamp for the key query. The key query returns the record's version for the specified timestamp. (To be more precise: The key query returns the record with the greatest timestamp <= asOfTimestamp)- Parameters:
asOfTimestamp- The timestamp of the query.- Throws:
NullPointerException- ifasOfTimestampis null
-
key
The key that was specified for this query.- Returns:
- The specified
keyof the query.
-
asOfTimestamp
The timestamp of the query, if specified.- Returns:
- The specified
asOfTimestampof the query.
-