Interface FrameWriter

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
ColumnarFrameWriter, RowBasedFrameWriter

public interface FrameWriter extends Closeable
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Write the current row to the frame that is under construction, if there is enough space to do so.
    void
     
    int
    Returns the number of rows written so far.
    long
    Returns the number of bytes that would be written by writeTo(org.apache.datasketches.memory.WritableMemory, long) if called now.
    default byte[]
    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 least getTotalSize() bytes available.
  • Method Details

    • 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 by writeTo(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 least 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 equal getTotalSize().
      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 interface AutoCloseable
      Specified by:
      close in interface Closeable