Java Code Examples for org.apache.jena.query.Query#hasAggregators()

The following examples show how to use org.apache.jena.query.Query#hasAggregators() . 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: SelectPlan.java    From sparql-generate with Apache License 2.0 6 votes vote down vote up
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 2
Source File: QueryStatistics.java    From IGUANA with GNU Affero General Public License v3.0 6 votes vote down vote up
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 3
Source File: SelectQueryPartialCopyVisitor.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
@Override
public void visitValues(final Query query) {
    if (query.hasValues() && !query.hasAggregators()) {
        List<Var> variables = query.getValuesVariables();
        List<Binding> values = query.getValuesData();
        output.setValuesDataBlock(variables, values);
        output.addProjectVars(variables);
    }
}
 
Example 4
Source File: SelectExtractionVisitor.java    From sparql-generate with Apache License 2.0 5 votes vote down vote up
@Override
public void visitValues(final Query query) {
    if (query.hasValues() && !query.hasAggregators()) {
    	isDummyQuery = false;
        List<Var> variables = query.getValuesVariables();
        List<Binding> values = query.getValuesData();
        output.setValuesDataBlock(variables, values);
        output.addProjectVars(variables);
    }
}