Class WindowKeySchema
- java.lang.Object
-
- org.apache.kafka.streams.state.internals.WindowKeySchema
-
- All Implemented Interfaces:
SegmentedBytesStore.KeySchema
public class WindowKeySchema extends java.lang.Object implements SegmentedBytesStore.KeySchema
-
-
Constructor Summary
Constructors Constructor Description WindowKeySchema()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K> K
extractStoreKey(byte[] binaryKey, StateSerdes<K,?> serdes)
static byte[]
extractStoreKeyBytes(byte[] binaryKey)
static int
extractStoreSequence(byte[] binaryKey)
static long
extractStoreTimestamp(byte[] binaryKey)
static Window
extractStoreWindow(byte[] binaryKey, long windowSize)
static <K> Windowed<K>
from(byte[] binaryKey, long windowSize, org.apache.kafka.common.serialization.Deserializer<K> deserializer, java.lang.String topic)
static Windowed<org.apache.kafka.common.utils.Bytes>
fromStoreKey(byte[] binaryKey, long windowSize)
static <K> Windowed<K>
fromStoreKey(byte[] binaryKey, long windowSize, StateSerdes<K,?> serdes)
org.apache.kafka.streams.state.internals.HasNextCondition
hasNextCondition(org.apache.kafka.common.utils.Bytes binaryKeyFrom, org.apache.kafka.common.utils.Bytes binaryKeyTo, long from, long to)
Create an implementation ofHasNextCondition
that knows when to stop iterating over the Segments.org.apache.kafka.common.utils.Bytes
lowerRange(org.apache.kafka.common.utils.Bytes key, long from)
Given a range of record keys and a time, construct a Segmented key that represents the lower range of keys to search when performing range queries.org.apache.kafka.common.utils.Bytes
lowerRangeFixedSize(org.apache.kafka.common.utils.Bytes key, long from)
Given a range of fixed size record keys and a time, construct a Segmented key that represents the lower range of keys to search when performing range queries.java.util.List<org.apache.kafka.streams.state.internals.Segment>
segmentsToSearch(org.apache.kafka.streams.state.internals.Segments segments, long from, long to)
Used duringSegmentedBytesStore.fetch(Bytes, long, long)
operations to determine which segments should be scanned.long
segmentTimestamp(org.apache.kafka.common.utils.Bytes key)
Extract the timestamp of the segment from the key.static TimeWindow
timeWindowForSize(long startMs, long windowSize)
Safely construct a time window of the given size, taking care of bounding endMs to Long.MAX_VALUE if necessarystatic <K> byte[]
toBinary(Windowed<K> timeKey, org.apache.kafka.common.serialization.Serializer<K> serializer, java.lang.String topic)
static <K> org.apache.kafka.common.utils.Bytes
toStoreKeyBinary(K key, long timestamp, int seqnum, StateSerdes<K,?> serdes)
static org.apache.kafka.common.utils.Bytes
toStoreKeyBinary(org.apache.kafka.common.utils.Bytes key, long timestamp, int seqnum)
static <K> org.apache.kafka.common.utils.Bytes
toStoreKeyBinary(Windowed<K> timeKey, int seqnum, StateSerdes<K,?> serdes)
static org.apache.kafka.common.utils.Bytes
toStoreKeyBinary(Windowed<org.apache.kafka.common.utils.Bytes> timeKey, int seqnum)
org.apache.kafka.common.utils.Bytes
upperRange(org.apache.kafka.common.utils.Bytes key, long to)
Given a range of record keys and a time, construct a Segmented key that represents the upper range of keys to search when performing range queries.org.apache.kafka.common.utils.Bytes
upperRangeFixedSize(org.apache.kafka.common.utils.Bytes key, long to)
Given a range of fixed size record keys and a time, construct a Segmented key that represents the upper range of keys to search when performing range queries.
-
-
-
Method Detail
-
upperRange
public org.apache.kafka.common.utils.Bytes upperRange(org.apache.kafka.common.utils.Bytes key, long to)
Description copied from interface:SegmentedBytesStore.KeySchema
Given a range of record keys and a time, construct a Segmented key that represents the upper range of keys to search when performing range queries.- Specified by:
upperRange
in interfaceSegmentedBytesStore.KeySchema
- Returns:
- The key that represents the upper range to search for in the store
- See Also:
SessionKeySchema.upperRange(org.apache.kafka.common.utils.Bytes, long)
,upperRange(org.apache.kafka.common.utils.Bytes, long)
-
lowerRange
public org.apache.kafka.common.utils.Bytes lowerRange(org.apache.kafka.common.utils.Bytes key, long from)
Description copied from interface:SegmentedBytesStore.KeySchema
Given a range of record keys and a time, construct a Segmented key that represents the lower range of keys to search when performing range queries.- Specified by:
lowerRange
in interfaceSegmentedBytesStore.KeySchema
- Returns:
- The key that represents the lower range to search for in the store
- See Also:
SessionKeySchema.lowerRange(org.apache.kafka.common.utils.Bytes, long)
,lowerRange(org.apache.kafka.common.utils.Bytes, long)
-
lowerRangeFixedSize
public org.apache.kafka.common.utils.Bytes lowerRangeFixedSize(org.apache.kafka.common.utils.Bytes key, long from)
Description copied from interface:SegmentedBytesStore.KeySchema
Given a range of fixed size record keys and a time, construct a Segmented key that represents the lower range of keys to search when performing range queries.- Specified by:
lowerRangeFixedSize
in interfaceSegmentedBytesStore.KeySchema
- Parameters:
key
- the first key in the rangefrom
- the first timestamp in the range- Returns:
- The key that represents the lower range to search for in the store
- See Also:
SessionKeySchema.lowerRange(org.apache.kafka.common.utils.Bytes, long)
,lowerRange(org.apache.kafka.common.utils.Bytes, long)
-
upperRangeFixedSize
public org.apache.kafka.common.utils.Bytes upperRangeFixedSize(org.apache.kafka.common.utils.Bytes key, long to)
Description copied from interface:SegmentedBytesStore.KeySchema
Given a range of fixed size record keys and a time, construct a Segmented key that represents the upper range of keys to search when performing range queries.- Specified by:
upperRangeFixedSize
in interfaceSegmentedBytesStore.KeySchema
- Parameters:
key
- the last key in the rangeto
- the last timestamp in the range- Returns:
- The key that represents the upper range to search for in the store
- See Also:
SessionKeySchema.upperRange(org.apache.kafka.common.utils.Bytes, long)
,upperRange(org.apache.kafka.common.utils.Bytes, long)
-
segmentTimestamp
public long segmentTimestamp(org.apache.kafka.common.utils.Bytes key)
Description copied from interface:SegmentedBytesStore.KeySchema
Extract the timestamp of the segment from the key. The key is a composite of the record-key, any timestamps, plus any additional information.- Specified by:
segmentTimestamp
in interfaceSegmentedBytesStore.KeySchema
- Returns:
- See Also:
SessionKeySchema.lowerRange(org.apache.kafka.common.utils.Bytes, long)
,lowerRange(org.apache.kafka.common.utils.Bytes, long)
-
hasNextCondition
public org.apache.kafka.streams.state.internals.HasNextCondition hasNextCondition(org.apache.kafka.common.utils.Bytes binaryKeyFrom, org.apache.kafka.common.utils.Bytes binaryKeyTo, long from, long to)
Description copied from interface:SegmentedBytesStore.KeySchema
Create an implementation ofHasNextCondition
that knows when to stop iterating over the Segments. Used duringSegmentedBytesStore.fetch(Bytes, Bytes, long, long)
operations- Specified by:
hasNextCondition
in interfaceSegmentedBytesStore.KeySchema
- Parameters:
binaryKeyFrom
- the first key in the rangebinaryKeyTo
- the last key in the rangefrom
- starting time rangeto
- ending time range- Returns:
-
segmentsToSearch
public java.util.List<org.apache.kafka.streams.state.internals.Segment> segmentsToSearch(org.apache.kafka.streams.state.internals.Segments segments, long from, long to)
Description copied from interface:SegmentedBytesStore.KeySchema
Used duringSegmentedBytesStore.fetch(Bytes, long, long)
operations to determine which segments should be scanned.- Specified by:
segmentsToSearch
in interfaceSegmentedBytesStore.KeySchema
- Returns:
- List of segments to search
-
timeWindowForSize
public static TimeWindow timeWindowForSize(long startMs, long windowSize)
Safely construct a time window of the given size, taking care of bounding endMs to Long.MAX_VALUE if necessary
-
toBinary
public static <K> byte[] toBinary(Windowed<K> timeKey, org.apache.kafka.common.serialization.Serializer<K> serializer, java.lang.String topic)
-
from
public static <K> Windowed<K> from(byte[] binaryKey, long windowSize, org.apache.kafka.common.serialization.Deserializer<K> deserializer, java.lang.String topic)
-
toStoreKeyBinary
public static org.apache.kafka.common.utils.Bytes toStoreKeyBinary(org.apache.kafka.common.utils.Bytes key, long timestamp, int seqnum)
-
toStoreKeyBinary
public static <K> org.apache.kafka.common.utils.Bytes toStoreKeyBinary(K key, long timestamp, int seqnum, StateSerdes<K,?> serdes)
-
toStoreKeyBinary
public static org.apache.kafka.common.utils.Bytes toStoreKeyBinary(Windowed<org.apache.kafka.common.utils.Bytes> timeKey, int seqnum)
-
toStoreKeyBinary
public static <K> org.apache.kafka.common.utils.Bytes toStoreKeyBinary(Windowed<K> timeKey, int seqnum, StateSerdes<K,?> serdes)
-
extractStoreKeyBytes
public static byte[] extractStoreKeyBytes(byte[] binaryKey)
-
extractStoreKey
public static <K> K extractStoreKey(byte[] binaryKey, StateSerdes<K,?> serdes)
-
extractStoreTimestamp
public static long extractStoreTimestamp(byte[] binaryKey)
-
extractStoreSequence
public static int extractStoreSequence(byte[] binaryKey)
-
fromStoreKey
public static <K> Windowed<K> fromStoreKey(byte[] binaryKey, long windowSize, StateSerdes<K,?> serdes)
-
fromStoreKey
public static Windowed<org.apache.kafka.common.utils.Bytes> fromStoreKey(byte[] binaryKey, long windowSize)
-
extractStoreWindow
public static Window extractStoreWindow(byte[] binaryKey, long windowSize)
-
-