use of com.linkedin.pinot.core.common.Block in project pinot by linkedin.
the class OrOperatorTest method testIntersectionForTwoLists.
@Test
public void testIntersectionForTwoLists() {
int[] list1 = new int[] { 2, 3, 10, 15, 16, 28 };
int[] list2 = new int[] { 3, 6, 8, 20, 28 };
List<BaseFilterOperator> operators = new ArrayList<>();
operators.add(makeFilterOperator(list1));
operators.add(makeFilterOperator(list2));
final OrOperator orOperator = new OrOperator(operators);
orOperator.open();
Block block;
TreeSet<Integer> set = new TreeSet<Integer>();
set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1)));
set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2)));
Iterator<Integer> expectedIterator = set.iterator();
while ((block = orOperator.nextBlock()) != null) {
final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet();
final BlockDocIdIterator iterator = blockDocIdSet.iterator();
int docId;
while ((docId = iterator.next()) != Constants.EOF) {
Assert.assertEquals(expectedIterator.next().intValue(), docId);
}
}
orOperator.close();
}
use of com.linkedin.pinot.core.common.Block in project pinot by linkedin.
the class OrOperatorTest method testIntersectionForThreeLists.
@Test
public void testIntersectionForThreeLists() {
int[] list1 = new int[] { 2, 3, 6, 10, 15, 16, 28 };
int[] list2 = new int[] { 3, 6, 8, 20, 28 };
int[] list3 = new int[] { 1, 2, 3, 6, 30 };
List<BaseFilterOperator> operators = new ArrayList<>();
operators.add(makeFilterOperator(list1));
operators.add(makeFilterOperator(list2));
operators.add(makeFilterOperator(list3));
final OrOperator orOperator = new OrOperator(operators);
orOperator.open();
Block block;
TreeSet<Integer> set = new TreeSet<Integer>();
set.addAll(Lists.newArrayList(ArrayUtils.toObject(list1)));
set.addAll(Lists.newArrayList(ArrayUtils.toObject(list2)));
set.addAll(Lists.newArrayList(ArrayUtils.toObject(list3)));
Iterator<Integer> expectedIterator = set.iterator();
while ((block = orOperator.nextBlock()) != null) {
final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet();
final BlockDocIdIterator iterator = blockDocIdSet.iterator();
int docId;
while ((docId = iterator.next()) != Constants.EOF) {
Assert.assertEquals(expectedIterator.next().intValue(), docId);
}
}
orOperator.close();
}
use of com.linkedin.pinot.core.common.Block in project pinot by linkedin.
the class ScanBasedFilterOperator method nextFilterBlock.
@Override
public BaseFilterBlock nextFilterBlock(BlockId BlockId) {
DataSourceMetadata dataSourceMetadata = dataSource.getDataSourceMetadata();
FilterBlockDocIdSet docIdSet;
Block nextBlock = dataSource.nextBlock();
BlockValSet blockValueSet = nextBlock.getBlockValueSet();
BlockMetadata blockMetadata = nextBlock.getMetadata();
if (dataSourceMetadata.isSingleValue()) {
docIdSet = new ScanBasedSingleValueDocIdSet(dataSource.getOperatorName(), blockValueSet, blockMetadata, predicateEvaluator);
} else {
docIdSet = new ScanBasedMultiValueDocIdSet(dataSource.getOperatorName(), blockValueSet, blockMetadata, predicateEvaluator);
}
if (startDocId != null) {
docIdSet.setStartDocId(startDocId);
}
if (endDocId != null) {
docIdSet.setEndDocId(endDocId);
}
return new ScanBlock(docIdSet);
}
use of com.linkedin.pinot.core.common.Block in project pinot by linkedin.
the class AndOperator method nextFilterBlock.
@Override
public BaseFilterBlock nextFilterBlock(BlockId BlockId) {
List<FilterBlockDocIdSet> blockDocIdSets = new ArrayList<FilterBlockDocIdSet>();
for (Operator operator : operators) {
Block block = operator.nextBlock();
FilterBlockDocIdSet blockDocIdSet = (FilterBlockDocIdSet) block.getBlockDocIdSet();
blockDocIdSets.add(blockDocIdSet);
}
andBlock = new AndBlock(blockDocIdSets);
return andBlock;
}
use of com.linkedin.pinot.core.common.Block in project pinot by linkedin.
the class BaseFilterOperator method getNextBlock.
@Override
public final BaseFilterBlock getNextBlock(BlockId blockId) {
if (nextBlockCallCounter > 0) {
return null;
}
Block nextBlock = nextFilterBlock(new BlockId(0));
nextBlockCallCounter = nextBlockCallCounter + 1;
return (BaseFilterBlock) nextBlock;
}
Aggregations