Package org.apache.druid.segment.serde
Class ComplexMetricSerde
- java.lang.Object
-
- org.apache.druid.segment.serde.ComplexMetricSerde
-
- Direct Known Subclasses:
HyperUniquesSerde
,NestedDataComplexTypeSerde
,SerializablePairLongStringComplexMetricSerde
public abstract class ComplexMetricSerde extends Object
-
-
Constructor Summary
Constructors Constructor Description ComplexMetricSerde()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract void
deserializeColumn(ByteBuffer buffer, ColumnBuilder builder)
Deprecated.void
deserializeColumn(ByteBuffer buffer, ColumnBuilder builder, ColumnConfig columnConfig)
Deserializes a ByteBuffer and adds it to the ColumnBuilder.Object
fromBytes(byte[] data, int start, int numBytes)
Converts byte[] to intermediate representation of the aggregate.abstract ComplexMetricExtractor
getExtractor()
abstract ObjectStrategy
getObjectStrategy()
Deprecated.GenericColumnSerializer
getSerializer(SegmentWriteOutMedium segmentWriteOutMedium, String column)
This method provides the ability for a ComplexMetricSerde to control its own serialization.abstract String
getTypeName()
<T extends Comparable<T>>
TypeStrategy<T>getTypeStrategy()
Get aTypeStrategy
to assist with writing individual complex values to aByteBuffer
.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.byte[]
toBytes(Object val)
Converts intermediate representation of aggregate to byte[].
-
-
-
Method Detail
-
getTypeName
public abstract String getTypeName()
-
getExtractor
public abstract ComplexMetricExtractor getExtractor()
-
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 deserializebuilder
- ColumnBuilder to add the column tocolumnConfig
- ColumnConfiguration used during deserialization
-
deserializeColumn
@Deprecated public abstract void deserializeColumn(ByteBuffer buffer, ColumnBuilder builder)
Deprecated.deserializeColumn(ByteBuffer, ColumnBuilder, ColumnConfig)
should be used instead of this. This method is left for backward compatibility.
-
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 aTypeStrategy
to assist with writing individual complex values to aByteBuffer
.- See Also:
TypeStrategy
-
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
- arraystart
- offset in the byte array where to start readingnumBytes
- number of bytes to read in given array- Returns:
- intermediate representation of the aggregate
-
getSerializer
public GenericColumnSerializer getSerializer(SegmentWriteOutMedium segmentWriteOutMedium, String column)
This method provides the ability for a ComplexMetricSerde to control its own serialization. For large column (i.e columns greater thanInteger.MAX_VALUE
) useLargeColumnSupportedComplexColumnSerializer
- Returns:
- an instance of GenericColumnSerializer used for serialization.
-
-