Source:
<code>protected List<ILogData> getNextEntries(QueuedStreamContext context, long maxGlobal, Function<ILogData, Boolean> contextCheckFn) { NavigableSet<Long> readSet = new TreeSet<>(); boolean readQueueIsEmpty = !fillReadQueue(maxGlobal, context); if (maxGlobal < context.checkpoint.startAddress) { throw new TrimmedException(); } if (readQueueIsEmpty) { return Collections.emptyList(); } readSet.addAll(context.readCpQueue); if (!context.readQueue.isEmpty() && context.readQueue.first() > maxGlobal) { } else { readSet.addAll(context.readQueue.headSet(maxGlobal, true)); } List<Long> toRead = readSet.stream() .collect(Collectors.toList()); List<ILogData> readFrom = readAll(toRead).stream() <START> .filter(x -> x.getType() == DataType.DATA || x.getType() == DataType.HOLE) <END> .filter(x -> x.containsStream(context.id)) .collect(Collectors.toList()); Optional<ILogData> contextEntry = readFrom.stream() .filter(contextCheckFn::apply).findFirst(); if (contextEntry.isPresent()) { log.trace("getNextEntries[{}] context switch @ {}", this, contextEntry.get().getGlobalAddress()); int idx = readFrom.indexOf(contextEntry.get()); readFrom = readFrom.subList(0, idx + 1); readSet.headSet(contextEntry.get().getGlobalAddress(), true).clear(); } else { context.readQueue.headSet(maxGlobal, true).clear(); } readFrom.forEach(entry -> addToResolvedQueue(context, entry.getGlobalAddress())); if (readFrom.size() > 0) { context.setGlobalPointerCheckGCTrimMark(readFrom.get(readFrom.size() - 1) .getGlobalAddress()); } return readFrom.stream().filter(entry -> !entry.isHole()) .collect(Collectors.toList()); }</code><technical_language>yeah I meant address hole itself, cool</technical_language>

Target:
protected List<ILogData> getNextEntries(QueuedStreamContext context, long maxGlobal, Function<ILogData, Boolean> contextCheckFn) { NavigableSet<Long> readSet = new TreeSet<>(); boolean readQueueIsEmpty = !fillReadQueue(maxGlobal, context); if (maxGlobal < context.checkpoint.startAddress) { throw new TrimmedException(); } if (readQueueIsEmpty) { return Collections.emptyList(); } readSet.addAll(context.readCpQueue); if (!context.readQueue.isEmpty() && context.readQueue.first() > maxGlobal) { } else { readSet.addAll(context.readQueue.headSet(maxGlobal, true)); } List<Long> toRead = readSet.stream() .collect(Collectors.toList()); List<ILogData> readFrom = readAll(toRead).stream() .filter(x -> x.isData() || x.isHole()) .filter(x -> x.containsStream(context.id)) .collect(Collectors.toList()); Optional<ILogData> contextEntry = readFrom.stream() .filter(contextCheckFn::apply).findFirst(); if (contextEntry.isPresent()) { log.trace("getNextEntries[{}] context switch @ {}", this, contextEntry.get().getGlobalAddress()); int idx = readFrom.indexOf(contextEntry.get()); readFrom = readFrom.subList(0, idx + 1); readSet.headSet(contextEntry.get().getGlobalAddress(), true).clear(); } else { context.readQueue.headSet(maxGlobal, true).clear(); } readFrom.forEach(entry -> addToResolvedQueue(context, entry.getGlobalAddress())); if (readFrom.size() > 0) { context.setGlobalPointerCheckGCTrimMark(readFrom.get(readFrom.size() - 1) .getGlobalAddress()); } return readFrom.stream() .filter(entry -> !entry.isHole()) .collect(Collectors.toList()); }