Search in sources :

Example 21 with DataTable

use of com.linkedin.pinot.common.utils.DataTable 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);
    }
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) QuerySource(com.linkedin.pinot.common.request.QuerySource) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 22 with DataTable

use of com.linkedin.pinot.common.utils.DataTable in project pinot by linkedin.

the class BrokerReduceServiceTest method testSumQuery.

@Test
public void testSumQuery() {
    BrokerRequest brokerRequest = getSumQuery();
    QuerySource querySource = new QuerySource();
    querySource.setTableName("midas");
    brokerRequest.setQuerySource(querySource);
    InstanceRequest instanceRequest = new InstanceRequest(0, brokerRequest);
    instanceRequest.setSearchSegments(new ArrayList<String>());
    for (IndexSegment segment : _indexSegmentList) {
        instanceRequest.addToSearchSegments(segment.getSegmentName());
    }
    Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    try {
        QueryRequest queryRequest = new QueryRequest(instanceRequest, TableDataManagerProvider.getServerMetrics());
        DataTable instanceResponse1 = _queryExecutor.processQuery(queryRequest, queryRunners);
        instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse1);
        DataTable instanceResponse2 = _queryExecutor.processQuery(queryRequest, queryRunners);
        instanceResponseMap.put(new ServerInstance("localhost:1111"), instanceResponse2);
        BrokerResponseNative brokerResponse = _reduceService.reduceOnDataTable(brokerRequest, instanceResponseMap);
        LOGGER.info("BrokerResponse is " + brokerResponse.getAggregationResults().get(0));
        LOGGER.info("Time used for BrokerResponse is " + brokerResponse.getTimeUsedMs());
    } catch (Exception e) {
        e.printStackTrace();
        // Should never happen
        throw new RuntimeException(e.toString(), e);
    }
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) HashMap(java.util.HashMap) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) QuerySource(com.linkedin.pinot.common.request.QuerySource) 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)

Example 23 with DataTable

use of com.linkedin.pinot.common.utils.DataTable in project pinot by linkedin.

the class SelectionOperatorServiceTest method testCompatibleRowsDataTableTransformation.

@Test
public void testCompatibleRowsDataTableTransformation() throws Exception {
    Collection<Serializable[]> rows = new ArrayList<>(2);
    rows.add(_row1.clone());
    rows.add(_compatibleRow1.clone());
    DataSchema dataSchema = _dataSchema.clone();
    Assert.assertTrue(dataSchema.isTypeCompatibleWith(_compatibleDataSchema));
    dataSchema.upgradeToCover(_compatibleDataSchema);
    Assert.assertEquals(dataSchema, _upgradedDataSchema);
    DataTable dataTable = SelectionOperatorUtils.getDataTableFromRows(rows, dataSchema);
    Serializable[] expectedRow1 = { 0L, 1.0, 2.0, 3.0, "4", new long[] { 5L }, new double[] { 6.0 }, new double[] { 7.0 }, new double[] { 8.0 }, new String[] { "9" } };
    Serializable[] expectedCompatibleRow1 = { 1L, 2.0, 3.0, 4.0, "5", new long[] { 6L }, new double[] { 7.0 }, new double[] { 8.0 }, new double[] { 9.0 }, new String[] { "10" } };
    Assert.assertEquals(SelectionOperatorUtils.extractRowFromDataTable(dataTable, 0), expectedRow1);
    Assert.assertEquals(SelectionOperatorUtils.extractRowFromDataTable(dataTable, 1), expectedCompatibleRow1);
}
Also used : DataSchema(com.linkedin.pinot.common.utils.DataSchema) DataTable(com.linkedin.pinot.common.utils.DataTable) Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 24 with DataTable

use of com.linkedin.pinot.common.utils.DataTable in project pinot by linkedin.

the class BrokerReduceServiceTest method testMinQuery.

@Test
public void testMinQuery() {
    BrokerRequest brokerRequest = getMinQuery();
    QuerySource querySource = new QuerySource();
    querySource.setTableName("midas");
    brokerRequest.setQuerySource(querySource);
    InstanceRequest instanceRequest = new InstanceRequest(0, brokerRequest);
    instanceRequest.setSearchSegments(new ArrayList<String>());
    for (IndexSegment segment : _indexSegmentList) {
        instanceRequest.addToSearchSegments(segment.getSegmentName());
    }
    Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    try {
        QueryRequest queryRequest = new QueryRequest(instanceRequest, TableDataManagerProvider.getServerMetrics());
        DataTable instanceResponse1 = _queryExecutor.processQuery(queryRequest, queryRunners);
        instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse1);
        DataTable instanceResponse2 = _queryExecutor.processQuery(queryRequest, queryRunners);
        instanceResponseMap.put(new ServerInstance("localhost:1111"), instanceResponse2);
        BrokerResponseNative brokerResponse = (BrokerResponseNative) _reduceService.reduceOnDataTable(brokerRequest, instanceResponseMap);
        LOGGER.info("BrokerResponse is " + brokerResponse.getAggregationResults().get(0));
        LOGGER.info("Time used for BrokerResponse is " + brokerResponse.getTimeUsedMs());
    } catch (Exception e) {
        e.printStackTrace();
        // Should never happen
        throw new RuntimeException(e.toString(), e);
    }
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) HashMap(java.util.HashMap) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) QuerySource(com.linkedin.pinot.common.request.QuerySource) 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)

Example 25 with DataTable

use of com.linkedin.pinot.common.utils.DataTable in project pinot by linkedin.

the class BrokerReduceServiceTest method testCountQuery.

@Test
public void testCountQuery() {
    BrokerRequest brokerRequest = getCountQuery();
    QuerySource querySource = new QuerySource();
    querySource.setTableName("midas");
    brokerRequest.setQuerySource(querySource);
    InstanceRequest instanceRequest = new InstanceRequest(0, brokerRequest);
    instanceRequest.setSearchSegments(new ArrayList<String>());
    for (IndexSegment segment : _indexSegmentList) {
        instanceRequest.addToSearchSegments(segment.getSegmentName());
    }
    Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>();
    QueryRequest queryRequest = new QueryRequest(instanceRequest, TableDataManagerProvider.getServerMetrics());
    DataTable instanceResponse1 = _queryExecutor.processQuery(queryRequest, queryRunners);
    instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse1);
    DataTable instanceResponse2 = _queryExecutor.processQuery(queryRequest, queryRunners);
    instanceResponseMap.put(new ServerInstance("localhost:1111"), instanceResponse2);
    BrokerResponseNative brokerResponse = _reduceService.reduceOnDataTable(brokerRequest, instanceResponseMap);
    AggregationResult aggregationResult = brokerResponse.getAggregationResults().get(0);
    LOGGER.info("BrokerResponse is " + aggregationResult);
    checkAggregationResult(aggregationResult, "count_star", 800004.0);
    LOGGER.info("Time used for BrokerResponse is " + brokerResponse.getTimeUsedMs());
}
Also used : DataTable(com.linkedin.pinot.common.utils.DataTable) QueryRequest(com.linkedin.pinot.common.query.QueryRequest) HashMap(java.util.HashMap) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) BrokerResponseNative(com.linkedin.pinot.common.response.broker.BrokerResponseNative) AggregationResult(com.linkedin.pinot.common.response.broker.AggregationResult) QuerySource(com.linkedin.pinot.common.request.QuerySource) 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)

Aggregations

DataTable (com.linkedin.pinot.common.utils.DataTable)49 Test (org.testng.annotations.Test)36 QueryRequest (com.linkedin.pinot.common.query.QueryRequest)35 InstanceRequest (com.linkedin.pinot.common.request.InstanceRequest)34 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)33 HashMap (java.util.HashMap)27 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)26 BrokerResponseNative (com.linkedin.pinot.common.response.broker.BrokerResponseNative)23 QuerySource (com.linkedin.pinot.common.request.QuerySource)18 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)12 AggregationResult (com.linkedin.pinot.common.response.broker.AggregationResult)8 BeforeTest (org.testng.annotations.BeforeTest)8 DataSchema (com.linkedin.pinot.common.utils.DataSchema)7 ArrayList (java.util.ArrayList)7 Nonnull (javax.annotation.Nonnull)5 DataTableImplV2 (com.linkedin.pinot.core.common.datatable.DataTableImplV2)4 ByteBuf (io.netty.buffer.ByteBuf)4 Map (java.util.Map)4 AfterTest (org.testng.annotations.AfterTest)4 DataTableBuilder (com.linkedin.pinot.core.common.datatable.DataTableBuilder)3