Search in sources :

Example 1 with AggregationOperator

use of com.linkedin.pinot.core.operator.query.AggregationOperator in project pinot by linkedin.

the class AggregationPlanNode method run.

@Override
public Operator run() {
    TransformExpressionOperator transformOperator = (TransformExpressionOperator) _transformPlanNode.run();
    SegmentMetadata segmentMetadata = _indexSegment.getSegmentMetadata();
    return new AggregationOperator(AggregationFunctionUtils.getAggregationFunctionContexts(_aggregationInfos, segmentMetadata), transformOperator, segmentMetadata.getTotalRawDocs());
}
Also used : SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) AggregationOperator(com.linkedin.pinot.core.operator.query.AggregationOperator) TransformExpressionOperator(com.linkedin.pinot.core.operator.transform.TransformExpressionOperator)

Example 2 with AggregationOperator

use of com.linkedin.pinot.core.operator.query.AggregationOperator in project pinot by linkedin.

the class InnerSegmentAggregationMultiValueQueriesTest method testMultiValueAggregationOnly.

@Test
public void testMultiValueAggregationOnly() {
    String query = "SELECT" + MULTI_VALUE_AGGREGATION + " FROM testTable";
    // Test query without filter.
    AggregationOperator aggregationOperator = getOperatorForQuery(query);
    IntermediateResultsBlock resultsBlock = (IntermediateResultsBlock) aggregationOperator.nextBlock();
    ExecutionStatistics executionStatistics = aggregationOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 100000L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 0L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 200000L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 100000L);
    List<Object> aggregationResult = resultsBlock.getAggregationResult();
    Assert.assertEquals(((Number) aggregationResult.get(0)).longValue(), 106688L);
    Assert.assertEquals(((Number) aggregationResult.get(1)).longValue(), 107243218420671L);
    Assert.assertEquals(((Number) aggregationResult.get(2)).intValue(), 2147483647);
    Assert.assertEquals(((Number) aggregationResult.get(3)).intValue(), 201);
    AvgPair avgResult = (AvgPair) aggregationResult.get(4);
    Assert.assertEquals((long) avgResult.getSum(), 121081150452570L);
    Assert.assertEquals(avgResult.getCount(), 106688L);
    // Test query with filter.
    aggregationOperator = getOperatorForQueryWithFilter(query);
    resultsBlock = (IntermediateResultsBlock) aggregationOperator.nextBlock();
    executionStatistics = aggregationOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 15620L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 282430L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 31240L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 100000L);
    aggregationResult = resultsBlock.getAggregationResult();
    Assert.assertEquals(((Number) aggregationResult.get(0)).longValue(), 15620L);
    Assert.assertEquals(((Number) aggregationResult.get(1)).longValue(), 28567975886777L);
    Assert.assertEquals(((Number) aggregationResult.get(2)).intValue(), 2147483647);
    Assert.assertEquals(((Number) aggregationResult.get(3)).intValue(), 203);
    avgResult = (AvgPair) aggregationResult.get(4);
    Assert.assertEquals((long) avgResult.getSum(), 28663153397978L);
    Assert.assertEquals(avgResult.getCount(), 15620L);
}
Also used : ExecutionStatistics(com.linkedin.pinot.core.operator.ExecutionStatistics) AggregationOperator(com.linkedin.pinot.core.operator.query.AggregationOperator) IntermediateResultsBlock(com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock) AvgPair(com.linkedin.pinot.core.query.aggregation.function.customobject.AvgPair) Test(org.testng.annotations.Test)

Example 3 with AggregationOperator

use of com.linkedin.pinot.core.operator.query.AggregationOperator in project pinot by linkedin.

the class InnerSegmentAggregationSingleValueQueriesTest method testAggregationOnly.

@Test
public void testAggregationOnly() {
    String query = "SELECT" + AGGREGATION + " FROM testTable";
    // Test query without filter.
    AggregationOperator aggregationOperator = getOperatorForQuery(query);
    IntermediateResultsBlock resultsBlock = (IntermediateResultsBlock) aggregationOperator.nextBlock();
    ExecutionStatistics executionStatistics = aggregationOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 30000L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 0L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 120000L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 30000L);
    List<Object> aggregationResult = resultsBlock.getAggregationResult();
    Assert.assertEquals(((Number) aggregationResult.get(0)).longValue(), 30000L);
    Assert.assertEquals(((Number) aggregationResult.get(1)).longValue(), 32317185437847L);
    Assert.assertEquals(((Number) aggregationResult.get(2)).intValue(), 2147419555);
    Assert.assertEquals(((Number) aggregationResult.get(3)).intValue(), 1689277);
    AvgPair avgResult = (AvgPair) aggregationResult.get(4);
    Assert.assertEquals((long) avgResult.getSum(), 28175373944314L);
    Assert.assertEquals(avgResult.getCount(), 30000L);
    // Test query with filter.
    aggregationOperator = getOperatorForQueryWithFilter(query);
    resultsBlock = (IntermediateResultsBlock) aggregationOperator.nextBlock();
    executionStatistics = aggregationOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 6129L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 84134L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 24516L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 30000L);
    aggregationResult = resultsBlock.getAggregationResult();
    Assert.assertEquals(((Number) aggregationResult.get(0)).longValue(), 6129L);
    Assert.assertEquals(((Number) aggregationResult.get(1)).longValue(), 6875947596072L);
    Assert.assertEquals(((Number) aggregationResult.get(2)).intValue(), 999813884);
    Assert.assertEquals(((Number) aggregationResult.get(3)).intValue(), 1980174);
    avgResult = (AvgPair) aggregationResult.get(4);
    Assert.assertEquals((long) avgResult.getSum(), 4699510391301L);
    Assert.assertEquals(avgResult.getCount(), 6129L);
}
Also used : ExecutionStatistics(com.linkedin.pinot.core.operator.ExecutionStatistics) AggregationOperator(com.linkedin.pinot.core.operator.query.AggregationOperator) IntermediateResultsBlock(com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock) AvgPair(com.linkedin.pinot.core.query.aggregation.function.customobject.AvgPair) Test(org.testng.annotations.Test)

Example 4 with AggregationOperator

use of com.linkedin.pinot.core.operator.query.AggregationOperator in project pinot by linkedin.

the class InnerSegmentAggregationMultiValueQueriesTest method testAggregationOnly.

@Test
public void testAggregationOnly() {
    String query = "SELECT" + AGGREGATION + " FROM testTable";
    // Test query without filter.
    AggregationOperator aggregationOperator = getOperatorForQuery(query);
    IntermediateResultsBlock resultsBlock = (IntermediateResultsBlock) aggregationOperator.nextBlock();
    ExecutionStatistics executionStatistics = aggregationOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 100000L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 0L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 400000L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 100000L);
    List<Object> aggregationResult = resultsBlock.getAggregationResult();
    Assert.assertEquals(((Number) aggregationResult.get(0)).longValue(), 100000L);
    Assert.assertEquals(((Number) aggregationResult.get(1)).longValue(), 100991525475000L);
    Assert.assertEquals(((Number) aggregationResult.get(2)).intValue(), 2147434110);
    Assert.assertEquals(((Number) aggregationResult.get(3)).intValue(), 1182655);
    AvgPair avgResult = (AvgPair) aggregationResult.get(4);
    Assert.assertEquals((long) avgResult.getSum(), 83439903673981L);
    Assert.assertEquals(avgResult.getCount(), 100000L);
    // Test query with filter.
    aggregationOperator = getOperatorForQueryWithFilter(query);
    resultsBlock = (IntermediateResultsBlock) aggregationOperator.nextBlock();
    executionStatistics = aggregationOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 15620L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 282430L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 62480L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 100000L);
    aggregationResult = resultsBlock.getAggregationResult();
    Assert.assertEquals(((Number) aggregationResult.get(0)).longValue(), 15620L);
    Assert.assertEquals(((Number) aggregationResult.get(1)).longValue(), 17287754700747L);
    Assert.assertEquals(((Number) aggregationResult.get(2)).intValue(), 999943053);
    Assert.assertEquals(((Number) aggregationResult.get(3)).intValue(), 1182655);
    avgResult = (AvgPair) aggregationResult.get(4);
    Assert.assertEquals((long) avgResult.getSum(), 11017594448983L);
    Assert.assertEquals(avgResult.getCount(), 15620L);
}
Also used : ExecutionStatistics(com.linkedin.pinot.core.operator.ExecutionStatistics) AggregationOperator(com.linkedin.pinot.core.operator.query.AggregationOperator) IntermediateResultsBlock(com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock) AvgPair(com.linkedin.pinot.core.query.aggregation.function.customobject.AvgPair) Test(org.testng.annotations.Test)

Aggregations

AggregationOperator (com.linkedin.pinot.core.operator.query.AggregationOperator)4 ExecutionStatistics (com.linkedin.pinot.core.operator.ExecutionStatistics)3 IntermediateResultsBlock (com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock)3 AvgPair (com.linkedin.pinot.core.query.aggregation.function.customobject.AvgPair)3 Test (org.testng.annotations.Test)3 SegmentMetadata (com.linkedin.pinot.common.segment.SegmentMetadata)1 TransformExpressionOperator (com.linkedin.pinot.core.operator.transform.TransformExpressionOperator)1