Interface Grouper.KeySerde<T>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Grouper.BufferComparator
bufferComparator()
Return an object that knows how to compare two serialized keys.Grouper.BufferComparator
bufferComparatorWithAggregators(AggregatorFactory[] aggregatorFactories, int[] aggregatorOffsets)
When pushing down limits, it may also be necessary to compare aggregated values along with the key using the bufferComparator.T
createKey()
Create a reusable key that can be passed toreadFromByteBuffer(T, java.nio.ByteBuffer, int)
.List<String>
getDictionary()
Return the dictionary of this KeySerde.Class<T>
keyClazz()
Class of the keys.int
keySize()
Size of the keys returned bytoByteBuffer(Object)
(which must be a fixed size)void
readFromByteBuffer(T key, ByteBuffer buffer, int position)
Deserialize a key from a buffer.void
reset()
Reset the keySerde to its initial state.ByteBuffer
toByteBuffer(T key)
Serialize a key.
-
-
-
Method Detail
-
keySize
int keySize()
Size of the keys returned bytoByteBuffer(Object)
(which must be a fixed size)
-
getDictionary
List<String> getDictionary()
Return the dictionary of this KeySerde. The return value should not be null.
-
toByteBuffer
@Nullable ByteBuffer toByteBuffer(T key)
Serialize a key. This will be called by theGrouper.aggregate(Object)
method. The buffer will not be retained after the aggregate method returns, so reusing buffers is OK.This method may return null, which indicates that some internal resource limit has been reached and no more keys can be generated. In this situation you can call
reset()
and try again, although beware the caveats on that method.- Parameters:
key
- key object- Returns:
- serialized key, or null if we are unable to serialize more keys due to resource limits
-
createKey
T createKey()
Create a reusable key that can be passed toreadFromByteBuffer(T, java.nio.ByteBuffer, int)
.
-
readFromByteBuffer
void readFromByteBuffer(T key, ByteBuffer buffer, int position)
Deserialize a key from a buffer. Will be called by theGrouper.iterator(boolean)
method.- Parameters:
key
- object fromcreateKey()
buffer
- buffer containing the keyposition
- key start position in the buffer
-
bufferComparator
Grouper.BufferComparator bufferComparator()
Return an object that knows how to compare two serialized keys. Will be called by theGrouper.iterator(boolean)
method if sorting is enabled.- Returns:
- comparator for keys
-
bufferComparatorWithAggregators
Grouper.BufferComparator bufferComparatorWithAggregators(AggregatorFactory[] aggregatorFactories, int[] aggregatorOffsets)
When pushing down limits, it may also be necessary to compare aggregated values along with the key using the bufferComparator.- Parameters:
aggregatorFactories
- Array of aggregators from a GroupByQueryaggregatorOffsets
- Offsets for each aggregator in aggregatorFactories pointing to their location within the grouping key + aggs buffer.- Returns:
- comparator for keys + aggs
-
reset
void reset()
Reset the keySerde to its initial state. After this method is called,readFromByteBuffer(T, java.nio.ByteBuffer, int)
andbufferComparator()
may no longer work properly on previously-serialized keys.
-
-