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;
}
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;
}
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;
}
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;
}
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);
}
}
}
}
}
}
Aggregations