Package org.apache.druid.frame.file
Class FrameFileWriter
- java.lang.Object
-
- org.apache.druid.frame.file.FrameFileWriter
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class FrameFileWriter extends Object implements Closeable
Writer forFrameFile. See that class for format information.
-
-
Field Summary
Fields Modifier and Type Field Description static intCHECKSUM_SEEDstatic byte[]MAGICstatic byteMARKER_FRAMEstatic byteMARKER_NO_MORE_FRAMESstatic intNO_PARTITIONstatic intTRAILER_LENGTH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Stops writing this file and closes early.voidclose()static FrameFileWriteropen(WritableByteChannel channel, ByteBuffer compressionBuffer, ByteTracker byteTracker)Opens a writer for a particular channel.voidwriteFrame(Frame frame, int partition)Write a frame.
-
-
-
Field Detail
-
MAGIC
public static final byte[] MAGIC
-
MARKER_FRAME
public static final byte MARKER_FRAME
- See Also:
- Constant Field Values
-
MARKER_NO_MORE_FRAMES
public static final byte MARKER_NO_MORE_FRAMES
- See Also:
- Constant Field Values
-
TRAILER_LENGTH
public static final int TRAILER_LENGTH
- See Also:
- Constant Field Values
-
CHECKSUM_SEED
public static final int CHECKSUM_SEED
- See Also:
- Constant Field Values
-
NO_PARTITION
public static final int NO_PARTITION
- See Also:
- Constant Field Values
-
-
Method Detail
-
open
public static FrameFileWriter open(WritableByteChannel channel, @Nullable ByteBuffer compressionBuffer, ByteTracker byteTracker)
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 file
-
writeFrame
public void writeFrame(Frame frame, int partition) throws IOException
Write a frame.- Parameters:
frame- the framepartition- partition number for a partitioned frame file, orNO_PARTITIONfor an unpartitioned file. Must be monotonically increasing.- Throws:
IOException
-
abort
public void abort() throws IOExceptionStops 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
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-