Package org.apache.druid.segment.nested
Class ScalarNestedCommonFormatColumnSerializer<T>
- java.lang.Object
-
- org.apache.druid.segment.nested.NestedCommonFormatColumnSerializer
-
- org.apache.druid.segment.nested.ScalarNestedCommonFormatColumnSerializer<T>
-
- All Implemented Interfaces:
GenericColumnSerializer<StructuredData>,Serializer
- Direct Known Subclasses:
ScalarDoubleColumnSerializer,ScalarLongColumnSerializer,ScalarStringColumnSerializer
public abstract class ScalarNestedCommonFormatColumnSerializer<T> extends NestedCommonFormatColumnSerializer
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanclosedForWriteprotected Closercloserprotected ByteBuffercolumnNameBytesprotected DictionaryIdLookupdictionaryIdLookupprotected booleandictionarySerializedprotected DictionaryWriter<T>dictionaryWriterprotected booleanhasNullsprotected IndexSpecindexSpecprotected FixedIndexedIntWriterintermediateValueWriterprotected static Loggerlogprotected Stringnameprotected SegmentWriteOutMediumsegmentWriteOutMediumprotected booleanwriteDictionary-
Fields inherited from class org.apache.druid.segment.nested.NestedCommonFormatColumnSerializer
NESTED_FIELD_PREFIX, RAW_FILE_NAME, V0
-
-
Constructor Summary
Constructors Constructor Description ScalarNestedCommonFormatColumnSerializer(String name, IndexSpec indexSpec, SegmentWriteOutMedium segmentWriteOutMedium, Closer closer)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intgetCardinality()StringgetColumnName()DictionaryIdLookupgetDictionaryIdLookup()longgetSerializedSize()Returns the number of bytes, that this Serializer will write to the output _channel_ (not smoosher) on aSerializer.writeTo(java.nio.channels.WritableByteChannel, org.apache.druid.java.util.common.io.smoosh.FileSmoosher)call.booleanhasNulls()voidopen()protected abstract voidopenValueColumnSerializer()Called duringopen()to allow opening any separate type specific value column serializersprotected abstract intprocessValue(Object rawValue)Called duringserialize(ColumnValueSelector)to convert value to dictionary id.voidserialize(ColumnValueSelector<? extends StructuredData> selector)voidsetDictionaryIdLookup(DictionaryIdLookup dictionaryIdLookup)protected abstract voidwriteDictionaryFile(FileSmoosher smoosher)voidwriteTo(WritableByteChannel channel, FileSmoosher smoosher)Writes the serialized form of this object.protected abstract voidwriteValueColumn(FileSmoosher smoosher)Called duringwriteTo(WritableByteChannel, FileSmoosher)to allow any type specific value column serializers to use theFileSmoosherto write stuff to places.-
Methods inherited from class org.apache.druid.segment.nested.NestedCommonFormatColumnSerializer
computeFilenameBytes, copyFromTempSmoosh, openDictionaryWriter, serializeDictionaries, serializeFields, writeInternal, writeV0Header
-
-
-
-
Field Detail
-
log
protected static final Logger log
-
name
protected final String name
-
segmentWriteOutMedium
protected final SegmentWriteOutMedium segmentWriteOutMedium
-
indexSpec
protected final IndexSpec indexSpec
-
closer
protected final Closer closer
-
dictionaryIdLookup
protected DictionaryIdLookup dictionaryIdLookup
-
dictionaryWriter
protected DictionaryWriter<T> dictionaryWriter
-
closedForWrite
protected boolean closedForWrite
-
dictionarySerialized
protected boolean dictionarySerialized
-
intermediateValueWriter
protected FixedIndexedIntWriter intermediateValueWriter
-
columnNameBytes
protected ByteBuffer columnNameBytes
-
hasNulls
protected boolean hasNulls
-
writeDictionary
protected boolean writeDictionary
-
-
Constructor Detail
-
ScalarNestedCommonFormatColumnSerializer
public ScalarNestedCommonFormatColumnSerializer(String name, IndexSpec indexSpec, SegmentWriteOutMedium segmentWriteOutMedium, Closer closer)
-
-
Method Detail
-
processValue
protected abstract int processValue(@Nullable Object rawValue) throws IOException
Called duringserialize(ColumnValueSelector)to convert value to dictionary id.Implementations may optionally also serialize the value to a type specific value column if they opened one with
openValueColumnSerializer(), or do whatever else is useful to do while handling a single row value.- Throws:
IOException
-
openValueColumnSerializer
protected abstract void openValueColumnSerializer() throws IOExceptionCalled duringopen()to allow opening any separate type specific value column serializers- Throws:
IOException
-
writeValueColumn
protected abstract void writeValueColumn(FileSmoosher smoosher) throws IOException
Called duringwriteTo(WritableByteChannel, FileSmoosher)to allow any type specific value column serializers to use theFileSmoosherto write stuff to places.- Throws:
IOException
-
writeDictionaryFile
protected abstract void writeDictionaryFile(FileSmoosher smoosher) throws IOException
- Throws:
IOException
-
getCardinality
public abstract int getCardinality()
-
getColumnName
public String getColumnName()
- Specified by:
getColumnNamein classNestedCommonFormatColumnSerializer
-
getDictionaryIdLookup
public DictionaryIdLookup getDictionaryIdLookup()
- Specified by:
getDictionaryIdLookupin classNestedCommonFormatColumnSerializer
-
setDictionaryIdLookup
public void setDictionaryIdLookup(DictionaryIdLookup dictionaryIdLookup)
- Specified by:
setDictionaryIdLookupin classNestedCommonFormatColumnSerializer
-
hasNulls
public boolean hasNulls()
- Specified by:
hasNullsin classNestedCommonFormatColumnSerializer
-
open
public void open() throws IOException- Throws:
IOException
-
serialize
public void serialize(ColumnValueSelector<? extends StructuredData> selector) throws IOException
- Throws:
IOException
-
getSerializedSize
public long getSerializedSize()
Description copied from interface:SerializerReturns the number of bytes, that this Serializer will write to the output _channel_ (not smoosher) on aSerializer.writeTo(java.nio.channels.WritableByteChannel, org.apache.druid.java.util.common.io.smoosh.FileSmoosher)call.
-
writeTo
public void writeTo(WritableByteChannel channel, FileSmoosher smoosher) throws IOException
Description copied from interface:SerializerWrites the serialized form of this object. The entire object may be written to the provided channel, or the object may be split over the provided channel and files added to the {@link FileSmoosher], where additional channels can be created viaFileSmoosher.addWithSmooshedWriter(String, long). The latter approach is useful when the serialized form of the object is too large for a single smoosh container. At the time this javadoc was written, the max smoosh container size is limit to the maxByteBuffersize.- Throws:
IOException
-
-