Java Code Examples for org.apache.jena.query.Query#hasGroupBy()
The following examples show how to use
org.apache.jena.query.Query#hasGroupBy() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryXExprNormalizer.java From sparql-generate with Apache License 2.0 | 6 votes |
@Override public void visitGroupBy(Query query) { if (query.hasGroupBy() && !query.getGroupBy().isEmpty()) { // Can have an empty GROUP BY list if the grouping is implicit // by use of an aggregate in the SELECT clause. final VarExprList namedExprs = query.getGroupBy(); final VarExprList newNamedExprs = new VarExprList(); for (Var var : namedExprs.getVars()) { if (namedExprs.hasExpr(var)) { final Expr nzed = enzer.normalize(namedExprs.getExpr(var)); newNamedExprs.add(var, nzed); } else { newNamedExprs.add(var); } } namedExprs.clear(); namedExprs.addAll(newNamedExprs); } }
Example 2
Source File: SelectQueryPartialCopyVisitor.java From sparql-generate with Apache License 2.0 | 6 votes |
@Override public void visitGroupBy(final Query query) { if (query.hasGroupBy()) { if (!query.getGroupBy().isEmpty()) { VarExprList namedExprs = query.getGroupBy(); for (Var var : namedExprs.getVars()) { Expr expr = namedExprs.getExpr(var); if (expr != null) { output.addGroupBy(var, expr); } else { output.addGroupBy(var.getVarName()); } } } } }
Example 3
Source File: SelectPlan.java From sparql-generate with Apache License 2.0 | 6 votes |
private Query createQuery(final SPARQLExtQuery select, final List<Var> variables, final List<Binding> values, final Context context) { // SPARQLExtQuery q = select.cloneQuery(); Binding binding = !values.isEmpty() ? values.get(0) : null; SelectQueryPartialCopyVisitor cloner = new SelectQueryPartialCopyVisitor(binding, context); select.visit(cloner); Query q = cloner.getOutput(); if (!isSelectType && !q.hasGroupBy() && !q.hasAggregators()) { variables.forEach(v -> { if (!q.getProjectVars().contains(v)) { q.getProject().add(v); } }); } return q; }
Example 4
Source File: SelectExtractionVisitor.java From sparql-generate with Apache License 2.0 | 6 votes |
@Override public void visitGroupBy(final Query query) { if (query.hasGroupBy()) { isDummyQuery = false; if (!query.getGroupBy().isEmpty()) { VarExprList namedExprs = query.getGroupBy(); for (Var var : namedExprs.getVars()) { Expr expr = namedExprs.getExpr(var); if (expr != null) { output.addGroupBy(var, expr); if (!query.isSelectType()) { output.addResultVar(var); } } else { output.addGroupBy(var.getVarName()); if (!query.isSelectType()) { output.addResultVar(var); } } } } } }
Example 5
Source File: QueryStatistics.java From IGUANA with GNU Affero General Public License v3.0 | 6 votes |
public void getStatistics(Query q) { if(q.isSelectType()) { size++; offset+=q.hasOffset()?1:0; aggr+=q.hasAggregators()?1:0; groupBy+=q.hasGroupBy()?1:0; having+=q.hasHaving()?1:0; orderBy+=q.hasOrderBy()?1:0; StatisticsVisitor visitor = new StatisticsVisitor(); visitor.setElementWhere(q.getQueryPattern()); ElementWalker.walk(q.getQueryPattern(), visitor); union+=visitor.union?1:0; optional+=visitor.optional?1:0; filter+=visitor.filter?1:0; triples += visitor.bgps; } }
Example 6
Source File: SPARQLExtQuerySerializer.java From sparql-generate with Apache License 2.0 | 5 votes |
@Override public void visitGroupBy(Query query) { if (query.hasGroupBy()) { // Can have an empty GROUP BY list if the groupin gis implicit // by use of an aggregate in the SELECT clause. if (!query.getGroupBy().isEmpty()) { out.print("GROUP BY "); appendNamedExprList(query, out, query.getGroupBy()); out.println(); } } }