use of org.openrdf.query.algebra.helpers.StatementPatternCollector in project incubator-rya by apache.
the class GeneralizedExternalProcessor method getQNodes.
private static Set<QueryModelNode> getQNodes(String node, QueryModelNode queryNode) {
if (node.equals("sp")) {
Set<QueryModelNode> eSet = new HashSet<QueryModelNode>();
StatementPatternCollector spc = new StatementPatternCollector();
queryNode.visit(spc);
List<StatementPattern> spList = spc.getStatementPatterns();
eSet.addAll(spList);
// returns empty set if list contains duplicate StatementPatterns
if (spList.size() > eSet.size()) {
return Sets.newHashSet();
} else {
return eSet;
}
} else if (node.equals("filter")) {
FilterCollector fvis = new FilterCollector();
queryNode.visit(fvis);
return Sets.newHashSet(fvis.getFilters());
} else {
throw new IllegalArgumentException("Invalid node type.");
}
}
use of org.openrdf.query.algebra.helpers.StatementPatternCollector in project incubator-rya by apache.
the class MongoEntityIndex2IT method getSPs.
private static List<StatementPattern> getSPs(final String sparql) throws MalformedQueryException {
final StatementPatternCollector spCollector = new StatementPatternCollector();
new SPARQLParser().parseQuery(sparql, null).getTupleExpr().visit(spCollector);
return spCollector.getStatementPatterns();
}
use of org.openrdf.query.algebra.helpers.StatementPatternCollector in project incubator-rya by apache.
the class EntityQueryNodeIT method getSPs.
/**
* TODO doc
*
* @param sparql
* @return
* @throws MalformedQueryException
*/
private static List<StatementPattern> getSPs(final String sparql) throws MalformedQueryException {
final StatementPatternCollector spCollector = new StatementPatternCollector();
new SPARQLParser().parseQuery(sparql, null).getTupleExpr().visit(spCollector);
return spCollector.getStatementPatterns();
}
Aggregations