use of io.engineblock.activityapi.cyclelog.buffers.results_rle.CycleResultsRLEBufferTarget in project engineblock by engineblock.
the class CycleLogOutput method onCycleResultSegment.
@Override
public void onCycleResultSegment(CycleResultsSegment segment) {
for (CycleResult cycleResult : segment) {
if (filter == null || filter.test(cycleResult)) {
boolean buffered = targetBuffer.onCycleResult(cycleResult);
if (!buffered) {
flush();
targetBuffer = new CycleResultsRLEBufferTarget(extentSizeInSpans);
boolean bufferedAfterFlush = targetBuffer.onCycleResult(cycleResult);
if (!bufferedAfterFlush) {
throw new RuntimeException("Failed to record result in new target buffer");
}
}
}
}
}
use of io.engineblock.activityapi.cyclelog.buffers.results_rle.CycleResultsRLEBufferTarget in project engineblock by engineblock.
the class CycleResultsRLEBufferReadableTest method testIteratorExhausted.
@Test
public void testIteratorExhausted() {
CycleResultsRLEBufferTarget t = new CycleResultsRLEBufferTarget(1000);
t.onCycleResult(1L, 5);
t.onCycleResult(2L, 6);
t.onCycleResult(4L, 8);
CycleResultsRLEBufferReadable cr = t.toSegmentsReadable();
Iterator<CycleResultsSegment> iterator = cr.iterator();
CycleResultsSegment s1 = iterator.next();
assertThat(s1.getCount()).isEqualTo(1);
CycleResultsSegment s2 = iterator.next();
assertThat(s2.getCount()).isEqualTo(1);
CycleResultsSegment s3 = iterator.next();
assertThat(s3.getCount()).isEqualTo(1);
assertThat(iterator.hasNext()).isFalse();
// long[] cycleValues = StreamSupport.stream(cr.spliterator(), false)
// .mapToLong(CycleResult::getCycle).toArray();
// int[] resultValues = StreamSupport.stream(cr.spliterator(), false)
// .mapToInt(CycleResult::getResult).toArray();
//
// assertThat(cycleValues).containsExactly(1L, 2L, 4L);
// assertThat(resultValues).containsExactly(5, 6, 8);
//
}
Aggregations