Class CycleResultsRLEBufferTarget

java.lang.Object
io.nosqlbench.engine.api.activityapi.cyclelog.buffers.results_rle.CycleResultsRLEBufferTarget
All Implemented Interfaces:
CanFilterResultValue, Output, AutoCloseable

public class CycleResultsRLEBufferTarget extends Object implements Output, CanFilterResultValue
Implements a convenient target buffer for Marker data that can be used to create nio ByteBuffers easily. This is not thread-safe. It is not meant to be used by concurrent callers. It is recommended to use the AutoCloseable method to ensure that partial runs are flushed automatically. Access the buffer for read via either the toByteBuffer() or the toSegmentsReadable() methods will automatically flush() and invalidate the writable buffer, so further writes will be deemed invalid and will cause an exception to be thrown.
  • Field Details

  • Constructor Details

    • CycleResultsRLEBufferTarget

      public CycleResultsRLEBufferTarget(ByteBuffer buf)
      Create a buffer with the provided ByteBuffer.
      Parameters:
      buf - the source data
    • CycleResultsRLEBufferTarget

      public CycleResultsRLEBufferTarget(int elementCount)
      Create a target RLE buffer for the specified getCount in memory, rounded to the nearest record getCount.
      Parameters:
      elementCount - The number of elements to buffer.
  • Method Details

    • toSegmentsReadable

      public CycleResultsRLEBufferReadable toSegmentsReadable()
      Convert the contents of this RLE buffer to a readable and invalide it for writing.
      Returns:
      a CycleResultRLEBuffer
    • toByteBuffer

      public ByteBuffer toByteBuffer()
    • onCycleResult

      public boolean onCycleResult(long cycle, int result)
      Record new cycle result data in the buffer, and optionally flush any completed RLE segments to the internal ByteBuffer.
      Specified by:
      onCycleResult in interface Output
      Parameters:
      cycle - The cycle number being marked.
      result - the result ordinal
      Returns:
      false if there was no more room in the buffer for another tuple, true otherwise.
      Throws:
      RuntimeException - if the buffer has been converted to a readable form
    • getRawBufferCapacity

      public int getRawBufferCapacity()
    • getRecordCapacity

      public int getRecordCapacity()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Output
    • onCycleResult

      public boolean onCycleResult(CycleResult cycleResult)
      Specified by:
      onCycleResult in interface Output
    • setFilter

      public void setFilter(Predicate<ResultReadable> filter)
      Specified by:
      setFilter in interface CanFilterResultValue