use of com.linkedin.pinot.common.request.BrokerRequest in project pinot by linkedin.
the class RealtimeQueriesSentinelTest method testAggregation.
@Test
public void testAggregation() throws Exception {
int counter = 0;
final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
final List<TestSimpleAggreationQuery> aggCalls = AVRO_QUERY_GENERATOR.giveMeNSimpleAggregationQueries(10000);
for (final TestSimpleAggreationQuery aggCall : aggCalls) {
LOGGER.info("running " + counter + " : " + aggCall.pql);
final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(aggCall.pql);
InstanceRequest instanceRequest = new InstanceRequest(counter++, brokerRequest);
instanceRequest.setSearchSegments(new ArrayList<String>());
instanceRequest.getSearchSegments().add("testTable_testTable");
QueryRequest queryRequest = new QueryRequest(instanceRequest, TableDataManagerProvider.getServerMetrics());
DataTable instanceResponse = QUERY_EXECUTOR.processQuery(queryRequest, queryRunners);
instanceResponseMap.clear();
instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse);
final BrokerResponseNative brokerResponse = REDUCE_SERVICE.reduceOnDataTable(brokerRequest, instanceResponseMap);
LOGGER.info("BrokerResponse is " + brokerResponse.getAggregationResults().get(0));
LOGGER.info("Result from avro is : " + aggCall.result);
Double actual = Double.parseDouble(brokerResponse.getAggregationResults().get(0).getValue().toString());
Double expected = aggCall.result;
try {
Assert.assertEquals(actual, expected);
} catch (AssertionError e) {
System.out.println("********************************");
System.out.println("query : " + aggCall.pql);
System.out.println("actual : " + actual);
System.out.println("expected : " + aggCall.result);
System.out.println("********************************");
throw e;
}
}
}
use of com.linkedin.pinot.common.request.BrokerRequest in project pinot by linkedin.
the class FilterOperatorBenchmark method main.
public static void main(String[] args) throws Exception {
String rootDir = args[0];
File[] segmentDirs = new File(rootDir).listFiles();
String query = args[1];
AtomicInteger totalDocsMatched = new AtomicInteger(0);
Pql2Compiler pql2Compiler = new Pql2Compiler();
BrokerRequest brokerRequest = pql2Compiler.compileToBrokerRequest(query);
List<Callable<Void>> segmentProcessors = new ArrayList<>();
long[] timesSpent = new long[segmentDirs.length];
for (int i = 0; i < segmentDirs.length; i++) {
File indexSegmentDir = segmentDirs[i];
System.out.println("Loading " + indexSegmentDir.getName());
Configuration tableDataManagerConfig = new PropertiesConfiguration();
List<String> invertedColumns = new ArrayList<>();
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".bitmap.inv");
}
};
String[] indexFiles = indexSegmentDir.list(filter);
for (String indexFileName : indexFiles) {
invertedColumns.add(indexFileName.replace(".bitmap.inv", ""));
}
tableDataManagerConfig.setProperty(IndexLoadingConfigMetadata.KEY_OF_LOADING_INVERTED_INDEX, invertedColumns);
IndexLoadingConfigMetadata indexLoadingConfigMetadata = new IndexLoadingConfigMetadata(tableDataManagerConfig);
IndexSegmentImpl indexSegmentImpl = (IndexSegmentImpl) Loaders.IndexSegment.load(indexSegmentDir, ReadMode.heap, indexLoadingConfigMetadata);
segmentProcessors.add(new SegmentProcessor(i, indexSegmentImpl, brokerRequest, totalDocsMatched, timesSpent));
}
ExecutorService executorService = Executors.newCachedThreadPool();
for (int run = 0; run < 5; run++) {
System.out.println("START RUN:" + run);
totalDocsMatched.set(0);
long start = System.currentTimeMillis();
List<Future<Void>> futures = executorService.invokeAll(segmentProcessors);
for (int i = 0; i < futures.size(); i++) {
futures.get(i).get();
}
long end = System.currentTimeMillis();
System.out.println("Total docs matched:" + totalDocsMatched + " took:" + (end - start));
System.out.println("Times spent:" + Arrays.toString(timesSpent));
System.out.println("END RUN:" + run);
}
System.exit(0);
}
use of com.linkedin.pinot.common.request.BrokerRequest in project pinot by linkedin.
the class InstanceServerStarter method getMaxQuery.
private static 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.BrokerRequest in project pinot by linkedin.
the class InstanceServerStarter method getMinQuery.
private static BrokerRequest getMinQuery() {
BrokerRequest query = new BrokerRequest();
AggregationInfo aggregationInfo = getMinAggregationInfo();
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.BrokerRequest 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;
}
Aggregations