Class CycleResultsRLEBufferTarget

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

public class CycleResultsRLEBufferTarget
extends java.lang.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 Summary

    Fields 
    Modifier and Type Field Description
    static int BYTES  
  • Constructor Summary

    Constructors 
    Constructor Description
    CycleResultsRLEBufferTarget​(int elementCount)
    Create a target RLE buffer for the specified getCount in memory, rounded to the nearest record getCount.
    CycleResultsRLEBufferTarget​(java.nio.ByteBuffer buf)
    Create a buffer with the provided ByteBuffer.
  • Method Summary

    Modifier and Type Method Description
    void close()  
    int getRawBufferCapacity()  
    int getRecordCapacity()  
    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.
    boolean onCycleResult​(CycleResult cycleResult)  
    void setFilter​(java.util.function.Predicate<ResultReadable> filter)  
    java.nio.ByteBuffer toByteBuffer()  
    CycleResultsRLEBufferReadable toSegmentsReadable()
    Convert the contents of this RLE buffer to a readable and invalide it for writing.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.nosqlbench.engine.api.activityapi.output.Output

    onCycleResultSegment
  • Field Details

  • Constructor Details

    • CycleResultsRLEBufferTarget

      public CycleResultsRLEBufferTarget​(java.nio.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 java.nio.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:
      java.lang.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 java.lang.AutoCloseable
      Specified by:
      close in interface Output
    • onCycleResult

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

      public void setFilter​(java.util.function.Predicate<ResultReadable> filter)
      Specified by:
      setFilter in interface CanFilterResultValue