Search in sources :

Example 6 with MProjectionOperator

use of com.linkedin.pinot.core.operator.MProjectionOperator 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

BReusableFilteredDocIdSetOperator (com.linkedin.pinot.core.operator.BReusableFilteredDocIdSetOperator)6 MProjectionOperator (com.linkedin.pinot.core.operator.MProjectionOperator)6 BaseOperator (com.linkedin.pinot.core.operator.BaseOperator)4 MatchEntireSegmentOperator (com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator)4 TransformExpressionOperator (com.linkedin.pinot.core.operator.transform.TransformExpressionOperator)4 TransformBlock (com.linkedin.pinot.core.operator.blocks.TransformBlock)3 AggregationInfo (com.linkedin.pinot.common.request.AggregationInfo)2 TransformExpressionTree (com.linkedin.pinot.common.request.transform.TransformExpressionTree)2 Operator (com.linkedin.pinot.core.common.Operator)2 AggregationFunctionInitializer (com.linkedin.pinot.core.plan.AggregationFunctionInitializer)2 AggregationFunctionContext (com.linkedin.pinot.core.query.aggregation.AggregationFunctionContext)2 Pql2Compiler (com.linkedin.pinot.pql.parsers.Pql2Compiler)2 HashMap (java.util.HashMap)2 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)1 GroupBy (com.linkedin.pinot.common.request.GroupBy)1 BlockValSet (com.linkedin.pinot.core.common.BlockValSet)1 IntermediateResultsBlock (com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock)1 ProjectionBlock (com.linkedin.pinot.core.operator.blocks.ProjectionBlock)1 ProjectionBlockValSet (com.linkedin.pinot.core.operator.docvalsets.ProjectionBlockValSet)1 BaseFilterOperator (com.linkedin.pinot.core.operator.filter.BaseFilterOperator)1