use of com.linkedin.pinot.core.operator.filter.BaseFilterOperator in project pinot by linkedin.
the class AndOperatorTest 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<BaseFilterOperator>();
operators.add(makeFilterOperator(list1));
operators.add(makeFilterOperator(list2));
operators.add(makeFilterOperator(list3));
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.filter.BaseFilterOperator in project pinot by linkedin.
the class AndOperatorTest method testComplexWithOr.
@Test
public void testComplexWithOr() {
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(list3));
operators.add(makeFilterOperator(list2));
final OrOperator orOperator = new OrOperator(operators);
List<BaseFilterOperator> operators1 = new ArrayList<>();
operators1.add(orOperator);
operators1.add(makeFilterOperator(list1));
final AndOperator andOperator = new AndOperator(operators1);
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.filter.BaseFilterOperator in project pinot by linkedin.
the class AndOperatorTest method testComplex.
@Test
public void testComplex() {
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));
final AndOperator andOperator1 = new AndOperator(operators);
List<BaseFilterOperator> operators1 = new ArrayList<>();
operators1.add(andOperator1);
operators1.add(makeFilterOperator(list3));
final AndOperator andOperator = new AndOperator(operators1);
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.filter.BaseFilterOperator in project pinot by linkedin.
the class OrOperatorTest method testComplex.
@Test
public void testComplex() {
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 };
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();
List<BaseFilterOperator> operators = new ArrayList<>();
operators.add(makeFilterOperator(list1));
operators.add(makeFilterOperator(list2));
final OrOperator orOperator1 = new OrOperator(operators);
List<BaseFilterOperator> operators1 = new ArrayList<>();
operators1.add(orOperator1);
operators1.add(makeFilterOperator(list3));
final OrOperator orOperator = new OrOperator(operators1);
orOperator.open();
BaseFilterBlock block;
while ((block = orOperator.getNextBlock()) != null) {
final BlockDocIdSet blockDocIdSet = block.getBlockDocIdSet();
final BlockDocIdIterator iterator = blockDocIdSet.iterator();
int docId;
while ((docId = iterator.next()) != Constants.EOF) {
// System.out.println(docId);
Assert.assertEquals(expectedIterator.next().intValue(), docId);
}
}
orOperator.close();
}
use of com.linkedin.pinot.core.operator.filter.BaseFilterOperator 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);
}
}
Aggregations