use of com.linkedin.pinot.common.request.InstanceRequest in project pinot by linkedin.
the class ScheduledRequestHandlerTest method getInstanceRequest.
private InstanceRequest getInstanceRequest() {
InstanceRequest request = new InstanceRequest();
request.setBrokerId("broker");
request.setEnableTrace(false);
request.setRequestId(1);
request.setSearchSegments(Arrays.asList("segment1", "segment2"));
request.setQuery(new BrokerRequest());
return request;
}
use of com.linkedin.pinot.common.request.InstanceRequest in project pinot by linkedin.
the class IntegrationTest method testMaxQuery.
@Test
public void testMaxQuery() {
BrokerRequest brokerRequest = getMaxQuery();
QuerySource querySource = new QuerySource();
querySource.setTableName("testTable");
brokerRequest.setQuerySource(querySource);
InstanceRequest instanceRequest = new InstanceRequest(0, brokerRequest);
addTestTableSearchSegmentsToInstanceRequest(instanceRequest);
try {
QueryRequest queryRequest = new QueryRequest(instanceRequest, _serverInstance.getServerMetrics());
DataTable instanceResponse = _queryExecutor.processQuery(queryRequest, queryRunners);
// System.out.println(instanceResponse.getDouble(0, 0));
// System.out.println(instanceResponse.getMetadata().get(DataTable.TIME_USED_MS_METADATA_KEY));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of com.linkedin.pinot.common.request.InstanceRequest 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;
}
Aggregations