use of org.apache.jena.sparql.expr.aggregate.Aggregator in project jena by apache.
the class ApplyTransformVisitor method visit.
@Override
public void visit(OpGroup opGroup) {
boolean changed = false;
VarExprList varExpr = opGroup.getGroupVars();
VarExprList varExpr2 = collect(varExpr);
if (varExpr != varExpr2)
changed = true;
List<ExprAggregator> aggs = opGroup.getAggregators();
List<ExprAggregator> aggs2 = aggs;
// And the aggregators...
aggs2 = new ArrayList<>();
for (ExprAggregator agg : aggs) {
Aggregator aggregator = agg.getAggregator();
Var v = agg.getVar();
// Variable associated with the aggregate
// Not .getExprVar()
Expr eVar = agg.getAggVar();
Expr eVar2 = transform(eVar);
if (eVar != eVar2)
changed = true;
// The Aggregator expression
ExprList e = aggregator.getExprList();
ExprList e2 = e;
if (e != null)
// Null means "no relevant expression" e.g. COUNT(*)
e2 = transform(e);
if (e != e2)
changed = true;
Aggregator a2 = aggregator.copy(e2);
aggs2.add(new ExprAggregator(eVar2.asVar(), a2));
}
OpGroup opGroup2 = opGroup;
if (changed)
opGroup2 = OpGroup.create(opGroup.getSubOp(), varExpr2, aggs2);
visit1(opGroup2);
}
use of org.apache.jena.sparql.expr.aggregate.Aggregator in project jena by apache.
the class ExprAggregator method applyNodeTransform.
@Override
public ExprAggregator applyNodeTransform(NodeTransform transform) {
// Can't rewrite this to a non-variable.
Node node = transform.apply(var);
if (!Var.isVar(node)) {
Log.warn(this, "Attempt to convert an aggregation variable to a non-variable: ignored");
node = var;
}
Var v = (Var) node;
Aggregator agg = aggregator.copyTransform(transform);
return new ExprAggregator(Var.alloc(node), agg);
}
use of org.apache.jena.sparql.expr.aggregate.Aggregator in project jena by apache.
the class ExprAggregator method copySubstitute.
@Override
public ExprAggregator copySubstitute(Binding binding) {
Var v = var;
Aggregator agg = aggregator;
return new ExprAggregator(v, agg);
}
Aggregations