Package org.apache.druid.frame.file
Class FrameFileWriter
java.lang.Object
org.apache.druid.frame.file.FrameFileWriter
- All Implemented Interfaces:
Closeable,AutoCloseable
Writer for
FrameFile. See that class for format information.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final byte[]static final bytestatic final bytestatic final bytestatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Stops writing this file and closes early.voidclose()static FrameFileWriteropen(WritableByteChannel channel, ByteBuffer compressionBuffer, ByteTracker byteTracker, WireTransferableContext wireTransferableContext) Opens a writer for a particular channel.voidwrite(RowsAndColumns rac, int partition) Write a batch of data to the file.
-
Field Details
-
MAGIC
public static final byte[] MAGIC -
MARKER_FRAME
public static final byte MARKER_FRAME- See Also:
-
MARKER_NO_MORE_FRAMES
public static final byte MARKER_NO_MORE_FRAMES- See Also:
-
MARKER_RAC
public static final byte MARKER_RAC- See Also:
-
TRAILER_LENGTH
public static final int TRAILER_LENGTH- See Also:
-
CHECKSUM_SEED
public static final int CHECKSUM_SEED- See Also:
-
NO_PARTITION
public static final int NO_PARTITION- See Also:
-
-
Method Details
-
open
public static FrameFileWriter open(WritableByteChannel channel, @Nullable ByteBuffer compressionBuffer, ByteTracker byteTracker, WireTransferableContext wireTransferableContext) Opens a writer for a particular channel.- Parameters:
channel- destination channelcompressionBuffer- result ofFrame.compressionBufferSize(long)for the largest possible frame size that will be written to this file, or null to allocate buffers dynamically. Providing an explicit buffer here, if possible, improves performance.byteTracker- tracker to limit the number of bytes that can be written to the frame filewireTransferableContext- context for wire transfer serialization
-
write
Write a batch of data to the file. If legacy frame serialization is enabled and the RowsAndColumns can be converted to a Frame, it will be written as raw frame bytes withMARKER_FRAME. Otherwise, it will be written usingWireTransferablewithMARKER_RAC.- Parameters:
rac- the RowsAndColumns to writepartition- partition number for a partitioned frame file, orNO_PARTITIONfor an unpartitioned file. Must be monotonically increasing.- Throws:
IOException
-
abort
Stops writing this file and closes early. Readers will be able to detect that the file is truncated due to the lack ofMARKER_NO_MORE_FRAMES. After calling this method,close()does nothing.- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-