Search in sources :

Example 1 with FilterQuery

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

the class InstanceServerStarter method getCountQuery.

private static 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)

Example 2 with FilterQuery

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

the class InstanceServerStarter method getSumQuery.

private static BrokerRequest getSumQuery() {
    BrokerRequest query = new BrokerRequest();
    AggregationInfo aggregationInfo = getSumAggregationInfo();
    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 3 with FilterQuery

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

the class BrokerRequestHandler method attachTimeBoundary.

/**
   * Attach time boundary to a broker request.
   *
   * @param hybridTableName hybrid table name.
   * @param brokerRequest original broker request.
   * @param isOfflineRequest flag for offline/realtime request.
   */
private void attachTimeBoundary(@Nonnull String hybridTableName, @Nonnull BrokerRequest brokerRequest, boolean isOfflineRequest) {
    TimeBoundaryInfo timeBoundaryInfo = _timeBoundaryService.getTimeBoundaryInfoFor(TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(hybridTableName));
    if (timeBoundaryInfo == null || timeBoundaryInfo.getTimeColumn() == null || timeBoundaryInfo.getTimeValue() == null) {
        LOGGER.warn("No time boundary attached for table: {}", hybridTableName);
        return;
    }
    // Create a range filter based on the request type.
    String timeValue = timeBoundaryInfo.getTimeValue();
    FilterQuery timeFilterQuery = new FilterQuery();
    timeFilterQuery.setOperator(FilterOperator.RANGE);
    timeFilterQuery.setColumn(timeBoundaryInfo.getTimeColumn());
    timeFilterQuery.setNestedFilterQueryIds(new ArrayList<Integer>());
    List<String> values = new ArrayList<>();
    if (isOfflineRequest) {
        values.add("(*\t\t" + timeValue + ")");
    } else {
        values.add("[" + timeValue + "\t\t*)");
    }
    timeFilterQuery.setValue(values);
    timeFilterQuery.setId(-1);
    // Attach the range filter to the current filter.
    FilterQuery currentFilterQuery = brokerRequest.getFilterQuery();
    if (currentFilterQuery != null) {
        FilterQuery andFilterQuery = new FilterQuery();
        andFilterQuery.setOperator(FilterOperator.AND);
        List<Integer> nestedFilterQueryIds = new ArrayList<>();
        nestedFilterQueryIds.add(currentFilterQuery.getId());
        nestedFilterQueryIds.add(timeFilterQuery.getId());
        andFilterQuery.setNestedFilterQueryIds(nestedFilterQueryIds);
        andFilterQuery.setId(-2);
        FilterQueryMap filterSubQueryMap = brokerRequest.getFilterSubQueryMap();
        filterSubQueryMap.putToFilterQueryMap(timeFilterQuery.getId(), timeFilterQuery);
        filterSubQueryMap.putToFilterQueryMap(andFilterQuery.getId(), andFilterQuery);
        brokerRequest.setFilterQuery(andFilterQuery);
        brokerRequest.setFilterSubQueryMap(filterSubQueryMap);
    } else {
        FilterQueryMap filterSubQueryMap = new FilterQueryMap();
        filterSubQueryMap.putToFilterQueryMap(timeFilterQuery.getId(), timeFilterQuery);
        brokerRequest.setFilterQuery(timeFilterQuery);
        brokerRequest.setFilterSubQueryMap(filterSubQueryMap);
    }
}
Also used : TimeBoundaryInfo(com.linkedin.pinot.routing.TimeBoundaryService.TimeBoundaryInfo) FilterQueryMap(com.linkedin.pinot.common.request.FilterQueryMap) ArrayList(java.util.ArrayList) FilterQuery(com.linkedin.pinot.common.request.FilterQuery)

Example 4 with FilterQuery

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

the class RequestUtils method traverseFilterQueryAndPopulateMap.

private static FilterQuery traverseFilterQueryAndPopulateMap(FilterQueryTree tree, Map<Integer, FilterQuery> filterQueryMap) {
    final List<Integer> f = new ArrayList<Integer>();
    if (null != tree.getChildren()) {
        for (final FilterQueryTree c : tree.getChildren()) {
            f.add(c.getId());
            final FilterQuery q = traverseFilterQueryAndPopulateMap(c, filterQueryMap);
            filterQueryMap.put(c.getId(), q);
        }
    }
    FilterQuery query = new FilterQuery();
    query.setColumn(tree.getColumn());
    query.setId(tree.getId());
    query.setNestedFilterQueryIds(f);
    query.setOperator(tree.getOperator());
    query.setValue(tree.getValue());
    return query;
}
Also used : ArrayList(java.util.ArrayList) FilterQuery(com.linkedin.pinot.common.request.FilterQuery)

Example 5 with FilterQuery

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

the class RequestUtils method buildFilterQuery.

public static FilterQueryTree buildFilterQuery(Integer id, Map<Integer, FilterQuery> queryMap) {
    FilterQuery q = queryMap.get(id);
    List<Integer> children = q.getNestedFilterQueryIds();
    List<FilterQueryTree> c = null;
    if (null != children && !children.isEmpty()) {
        c = new ArrayList<FilterQueryTree>();
        for (final Integer i : children) {
            final FilterQueryTree t = buildFilterQuery(i, queryMap);
            c.add(t);
        }
    }
    FilterQueryTree q2 = new FilterQueryTree(id, q.getColumn(), q.getValue(), q.getOperator(), c);
    return q2;
}
Also used : FilterQuery(com.linkedin.pinot.common.request.FilterQuery)

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