Search in sources :

Example 46 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.

the class RealtimeQueriesSentinelTest method test1.

@Test
public void test1() throws Exception {
    final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    String query = "select sum('count') from testTable where column13='1540094560' group by column3 top 100 limit 0";
    Map<Object, Double> fromAvro = new HashMap<Object, Double>();
    fromAvro.put(null, 2.0D);
    fromAvro.put("", 1.2469280068E10D);
    fromAvro.put("F", 127.0D);
    fromAvro.put("A", 20.0D);
    fromAvro.put("H", 29.0D);
    final BrokerRequest brokerRequest = REQUEST_COMPILER.compileToBrokerRequest(query);
    InstanceRequest instanceRequest = new InstanceRequest(485, 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);
    BrokerResponseNative brokerResponse = REDUCE_SERVICE.reduceOnDataTable(brokerRequest, instanceResponseMap);
    JSONArray actual = brokerResponse.toJson().getJSONArray("aggregationResults").getJSONObject(0).getJSONArray("groupByResult");
    assertGroupByResults(actual, fromAvro);
}
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) JSONArray(org.json.JSONArray) 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 47 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative 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 48 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.

the class InterSegmentAggregationMultiValueQueriesTest method testSumMV.

@Test
public void testSumMV() {
    String query = "SELECT SUMMV(column6) FROM testTable";
    BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 400000L, 400000L, new String[] { "484324601810280.00000" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 62480L, 1129720L, 62480L, 400000L, new String[] { "114652613591912.00000" });
    brokerResponse = getBrokerResponseForQuery(query + SV_GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "402591409613620.00000" });
    brokerResponse = getBrokerResponseForQuery(query + MV_GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "393483780531788.00000" });
}
Also used : BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) Test(org.testng.annotations.Test)

Example 49 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.

the class InterSegmentAggregationMultiValueQueriesTest method testPercentileEst50MV.

@Test
public void testPercentileEst50MV() {
    String query = "SELECT PERCENTILEEST50MV(column6) FROM testTable";
    BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 400000L, 400000L, new String[] { "2147483647" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 62480L, 1129720L, 62480L, 400000L, new String[] { "2147483647" });
    brokerResponse = getBrokerResponseForQuery(query + SV_GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647" });
    brokerResponse = getBrokerResponseForQuery(query + MV_GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647" });
}
Also used : BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) Test(org.testng.annotations.Test)

Example 50 with BrokerResponseNative

use of com.linkedin.pinot.common.response.broker.BrokerResponseNative in project pinot by linkedin.

the class InterSegmentAggregationMultiValueQueriesTest method testPercentileEst95MV.

@Test
public void testPercentileEst95MV() {
    String query = "SELECT PERCENTILEEST95MV(column6) FROM testTable";
    BrokerResponseNative brokerResponse = getBrokerResponseForQuery(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 400000L, 400000L, new String[] { "2147483647" });
    brokerResponse = getBrokerResponseForQueryWithFilter(query);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 62480L, 1129720L, 62480L, 400000L, new String[] { "2147483647" });
    brokerResponse = getBrokerResponseForQuery(query + SV_GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647" });
    brokerResponse = getBrokerResponseForQuery(query + MV_GROUP_BY);
    QueriesTestUtils.verifyAggregationResult(brokerResponse, 400000L, 0L, 800000L, 400000L, new String[] { "2147483647" });
}
Also used : BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) Test(org.testng.annotations.Test)

Aggregations

BrokerResponseNative (com.linkedin.pinot.common.response.broker.BrokerResponseNative)58 Test (org.testng.annotations.Test)56 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)23 DataTable (com.linkedin.pinot.common.utils.DataTable)23 HashMap (java.util.HashMap)23 QueryRequest (com.linkedin.pinot.common.query.QueryRequest)22 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)22 InstanceRequest (com.linkedin.pinot.common.request.InstanceRequest)22 QuerySource (com.linkedin.pinot.common.request.QuerySource)8 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)8 AggregationResult (com.linkedin.pinot.common.response.broker.AggregationResult)6 RealtimeSegmentImplTest (com.linkedin.pinot.core.realtime.impl.kafka.RealtimeSegmentImplTest)3 TestGroupByAggreationQuery (com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestGroupByAggreationQuery)2 TestSimpleAggreationQuery (com.linkedin.pinot.common.query.gen.AvroQueryGenerator.TestSimpleAggreationQuery)2 QueryProcessingException (com.linkedin.pinot.common.response.broker.QueryProcessingException)2 JSONArray (org.json.JSONArray)2 SelectionResults (com.linkedin.pinot.common.response.broker.SelectionResults)1 DataSchema (com.linkedin.pinot.common.utils.DataSchema)1 AggregationFunction (com.linkedin.pinot.core.query.aggregation.function.AggregationFunction)1 Serializable (java.io.Serializable)1