Package org.apache.druid.frame.write
Interface FrameWriter
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
ColumnarFrameWriter
,RowBasedFrameWriter
public interface FrameWriter extends Closeable
Writer forFrame
. See that class for format information. Generally obtained through aFrameWriters.makeFrameWriterFactory(org.apache.druid.frame.FrameType, org.apache.druid.frame.allocation.MemoryAllocatorFactory, org.apache.druid.segment.column.RowSignature, java.util.List<org.apache.druid.frame.key.KeyColumn>)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
addSelection()
Write the current row to the frame that is under construction, if there is enough space to do so.void
close()
int
getNumRows()
Returns the number of rows written so far.long
getTotalSize()
Returns the number of bytes that would be written bywriteTo(org.apache.datasketches.memory.WritableMemory, long)
if called now.default byte[]
toByteArray()
Returns a frame as a newly-allocated byte array.long
writeTo(org.apache.datasketches.memory.WritableMemory memory, long position)
Writes the frame to the provided memory location, which must have at leastgetTotalSize()
bytes available.
-
-
-
Method Detail
-
addSelection
boolean addSelection()
Write the current row to the frame that is under construction, if there is enough space to do so.If this method returns false on an empty frame, or in a situation where starting a new frame is impractical, it is conventional (although not required) for the caller to throw
FrameRowTooLargeException
.- Returns:
- true if the row was written, false if there was not enough space
-
getNumRows
int getNumRows()
Returns the number of rows written so far.
-
getTotalSize
long getTotalSize()
Returns the number of bytes that would be written bywriteTo(org.apache.datasketches.memory.WritableMemory, long)
if called now.
-
writeTo
long writeTo(org.apache.datasketches.memory.WritableMemory memory, long position)
Writes the frame to the provided memory location, which must have at leastgetTotalSize()
bytes available. Once this method is called, the frame writer is no longer usable and must be closed. Returns the number of bytes written, which will equalgetTotalSize()
.- Throws:
IllegalStateException
- if the provided memory does not have sufficient space to write this frame.
-
toByteArray
default byte[] toByteArray()
Returns a frame as a newly-allocated byte array. Once this method is called, the frame writer is no longer usable and must be closed. In general, it is more efficient to write a frame into a pre-existing buffer, but this method is provided as a convenience.
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-