Search in sources :

Example 36 with AggregationInfo

use of com.linkedin.pinot.common.request.AggregationInfo in project pinot by linkedin.

the class QueryExecutorTest method getSumQuery.

private BrokerRequest getSumQuery() {
    BrokerRequest query = new BrokerRequest();
    AggregationInfo aggregationInfo = getSumAggregationInfo();
    List<AggregationInfo> aggregationsInfo = new ArrayList<AggregationInfo>();
    aggregationsInfo.add(aggregationInfo);
    query.setAggregationsInfo(aggregationsInfo);
    FilterQuery filterQuery = getFilterQuery();
    query.setFilterQuery(filterQuery);
    return query;
}
Also used : ArrayList(java.util.ArrayList) FilterQuery(com.linkedin.pinot.common.request.FilterQuery) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo)

Example 37 with AggregationInfo

use of com.linkedin.pinot.common.request.AggregationInfo in project pinot by linkedin.

the class QueryExecutorTest method getMinAggregationInfo.

private AggregationInfo getMinAggregationInfo() {
    String type = "min";
    Map<String, String> params = new HashMap<String, String>();
    params.put("column", "met");
    AggregationInfo aggregationInfo = new AggregationInfo();
    aggregationInfo.setAggregationType(type);
    aggregationInfo.setAggregationParams(params);
    return aggregationInfo;
}
Also used : HashMap(java.util.HashMap) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo)

Example 38 with AggregationInfo

use of com.linkedin.pinot.common.request.AggregationInfo in project pinot by linkedin.

the class QueryExecutorTest method getMaxQuery.

private BrokerRequest getMaxQuery() {
    BrokerRequest query = new BrokerRequest();
    AggregationInfo aggregationInfo = getMaxAggregationInfo();
    List<AggregationInfo> aggregationsInfo = new ArrayList<AggregationInfo>();
    aggregationsInfo.add(aggregationInfo);
    query.setAggregationsInfo(aggregationsInfo);
    FilterQuery filterQuery = getFilterQuery();
    query.setFilterQuery(filterQuery);
    return query;
}
Also used : ArrayList(java.util.ArrayList) FilterQuery(com.linkedin.pinot.common.request.FilterQuery) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo)

Example 39 with AggregationInfo

use of com.linkedin.pinot.common.request.AggregationInfo in project pinot by linkedin.

the class ScanBasedQueryProcessor method processQuery.

public QueryResponse processQuery(String query) throws Exception {
    long startTimeInMillis = System.currentTimeMillis();
    Pql2Compiler pql2Compiler = new Pql2Compiler();
    BrokerRequest brokerRequest = pql2Compiler.compileToBrokerRequest(query);
    ResultTable results = null;
    Aggregation aggregation = null;
    List<String> groupByColumns;
    List<AggregationInfo> aggregationsInfo = brokerRequest.getAggregationsInfo();
    if (aggregationsInfo != null) {
        GroupBy groupBy = brokerRequest.getGroupBy();
        groupByColumns = (brokerRequest.isSetGroupBy()) ? groupBy.getColumns() : null;
        long topN = (groupByColumns != null) ? groupBy.getTopN() : 10;
        aggregation = new Aggregation(brokerRequest.getAggregationsInfo(), groupByColumns, topN);
    }
    int numDocsScanned = 0;
    int totalDocs = 0;
    int numSegments = 0;
    LOGGER.info("Processing Query: {}", query);
    List<ResultTable> resultTables = processSegments(query, brokerRequest);
    for (ResultTable segmentResults : resultTables) {
        numDocsScanned += segmentResults.getNumDocsScanned();
        totalDocs += segmentResults.getTotalDocs();
        ++numSegments;
        results = (results == null) ? segmentResults : results.append(segmentResults);
    }
    if (aggregation != null && numSegments > 1 && numDocsScanned > 0) {
        results = aggregation.aggregate(results);
    }
    if (results != null) {
        results.setNumDocsScanned(numDocsScanned);
        results.setTotalDocs(totalDocs);
        long totalUsedMs = System.currentTimeMillis() - startTimeInMillis;
        results.setProcessingTime(totalUsedMs);
        results.seal();
    }
    QueryResponse queryResponse = new QueryResponse(results);
    return queryResponse;
}
Also used : GroupBy(com.linkedin.pinot.common.request.GroupBy) Pql2Compiler(com.linkedin.pinot.pql.parsers.Pql2Compiler) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo)

Example 40 with AggregationInfo

use of com.linkedin.pinot.common.request.AggregationInfo in project pinot by linkedin.

the class BrokerRequestPreProcessor method rewriteFastHllColumnName.

/**
   * Rewrite 'fasthll' column name.
   *
   * @param indexSegments list of index segments.
   * @param aggregationsInfo list of aggregation info.
   */
private static void rewriteFastHllColumnName(List<IndexSegment> indexSegments, List<AggregationInfo> aggregationsInfo) {
    // Consistent check.
    for (AggregationInfo aggregationInfo : aggregationsInfo) {
        if (aggregationInfo.getAggregationType().equalsIgnoreCase("fasthll")) {
            String column = aggregationInfo.getAggregationParams().get("column").trim();
            boolean isFirstSegment = true;
            String firstSegmentName = null;
            String hllDerivedColumn = null;
            for (IndexSegment indexSegment : indexSegments) {
                SegmentMetadata segmentMetadata = indexSegment.getSegmentMetadata();
                if (isFirstSegment) {
                    // Use metadata from first index segment to perform rewrite.
                    isFirstSegment = false;
                    firstSegmentName = segmentMetadata.getName();
                    hllDerivedColumn = segmentMetadata.getDerivedColumn(column, MetricFieldSpec.DerivedMetricType.HLL);
                    if (hllDerivedColumn != null) {
                        aggregationInfo.getAggregationParams().put("column", hllDerivedColumn);
                    }
                } else {
                    // Perform consistency check on other index segments.
                    String hllDerivedColumnToCheck = segmentMetadata.getDerivedColumn(column, MetricFieldSpec.DerivedMetricType.HLL);
                    if (!Objects.equals(hllDerivedColumn, hllDerivedColumnToCheck)) {
                        throw new RuntimeException("Found inconsistency HLL derived column name. In segment " + firstSegmentName + ": " + hllDerivedColumn + "; In segment " + segmentMetadata.getName() + ": " + hllDerivedColumnToCheck);
                    }
                }
            }
        }
    }
}
Also used : SegmentMetadata(com.linkedin.pinot.common.segment.SegmentMetadata) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo)

Aggregations

AggregationInfo (com.linkedin.pinot.common.request.AggregationInfo)51 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)22 ArrayList (java.util.ArrayList)21 HashMap (java.util.HashMap)21 FilterQuery (com.linkedin.pinot.common.request.FilterQuery)9 GroupBy (com.linkedin.pinot.common.request.GroupBy)6 AggregationFunctionContext (com.linkedin.pinot.core.query.aggregation.AggregationFunctionContext)5 AggregationFunctionInitializer (com.linkedin.pinot.core.plan.AggregationFunctionInitializer)3 Selection (com.linkedin.pinot.common.request.Selection)2 Operator (com.linkedin.pinot.core.common.Operator)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 IntermediateResultsBlock (com.linkedin.pinot.core.operator.blocks.IntermediateResultsBlock)2 MatchEntireSegmentOperator (com.linkedin.pinot.core.operator.filter.MatchEntireSegmentOperator)2 TransformExpressionOperator (com.linkedin.pinot.core.operator.transform.TransformExpressionOperator)2 Pql2Compiler (com.linkedin.pinot.pql.parsers.Pql2Compiler)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Test (org.testng.annotations.Test)2