Package org.apache.druid.segment.data
Class GenericIndexedWriter<T>
- java.lang.Object
-
- org.apache.druid.segment.data.GenericIndexedWriter<T>
-
- All Implemented Interfaces:
DictionaryWriter<T>,Serializer
public class GenericIndexedWriter<T> extends Object implements DictionaryWriter<T>
Streams arrays of objects out in the binary format described byGenericIndexedThe versionEncodedStringDictionaryWriter.VERSIONis reserved and must never be specified as theGenericIndexedversion byte, else it will interfere with string column deserialization.
-
-
Constructor Summary
Constructors Constructor Description GenericIndexedWriter(SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, ObjectStrategy<T> strategy)GenericIndexedWriter(SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, ObjectStrategy<T> strategy, int fileSizeLimit)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ObjectStrategy<ByteBuffer>compressedByteBuffersWriteObjectStrategy(CompressionStrategy compressionStrategy, int bufferSize, Closer closer)static StringgenerateHeaderFileName(String fileNameBase)static StringgenerateValueFileName(String fileNameBase, int fileNum)Tget(int index)intgetCardinality()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.booleanisSorted()static GenericIndexedWriter<ByteBuffer>ofCompressedByteBuffers(SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, CompressionStrategy compressionStrategy, int bufferSize, Closer closer)voidopen()voidsetObjectsNotSorted()voidwrite(T objectToWrite)voidwriteTo(WritableByteChannel channel, FileSmoosher smoosher)Writes serialized form of this object to the given channel.
-
-
-
Constructor Detail
-
GenericIndexedWriter
public GenericIndexedWriter(SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, ObjectStrategy<T> strategy)
-
GenericIndexedWriter
public GenericIndexedWriter(SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, ObjectStrategy<T> strategy, int fileSizeLimit)
-
-
Method Detail
-
ofCompressedByteBuffers
public static GenericIndexedWriter<ByteBuffer> ofCompressedByteBuffers(SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, CompressionStrategy compressionStrategy, int bufferSize, Closer closer)
-
compressedByteBuffersWriteObjectStrategy
public static ObjectStrategy<ByteBuffer> compressedByteBuffersWriteObjectStrategy(CompressionStrategy compressionStrategy, int bufferSize, Closer closer)
-
open
public void open() throws IOException- Specified by:
openin interfaceDictionaryWriter<T>- Throws:
IOException
-
setObjectsNotSorted
public void setObjectsNotSorted()
-
isSorted
public boolean isSorted()
- Specified by:
isSortedin interfaceDictionaryWriter<T>
-
write
public void write(@Nullable T objectToWrite) throws IOException
- Specified by:
writein interfaceDictionaryWriter<T>- Throws:
IOException
-
get
@Nullable public T get(int index) throws IOException
- Specified by:
getin interfaceDictionaryWriter<T>- Throws:
IOException
-
getCardinality
public int getCardinality()
- Specified by:
getCardinalityin interfaceDictionaryWriter<T>
-
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.- Specified by:
getSerializedSizein interfaceSerializer
-
writeTo
public void writeTo(WritableByteChannel channel, @Nullable FileSmoosher smoosher) throws IOException
Description copied from interface:SerializerWrites serialized form of this object to the given channel. If parallel data streams are needed, they could be created with the provided smoosher.- Specified by:
writeToin interfaceSerializer- Throws:
IOException
-
-