Search in sources :

Example 6 with Operator

use of com.linkedin.pinot.core.common.Operator in project pinot by linkedin.

the class BaseSumStarTreeIndexTest method computeSumUsingRawDocs.

/**
   * Helper method to compute the sums using raw index.
   *  @param metricNames
   * @param brokerRequest
   */
private Map<String, double[]> computeSumUsingRawDocs(IndexSegment segment, List<String> metricNames, BrokerRequest brokerRequest) {
    FilterPlanNode planNode = new FilterPlanNode(segment, brokerRequest);
    Operator rawOperator = planNode.run();
    BlockDocIdIterator rawDocIdIterator = rawOperator.nextBlock().getBlockDocIdSet().iterator();
    List<String> groupByColumns = Collections.EMPTY_LIST;
    if (brokerRequest.isSetAggregationsInfo() && brokerRequest.isSetGroupBy()) {
        groupByColumns = brokerRequest.getGroupBy().getColumns();
    }
    return computeSum(segment, rawDocIdIterator, metricNames, groupByColumns);
}
Also used : StarTreeIndexOperator(com.linkedin.pinot.core.operator.filter.StarTreeIndexOperator) Operator(com.linkedin.pinot.core.common.Operator) FilterPlanNode(com.linkedin.pinot.core.plan.FilterPlanNode) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator)

Example 7 with Operator

use of com.linkedin.pinot.core.common.Operator 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;
}
Also used : Operator(com.linkedin.pinot.core.common.Operator) AndBlock(com.linkedin.pinot.core.operator.blocks.AndBlock) ArrayList(java.util.ArrayList) AndBlock(com.linkedin.pinot.core.operator.blocks.AndBlock) Block(com.linkedin.pinot.core.common.Block) BaseFilterBlock(com.linkedin.pinot.core.operator.blocks.BaseFilterBlock) FilterBlockDocIdSet(com.linkedin.pinot.core.operator.docidsets.FilterBlockDocIdSet)

Example 8 with Operator

use of com.linkedin.pinot.core.common.Operator in project pinot by linkedin.

the class TransformGroupByTest method executeGroupByQuery.

/**
   * Helper method that executes the group by query on the index and returns the group by result.
   *
   * @param query Query to execute
   * @return Group by result
   */
private AggregationGroupByResult executeGroupByQuery(IndexSegment indexSegment, String query) {
    Operator filterOperator = new MatchEntireSegmentOperator(indexSegment.getSegmentMetadata().getTotalDocs());
    final BReusableFilteredDocIdSetOperator docIdSetOperator = new BReusableFilteredDocIdSetOperator(filterOperator, indexSegment.getSegmentMetadata().getTotalDocs(), NUM_ROWS);
    final Map<String, BaseOperator> dataSourceMap = buildDataSourceMap(indexSegment.getSegmentMetadata().getSchema());
    final MProjectionOperator projectionOperator = new MProjectionOperator(dataSourceMap, docIdSetOperator);
    Pql2Compiler compiler = new Pql2Compiler();
    BrokerRequest brokerRequest = compiler.compileToBrokerRequest(query);
    List<AggregationInfo> aggregationsInfo = brokerRequest.getAggregationsInfo();
    int numAggFunctions = aggregationsInfo.size();
    AggregationFunctionContext[] aggrFuncContextArray = new AggregationFunctionContext[numAggFunctions];
    AggregationFunctionInitializer aggFuncInitializer = new AggregationFunctionInitializer(indexSegment.getSegmentMetadata());
    for (int i = 0; i < numAggFunctions; i++) {
        AggregationInfo aggregationInfo = aggregationsInfo.get(i);
        aggrFuncContextArray[i] = AggregationFunctionContext.instantiate(aggregationInfo);
        aggrFuncContextArray[i].getAggregationFunction().accept(aggFuncInitializer);
    }
    GroupBy groupBy = brokerRequest.getGroupBy();
    Set<String> expressions = new HashSet<>(groupBy.getExpressions());
    TransformExpressionOperator transformOperator = new TransformExpressionOperator(projectionOperator, TransformPlanNode.buildTransformExpressionTrees(expressions));
    AggregationGroupByOperator groupByOperator = new AggregationGroupByOperator(aggrFuncContextArray, groupBy, Integer.MAX_VALUE, transformOperator, NUM_ROWS);
    IntermediateResultsBlock block = (IntermediateResultsBlock) groupByOperator.nextBlock();
    return block.getAggregationGroupByResult();
}
Also used : MatchEntireSegmentOperator(com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator) AggregationGroupByOperator(com.linkedin.pinot.core.operator.query.AggregationGroupByOperator) BaseOperator(com.linkedin.pinot.core.operator.BaseOperator) BReusableFilteredDocIdSetOperator(com.linkedin.pinot.core.operator.BReusableFilteredDocIdSetOperator) Operator(com.linkedin.pinot.core.common.Operator) MProjectionOperator(com.linkedin.pinot.core.operator.MProjectionOperator) TransformExpressionOperator(com.linkedin.pinot.core.operator.transform.TransformExpressionOperator) BaseOperator(com.linkedin.pinot.core.operator.BaseOperator) GroupBy(com.linkedin.pinot.common.request.GroupBy) AggregationFunctionInitializer(com.linkedin.pinot.core.plan.AggregationFunctionInitializer) TransformExpressionOperator(com.linkedin.pinot.core.operator.transform.TransformExpressionOperator) Pql2Compiler(com.linkedin.pinot.pql.parsers.Pql2Compiler) MProjectionOperator(com.linkedin.pinot.core.operator.MProjectionOperator) MatchEntireSegmentOperator(com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator) AggregationGroupByOperator(com.linkedin.pinot.core.operator.query.AggregationGroupByOperator) BReusableFilteredDocIdSetOperator(com.linkedin.pinot.core.operator.BReusableFilteredDocIdSetOperator) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo) IntermediateResultsBlock(com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock) AggregationFunctionContext(com.linkedin.pinot.core.query.aggregation.AggregationFunctionContext) HashSet(java.util.HashSet)

Example 9 with Operator

use of com.linkedin.pinot.core.common.Operator in project pinot by linkedin.

the class TransformExpressionOperatorTest method evaluateExpression.

/**
   * Helper method to evaluate one expression using the TransformOperator.
   * @param expression Expression to evaluate
   * @return Result of evaluation
   */
private double[] evaluateExpression(String expression) {
    Operator filterOperator = new MatchEntireSegmentOperator(_indexSegment.getSegmentMetadata().getTotalDocs());
    final BReusableFilteredDocIdSetOperator docIdSetOperator = new BReusableFilteredDocIdSetOperator(filterOperator, _indexSegment.getSegmentMetadata().getTotalDocs(), NUM_ROWS);
    final Map<String, BaseOperator> dataSourceMap = buildDataSourceMap(_indexSegment.getSegmentMetadata().getSchema());
    final MProjectionOperator projectionOperator = new MProjectionOperator(dataSourceMap, docIdSetOperator);
    Pql2Compiler compiler = new Pql2Compiler();
    List<TransformExpressionTree> expressionTrees = new ArrayList<>(1);
    expressionTrees.add(compiler.compileToExpressionTree(expression));
    TransformExpressionOperator transformOperator = new TransformExpressionOperator(projectionOperator, expressionTrees);
    transformOperator.open();
    TransformBlock transformBlock = (TransformBlock) transformOperator.getNextBlock();
    BlockValSet blockValueSet = transformBlock.getBlockValueSet(expression);
    double[] actual = blockValueSet.getDoubleValuesSV();
    transformOperator.close();
    return actual;
}
Also used : BaseOperator(com.linkedin.pinot.core.operator.BaseOperator) BReusableFilteredDocIdSetOperator(com.linkedin.pinot.core.operator.BReusableFilteredDocIdSetOperator) MatchEntireSegmentOperator(com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator) Operator(com.linkedin.pinot.core.common.Operator) MProjectionOperator(com.linkedin.pinot.core.operator.MProjectionOperator) TransformExpressionOperator(com.linkedin.pinot.core.operator.transform.TransformExpressionOperator) BaseOperator(com.linkedin.pinot.core.operator.BaseOperator) TransformExpressionOperator(com.linkedin.pinot.core.operator.transform.TransformExpressionOperator) Pql2Compiler(com.linkedin.pinot.pql.parsers.Pql2Compiler) ArrayList(java.util.ArrayList) MProjectionOperator(com.linkedin.pinot.core.operator.MProjectionOperator) MatchEntireSegmentOperator(com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator) TransformBlock(com.linkedin.pinot.core.operator.blocks.TransformBlock) BReusableFilteredDocIdSetOperator(com.linkedin.pinot.core.operator.BReusableFilteredDocIdSetOperator) TransformExpressionTree(com.linkedin.pinot.common.request.transform.TransformExpressionTree) BlockValSet(com.linkedin.pinot.core.common.BlockValSet)

Aggregations

Operator (com.linkedin.pinot.core.common.Operator)9 ArrayList (java.util.ArrayList)5 MatchEntireSegmentOperator (com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator)4 Block (com.linkedin.pinot.core.common.Block)3 IntermediateResultsBlock (com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock)3 StarTreeIndexOperator (com.linkedin.pinot.core.operator.filter.StarTreeIndexOperator)3 QueryException (com.linkedin.pinot.common.exception.QueryException)2 AggregationInfo (com.linkedin.pinot.common.request.AggregationInfo)2 FilterOperator (com.linkedin.pinot.common.request.FilterOperator)2 BReusableFilteredDocIdSetOperator (com.linkedin.pinot.core.operator.BReusableFilteredDocIdSetOperator)2 BaseOperator (com.linkedin.pinot.core.operator.BaseOperator)2 MProjectionOperator (com.linkedin.pinot.core.operator.MProjectionOperator)2 BaseFilterBlock (com.linkedin.pinot.core.operator.blocks.BaseFilterBlock)2 FilterBlockDocIdSet (com.linkedin.pinot.core.operator.docidsets.FilterBlockDocIdSet)2 AndOperator (com.linkedin.pinot.core.operator.filter.AndOperator)2 BaseFilterOperator (com.linkedin.pinot.core.operator.filter.BaseFilterOperator)2 BitmapBasedFilterOperator (com.linkedin.pinot.core.operator.filter.BitmapBasedFilterOperator)2 EmptyFilterOperator (com.linkedin.pinot.core.operator.filter.EmptyFilterOperator)2 OrOperator (com.linkedin.pinot.core.operator.filter.OrOperator)2 ScanBasedFilterOperator (com.linkedin.pinot.core.operator.filter.ScanBasedFilterOperator)2