Search in sources :

Example 6 with TransformExpressionOperator

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

TransformExpressionOperator (com.linkedin.pinot.core.operator.transform.TransformExpressionOperator)6 BReusableFilteredDocIdSetOperator (com.linkedin.pinot.core.operator.BReusableFilteredDocIdSetOperator)4 MProjectionOperator (com.linkedin.pinot.core.operator.MProjectionOperator)4 MatchEntireSegmentOperator (com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator)4 BaseOperator (com.linkedin.pinot.core.operator.BaseOperator)3 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 SegmentMetadata (com.linkedin.pinot.common.segment.SegmentMetadata)2 Operator (com.linkedin.pinot.core.common.Operator)2 AggregationGroupByOperator (com.linkedin.pinot.core.operator.query.AggregationGroupByOperator)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 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 AggregationOperator (com.linkedin.pinot.core.operator.query.AggregationOperator)1 AggregationExecutor (com.linkedin.pinot.core.query.aggregation.AggregationExecutor)1