Search in sources :

Example 71 with BrokerRequest

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;
        }
    }
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) HashMap(java.util.HashMap) BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) TestSimpleAggreationQuery(com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) ServerInstance(com.linkedin.pinot.common.response.ServerInstance) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest) Test(org.testng.annotations.Test) RealtimeSegmentImplTest(com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)

Example 72 with BrokerRequest

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);
}
Also used : Configuration(org.apache.commons.configuration.Configuration) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Pql2Compiler(com.linkedin.pinot.pql.parsers.Pql2Compiler) ArrayList(java.util.ArrayList) IndexLoadingConfigMetadata(com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Callable(java.util.concurrent.Callable) FilenameFilter(java.io.FilenameFilter) IndexSegmentImpl(com.linkedin.pinot.core.segment.index.IndexSegmentImpl) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) File(java.io.File)

Example 73 with BrokerRequest

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;
}
Also used : ArrayList(java.util.ArrayList) FilterQuery(com.linkedin.pinot.common.request.FilterQuery) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo)

Example 74 with BrokerRequest

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;
}
Also used : ArrayList(java.util.ArrayList) FilterQuery(com.linkedin.pinot.common.request.FilterQuery) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo)

Example 75 with BrokerRequest

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;
}
Also used : BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest)

Aggregations

BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)77 Test (org.testng.annotations.Test)38 InstanceRequest (com.linkedin.pinot.common.request.InstanceRequest)33 DataTable (com.linkedin.pinot.common.utils.DataTable)33 QueryRequest (com.linkedin.pinot.common.query.QueryRequest)31 HashMap (java.util.HashMap)24 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)23 AggregationInfo (com.linkedin.pinot.common.request.AggregationInfo)22 BrokerResponseNative (com.linkedin.pinot.common.response.broker.BrokerResponseNative)22 ArrayList (java.util.ArrayList)22 QuerySource (com.linkedin.pinot.common.request.QuerySource)18 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)13 Pql2Compiler (com.linkedin.pinot.pql.parsers.Pql2Compiler)10 FilterQuery (com.linkedin.pinot.common.request.FilterQuery)9 FilterQueryTree (com.linkedin.pinot.common.utils.request.FilterQueryTree)7 AggregationResult (com.linkedin.pinot.common.response.broker.AggregationResult)6 GroupBy (com.linkedin.pinot.common.request.GroupBy)4 Nonnull (javax.annotation.Nonnull)4 AfterTest (org.testng.annotations.AfterTest)4 BeforeTest (org.testng.annotations.BeforeTest)4