Interface Grouper.KeySerde<T>

  • Enclosing interface:
    Grouper<KeyType>

    public static interface Grouper.KeySerde<T>
    Possibly-stateful object responsible for serde and comparison of keys. Does not need to be thread-safe.
    • Method Detail

      • keySize

        int keySize()
        Size of the keys returned by toByteBuffer(Object) (which must be a fixed size)
      • keyClazz

        Class<T> keyClazz()
        Class of the keys.
      • 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 the Grouper.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
      • readFromByteBuffer

        void readFromByteBuffer​(T key,
                                ByteBuffer buffer,
                                int position)
        Deserialize a key from a buffer. Will be called by the Grouper.iterator(boolean) method.
        Parameters:
        key - object from createKey()
        buffer - buffer containing the key
        position - key start position in the buffer
      • 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 GroupByQuery
        aggregatorOffsets - Offsets for each aggregator in aggregatorFactories pointing to their location within the grouping key + aggs buffer.
        Returns:
        comparator for keys + aggs