Class ComplexMetricSerde

java.lang.Object
org.apache.druid.segment.serde.ComplexMetricSerde
Direct Known Subclasses:
AbstractSerializableLongObjectPairSerde, HyperUniquesSerde, NestedDataComplexTypeSerde, SerializablePairLongStringComplexMetricSerde

public abstract class ComplexMetricSerde extends Object
  • Constructor Details

    • ComplexMetricSerde

      public ComplexMetricSerde()
  • Method Details

    • getTypeName

      public abstract String getTypeName()
    • getExtractor

      public abstract ComplexMetricExtractor getExtractor()
    • getObjectStrategy

      @Deprecated public abstract ObjectStrategy getObjectStrategy()
      Deprecated.
      This is deprecated because its usage is going to be removed from the code.

      It was introduced before deserializeColumn() existed. This method creates the assumption that Druid knows how to interpret the actual column representation of the data, but I would much prefer that the ComplexMetricSerde objects be in charge of creating and interpreting the whole column, which is what deserializeColumn lets them do.

      Returns:
      an ObjectStrategy as used by GenericIndexed
    • getTypeStrategy

      public <T extends Comparable<T>> TypeStrategy<T> getTypeStrategy()
      Get a TypeStrategy to assist with writing individual complex values to a ByteBuffer.
      See Also:
    • inputSizeFn

      @Nullable public com.google.common.base.Function<Object,Long> inputSizeFn()
      Returns a function that can convert the Object provided by the ComplexColumn created through deserializeColumn into a number of expected input bytes to produce that object.

      This is used to approximate the size of the input data via the SegmentMetadataQuery and does not need to be overridden if you do not care about the query.

      Returns:
      A function that can compute the size of the complex object or null if you cannot/do not want to compute it
    • toBytes

      public byte[] toBytes(@Nullable Object val)
      Converts intermediate representation of aggregate to byte[].
      Parameters:
      val - intermediate representation of aggregate
      Returns:
      serialized intermediate representation of aggregate in byte[]
    • fromBytes

      public Object fromBytes(byte[] data, int start, int numBytes)
      Converts byte[] to intermediate representation of the aggregate.
      Parameters:
      data - array
      start - offset in the byte array where to start reading
      numBytes - number of bytes to read in given array
      Returns:
      intermediate representation of the aggregate
    • deserializeColumn

      public void deserializeColumn(ByteBuffer buffer, ColumnBuilder builder, ColumnConfig columnConfig)
      Deserializes a ByteBuffer and adds it to the ColumnBuilder. This method allows for the ComplexMetricSerde to implement it's own versioning scheme to allow for changes of binary format in a forward-compatible manner.
      Parameters:
      buffer - the buffer to deserialize
      builder - ColumnBuilder to add the column to
      columnConfig - ColumnConfiguration used during deserialization
    • deserializeColumn

      @Deprecated public void deserializeColumn(ByteBuffer buffer, ColumnBuilder builder)
      Deprecated.
      deserializeColumn(ByteBuffer, ColumnBuilder, ColumnConfig) should be used instead of this. This method is left for backward compatibility.
    • getSerializer

      @Nullable @Deprecated public GenericColumnSerializer getSerializer(SegmentWriteOutMedium segmentWriteOutMedium, String column)
      Deprecated.
      getSerializer(SegmentWriteOutMedium, String, IndexSpec) should be used instead of this. This method is left for backward compatibility.
    • getSerializer

      public GenericColumnSerializer getSerializer(SegmentWriteOutMedium segmentWriteOutMedium, String column, IndexSpec indexSpec)
      This method provides the ability for a ComplexMetricSerde to control its own serialization. Default implementation uses CompressedComplexColumnSerializer if IndexSpec.complexMetricCompression is not null or uncompressed/none, or LargeColumnSupportedComplexColumnSerializer if no compression is specified.
      Returns:
      an instance of GenericColumnSerializer used for serialization.