Search in sources :

Example 16 with ExecutionStatistics

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

Example 17 with ExecutionStatistics

use of com.linkedin.pinot.core.operator.ExecutionStatistics in project pinot by linkedin.

the class InnerSegmentAggregationSingleValueQueriesTest method testMediumAggregationGroupBy.

@Test
public void testMediumAggregationGroupBy() {
    String query = "SELECT" + AGGREGATION + " FROM testTable" + MEDIUM_GROUP_BY;
    // NOTE: here we assume the first group key returned from the iterator is constant.
    // Test query without filter.
    AggregationGroupByOperator aggregationGroupByOperator = getOperatorForQuery(query);
    IntermediateResultsBlock resultsBlock = (IntermediateResultsBlock) aggregationGroupByOperator.nextBlock();
    ExecutionStatistics executionStatistics = aggregationGroupByOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 30000L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 0L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 210000L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 30000L);
    AggregationGroupByResult aggregationGroupByResult = resultsBlock.getAggregationGroupByResult();
    GroupKeyGenerator.GroupKey firstGroupKey = aggregationGroupByResult.getGroupKeyIterator().next();
    Assert.assertEquals(firstGroupKey.getStringKey(), "1577638897\tP\tKrNxpdycSiwoRohEiTIlLqDHnx");
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 0)).longValue(), 5L);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 1)).longValue(), 1211410535L);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 2)).intValue(), 1720170285);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 3)).intValue(), 1585725369);
    AvgPair avgResult = (AvgPair) aggregationGroupByResult.getResultForKey(firstGroupKey, 4);
    Assert.assertEquals((long) avgResult.getSum(), 8398774425L);
    Assert.assertEquals(avgResult.getCount(), 5L);
    // Test query with filter.
    aggregationGroupByOperator = getOperatorForQueryWithFilter(query);
    resultsBlock = (IntermediateResultsBlock) aggregationGroupByOperator.nextBlock();
    executionStatistics = aggregationGroupByOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 6129L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 84134L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 42903L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 30000L);
    aggregationGroupByResult = resultsBlock.getAggregationGroupByResult();
    firstGroupKey = aggregationGroupByResult.getGroupKeyIterator().next();
    Assert.assertEquals(firstGroupKey.getStringKey(), "1096298724\tP\tKrNxpdycSiwoRohEiTIlLqDHnx");
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 0)).longValue(), 7L);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 1)).longValue(), 13531749490L);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 2)).intValue(), 478007592);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 3)).intValue(), 394608493);
    avgResult = (AvgPair) aggregationGroupByResult.getResultForKey(firstGroupKey, 4);
    Assert.assertEquals((long) avgResult.getSum(), 1229066783L);
    Assert.assertEquals(avgResult.getCount(), 7L);
}
Also used : ExecutionStatistics(com.linkedin.pinot.core.operator.ExecutionStatistics) AggregationGroupByOperator(com.linkedin.pinot.core.operator.query.AggregationGroupByOperator) IntermediateResultsBlock(com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock) GroupKeyGenerator(com.linkedin.pinot.core.query.aggregation.groupby.GroupKeyGenerator) AvgPair(com.linkedin.pinot.core.query.aggregation.function.customobject.AvgPair) AggregationGroupByResult(com.linkedin.pinot.core.query.aggregation.groupby.AggregationGroupByResult) Test(org.testng.annotations.Test)

Example 18 with ExecutionStatistics

use of com.linkedin.pinot.core.operator.ExecutionStatistics in project pinot by linkedin.

the class InnerSegmentAggregationSingleValueQueriesTest method testLargeAggregationGroupBy.

@Test
public void testLargeAggregationGroupBy() {
    String query = "SELECT" + AGGREGATION + " FROM testTable" + LARGE_GROUP_BY;
    // NOTE: here we assume the first group key returned from the iterator is constant.
    // Test query without filter.
    AggregationGroupByOperator aggregationGroupByOperator = getOperatorForQuery(query);
    IntermediateResultsBlock resultsBlock = (IntermediateResultsBlock) aggregationGroupByOperator.nextBlock();
    ExecutionStatistics executionStatistics = aggregationGroupByOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 30000L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 0L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 270000L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 30000L);
    AggregationGroupByResult aggregationGroupByResult = resultsBlock.getAggregationGroupByResult();
    GroupKeyGenerator.GroupKey firstGroupKey = aggregationGroupByResult.getGroupKeyIterator().next();
    Assert.assertEquals(firstGroupKey.getStringKey(), "1784773968\t204243323\t628170461\t1985159279\t296467636\tP\tHEuxNvH\t402773817\t2047180536");
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 0)).longValue(), 1L);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 1)).longValue(), 1784773968L);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 2)).intValue(), 204243323);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 3)).intValue(), 628170461);
    AvgPair avgResult = (AvgPair) aggregationGroupByResult.getResultForKey(firstGroupKey, 4);
    Assert.assertEquals((long) avgResult.getSum(), 1985159279L);
    Assert.assertEquals(avgResult.getCount(), 1L);
    // Test query with filter.
    aggregationGroupByOperator = getOperatorForQueryWithFilter(query);
    resultsBlock = (IntermediateResultsBlock) aggregationGroupByOperator.nextBlock();
    executionStatistics = aggregationGroupByOperator.getExecutionStatistics();
    Assert.assertEquals(executionStatistics.getNumDocsScanned(), 6129L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedInFilter(), 84134L);
    Assert.assertEquals(executionStatistics.getNumEntriesScannedPostFilter(), 55161L);
    Assert.assertEquals(executionStatistics.getNumTotalRawDocs(), 30000L);
    aggregationGroupByResult = resultsBlock.getAggregationGroupByResult();
    firstGroupKey = aggregationGroupByResult.getGroupKeyIterator().next();
    Assert.assertEquals(firstGroupKey.getStringKey(), "1361199163\t178133991\t296467636\t788414092\t1719301234\tP\tMaztCmmxxgguBUxPti\t1284373442\t752388855");
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 0)).longValue(), 1L);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 1)).longValue(), 1361199163L);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 2)).intValue(), 178133991);
    Assert.assertEquals(((Number) aggregationGroupByResult.getResultForKey(firstGroupKey, 3)).intValue(), 296467636);
    avgResult = (AvgPair) aggregationGroupByResult.getResultForKey(firstGroupKey, 4);
    Assert.assertEquals((long) avgResult.getSum(), 788414092L);
    Assert.assertEquals(avgResult.getCount(), 1L);
}
Also used : ExecutionStatistics(com.linkedin.pinot.core.operator.ExecutionStatistics) AggregationGroupByOperator(com.linkedin.pinot.core.operator.query.AggregationGroupByOperator) IntermediateResultsBlock(com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock) GroupKeyGenerator(com.linkedin.pinot.core.query.aggregation.groupby.GroupKeyGenerator) AvgPair(com.linkedin.pinot.core.query.aggregation.function.customobject.AvgPair) AggregationGroupByResult(com.linkedin.pinot.core.query.aggregation.groupby.AggregationGroupByResult) Test(org.testng.annotations.Test)

Example 19 with ExecutionStatistics

use of com.linkedin.pinot.core.operator.ExecutionStatistics in project pinot by linkedin.

the class AggregationGroupByOperator method getNextBlock.

@Override
public Block getNextBlock() {
    int numDocsScanned = 0;
    // Perform aggregation group-by on all the blocks.
    GroupByExecutor groupByExecutor = new DefaultGroupByExecutor(_aggregationFunctionContexts, _groupBy, _numGroupsLimit);
    groupByExecutor.init();
    TransformBlock transformBlock;
    while ((transformBlock = (TransformBlock) _transformOperator.nextBlock()) != null) {
        numDocsScanned += transformBlock.getNumDocs();
        groupByExecutor.process(transformBlock);
    }
    groupByExecutor.finish();
    // Create execution statistics.
    long numEntriesScannedInFilter = _transformOperator.getExecutionStatistics().getNumEntriesScannedInFilter();
    long numEntriesScannedPostFilter = numDocsScanned * _transformOperator.getNumProjectionColumns();
    _executionStatistics = new ExecutionStatistics(numDocsScanned, numEntriesScannedInFilter, numEntriesScannedPostFilter, _numTotalRawDocs);
    // Build intermediate result block based on aggregation group-by result from the executor.
    return new IntermediateResultsBlock(_aggregationFunctionContexts, groupByExecutor.getResult());
}
Also used : ExecutionStatistics(com.linkedin.pinot.core.operator.ExecutionStatistics) TransformBlock(com.linkedin.pinot.core.operator.blocks.TransformBlock) DefaultGroupByExecutor(com.linkedin.pinot.core.query.aggregation.groupby.DefaultGroupByExecutor) IntermediateResultsBlock(com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock) GroupByExecutor(com.linkedin.pinot.core.query.aggregation.groupby.GroupByExecutor) DefaultGroupByExecutor(com.linkedin.pinot.core.query.aggregation.groupby.DefaultGroupByExecutor)

Aggregations

ExecutionStatistics (com.linkedin.pinot.core.operator.ExecutionStatistics)19 IntermediateResultsBlock (com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock)19 Test (org.testng.annotations.Test)15 AvgPair (com.linkedin.pinot.core.query.aggregation.function.customobject.AvgPair)9 DataSchema (com.linkedin.pinot.common.utils.DataSchema)6 AggregationGroupByOperator (com.linkedin.pinot.core.operator.query.AggregationGroupByOperator)6 AggregationGroupByResult (com.linkedin.pinot.core.query.aggregation.groupby.AggregationGroupByResult)6 GroupKeyGenerator (com.linkedin.pinot.core.query.aggregation.groupby.GroupKeyGenerator)6 Serializable (java.io.Serializable)6 MSelectionOnlyOperator (com.linkedin.pinot.core.operator.query.MSelectionOnlyOperator)4 List (java.util.List)4 AggregationOperator (com.linkedin.pinot.core.operator.query.AggregationOperator)3 DocIdSetBlock (com.linkedin.pinot.core.operator.blocks.DocIdSetBlock)2 ProjectionBlock (com.linkedin.pinot.core.operator.blocks.ProjectionBlock)2 TransformBlock (com.linkedin.pinot.core.operator.blocks.TransformBlock)2 MSelectionOrderByOperator (com.linkedin.pinot.core.operator.query.MSelectionOrderByOperator)2 Queue (java.util.Queue)2 AggregationExecutor (com.linkedin.pinot.core.query.aggregation.AggregationExecutor)1 DefaultAggregationExecutor (com.linkedin.pinot.core.query.aggregation.DefaultAggregationExecutor)1 DefaultGroupByExecutor (com.linkedin.pinot.core.query.aggregation.groupby.DefaultGroupByExecutor)1