use of com.linkedin.pinot.core.operator.dociditerators.BitmapDocIdIterator in project pinot by linkedin.
the class StarTreeIndexOperator method nextFilterBlock.
@Override
public BaseFilterBlock nextFilterBlock(BlockId blockId) {
MutableRoaringBitmap finalResult = null;
if (emptyResult) {
finalResult = new MutableRoaringBitmap();
final BitmapDocIdIterator bitmapDocIdIterator = new BitmapDocIdIterator(finalResult.getIntIterator());
return createBaseFilterBlock(bitmapDocIdIterator);
}
List<BaseFilterOperator> matchingLeafOperators = buildMatchingLeafOperators();
if (matchingLeafOperators.size() == 1) {
BaseFilterOperator baseFilterOperator = (BaseFilterOperator) matchingLeafOperators.get(0);
return baseFilterOperator.nextFilterBlock(blockId);
} else {
CompositeOperator compositeOperator = new CompositeOperator(matchingLeafOperators);
return compositeOperator.nextFilterBlock(blockId);
}
}
use of com.linkedin.pinot.core.operator.dociditerators.BitmapDocIdIterator in project pinot by linkedin.
the class AndBlockDocIdSet method slowIterator.
public BlockDocIdIterator slowIterator() {
List<BlockDocIdIterator> rawIterators = new ArrayList<>();
boolean useBitmapBasedIntersection = false;
for (BlockDocIdSet docIdSet : blockDocIdSets) {
if (docIdSet instanceof BitmapDocIdSet) {
useBitmapBasedIntersection = true;
}
}
BlockDocIdIterator[] docIdIterators;
if (useBitmapBasedIntersection) {
List<ImmutableRoaringBitmap> allBitmaps = new ArrayList<ImmutableRoaringBitmap>();
for (BlockDocIdSet docIdSet : blockDocIdSets) {
if (docIdSet instanceof SortedDocIdSet) {
MutableRoaringBitmap bitmap = new MutableRoaringBitmap();
SortedDocIdSet sortedDocIdSet = (SortedDocIdSet) docIdSet;
List<IntPair> pairs = sortedDocIdSet.getRaw();
for (IntPair pair : pairs) {
// add takes [start, end) i.e inclusive
bitmap.add(pair.getLeft(), pair.getRight() + 1);
// start, exclusive end.
}
allBitmaps.add(bitmap);
} else if (docIdSet instanceof BitmapDocIdSet) {
BitmapDocIdSet bitmapDocIdSet = (BitmapDocIdSet) docIdSet;
ImmutableRoaringBitmap childBitmap = bitmapDocIdSet.getRaw();
allBitmaps.add(childBitmap);
} else {
BlockDocIdIterator iterator = docIdSet.iterator();
rawIterators.add(iterator);
}
}
IntIterator intIterator;
if (allBitmaps.size() > 1) {
MutableRoaringBitmap answer = (MutableRoaringBitmap) allBitmaps.get(0).clone();
for (int i = 1; i < allBitmaps.size(); i++) {
answer.and(allBitmaps.get(i));
}
intIterator = answer.getIntIterator();
} else {
intIterator = allBitmaps.get(0).getIntIterator();
}
BitmapDocIdIterator singleBitmapBlockIdIterator = new BitmapDocIdIterator(intIterator);
singleBitmapBlockIdIterator.setStartDocId(minDocId);
singleBitmapBlockIdIterator.setEndDocId(maxDocId);
rawIterators.add(0, singleBitmapBlockIdIterator);
docIdIterators = new BlockDocIdIterator[rawIterators.size()];
rawIterators.toArray(docIdIterators);
} else {
docIdIterators = new BlockDocIdIterator[blockDocIdSets.size()];
for (int srcId = 0; srcId < blockDocIdSets.size(); srcId++) {
docIdIterators[srcId] = blockDocIdSets.get(srcId).iterator();
}
}
return new AndDocIdIterator(docIdIterators);
}
use of com.linkedin.pinot.core.operator.dociditerators.BitmapDocIdIterator in project pinot by linkedin.
the class BitmapDocIdSet method iterator.
@Override
public BlockDocIdIterator iterator() {
bitmapBasedBlockIdIterator = new BitmapDocIdIterator(answer.getIntIterator());
bitmapBasedBlockIdIterator.setStartDocId(startDocId);
bitmapBasedBlockIdIterator.setEndDocId(endDocId);
return bitmapBasedBlockIdIterator;
}
use of com.linkedin.pinot.core.operator.dociditerators.BitmapDocIdIterator in project pinot by linkedin.
the class OrBlockDocIdSet method iterator.
@Override
public BlockDocIdIterator iterator() {
List<BlockDocIdIterator> rawIterators = new ArrayList<>();
boolean useBitmapOr = false;
for (BlockDocIdSet docIdSet : docIdSets) {
if (docIdSet instanceof BitmapDocIdSet) {
useBitmapOr = true;
}
}
if (useBitmapOr) {
List<ImmutableRoaringBitmap> allBitmaps = new ArrayList<ImmutableRoaringBitmap>();
for (BlockDocIdSet docIdSet : docIdSets) {
if (docIdSet instanceof SortedDocIdSet) {
MutableRoaringBitmap bitmap = new MutableRoaringBitmap();
SortedDocIdSet sortedDocIdSet = (SortedDocIdSet) docIdSet;
List<Pairs.IntPair> pairs = sortedDocIdSet.getRaw();
for (Pairs.IntPair pair : pairs) {
//add takes [start, end) i.e inclusive start, exclusive end.
bitmap.add(pair.getLeft(), pair.getRight() + 1);
}
allBitmaps.add(bitmap);
} else if (docIdSet instanceof BitmapDocIdSet) {
BitmapDocIdSet bitmapDocIdSet = (BitmapDocIdSet) docIdSet;
ImmutableRoaringBitmap childBitmap = bitmapDocIdSet.getRaw();
allBitmaps.add(childBitmap);
} else {
BlockDocIdIterator iterator = docIdSet.iterator();
rawIterators.add(iterator);
}
}
MutableRoaringBitmap answer = allBitmaps.get(0).toMutableRoaringBitmap();
for (int i = 1; i < allBitmaps.size(); i++) {
answer.or(allBitmaps.get(i));
}
intIterator = answer.getIntIterator();
BitmapDocIdIterator singleBitmapBlockIdIterator = new BitmapDocIdIterator(intIterator);
singleBitmapBlockIdIterator.setStartDocId(minDocId);
singleBitmapBlockIdIterator.setEndDocId(maxDocId);
rawIterators.add(singleBitmapBlockIdIterator);
docIdIterators = new BlockDocIdIterator[rawIterators.size()];
rawIterators.toArray(docIdIterators);
} else {
docIdIterators = new BlockDocIdIterator[docIdSets.size()];
for (int srcId = 0; srcId < docIdSets.size(); srcId++) {
docIdIterators[srcId] = docIdSets.get(srcId).iterator();
}
}
// if (docIdIterators.length == 1) {
// return docIdIterators[0];
// } else {
OrDocIdIterator orDocIdIterator = new OrDocIdIterator(docIdIterators);
orDocIdIterator.setStartDocId(minDocId);
orDocIdIterator.setEndDocId(maxDocId);
return orDocIdIterator;
// }
}
Aggregations