Class 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.
    • Constructor Detail

      • 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 Detail

      • 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