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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations