Search in sources :

Example 1 with CycleResultArray

use of io.engineblock.activityapi.cyclelog.buffers.results.CycleResultArray in project engineblock by engineblock.

the class ReorderingConcurrentResultBuffer method onCycleResultSegment.

@Override
public synchronized void onCycleResultSegment(CycleResultsSegment segment) {
    if (resultFilter != null) {
        segment = segment.filter(resultFilter);
    }
    if (!(segment instanceof CanSortCycles)) {
        segment = new CycleResultArray(segment);
    }
    ((CanSortCycles) segment).sort();
    segments.add(segment);
    segmentCount++;
    currentCount += segment.getCount();
    if (currentCount >= threshold) {
        logger.trace("Reordering threshold met: " + currentCount + "/" + threshold + ", sorting and pushing. (" + segments.size() + " segments)");
        Collections.sort(segments);
        while (currentCount >= threshold) {
            CycleResultsSegment head = segments.removeFirst();
            downstream.onCycleResultSegment(head);
            segmentCount--;
            currentCount -= head.getCount();
        }
    }
}
Also used : CycleResultArray(io.engineblock.activityapi.cyclelog.buffers.results.CycleResultArray) CycleResultsSegment(io.engineblock.activityapi.cyclelog.buffers.results.CycleResultsSegment)

Aggregations

CycleResultArray (io.engineblock.activityapi.cyclelog.buffers.results.CycleResultArray)1 CycleResultsSegment (io.engineblock.activityapi.cyclelog.buffers.results.CycleResultsSegment)1