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 int
CHECKSUM_SEED
static byte[]
MAGIC
static byte
MARKER_FRAME
static byte
MARKER_NO_MORE_FRAMES
static int
NO_PARTITION
static int
TRAILER_LENGTH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Stops writing this file and closes early.void
close()
static FrameFileWriter
open(WritableByteChannel channel, ByteBuffer compressionBuffer, ByteTracker byteTracker)
Opens a writer for a particular channel.void
writeFrame(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_PARTITION
for an unpartitioned file. Must be monotonically increasing.- Throws:
IOException
-
abort
public void abort() throws IOException
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
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-