Skip to content

Commit

Permalink
optimise iteration (apache#8213)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardstartin authored and xiangfu0 committed Feb 23, 2022
1 parent c0ee672 commit 16912af
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
import org.apache.pinot.spi.utils.ByteArray;
import org.apache.pinot.spi.utils.FixedIntArray;
import org.apache.pinot.spi.utils.builder.TableNameBuilder;
import org.roaringbitmap.IntIterator;
import org.roaringbitmap.BatchIterator;
import org.roaringbitmap.buffer.MutableRoaringBitmap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -911,11 +912,15 @@ public int[] getSortedDocIdIterationOrderWithSortedColumn(String column) {
// Re-order documents using the inverted index
RealtimeInvertedIndexReader invertedIndex = indexContainer._invertedIndex;
int[] docIds = new int[_numDocsIndexed];
int[] batch = new int[256];
int docIdIndex = 0;
for (int dictId : dictIds) {
IntIterator intIterator = invertedIndex.getDocIds(dictId).getIntIterator();
while (intIterator.hasNext()) {
docIds[docIdIndex++] = intIterator.next();
MutableRoaringBitmap bitmap = invertedIndex.getDocIds(dictId);
BatchIterator iterator = bitmap.getBatchIterator();
while (iterator.hasNext()) {
int limit = iterator.nextBatch(batch);
System.arraycopy(batch, 0, docIds, docIdIndex, limit);
docIdIndex += limit;
}
}

Expand Down

0 comments on commit 16912af

Please sign in to comment.