Search in sources :

Example 6 with FilterQuery

use of com.linkedin.pinot.common.request.FilterQuery in project pinot by linkedin.

the class RequestUtils method generateFilterQueryTree.

/**
   * Generate FilterQueryTree from Broker Request
   * @param request Broker Request
   * @return
   */
public static FilterQueryTree generateFilterQueryTree(BrokerRequest request) {
    FilterQueryTree root = null;
    FilterQuery q = request.getFilterQuery();
    if (null != q && null != request.getFilterSubQueryMap()) {
        root = buildFilterQuery(q.getId(), request.getFilterSubQueryMap().getFilterQueryMap());
    }
    return root;
}
Also used : FilterQuery(com.linkedin.pinot.common.request.FilterQuery)

Example 7 with FilterQuery

use of com.linkedin.pinot.common.request.FilterQuery in project pinot by linkedin.

the class RequestUtils method generateFilterFromTree.

/**
   * Generates thrift compliant filterQuery and populate it in the broker request
   * @param filterQueryTree
   * @param request
   */
public static void generateFilterFromTree(FilterQueryTree filterQueryTree, BrokerRequest request) {
    Map<Integer, FilterQuery> filterQueryMap = new HashMap<Integer, FilterQuery>();
    FilterQuery root = traverseFilterQueryAndPopulateMap(filterQueryTree, filterQueryMap);
    filterQueryMap.put(root.getId(), root);
    request.setFilterQuery(root);
    FilterQueryMap mp = new FilterQueryMap();
    mp.setFilterQueryMap(filterQueryMap);
    request.setFilterSubQueryMap(mp);
}
Also used : HashMap(java.util.HashMap) FilterQueryMap(com.linkedin.pinot.common.request.FilterQueryMap) FilterQuery(com.linkedin.pinot.common.request.FilterQuery)

Example 8 with FilterQuery

use of com.linkedin.pinot.common.request.FilterQuery in project pinot by linkedin.

the class BrokerRequestSerializationTest method testSerialization.

@Test
public static void testSerialization() throws TException {
    BrokerRequest req = new BrokerRequest();
    // Populate Query Type
    QueryType type = new QueryType();
    type.setHasAggregation(true);
    type.setHasFilter(true);
    type.setHasSelection(true);
    type.setHasGroup_by(true);
    req.setQueryType(type);
    // Populate Query source
    QuerySource s = new QuerySource();
    s.setTableName("dummy");
    req.setQuerySource(s);
    req.setDuration("dummy");
    req.setTimeInterval("dummy");
    //Populate Group-By
    GroupBy groupBy = new GroupBy();
    List<String> columns = new ArrayList<String>();
    columns.add("dummy1");
    columns.add("dummy2");
    groupBy.setColumns(columns);
    groupBy.setTopN(100);
    req.setGroupBy(groupBy);
    //Populate Selections
    Selection sel = new Selection();
    sel.setSize(1);
    SelectionSort s2 = new SelectionSort();
    s2.setColumn("dummy1");
    s2.setIsAsc(true);
    sel.addToSelectionSortSequence(s2);
    sel.addToSelectionColumns("dummy1");
    req.setSelections(sel);
    //Populate FilterQuery
    FilterQuery q1 = new FilterQuery();
    q1.setId(1);
    q1.setColumn("dummy1");
    q1.addToValue("dummy1");
    q1.addToNestedFilterQueryIds(2);
    q1.setOperator(FilterOperator.AND);
    FilterQuery q2 = new FilterQuery();
    q2.setId(2);
    q2.setColumn("dummy2");
    q2.addToValue("dummy2");
    q2.setOperator(FilterOperator.AND);
    FilterQueryMap map = new FilterQueryMap();
    map.putToFilterQueryMap(1, q1);
    map.putToFilterQueryMap(2, q2);
    req.setFilterQuery(q1);
    req.setFilterSubQueryMap(map);
    //Populate Aggregations
    AggregationInfo agg = new AggregationInfo();
    agg.setAggregationType("dummy1");
    agg.putToAggregationParams("key1", "dummy1");
    req.addToAggregationsInfo(agg);
    TSerializer normalSerializer = new TSerializer();
    TSerializer compactSerializer = new TSerializer(new TCompactProtocol.Factory());
    normalSerializer.serialize(req);
    compactSerializer.serialize(req);
//    int numRequests = 100000;
//    TimerContext t = MetricsHelper.startTimer();
//    TSerializer serializer = new TSerializer(new TCompactProtocol.Factory());
//    //TSerializer serializer = new TSerializer();
//    //Compact : Size 183 , Serialization Latency : 0.03361ms
//    // Normal : Size 385 , Serialization Latency : 0.01144ms
//
//    for (int i = 0; i < numRequests; i++) {
//      try {
//        serializer.serialize(req);
//        //System.out.println(s3.length);
//        //break;
//      } catch (TException e) {
//        e.printStackTrace();
//      }
//    }
//    t.stop();
//    System.out.println("Latency is :" + (t.getLatencyMs() / (float) numRequests));
}
Also used : GroupBy(com.linkedin.pinot.common.request.GroupBy) Selection(com.linkedin.pinot.common.request.Selection) ArrayList(java.util.ArrayList) FilterQuery(com.linkedin.pinot.common.request.FilterQuery) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) TSerializer(org.apache.thrift.TSerializer) FilterQueryMap(com.linkedin.pinot.common.request.FilterQueryMap) QuerySource(com.linkedin.pinot.common.request.QuerySource) SelectionSort(com.linkedin.pinot.common.request.SelectionSort) BrokerRequest(com.linkedin.pinot.common.request.BrokerRequest) AggregationInfo(com.linkedin.pinot.common.request.AggregationInfo) QueryType(com.linkedin.pinot.common.request.QueryType) Test(org.testng.annotations.Test)

Example 9 with FilterQuery

use of com.linkedin.pinot.common.request.FilterQuery in project pinot by linkedin.

the class QueryExecutorTest method getMinQuery.

private 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 10 with FilterQuery

use of com.linkedin.pinot.common.request.FilterQuery in project pinot by linkedin.

the class QueryExecutorTest method getCountQuery.

private BrokerRequest getCountQuery() {
    BrokerRequest query = new BrokerRequest();
    AggregationInfo aggregationInfo = getCountAggregationInfo();
    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)

Aggregations

FilterQuery (com.linkedin.pinot.common.request.FilterQuery)15 ArrayList (java.util.ArrayList)11 AggregationInfo (com.linkedin.pinot.common.request.AggregationInfo)9 BrokerRequest (com.linkedin.pinot.common.request.BrokerRequest)9 FilterQueryMap (com.linkedin.pinot.common.request.FilterQueryMap)3 GroupBy (com.linkedin.pinot.common.request.GroupBy)1 QuerySource (com.linkedin.pinot.common.request.QuerySource)1 QueryType (com.linkedin.pinot.common.request.QueryType)1 Selection (com.linkedin.pinot.common.request.Selection)1 SelectionSort (com.linkedin.pinot.common.request.SelectionSort)1 FilterQueryTree (com.linkedin.pinot.common.utils.request.FilterQueryTree)1 TimeBoundaryInfo (com.linkedin.pinot.routing.TimeBoundaryService.TimeBoundaryInfo)1 HashMap (java.util.HashMap)1 TSerializer (org.apache.thrift.TSerializer)1 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)1 Test (org.testng.annotations.Test)1