diff --git a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java index 878b79682e9..b66373c7b49 100644 --- a/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java +++ b/processing/src/main/java/io/druid/segment/incremental/IncrementalIndexStorageAdapter.java @@ -241,21 +241,27 @@ public class IncrementalIndexStorageAdapter implements StorageAdapter if (numAdvanced == -1) { numAdvanced = 0; + while (baseIter.hasNext()) { + currEntry.set(baseIter.next()); + if (filterMatcher.matches()) { + return; + } + + numAdvanced++; + } } else { Iterators.advance(baseIter, numAdvanced); - } + while (baseIter.hasNext()) { + currEntry.set(baseIter.next()); + if (filterMatcher.matches()) { + break; + } - while (baseIter.hasNext()) { - currEntry.set(baseIter.next()); - if (filterMatcher.matches()) { - return; + numAdvanced++; } - - numAdvanced++; } done = cursorMap.size() == 0 || !baseIter.hasNext(); - } @Override