use of com.linkedin.pinot.common.request.Selection in project pinot by linkedin.
the class StarColumnListAstNode method updateBrokerRequest.
@Override
public void updateBrokerRequest(BrokerRequest brokerRequest) {
Selection selection = new Selection();
List<String> modifiableList = new ArrayList<>(1);
modifiableList.add("*");
selection.setSelectionColumns(modifiableList);
brokerRequest.setSelections(selection);
}
use of com.linkedin.pinot.common.request.Selection in project pinot by linkedin.
the class OrderByAstNode method updateBrokerRequest.
@Override
public void updateBrokerRequest(BrokerRequest brokerRequest) {
Selection selections = brokerRequest.getSelections();
for (AstNode astNode : getChildren()) {
if (astNode instanceof OrderByExpressionAstNode) {
OrderByExpressionAstNode node = (OrderByExpressionAstNode) astNode;
SelectionSort elem = new SelectionSort();
elem.setColumn(node.getColumn());
elem.setIsAsc("asc".equalsIgnoreCase(node.getOrdering()));
selections.addToSelectionSortSequence(elem);
} else {
throw new Pql2CompilationException("Child node of ORDER BY node is not an expression node");
}
}
}
use of com.linkedin.pinot.common.request.Selection 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));
}
use of com.linkedin.pinot.common.request.Selection in project pinot by linkedin.
the class OutputColumnAstNode method updateBrokerRequest.
@Override
public void updateBrokerRequest(BrokerRequest brokerRequest) {
for (AstNode astNode : getChildren()) {
// If the column is a function call, it must be an aggregation function
if (astNode instanceof FunctionCallAstNode) {
FunctionCallAstNode node = (FunctionCallAstNode) astNode;
brokerRequest.addToAggregationsInfo(node.buildAggregationInfo());
} else if (astNode instanceof IdentifierAstNode) {
Selection selection = brokerRequest.getSelections();
if (selection == null) {
selection = new Selection();
brokerRequest.setSelections(selection);
}
IdentifierAstNode node = (IdentifierAstNode) astNode;
selection.addToSelectionColumns(node.getName());
} else {
throw new Pql2CompilationException("Output column is neither a function nor an identifier");
}
}
}
use of com.linkedin.pinot.common.request.Selection in project pinot by linkedin.
the class SelectAstNode method updateBrokerRequest.
@Override
public void updateBrokerRequest(BrokerRequest brokerRequest) {
// Set the query source
QuerySource querySource = new QuerySource();
querySource.setTableName(_resourceName);
brokerRequest.setQuerySource(querySource);
sendBrokerRequestUpdateToChildren(brokerRequest);
// If there is a selection, set its limit if applicable
Selection selections = brokerRequest.getSelections();
if (selections != null) {
if (_recordLimit != -1) {
selections.setSize(_recordLimit);
}
if (_offset != -1) {
selections.setOffset(_offset);
}
}
// If there is a topN clause, set it on the group by
GroupBy groupBy = brokerRequest.getGroupBy();
if (groupBy != null) {
if (_topN != -1) {
groupBy.setTopN(_topN);
} else {
// Pinot quirk: default to top 10
groupBy.setTopN(10);
}
}
// Pinot quirk: if there is both a selection and an aggregation, remove the selection
if (brokerRequest.getAggregationsInfoSize() != 0 && brokerRequest.isSetSelections()) {
brokerRequest.setSelections(null);
}
}
Aggregations