Search in sources :

Example 6 with StatementPatternCollector

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.");
    }
}
Also used : StatementPatternCollector(org.openrdf.query.algebra.helpers.StatementPatternCollector) StatementPattern(org.openrdf.query.algebra.StatementPattern) QueryModelNode(org.openrdf.query.algebra.QueryModelNode) HashSet(java.util.HashSet)

Example 7 with StatementPatternCollector

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();
}
Also used : StatementPatternCollector(org.openrdf.query.algebra.helpers.StatementPatternCollector) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser)

Example 8 with StatementPatternCollector

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();
}
Also used : StatementPatternCollector(org.openrdf.query.algebra.helpers.StatementPatternCollector) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser)

Aggregations

StatementPatternCollector (org.openrdf.query.algebra.helpers.StatementPatternCollector)8 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)4 HashSet (java.util.HashSet)2 QueryModelNode (org.openrdf.query.algebra.QueryModelNode)2 StatementPattern (org.openrdf.query.algebra.StatementPattern)2 Property (org.apache.rya.indexing.entity.model.Property)1 EntityQueryNode (org.apache.rya.indexing.entity.query.EntityQueryNode)1 Test (org.junit.Test)1 BindingSet (org.openrdf.query.BindingSet)1 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)1 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)1