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 byGenericIndexed
The versionEncodedStringDictionaryWriter.VERSION
is reserved and must never be specified as theGenericIndexed
version 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 String
generateHeaderFileName(String fileNameBase)
static String
generateValueFileName(String fileNameBase, int fileNum)
T
get(int index)
int
getCardinality()
long
getSerializedSize()
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.boolean
isSorted()
static GenericIndexedWriter<ByteBuffer>
ofCompressedByteBuffers(SegmentWriteOutMedium segmentWriteOutMedium, String filenameBase, CompressionStrategy compressionStrategy, int bufferSize)
void
open()
void
setObjectsNotSorted()
void
write(T objectToWrite)
void
writeTo(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)
-
compressedByteBuffersWriteObjectStrategy
public static ObjectStrategy<ByteBuffer> compressedByteBuffersWriteObjectStrategy(CompressionStrategy compressionStrategy, int bufferSize, Closer closer)
-
open
public void open() throws IOException
- Specified by:
open
in interfaceDictionaryWriter<T>
- Throws:
IOException
-
setObjectsNotSorted
public void setObjectsNotSorted()
-
isSorted
public boolean isSorted()
- Specified by:
isSorted
in interfaceDictionaryWriter<T>
-
write
public void write(@Nullable T objectToWrite) throws IOException
- Specified by:
write
in interfaceDictionaryWriter<T>
- Throws:
IOException
-
get
@Nullable public T get(int index) throws IOException
- Specified by:
get
in interfaceDictionaryWriter<T>
- Throws:
IOException
-
getCardinality
public int getCardinality()
- Specified by:
getCardinality
in interfaceDictionaryWriter<T>
-
getSerializedSize
public long getSerializedSize()
Description copied from interface:Serializer
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.- Specified by:
getSerializedSize
in interfaceSerializer
-
writeTo
public void writeTo(WritableByteChannel channel, @Nullable FileSmoosher smoosher) throws IOException
Description copied from interface:Serializer
Writes 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:
writeTo
in interfaceSerializer
- Throws:
IOException
-
-