use of com.yahoo.searchlib.expression.ExpressionNode in project vespa by vespa-engine.
the class Group method clone.
@Override
public Group clone() {
Group obj = (Group) super.clone();
if (id != null) {
obj.id = (ResultNode) id.clone();
}
obj.aggregationResults = new ArrayList<AggregationResult>();
for (AggregationResult result : aggregationResults) {
obj.aggregationResults.add(result.clone());
}
obj.orderByIdx = new ArrayList<Integer>();
for (Integer idx : orderByIdx) {
obj.orderByIdx.add(idx);
}
obj.orderByExp = new ArrayList<ExpressionNode>();
RefResolver resolver = new RefResolver(obj);
for (ExpressionNode exp : orderByExp) {
exp = exp.clone();
exp.select(REF_LOCATOR, resolver);
obj.orderByExp.add(exp);
}
obj.children = new ArrayList<Group>();
for (Group child : children) {
obj.children.add(child.clone());
}
return obj;
}
use of com.yahoo.searchlib.expression.ExpressionNode in project vespa by vespa-engine.
the class Group method executeOrderBy.
private void executeOrderBy() {
for (ExpressionNode node : orderByExp) {
node.prepare();
node.execute();
}
}
use of com.yahoo.searchlib.expression.ExpressionNode in project vespa by vespa-engine.
the class Group method postMerge.
/**
* <p>After merging, this method will prune all levels so that they do not exceed the configured maximum number of
* groups per level.</p>
*
* @param levels The specs of all grouping levels.
* @param firstLevel The first level to merge.
* @param currentLevel The current level.
*/
public void postMerge(List<GroupingLevel> levels, int firstLevel, int currentLevel) {
if (currentLevel >= firstLevel) {
for (AggregationResult result : aggregationResults) {
result.postMerge();
}
for (ExpressionNode result : orderByExp) {
result.execute();
}
}
if (currentLevel < levels.size()) {
int maxGroups = (int) levels.get(currentLevel).getMaxGroups();
for (Group group : children) {
group.executeOrderBy();
}
if (maxGroups >= 0 && children.size() > maxGroups) {
// prune groups
sortChildrenByRank();
children = children.subList(0, maxGroups);
sortChildrenById();
}
for (Group group : children) {
group.postMerge(levels, firstLevel, currentLevel + 1);
}
}
}
use of com.yahoo.searchlib.expression.ExpressionNode in project vespa by vespa-engine.
the class ExpressionConverter method toSubNode.
private MultiArgFunctionNode toSubNode(Iterable<GroupingExpression> lst) {
MultiArgFunctionNode ret = new AddFunctionNode();
int i = 0;
for (GroupingExpression exp : lst) {
ExpressionNode node = toExpressionNode(exp);
if (++i > 1) {
node = new NegateFunctionNode(node);
}
ret.addArg(node);
}
return ret;
}
use of com.yahoo.searchlib.expression.ExpressionNode in project vespa by vespa-engine.
the class Group method onDeserialize.
@Override
protected void onDeserialize(Deserializer buf) {
super.onDeserialize(buf);
id = (ResultNode) deserializeOptional(buf);
rank = buf.getDouble(null);
orderByIdx.clear();
int orderByCount = buf.getInt(null);
for (int i = 0; i < orderByCount; i++) {
orderByIdx.add(buf.getInt(null));
}
int numResults = buf.getInt(null);
for (int i = 0; i < numResults; i++) {
AggregationResult e = (AggregationResult) deserializeOptional(buf);
aggregationResults.add(e);
}
int numExpressionResults = buf.getInt(null);
RefResolver resolver = new RefResolver(this);
for (int i = 0; i < numExpressionResults; i++) {
ExpressionNode exp = (ExpressionNode) deserializeOptional(buf);
exp.select(REF_LOCATOR, resolver);
orderByExp.add(exp);
}
int numGroups = buf.getInt(null);
for (int i = 0; i < numGroups; i++) {
Group g = new Group();
g.deserializeWithId(buf);
children.add(g);
}
tag = buf.getInt(null);
}
Aggregations