use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.
the class ApproximateQueryTestUtil method runQuery.
public static Object runQuery(QueryExecutor queryExecutor, List<String> segments, AvroQueryGenerator.TestAggreationQuery query, ServerMetrics metrics) {
LOGGER.info("\nRunning: " + query.getPql());
final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(query.getPql());
InstanceRequest instanceRequest = new InstanceRequest(counter++, brokerRequest);
instanceRequest.setSearchSegments(new ArrayList<String>());
for (String segment : segments) {
instanceRequest.getSearchSegments().add(segment);
}
QueryRequest queryRequest = new QueryRequest(instanceRequest, metrics);
final DataTable instanceResponse = queryExecutor.processQuery(queryRequest, queryRunners);
final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse);
final BrokerResponseNative brokerResponse = REDUCE_SERVICE.reduceOnDataTable(brokerRequest, instanceResponseMap);
AggregationResult result = brokerResponse.getAggregationResults().get(0);
Assert.assertNotNull(result);
if (result.getValue() != null) {
LOGGER.info("Aggregation Result is " + result.getValue().toString());
} else if (result.getGroupByResult() != null) {
LOGGER.info("GroupBy Result is " + result.getGroupByResult().toString());
} else {
throw new RuntimeException("Aggregation and GroupBy Results both null.");
}
// compute value
Object val;
if (query instanceof AvroQueryGenerator.TestSimpleAggreationQuery) {
val = Double.parseDouble(brokerResponse.getAggregationResults().get(0).getValue().toString());
} else {
val = brokerResponse.getAggregationResults().get(0).getGroupByResult();
}
return val;
}
use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.
the class InterSegmentAggregationMultiValueQueriesTest method testCountMV.
@Test
public void testCountMV() {
String query = "SELECT COUNTMV(column6) FROM testTable";
BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 400000L, 400000L, new String[] { "426752" });
brokerResponse = getBrokerResponseForQueryWithFilter(query);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 62480L, 1129720L, 62480L, 400000L, new String[] { "62480" });
brokerResponse = getBrokerResponseForQuery(query + SV_GROUP_BY);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "231056" });
brokerResponse = getBrokerResponseForQuery(query + MV_GROUP_BY);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "199896" });
}
use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.
the class InterSegmentAggregationMultiValueQueriesTest method testPercentile50MV.
@Test
public void testPercentile50MV() {
String query = "SELECT PERCENTILE50MV(column6) FROM testTable";
BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 400000L, 400000L, new String[] { "2147483647.00000" });
brokerResponse = getBrokerResponseForQueryWithFilter(query);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 62480L, 1129720L, 62480L, 400000L, new String[] { "2147483647.00000" });
brokerResponse = getBrokerResponseForQuery(query + SV_GROUP_BY);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647.00000" });
brokerResponse = getBrokerResponseForQuery(query + MV_GROUP_BY);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647.00000" });
}
use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.
the class InterSegmentAggregationMultiValueQueriesTest method testPercentile95MV.
@Test
public void testPercentile95MV() {
String query = "SELECT PERCENTILE95MV(column6) FROM testTable";
BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 400000L, 400000L, new String[] { "2147483647.00000" });
brokerResponse = getBrokerResponseForQueryWithFilter(query);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 62480L, 1129720L, 62480L, 400000L, new String[] { "2147483647.00000" });
brokerResponse = getBrokerResponseForQuery(query + SV_GROUP_BY);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647.00000" });
brokerResponse = getBrokerResponseForQuery(query + MV_GROUP_BY);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647.00000" });
}
use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.
the class InterSegmentAggregationMultiValueQueriesTest method testAvgMV.
@Test
public void testAvgMV() {
String query = "SELECT AVGMV(column6) FROM testTable";
BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 400000L, 400000L, new String[] { "1134908803.73210" });
brokerResponse = getBrokerResponseForQueryWithFilter(query);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 62480L, 1129720L, 62480L, 400000L, new String[] { "1835029026.75916" });
brokerResponse = getBrokerResponseForQuery(query + SV_GROUP_BY);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647.00000" });
brokerResponse = getBrokerResponseForQuery(query + MV_GROUP_BY);
QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647.00000" });
}
Aggregations