Class TimestampedRangeWithHeadersQuery<K,V>
- Type Parameters:
K- Type of keysV- Type of values
- All Implemented Interfaces:
Query<ReadOnlyRecordIterator<K,V>>
TimestampedKeyValueStoreWithHeaders, returning each record together with its headers.
This is the headers-aware parallel of TimestampedRangeQuery: it returns a
ReadOnlyRecordIterator of ReadOnlyRecord elements, each carrying the key, value,
timestamp, and headers, whereas TimestampedRangeQuery returns a
KeyValueIterator of
ValueAndTimestamp (value and timestamp only, no headers).
A range query retrieves a set of records, specified using an upper and/or lower bound on the
keys. A scan query (no bounds) retrieves all records contained in the store. Keys' order is based
on the serialized byte[] of the keys, not the 'logical' key order.
Headers are persisted and returned only when the store is backed by a native headers store,
i.e. built with a KIP-1271 WithHeaders byte-store supplier (e.g.
Stores.persistentTimestampedKeyValueStoreWithHeaders). A WithHeaders store built
over a legacy (non-headers) supplier cannot persist headers, so the store-served reads come back
with empty headers().
Against a plain store not built with the WithHeaders builder at all, this query type is
unsupported and fails with FailureReason.UNKNOWN_QUERY_TYPE.
Each element is a ReadOnlyRecord, whose timestamp is non-negative. If the backing store
does not persist timestamps -- for example a WithHeaders store built over a plain
KeyValueStore supplier, which surfaces every entry with
NO_TIMESTAMP (-1) -- that entry cannot be represented, so advancing the returned
ReadOnlyRecordIterator throws StreamsException at
that entry. Back the store with Stores.persistentTimestampedKeyValueStoreWithHeaders(...) to
persist timestamps and headers, or use TimestampedRangeQuery if headers are not needed.
-
Method Summary
Modifier and TypeMethodDescriptionThe lower bound of the query, if specified.Determines if the serializedbyte[]of the keys in ascending or descending or unordered order.The upper bound of the query, if specified.Set the query to return the serializedbyte[]of the keys in ascending order.Set the query to return the serializedbyte[]of the keys in descending order.static <K,V> TimestampedRangeWithHeadersQuery <K, V> withLowerBound(K lower) Interactive range query using a lower bound to filter the keys returned.static <K,V> TimestampedRangeWithHeadersQuery <K, V> Interactive scan query that returns all records in the store.static <K,V> TimestampedRangeWithHeadersQuery <K, V> withRange(K lower, K upper) Interactive range query using a lower and upper bound to filter the keys returned.static <K,V> TimestampedRangeWithHeadersQuery <K, V> withUpperBound(K upper) Interactive range query using an upper bound to filter the keys returned.
-
Method Details
-
withRange
Interactive range query using a lower and upper bound to filter the keys returned.- Type Parameters:
K- The key typeV- The value type- Parameters:
lower- The key that specifies the lower bound of the rangeupper- The key that specifies the upper bound of the range
-
withUpperBound
Interactive range query using an upper bound to filter the keys returned.- Type Parameters:
K- The key typeV- The value type- Parameters:
upper- The key that specifies the upper bound of the range
-
withLowerBound
Interactive range query using a lower bound to filter the keys returned.- Type Parameters:
K- The key typeV- The value type- Parameters:
lower- The key that specifies the lower bound of the range
-
withNoBounds
Interactive scan query that returns all records in the store.- Type Parameters:
K- The key typeV- The value type
-
withDescendingKeys
Set the query to return the serializedbyte[]of the keys in descending order. Order is based on the serializedbyte[]of the keys, not the 'logical' key order.- Returns:
- a new query instance with the descending flag set.
-
withAscendingKeys
Set the query to return the serializedbyte[]of the keys in ascending order. Order is based on the serializedbyte[]of the keys, not the 'logical' key order.- Returns:
- a new query instance with the ascending flag set.
-
lowerBound
-
upperBound
-
resultOrder
Determines if the serializedbyte[]of the keys in ascending or descending or unordered order. Order is based on the serializedbyte[]of the keys, not the 'logical' key order.- Returns:
- the order of the returned records based on the serialized
byte[]of the keys (can be unordered, ascending, or descending).
-