Search in sources :

Example 71 with SPARQLParser

use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.

the class QueryVariableNormalizerTest method testSimpleVarGraph.

@Test
public void testSimpleVarGraph() throws Exception {
    SPARQLParser parser1 = new SPARQLParser();
    SPARQLParser parser2 = new SPARQLParser();
    ParsedQuery pq1 = parser1.parseQuery(q22, null);
    ParsedQuery pq2 = parser2.parseQuery(q23, null);
    List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
    Assert.assertTrue(normalize.size() == 1);
    for (TupleExpr s : normalize) {
        Assert.assertTrue(tupleEquals(s, pq1.getTupleExpr()));
    }
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) TupleExpr(org.openrdf.query.algebra.TupleExpr) Test(org.junit.Test)

Example 72 with SPARQLParser

use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.

the class QueryVariableNormalizerTest method tesVarConstantGraph.

@Test
public void tesVarConstantGraph() throws Exception {
    SPARQLParser parser1 = new SPARQLParser();
    SPARQLParser parser2 = new SPARQLParser();
    ParsedQuery pq1 = parser1.parseQuery(q19, null);
    ParsedQuery pq2 = parser2.parseQuery(q20, null);
    List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
    Assert.assertTrue(normalize.size() == 0);
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) TupleExpr(org.openrdf.query.algebra.TupleExpr) Test(org.junit.Test)

Example 73 with SPARQLParser

use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.

the class QueryVariableNormalizerTest method testConstantGraph.

@Test
public void testConstantGraph() throws Exception {
    SPARQLParser parser1 = new SPARQLParser();
    SPARQLParser parser2 = new SPARQLParser();
    ParsedQuery pq1 = parser1.parseQuery(q20, null);
    ParsedQuery pq2 = parser2.parseQuery(q21, null);
    List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
    Assert.assertTrue(normalize.size() == 1);
    for (TupleExpr s : normalize) {
        Assert.assertTrue(tupleEquals(s, pq1.getTupleExpr()));
    }
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) TupleExpr(org.openrdf.query.algebra.TupleExpr) Test(org.junit.Test)

Example 74 with SPARQLParser

use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.

the class QueryVariableNormalizerTest method testLargeNeq.

/**
 * @throws Exception
 *             Tests QueryVariableNormalizerContext on the large query q11
 *             and q6, which have many similar nodes, to see if the correct
 *             number of outputs are produced.
 */
@Test
public void testLargeNeq() throws Exception {
    SPARQLParser parser1 = new SPARQLParser();
    SPARQLParser parser2 = new SPARQLParser();
    ParsedQuery pq1 = parser1.parseQuery(q11, null);
    ParsedQuery pq2 = parser2.parseQuery(q6, null);
    List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
    Assert.assertTrue(normalize.size() == 33);
    for (TupleExpr s : normalize) {
        Assert.assertTrue(isTupleSubset(pq1.getTupleExpr(), s));
    }
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) TupleExpr(org.openrdf.query.algebra.TupleExpr) Test(org.junit.Test)

Example 75 with SPARQLParser

use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.

the class QueryVariableNormalizerTest method testEqThreeDiffVars.

/**
 * @throws Exception
 *             Tests QueryVariableNormalizerContext on the queries q1,q2
 *             which are the same up to a relabeling of variables.
 */
@Test
public void testEqThreeDiffVars() throws Exception {
    SPARQLParser parser1 = new SPARQLParser();
    SPARQLParser parser2 = new SPARQLParser();
    ParsedQuery pq1 = parser1.parseQuery(q1, null);
    ParsedQuery pq2 = parser2.parseQuery(q2, null);
    List<TupleExpr> normalize = QueryVariableNormalizer.getNormalizedIndex(pq1.getTupleExpr(), pq2.getTupleExpr());
    Assert.assertEquals(1, normalize.size());
    for (TupleExpr s : normalize) {
        Assert.assertTrue(tupleEquals(s, pq1.getTupleExpr()));
    }
}
Also used : SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) TupleExpr(org.openrdf.query.algebra.TupleExpr) Test(org.junit.Test)

Aggregations

SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)265 ParsedQuery (org.openrdf.query.parser.ParsedQuery)249 Test (org.junit.Test)212 TupleExpr (org.openrdf.query.algebra.TupleExpr)162 ArrayList (java.util.ArrayList)100 ExternalTupleSet (org.apache.rya.indexing.external.tupleSet.ExternalTupleSet)99 SimpleExternalTupleSet (org.apache.rya.indexing.external.tupleSet.SimpleExternalTupleSet)86 StatementPattern (org.openrdf.query.algebra.StatementPattern)82 QueryModelNode (org.openrdf.query.algebra.QueryModelNode)62 PCJOptimizer (org.apache.rya.indexing.pcj.matching.PCJOptimizer)46 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)45 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)43 RyaURI (org.apache.rya.api.domain.RyaURI)42 BindingSet (org.openrdf.query.BindingSet)41 RyaStatement (org.apache.rya.api.domain.RyaStatement)39 Projection (org.openrdf.query.algebra.Projection)37 RyaType (org.apache.rya.api.domain.RyaType)35 HashSet (java.util.HashSet)27 StatementMetadata (org.apache.rya.api.domain.StatementMetadata)20 LiteralImpl (org.openrdf.model.impl.LiteralImpl)19