use of com.linkedin.pinot.common.request.BrokerRequest in project pinot by linkedin.
the class IntegrationTest method getMinQuery.
private BrokerRequest getMinQuery() {
BrokerRequest query = new BrokerRequest();
AggregationInfo aggregationInfo = getMinAggregationInfo();
List<AggregationInfo> aggregationsInfo = new ArrayList<AggregationInfo>();
aggregationsInfo.add(aggregationInfo);
query.setAggregationsInfo(aggregationsInfo);
return query;
}
use of com.linkedin.pinot.common.request.BrokerRequest in project pinot by linkedin.
the class IntegrationTest method testMinQuery.
@Test
public void testMinQuery() {
BrokerRequest brokerRequest = getMinQuery();
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.BrokerRequest in project pinot by linkedin.
the class IntegrationTest method testSumQuery.
@Test
public void testSumQuery() {
BrokerRequest brokerRequest = getSumQuery();
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.BrokerRequest in project pinot by linkedin.
the class StarTreeQueryGenerator method main.
/**
* Given star tree segments directory and number of queries, generate star tree queries.
* Usage: StarTreeQueryGenerator starTreeSegmentsDirectory numQueries
*
* @param args arguments.
*/
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: StarTreeQueryGenerator starTreeSegmentsDirectory numQueries");
return;
}
// Get segment metadata for the first segment to get table name and verify query is fit for star tree.
File segmentsDir = new File(args[0]);
Preconditions.checkState(segmentsDir.exists());
Preconditions.checkState(segmentsDir.isDirectory());
File[] segments = segmentsDir.listFiles();
Preconditions.checkNotNull(segments);
File segment = segments[0];
IndexSegment indexSegment = Loaders.IndexSegment.load(segment, ReadMode.heap);
SegmentMetadata segmentMetadata = indexSegment.getSegmentMetadata();
String tableName = segmentMetadata.getTableName();
// Set up star tree query generator.
int numQueries = Integer.parseInt(args[1]);
SegmentInfoProvider infoProvider = new SegmentInfoProvider(args[0]);
StarTreeQueryGenerator generator = new StarTreeQueryGenerator(tableName, infoProvider.getSingleValueDimensionColumns(), infoProvider.getMetricColumns(), infoProvider.getSingleValueDimensionValuesMap());
Pql2Compiler compiler = new Pql2Compiler();
for (int i = 0; i < numQueries; i++) {
String query = generator.nextQuery();
System.out.println(query);
// Verify that query is fit for star tree.
BrokerRequest brokerRequest = compiler.compileToBrokerRequest(query);
Preconditions.checkState(RequestUtils.isFitForStarTreeIndex(segmentMetadata, RequestUtils.generateFilterQueryTree(brokerRequest), brokerRequest));
}
}
use of com.linkedin.pinot.common.request.BrokerRequest in project pinot by linkedin.
the class Pql2CompilerTest method testTopZeroFor.
private void testTopZeroFor(Pql2Compiler compiler, String s, final int expectedTopN, boolean parseException) throws Exception {
BrokerRequest req;
try {
req = compiler.compileToBrokerRequest(s);
} catch (Pql2CompilationException e) {
if (parseException) {
return;
}
throw e;
}
Assert.assertTrue(req.isSetGroupBy());
GroupBy groupBy = req.getGroupBy();
Assert.assertTrue(groupBy.isSetTopN());
Assert.assertEquals(expectedTopN, groupBy.getTopN());
}
Aggregations