use of com.linkedin.pinot.core.operator.blocks.BaseFilterBlock in project pinot by linkedin.
the class FilterTreeOptimizationTest method testQuery.
/**
* Helper method to perform the actual testing for the given query.
* <ul>
* <li> Constructs the operator tree with and without alwaysFalse optimizations. </li>
* <li> Compares that all docIds filtered by the two operators are identical. </li>
* </ul>
* @param query Query to run.
*/
private void testQuery(String query) {
BrokerRequest brokerRequest = _compiler.compileToBrokerRequest(query);
FilterQueryTree filterQueryTree = RequestUtils.generateFilterQueryTree(brokerRequest);
BaseFilterOperator expectedOperator = FilterPlanNode.constructPhysicalOperator(filterQueryTree, _indexSegment, false);
BaseFilterOperator actualOperator = FilterPlanNode.constructPhysicalOperator(filterQueryTree, _indexSegment, true);
BaseFilterBlock expectedBlock;
while ((expectedBlock = expectedOperator.getNextBlock()) != null) {
BaseFilterBlock actualBlock = actualOperator.getNextBlock();
Assert.assertNotNull(actualBlock);
final BlockDocIdSet expectedDocIdSet = expectedBlock.getBlockDocIdSet();
final BlockDocIdIterator expectedIterator = expectedDocIdSet.iterator();
final BlockDocIdSet actualDocIdSet = actualBlock.getBlockDocIdSet();
final BlockDocIdIterator actualIterator = actualDocIdSet.iterator();
int expectedDocId;
int actualDocId;
while (((expectedDocId = expectedIterator.next()) != Constants.EOF) && ((actualDocId = actualIterator.next()) != Constants.EOF)) {
Assert.assertEquals(actualDocId, expectedDocId);
}
Assert.assertTrue(expectedIterator.next() == Constants.EOF);
Assert.assertTrue(actualIterator.next() == Constants.EOF);
}
}
use of com.linkedin.pinot.core.operator.blocks.BaseFilterBlock in project pinot by linkedin.
the class AndOperatorTest 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 AndOperator andOperator = new AndOperator(operators);
andOperator.open();
BaseFilterBlock block;
while ((block = andOperator.getNextBlock()) != null) {
final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet();
final BlockDocIdIterator iterator = blockDocIdSet.iterator();
int docId;
while ((docId = iterator.next()) != Constants.EOF) {
// System.out.println(docId);
}
}
andOperator.close();
}
use of com.linkedin.pinot.core.operator.blocks.BaseFilterBlock 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.operator.blocks.BaseFilterBlock 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.operator.blocks.BaseFilterBlock 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