Package org.apache.druid.frame.write
Class RowBasedFrameWriter
- java.lang.Object
-
- org.apache.druid.frame.write.RowBasedFrameWriter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FrameWriter
public class RowBasedFrameWriter extends Object implements FrameWriter
Write row-based frames: typeFrameType.ROW_BASED
. Row-based frames have two regions: an offset region and data region. The offset region has one integer per row containing the ending position of each row within the data region. The data region has each row laid out back to back. Each row has a header section with one int per field, containing the end position of that field relative to the start of the row. This header is followed by the fields.
-
-
Field Summary
Fields Modifier and Type Field Description static int
NUM_REGIONS
static int
ROW_DATA_REGION
static int
ROW_OFFSET_REGION
-
Constructor Summary
Constructors Constructor Description RowBasedFrameWriter(RowSignature signature, List<KeyColumn> sortColumns, List<FieldWriter> fieldWriters, Supplier<MemoryRange<org.apache.datasketches.memory.Memory>> rowMemorySupplier, AppendableMemory rowOrderMemory, AppendableMemory rowOffsetMemory, AppendableMemory dataMemory)
-
Method Summary
All Methods Instance Methods Concrete 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 byFrameWriter.writeTo(org.apache.datasketches.memory.WritableMemory, long)
if called now.long
writeTo(org.apache.datasketches.memory.WritableMemory memory, long startPosition)
Writes the frame to the provided memory location, which must have at leastFrameWriter.getTotalSize()
bytes available.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.frame.write.FrameWriter
toByteArray
-
-
-
-
Field Detail
-
ROW_OFFSET_REGION
public static final int ROW_OFFSET_REGION
- See Also:
- Constant Field Values
-
ROW_DATA_REGION
public static final int ROW_DATA_REGION
- See Also:
- Constant Field Values
-
NUM_REGIONS
public static final int NUM_REGIONS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RowBasedFrameWriter
public RowBasedFrameWriter(RowSignature signature, List<KeyColumn> sortColumns, List<FieldWriter> fieldWriters, @Nullable Supplier<MemoryRange<org.apache.datasketches.memory.Memory>> rowMemorySupplier, @Nullable AppendableMemory rowOrderMemory, AppendableMemory rowOffsetMemory, AppendableMemory dataMemory)
-
-
Method Detail
-
addSelection
public boolean addSelection()
Description copied from interface:FrameWriter
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
.- Specified by:
addSelection
in interfaceFrameWriter
- Returns:
- true if the row was written, false if there was not enough space
-
getNumRows
public int getNumRows()
Description copied from interface:FrameWriter
Returns the number of rows written so far.- Specified by:
getNumRows
in interfaceFrameWriter
-
getTotalSize
public long getTotalSize()
Description copied from interface:FrameWriter
Returns the number of bytes that would be written byFrameWriter.writeTo(org.apache.datasketches.memory.WritableMemory, long)
if called now.- Specified by:
getTotalSize
in interfaceFrameWriter
-
writeTo
public long writeTo(org.apache.datasketches.memory.WritableMemory memory, long startPosition)
Description copied from interface:FrameWriter
Writes the frame to the provided memory location, which must have at leastFrameWriter.getTotalSize()
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 equalFrameWriter.getTotalSize()
.- Specified by:
writeTo
in interfaceFrameWriter
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFrameWriter
-
-