Class CycleResultsRLEBufferTarget
java.lang.Object
io.nosqlbench.engine.api.activityapi.cyclelog.buffers.results_rle.CycleResultsRLEBufferTarget
- All Implemented Interfaces:
CanFilterResultValue,Output,AutoCloseable
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 -
Constructor Summary
ConstructorsConstructorDescriptionCycleResultsRLEBufferTarget(int elementCount) Create a target RLE buffer for the specified getCount in memory, rounded to the nearest record getCount.Create a buffer with the provided ByteBuffer. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intintbooleanonCycleResult(long cycle, int result) Record new cycle result data in the buffer, and optionally flush any completed RLE segments to the internal ByteBuffer.booleanonCycleResult(CycleResult cycleResult) voidsetFilter(Predicate<ResultReadable> filter) 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, waitMethods inherited from interface io.nosqlbench.engine.api.activityapi.output.Output
onCycleResultSegment
-
Field Details
-
BYTES
public static final int BYTES- See Also:
-
-
Constructor Details
-
CycleResultsRLEBufferTarget
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
Convert the contents of this RLE buffer to a readable and invalide it for writing.- Returns:
- a CycleResultRLEBuffer
-
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:
onCycleResultin interfaceOutput- 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceOutput
-
onCycleResult
- Specified by:
onCycleResultin interfaceOutput
-
setFilter
- Specified by:
setFilterin interfaceCanFilterResultValue
-