RYA-11 fixing compile errors commit
Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/358c13b8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/358c13b8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/358c13b8 Branch: refs/heads/develop Commit: 358c13b83dc04887f95afee1c326971602d31647 Parents: efcae82 Author: pujav65 <puja...@gmail.com> Authored: Mon Mar 14 10:55:31 2016 -0400 Committer: Aaron Mihalik <miha...@alum.mit.edu> Committed: Mon Mar 14 14:56:35 2016 -0400 ---------------------------------------------------------------------- .../AccumuloConstantPcjIntegrationTest.java | 3 +- .../external/AccumuloIndexSetTest2.java | 804 ------------------- .../external/AccumuloPcjIntegrationTest.java | 3 +- .../external/PcjIntegrationTestingUtil.java | 5 +- .../PrecompJoinOptimizerIntegrationTest.java | 499 +----------- .../external/tupleSet/AccumuloIndexSetTest.java | 3 +- .../src/main/java/MongoRyaDirectExample.java | 15 +- .../src/main/java/RyaDirectExample.java | 23 +- 8 files changed, 37 insertions(+), 1318 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/358c13b8/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloConstantPcjIntegrationTest.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloConstantPcjIntegrationTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloConstantPcjIntegrationTest.java index bd84bf5..491c39d 100644 --- a/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloConstantPcjIntegrationTest.java +++ b/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloConstantPcjIntegrationTest.java @@ -24,6 +24,7 @@ import java.util.List; import mvm.rya.api.persist.RyaDAOException; import mvm.rya.indexing.external.tupleSet.PcjTables.PcjException; import mvm.rya.indexing.external.tupleSet.PcjTables.PcjVarOrderFactory; +import mvm.rya.rdftriplestore.inference.InferenceEngineException; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -69,7 +70,7 @@ public class AccumuloConstantPcjIntegrationTest { TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, AccumuloException, AccumuloSecurityException, TableExistsException, - TableNotFoundException, RyaDAOException { + TableNotFoundException, RyaDAOException, InferenceEngineException { repo = PcjIntegrationTestingUtil.getNonPcjRepo(prefix, "instance"); conn = repo.getConnection(); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/358c13b8/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloIndexSetTest2.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloIndexSetTest2.java b/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloIndexSetTest2.java deleted file mode 100644 index 54beecd..0000000 --- a/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloIndexSetTest2.java +++ /dev/null @@ -1,804 +0,0 @@ -package mvm.rya.indexing.external; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -import java.util.Arrays; -import java.util.List; - -import junit.framework.Assert; -import mvm.rya.accumulo.AccumuloRdfConfiguration; -import mvm.rya.api.persist.RyaDAOException; -import mvm.rya.indexing.RyaSailFactory; -import mvm.rya.indexing.accumulo.ConfigUtils; -import mvm.rya.indexing.external.tupleSet.AccumuloIndexSet; -import mvm.rya.rdftriplestore.inference.InferenceEngineException; - -import org.apache.accumulo.core.client.AccumuloException; -import org.apache.accumulo.core.client.AccumuloSecurityException; -import org.apache.accumulo.core.client.Connector; -import org.apache.accumulo.core.client.MutationsRejectedException; -import org.apache.accumulo.core.client.TableExistsException; -import org.apache.accumulo.core.client.TableNotFoundException; -import org.apache.accumulo.core.client.mock.MockInstance; -import org.apache.accumulo.core.client.security.tokens.PasswordToken; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openrdf.model.URI; -import org.openrdf.model.impl.LiteralImpl; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.model.vocabulary.RDF; -import org.openrdf.model.vocabulary.RDFS; -import org.openrdf.query.BindingSet; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.QueryLanguage; -import org.openrdf.query.QueryResultHandlerException; -import org.openrdf.query.TupleQueryResultHandler; -import org.openrdf.query.TupleQueryResultHandlerException; -import org.openrdf.repository.RepositoryException; -import org.openrdf.repository.sail.SailRepository; -import org.openrdf.repository.sail.SailRepositoryConnection; -import org.openrdf.sail.Sail; -import org.openrdf.sail.SailException; - -public class AccumuloIndexSetTest2 { - - private SailRepositoryConnection conn; - private SailRepository repo; - private Connector accCon; - String tablePrefix = "table_"; - AccumuloRdfConfiguration conf; - URI sub, sub2, obj, obj2, subclass, subclass2, talksTo; - - @Before - public void init() throws RepositoryException, TupleQueryResultHandlerException, QueryEvaluationException, - MalformedQueryException, AccumuloException, AccumuloSecurityException, TableExistsException, - RyaDAOException, InferenceEngineException { - - conf = new AccumuloRdfConfiguration(); - conf.set(ConfigUtils.USE_PCJ, "true"); - conf.set(ConfigUtils.USE_MOCK_INSTANCE, "true"); - conf.set(ConfigUtils.CLOUDBASE_INSTANCE, "instance"); - conf.setTablePrefix(tablePrefix); - conf.setPcjTables(Arrays.asList("table1", "table2")); - - Sail sail = RyaSailFactory.getInstance(conf); - repo = new SailRepository(sail); - repo.initialize(); - conn = repo.getConnection(); - - sub = new URIImpl("uri:entity"); - subclass = new URIImpl("uri:class"); - obj = new URIImpl("uri:obj"); - talksTo = new URIImpl("uri:talksTo"); - - conn.add(sub, RDF.TYPE, subclass); - conn.add(sub, RDFS.LABEL, new LiteralImpl("label")); - conn.add(sub, talksTo, obj); - - sub2 = new URIImpl("uri:entity2"); - subclass2 = new URIImpl("uri:class2"); - obj2 = new URIImpl("uri:obj2"); - - conn.add(sub2, RDF.TYPE, subclass2); - conn.add(sub2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(sub2, talksTo, obj2); - - accCon = new MockInstance("instance").getConnector("root", new PasswordToken("".getBytes())); - accCon.tableOperations().create("table1"); - accCon.tableOperations().create("table2"); - - } - - @After - public void close() throws RepositoryException, AccumuloException, AccumuloSecurityException, - TableNotFoundException { - - conf = null; - conn.close(); - accCon.tableOperations().delete(tablePrefix + "spo"); - accCon.tableOperations().delete(tablePrefix + "po"); - accCon.tableOperations().delete(tablePrefix + "osp"); - - if (accCon.tableOperations().exists("table1")) { - accCon.tableOperations().delete("table1"); - } - - if (accCon.tableOperations().exists("table2")) { - accCon.tableOperations().delete("table2"); - } - - } - - @Test - public void testEvaluateTwoIndexTwoVarOrder2() throws RepositoryException, MalformedQueryException, SailException, - QueryEvaluationException, MutationsRejectedException, TableNotFoundException, - TupleQueryResultHandlerException { - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - String indexSparqlString = ""// - + "SELECT ?c ?e ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?e ?o ?l " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(2, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexTwoVarInvalidOrder() throws RepositoryException, MalformedQueryException, - SailException, QueryEvaluationException, MutationsRejectedException, TableNotFoundException, - TupleQueryResultHandlerException { - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - String indexSparqlString = ""// - + "SELECT ?e ?c ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?e ?o ?l " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(2, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexThreeVarOrder1() throws MalformedQueryException, SailException, - QueryEvaluationException, MutationsRejectedException, TableNotFoundException, RepositoryException, - TupleQueryResultHandlerException { - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - String indexSparqlString = ""// - + "SELECT ?c ?e ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?e ?c ?l ?f ?o" // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(2, crh.getCount()); - - } - - // @Test - public void testEvaluateTwoIndexThreeVarsDiffLabel() throws RepositoryException, MalformedQueryException, - SailException, QueryEvaluationException, MutationsRejectedException, TableNotFoundException, - TupleQueryResultHandlerException { - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - // TODO Auto-generated method stub - String indexSparqlString = ""// - + "SELECT ?dog ?pig ?owl " // - + "{" // - + " ?pig a ?dog . "// - + " ?pig <http://www.w3.org/2000/01/rdf-schema#label> ?owl "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?e ?c ?l ?f ?o" // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(2, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexThreeVarOrder2() throws RepositoryException, MalformedQueryException, - SailException, QueryEvaluationException, MutationsRejectedException, TableNotFoundException, - TupleQueryResultHandlerException { - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - // TODO Auto-generated method stub - String indexSparqlString = ""// - + "SELECT ?c ?e ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?o ?f ?e ?c ?l " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(2, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexThreeVarOrder3ThreeBindingSet() throws TupleQueryResultHandlerException, - QueryEvaluationException, MalformedQueryException, RepositoryException, SailException, - MutationsRejectedException, TableNotFoundException { - - URI sub3 = new URIImpl("uri:entity3"); - URI subclass3 = new URIImpl("uri:class3"); - URI obj3 = new URIImpl("uri:obj3"); - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - URI superclass3 = new URIImpl("uri:superclass3"); - - conn.add(sub3, RDF.TYPE, subclass3); - conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3")); - conn.add(sub3, talksTo, obj3); - - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(subclass3, RDF.TYPE, superclass3); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(obj3, RDFS.LABEL, new LiteralImpl("label3")); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - String indexSparqlString = ""// - + "SELECT ?c ?e ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?o ?f ?l ?e ?c " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(3, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexThreeVarOrder5ThreeBindingSet() throws MalformedQueryException, SailException, - QueryEvaluationException, MutationsRejectedException, TableNotFoundException, RepositoryException, - TupleQueryResultHandlerException { - - URI sub3 = new URIImpl("uri:entity3"); - URI subclass3 = new URIImpl("uri:class3"); - URI obj3 = new URIImpl("uri:obj3"); - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - URI superclass3 = new URIImpl("uri:superclass3"); - - conn.add(sub3, RDF.TYPE, subclass3); - conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3")); - conn.add(sub3, talksTo, obj3); - - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(subclass3, RDF.TYPE, superclass3); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(obj3, RDFS.LABEL, new LiteralImpl("label3")); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - // TODO Auto-generated method stub - String indexSparqlString = ""// - + "SELECT ?c ?e ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?o ?f ?e ?l ?c " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(3, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexThreeVarOrder4ThreeBindingSet() throws MalformedQueryException, SailException, - QueryEvaluationException, MutationsRejectedException, TableNotFoundException, RepositoryException, - TupleQueryResultHandlerException { - - URI sub3 = new URIImpl("uri:entity3"); - URI subclass3 = new URIImpl("uri:class3"); - URI obj3 = new URIImpl("uri:obj3"); - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - URI superclass3 = new URIImpl("uri:superclass3"); - - conn.add(sub3, RDF.TYPE, subclass3); - conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3")); - conn.add(sub3, talksTo, obj3); - - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(subclass3, RDF.TYPE, superclass3); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(obj3, RDFS.LABEL, new LiteralImpl("label3")); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - // TODO Auto-generated method stub - String indexSparqlString = ""// - + "SELECT ?c ?e ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?o ?f ?c ?e ?l " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(3, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexThreeVarOrder6ThreeBindingSet() throws MalformedQueryException, SailException, - QueryEvaluationException, MutationsRejectedException, TableNotFoundException, RepositoryException, - TupleQueryResultHandlerException { - - URI sub3 = new URIImpl("uri:entity3"); - URI subclass3 = new URIImpl("uri:class3"); - URI obj3 = new URIImpl("uri:obj3"); - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - URI superclass3 = new URIImpl("uri:superclass3"); - - conn.add(sub3, RDF.TYPE, subclass3); - conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3")); - conn.add(sub3, talksTo, obj3); - - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(subclass3, RDF.TYPE, superclass3); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(obj3, RDFS.LABEL, new LiteralImpl("label3")); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - String indexSparqlString = ""// - + "SELECT ?c ?e ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?c ?l ?e ?o ?f " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(3, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexThreeVarOrder7ThreeBindingSet() throws MalformedQueryException, SailException, - QueryEvaluationException, MutationsRejectedException, TableNotFoundException, RepositoryException, - TupleQueryResultHandlerException { - - URI sub3 = new URIImpl("uri:entity3"); - URI subclass3 = new URIImpl("uri:class3"); - URI obj3 = new URIImpl("uri:obj3"); - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - URI superclass3 = new URIImpl("uri:superclass3"); - - conn.add(sub3, RDF.TYPE, subclass3); - conn.add(sub3, RDFS.LABEL, new LiteralImpl("label3")); - conn.add(sub3, talksTo, obj3); - - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(subclass3, RDF.TYPE, superclass3); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(obj3, RDFS.LABEL, new LiteralImpl("label3")); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - String indexSparqlString = ""// - + "SELECT ?c ?e ?l " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?o ?l ?c ?e ?f " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(3, crh.getCount()); - - } - - @Test - public void testEvaluateOneIndex() throws RepositoryException, MalformedQueryException, SailException, - QueryEvaluationException, MutationsRejectedException, TableNotFoundException, - TupleQueryResultHandlerException { - - String indexSparqlString = ""// - + "SELECT ?dog ?pig ?duck " // - + "{" // - + " ?pig a ?dog . "// - + " ?pig <http://www.w3.org/2000/01/rdf-schema#label> ?duck "// - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, indexSparqlString).evaluate(crh); - - Assert.assertEquals(2, crh.getCount()); - - } - - @Test - public void testEvaluateTwoIndexThreeVarOrder3() throws RepositoryException, MalformedQueryException, - SailException, QueryEvaluationException, MutationsRejectedException, TableNotFoundException, - TupleQueryResultHandlerException { - - URI superclass = new URIImpl("uri:superclass"); - URI superclass2 = new URIImpl("uri:superclass2"); - - conn.add(subclass, RDF.TYPE, superclass); - conn.add(subclass2, RDF.TYPE, superclass2); - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - String indexSparqlString = ""// - + "SELECT ?dog ?pig ?duck " // - + "{" // - + " ?pig a ?dog . "// - + " ?pig <http://www.w3.org/2000/01/rdf-schema#label> ?duck "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?o ?f ?e ?c ?l " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?f ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l. "// - + " ?c a ?f . " // - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, "table1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, "table2"); - - CountingResultHandler crh = new CountingResultHandler(); - - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(2, crh.getCount()); - - } - - public static class CountingResultHandler implements TupleQueryResultHandler { - private int count = 0; - - public int getCount() { - return count; - } - - public void resetCount() { - this.count = 0; - } - - @Override - public void startQueryResult(List<String> arg0) throws TupleQueryResultHandlerException { - } - - @Override - public void handleSolution(BindingSet arg0) throws TupleQueryResultHandlerException { - count++; - } - - @Override - public void endQueryResult() throws TupleQueryResultHandlerException { - } - - @Override - public void handleBoolean(boolean arg0) throws QueryResultHandlerException { - // TODO Auto-generated method stub - - } - - @Override - public void handleLinks(List<String> arg0) throws QueryResultHandlerException { - // TODO Auto-generated method stub - - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/358c13b8/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloPcjIntegrationTest.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloPcjIntegrationTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloPcjIntegrationTest.java index a18be2f..a13bea9 100644 --- a/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloPcjIntegrationTest.java +++ b/extras/indexing/src/test/java/mvm/rya/indexing/external/AccumuloPcjIntegrationTest.java @@ -30,6 +30,7 @@ import mvm.rya.indexing.external.tupleSet.AccumuloIndexSet; import mvm.rya.indexing.external.tupleSet.ExternalTupleSet; import mvm.rya.indexing.external.tupleSet.PcjTables.PcjException; import mvm.rya.indexing.external.tupleSet.PcjTables.PcjVarOrderFactory; +import mvm.rya.rdftriplestore.inference.InferenceEngineException; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -82,7 +83,7 @@ public class AccumuloPcjIntegrationTest { TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, - TableNotFoundException { + TableNotFoundException, InferenceEngineException { repo = PcjIntegrationTestingUtil.getNonPcjRepo(prefix, "instance"); conn = repo.getConnection(); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/358c13b8/extras/indexing/src/test/java/mvm/rya/indexing/external/PcjIntegrationTestingUtil.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/external/PcjIntegrationTestingUtil.java b/extras/indexing/src/test/java/mvm/rya/indexing/external/PcjIntegrationTestingUtil.java index d065afb..42e8b09 100644 --- a/extras/indexing/src/test/java/mvm/rya/indexing/external/PcjIntegrationTestingUtil.java +++ b/extras/indexing/src/test/java/mvm/rya/indexing/external/PcjIntegrationTestingUtil.java @@ -38,6 +38,7 @@ import mvm.rya.indexing.external.tupleSet.PcjTables.PcjMetadata; import mvm.rya.indexing.external.tupleSet.PcjTables.PcjVarOrderFactory; import mvm.rya.indexing.external.tupleSet.PcjTables.ShiftVarOrderFactory; import mvm.rya.indexing.external.tupleSet.PcjTables.VariableOrder; +import mvm.rya.rdftriplestore.inference.InferenceEngineException; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -92,7 +93,7 @@ public class PcjIntegrationTestingUtil { public static SailRepository getPcjRepo(String tablePrefix, String instance) throws AccumuloException, AccumuloSecurityException, - RyaDAOException, RepositoryException { + RyaDAOException, RepositoryException, InferenceEngineException { final AccumuloRdfConfiguration pcjConf = new AccumuloRdfConfiguration(); pcjConf.set(ConfigUtils.USE_PCJ, "true"); @@ -108,7 +109,7 @@ public class PcjIntegrationTestingUtil { public static SailRepository getNonPcjRepo(String tablePrefix, String instance) throws AccumuloException, - AccumuloSecurityException, RyaDAOException, RepositoryException { + AccumuloSecurityException, RyaDAOException, RepositoryException, InferenceEngineException { final AccumuloRdfConfiguration nonPcjConf = new AccumuloRdfConfiguration(); nonPcjConf.set(ConfigUtils.USE_MOCK_INSTANCE, "true"); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/358c13b8/extras/indexing/src/test/java/mvm/rya/indexing/external/PrecompJoinOptimizerIntegrationTest.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/external/PrecompJoinOptimizerIntegrationTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/external/PrecompJoinOptimizerIntegrationTest.java index dff310a..324dac5 100644 --- a/extras/indexing/src/test/java/mvm/rya/indexing/external/PrecompJoinOptimizerIntegrationTest.java +++ b/extras/indexing/src/test/java/mvm/rya/indexing/external/PrecompJoinOptimizerIntegrationTest.java @@ -22,15 +22,9 @@ package mvm.rya.indexing.external; import java.util.List; import mvm.rya.api.persist.RyaDAOException; -<<<<<<< HEAD import mvm.rya.indexing.external.tupleSet.PcjTables.PcjException; import mvm.rya.indexing.external.tupleSet.PcjTables.PcjVarOrderFactory; -======= -import mvm.rya.indexing.RyaSailFactory; -import mvm.rya.indexing.accumulo.ConfigUtils; -import mvm.rya.indexing.external.tupleSet.AccumuloIndexSet; import mvm.rya.rdftriplestore.inference.InferenceEngineException; ->>>>>>> RYA-34 fixing inference with mongo db import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -75,7 +69,7 @@ public class PrecompJoinOptimizerIntegrationTest { TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, - TableNotFoundException { + TableNotFoundException, InferenceEngineException { repo = PcjIntegrationTestingUtil.getNonPcjRepo(tablePrefix, "instance"); conn = repo.getConnection(); @@ -121,7 +115,7 @@ public class PrecompJoinOptimizerIntegrationTest { throws TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, - SailException, TableNotFoundException, PcjException { + SailException, TableNotFoundException, PcjException, InferenceEngineException { final String indexSparqlString = ""// + "SELECT ?e ?l ?c " // @@ -207,7 +201,7 @@ public class PrecompJoinOptimizerIntegrationTest { throws TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, - SailException, TableNotFoundException, PcjException { + SailException, TableNotFoundException, PcjException, InferenceEngineException { final String indexSparqlString = ""// + "SELECT ?e ?l ?c " // @@ -248,7 +242,7 @@ public class PrecompJoinOptimizerIntegrationTest { throws TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, - SailException, TableNotFoundException, PcjException { + SailException, TableNotFoundException, PcjException, InferenceEngineException { final String indexSparqlString2 = ""// + "SELECT ?e ?l ?c " // @@ -290,7 +284,7 @@ public class PrecompJoinOptimizerIntegrationTest { throws TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, RepositoryException, AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, - SailException, TableNotFoundException, PcjException { + SailException, TableNotFoundException, PcjException, InferenceEngineException { final String indexSparqlString1 = ""// + "SELECT ?e ?l ?c " // @@ -336,7 +330,7 @@ public class PrecompJoinOptimizerIntegrationTest { AccumuloSecurityException, TableExistsException, RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, TableNotFoundException, - TupleQueryResultHandlerException, RyaDAOException, PcjException { + TupleQueryResultHandlerException, RyaDAOException, PcjException, InferenceEngineException { conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); @@ -394,7 +388,7 @@ public class PrecompJoinOptimizerIntegrationTest { throws AccumuloException, AccumuloSecurityException, TableExistsException, RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, TableNotFoundException, - TupleQueryResultHandlerException, RyaDAOException, PcjException { + TupleQueryResultHandlerException, RyaDAOException, PcjException, InferenceEngineException { conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); @@ -499,481 +493,4 @@ public class PrecompJoinOptimizerIntegrationTest { } } -======= - private SailRepositoryConnection conn; - private SailRepository repo; - private Connector accCon; - String tablePrefix = "table_"; - AccumuloRdfConfiguration conf; - URI sub, sub2, obj,obj2,subclass, subclass2, talksTo; - - - - - @Before - public void init() throws RepositoryException, TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, - AccumuloException, AccumuloSecurityException, TableExistsException, RyaDAOException, InferenceEngineException { - - conf = new AccumuloRdfConfiguration(); - conf.set(ConfigUtils.USE_PCJ, "true"); - conf.set(ConfigUtils.USE_MOCK_INSTANCE,"true"); - conf.set(ConfigUtils.CLOUDBASE_INSTANCE, "instance"); - conf.setTablePrefix(tablePrefix); - - Sail sail = RyaSailFactory.getInstance(conf); - repo = new SailRepository(sail); - repo.initialize(); - conn = repo.getConnection(); - - sub = new URIImpl("uri:entity"); - subclass = new URIImpl("uri:class"); - obj = new URIImpl("uri:obj"); - talksTo = new URIImpl("uri:talksTo"); - - conn.add(sub, RDF.TYPE, subclass); - conn.add(sub, RDFS.LABEL, new LiteralImpl("label")); - conn.add(sub, talksTo, obj); - - sub2 = new URIImpl("uri:entity2"); - subclass2 = new URIImpl("uri:class2"); - obj2 = new URIImpl("uri:obj2"); - - conn.add(sub2, RDF.TYPE, subclass2); - conn.add(sub2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(sub2, talksTo, obj2); - - accCon = new MockInstance("instance").getConnector("root",new PasswordToken("".getBytes())); - - } - - - @After - public void close() throws RepositoryException, AccumuloException, AccumuloSecurityException, TableNotFoundException { - - conf = null; - conn.close(); - accCon.tableOperations().delete(tablePrefix + "spo"); - accCon.tableOperations().delete(tablePrefix + "po"); - accCon.tableOperations().delete(tablePrefix + "osp"); - } - - - - @Test - public void testEvaluateSingeIndex() throws TupleQueryResultHandlerException, QueryEvaluationException, - MalformedQueryException, RepositoryException, AccumuloException, - AccumuloSecurityException, TableExistsException, RyaDAOException, SailException, TableNotFoundException { - - if (accCon.tableOperations().exists(tablePrefix + "INDEX1")) { - accCon.tableOperations().delete(tablePrefix + "INDEX1"); - } - accCon.tableOperations().create(tablePrefix + "INDEX1"); - - String indexSparqlString = ""// - + "SELECT ?e ?l ?c " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - AccumuloIndexSet ais = new AccumuloIndexSet(indexSparqlString, conn, accCon, tablePrefix + "INDEX1"); - - - String queryString = ""// - + "SELECT ?e ?c ?l ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "// - + " ?e <uri:talksTo> ?o . "// - + "}";// - - CountingResultHandler crh = new CountingResultHandler(); - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - -// Scanner scan = accCon.createScanner(tablePrefix + "spo", new Authorizations("U")); -// -// for(Entry<Key,Value> e: scan) { -// System.out.println(e.getKey().getRow()); -// } - - Assert.assertEquals(2, crh.getCount()); - - - } - - - - - - - @Test - public void testEvaluateTwoIndexTwoVarOrder1() throws AccumuloException, AccumuloSecurityException, - TableExistsException, RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, - TableNotFoundException, TupleQueryResultHandlerException, RyaDAOException { - - if (accCon.tableOperations().exists(tablePrefix + "INDEX1")) { - accCon.tableOperations().delete(tablePrefix + "INDEX1"); - } - - if (accCon.tableOperations().exists(tablePrefix + "INDEX2")) { - accCon.tableOperations().delete(tablePrefix + "INDEX2"); - } - - accCon.tableOperations().create(tablePrefix + "INDEX1"); - accCon.tableOperations().create(tablePrefix + "INDEX2"); - - - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - - - String indexSparqlString = ""// - + "SELECT ?e ?l ?c " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?e ?o ?l " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String queryString = ""// - + "SELECT ?e ?c ?l ?o " // - + "{" // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "// - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, tablePrefix + "INDEX1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, tablePrefix + "INDEX2"); - - CountingResultHandler crh = new CountingResultHandler(); - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(2, crh.getCount()); - - - - - } - - - @Test - public void testEvaluateSingeFilterIndex() throws TupleQueryResultHandlerException, QueryEvaluationException, - MalformedQueryException, RepositoryException, AccumuloException, - AccumuloSecurityException, TableExistsException, RyaDAOException, SailException, TableNotFoundException { - - if (accCon.tableOperations().exists(tablePrefix + "INDEX1")) { - accCon.tableOperations().delete(tablePrefix + "INDEX1"); - } - accCon.tableOperations().create(tablePrefix + "INDEX1"); - - String indexSparqlString = ""// - + "SELECT ?e ?l ?c " // - + "{" // - + " Filter(?e = <uri:entity>) " // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - AccumuloIndexSet ais = new AccumuloIndexSet(indexSparqlString, conn, accCon, tablePrefix + "INDEX1"); - - - String queryString = ""// - + "SELECT ?e ?c ?l ?o " // - + "{" // - + " Filter(?e = <uri:entity>) " // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "// - + " ?e <uri:talksTo> ?o . "// - + "}";// - - CountingResultHandler crh = new CountingResultHandler(); - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(1, crh.getCount()); - - - } - - - - - @Test - public void testEvaluateSingeFilterWithUnion() throws TupleQueryResultHandlerException, QueryEvaluationException, - MalformedQueryException, RepositoryException, AccumuloException, - AccumuloSecurityException, TableExistsException, RyaDAOException, SailException, TableNotFoundException { - - if (accCon.tableOperations().exists(tablePrefix + "INDEX2")) { - accCon.tableOperations().delete(tablePrefix + "INDEX2"); - } - accCon.tableOperations().create(tablePrefix + "INDEX2"); - - String indexSparqlString2 = ""// - + "SELECT ?e ?l ?c " // - + "{" // - + " Filter(?l = \"label2\") " // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, tablePrefix + "INDEX2"); - - - String queryString = ""// - + "SELECT ?e ?c ?o ?m ?l" // - + "{" // - + " Filter(?l = \"label2\") " // - + " ?e <uri:talksTo> ?o . "// - + " { ?e a ?c . ?e <http://www.w3.org/2000/01/rdf-schema#label> ?m }"// - + " UNION { ?e a ?c . ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l }"// - + "}";// - - CountingResultHandler crh = new CountingResultHandler(); - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(1, crh.getCount()); - - - } - - - - @Test - public void testEvaluateSingeFilterWithLeftJoin() throws TupleQueryResultHandlerException, QueryEvaluationException, - MalformedQueryException, RepositoryException, AccumuloException, - AccumuloSecurityException, TableExistsException, RyaDAOException, SailException, TableNotFoundException { - - if (accCon.tableOperations().exists(tablePrefix + "INDEX1")) { - accCon.tableOperations().delete(tablePrefix + "INDEX1"); - } - accCon.tableOperations().create(tablePrefix + "INDEX1"); - - String indexSparqlString1 = ""// - + "SELECT ?e ?l ?c " // - + "{" // - + " Filter(?l = \"label3\") " // - + " ?e a ?c . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - - URI sub3 = new URIImpl("uri:entity3"); - URI subclass3 = new URIImpl("uri:class3"); - conn.add(sub3, RDF.TYPE, subclass3); - conn.add(sub3,RDFS.LABEL, new LiteralImpl("label3")); - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString1, conn, accCon, tablePrefix + "INDEX1"); - - String queryString = ""// - + "SELECT ?e ?c ?o ?m ?l" // - + "{" // - + " Filter(?l = \"label3\") " // - + " ?e a ?c . " // - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . " // - + " OPTIONAL { ?e <uri:talksTo> ?o . ?e <http://www.w3.org/2000/01/rdf-schema#label> ?m }"// - + "}";// - - CountingResultHandler crh = new CountingResultHandler(); - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(1, crh.getCount()); - - - } - - - - - - - - @Test - public void testEvaluateTwoIndexUnionFilter() throws AccumuloException, AccumuloSecurityException, - TableExistsException, RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, - TableNotFoundException, TupleQueryResultHandlerException, RyaDAOException { - - if (accCon.tableOperations().exists(tablePrefix + "INDEX1")) { - accCon.tableOperations().delete(tablePrefix + "INDEX1"); - } - - if (accCon.tableOperations().exists(tablePrefix + "INDEX2")) { - accCon.tableOperations().delete(tablePrefix + "INDEX2"); - } - - accCon.tableOperations().create(tablePrefix + "INDEX1"); - accCon.tableOperations().create(tablePrefix + "INDEX2"); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(sub, RDF.TYPE, obj); - conn.add(sub2, RDF.TYPE, obj2); - - - String indexSparqlString = ""// - + "SELECT ?e ?l ?o " // - + "{" // - + " Filter(?l = \"label2\") " // - + " ?e a ?o . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?e ?l ?o " // - + "{" // - + " Filter(?l = \"label2\") " // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String queryString = ""// - + "SELECT ?c ?e ?l ?o " // - + "{" // - + " Filter(?l = \"label2\") " // - + " ?e a ?c . "// - + " { ?e a ?o . ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l }"// - + " UNION { ?e <uri:talksTo> ?o . ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l }"// - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, tablePrefix + "INDEX1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, tablePrefix + "INDEX2"); - - CountingResultHandler crh = new CountingResultHandler(); - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - - Assert.assertEquals(6, crh.getCount()); - - - - } - - - - - - @Test - public void testEvaluateTwoIndexLeftJoinUnionFilter() throws AccumuloException, AccumuloSecurityException, - TableExistsException, RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, - TableNotFoundException, TupleQueryResultHandlerException, RyaDAOException { - - if (accCon.tableOperations().exists(tablePrefix + "INDEX1")) { - accCon.tableOperations().delete(tablePrefix + "INDEX1"); - } - - if (accCon.tableOperations().exists(tablePrefix + "INDEX2")) { - accCon.tableOperations().delete(tablePrefix + "INDEX2"); - } - - accCon.tableOperations().create(tablePrefix + "INDEX1"); - accCon.tableOperations().create(tablePrefix + "INDEX2"); - - conn.add(obj, RDFS.LABEL, new LiteralImpl("label")); - conn.add(obj2, RDFS.LABEL, new LiteralImpl("label2")); - conn.add(sub, RDF.TYPE, obj); - conn.add(sub2, RDF.TYPE, obj2); - - URI livesIn = new URIImpl("uri:livesIn"); - URI city = new URIImpl("uri:city"); - URI city2 = new URIImpl("uri:city2"); - URI city3 = new URIImpl("uri:city3"); - conn.add(sub,livesIn,city); - conn.add(sub2,livesIn,city2); - conn.add(sub2,livesIn,city3); - conn.add(sub,livesIn,city3); - - - String indexSparqlString = ""// - + "SELECT ?e ?l ?o " // - + "{" // - + " ?e a ?o . "// - + " ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String indexSparqlString2 = ""// - + "SELECT ?e ?l ?o " // - + "{" // - + " ?e <uri:talksTo> ?o . "// - + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "// - + "}";// - - String queryString = ""// - + "SELECT ?c ?e ?l ?o " // - + "{" // - + " Filter(?c = <uri:city3>) " // - + " ?e <uri:livesIn> ?c . "// - + " OPTIONAL{{ ?e a ?o . ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l }"// - + " UNION { ?e <uri:talksTo> ?o . ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l }}"// - + "}";// - - AccumuloIndexSet ais1 = new AccumuloIndexSet(indexSparqlString, conn, accCon, tablePrefix + "INDEX1"); - AccumuloIndexSet ais2 = new AccumuloIndexSet(indexSparqlString2, conn, accCon, tablePrefix + "INDEX2"); - - CountingResultHandler crh = new CountingResultHandler(); - conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString).evaluate(crh); - -// Scanner scan = accCon.createScanner(tablePrefix + "spo", new Authorizations("U")); -// -// for(Entry<Key,Value> e: scan) { -// System.out.println(e.getKey().getRow()); -// } - - Assert.assertEquals(6, crh.getCount()); - - - - } - - - - - public static class CountingResultHandler implements TupleQueryResultHandler { - private int count = 0; - - public int getCount() { - return count; - } - - public void resetCount() { - this.count = 0; - } - - @Override - public void startQueryResult(List<String> arg0) throws TupleQueryResultHandlerException { - } - - - @Override - public void handleSolution(BindingSet arg0) throws TupleQueryResultHandlerException { - System.out.println(arg0); - count++; - System.out.println("Count is " + count); - } - - @Override - public void endQueryResult() throws TupleQueryResultHandlerException { - } - - @Override - public void handleBoolean(boolean arg0) throws QueryResultHandlerException { - // TODO Auto-generated method stub - - } - - @Override - public void handleLinks(List<String> arg0) throws QueryResultHandlerException { - // TODO Auto-generated method stub - - } - } - - - - - -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/358c13b8/extras/indexing/src/test/java/mvm/rya/indexing/external/tupleSet/AccumuloIndexSetTest.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/external/tupleSet/AccumuloIndexSetTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/external/tupleSet/AccumuloIndexSetTest.java index 37cca41..c400f03 100644 --- a/extras/indexing/src/test/java/mvm/rya/indexing/external/tupleSet/AccumuloIndexSetTest.java +++ b/extras/indexing/src/test/java/mvm/rya/indexing/external/tupleSet/AccumuloIndexSetTest.java @@ -38,6 +38,7 @@ import mvm.rya.indexing.external.tupleSet.PcjTables.PcjException; import mvm.rya.indexing.external.tupleSet.PcjTables.PcjTableNameFactory; import mvm.rya.indexing.external.tupleSet.PcjTables.PcjVarOrderFactory; import mvm.rya.rdftriplestore.RyaSailRepository; +import mvm.rya.rdftriplestore.inference.InferenceEngineException; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -80,7 +81,7 @@ public class AccumuloIndexSetTest { protected String prefix = "rya_"; @Before - public void init() throws AccumuloException, AccumuloSecurityException, RyaDAOException, RepositoryException, TableNotFoundException { + public void init() throws AccumuloException, AccumuloSecurityException, RyaDAOException, RepositoryException, TableNotFoundException, InferenceEngineException { accumuloConn = ConfigUtils.getConnector(conf); final TableOperations ops = accumuloConn.tableOperations(); if(ops.exists(prefix+"INDEX_"+ "testPcj")) { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/358c13b8/extras/indexingExample/src/main/java/MongoRyaDirectExample.java ---------------------------------------------------------------------- diff --git a/extras/indexingExample/src/main/java/MongoRyaDirectExample.java b/extras/indexingExample/src/main/java/MongoRyaDirectExample.java index d42d96a..c1ff790 100644 --- a/extras/indexingExample/src/main/java/MongoRyaDirectExample.java +++ b/extras/indexingExample/src/main/java/MongoRyaDirectExample.java @@ -19,13 +19,6 @@ import java.util.List; -import mvm.rya.api.RdfCloudTripleStoreConfiguration; -import mvm.rya.indexing.accumulo.ConfigUtils; -import mvm.rya.indexing.accumulo.geo.GeoConstants; -import mvm.rya.mongodb.MongoDBRdfConfiguration; -import mvm.rya.rdftriplestore.RdfCloudTripleStore; -import mvm.rya.rdftriplestore.inference.InferenceEngineException; - import org.apache.commons.lang.Validate; import org.apache.hadoop.conf.Configuration; import org.apache.log4j.Logger; @@ -50,6 +43,14 @@ import org.openrdf.repository.sail.SailRepository; import org.openrdf.repository.sail.SailRepositoryConnection; import org.openrdf.sail.Sail; +import mvm.rya.api.RdfCloudTripleStoreConfiguration; +import mvm.rya.indexing.accumulo.ConfigUtils; +import mvm.rya.indexing.accumulo.geo.GeoConstants; +import mvm.rya.mongodb.MongoDBRdfConfiguration; +import mvm.rya.rdftriplestore.RdfCloudTripleStore; +import mvm.rya.rdftriplestore.inference.InferenceEngineException; +import mvm.rya.sail.config.RyaSailFactory; + public class MongoRyaDirectExample { private static final Logger log = Logger.getLogger(MongoRyaDirectExample.class); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/358c13b8/extras/indexingExample/src/main/java/RyaDirectExample.java ---------------------------------------------------------------------- diff --git a/extras/indexingExample/src/main/java/RyaDirectExample.java b/extras/indexingExample/src/main/java/RyaDirectExample.java index 2c4e954..eec98d6 100644 --- a/extras/indexingExample/src/main/java/RyaDirectExample.java +++ b/extras/indexingExample/src/main/java/RyaDirectExample.java @@ -19,16 +19,6 @@ import java.util.List; -import mvm.rya.accumulo.AccumuloRdfConfiguration; -import mvm.rya.api.RdfCloudTripleStoreConfiguration; -import mvm.rya.api.persist.RyaDAOException; -import mvm.rya.sail.config.RyaSailFactory; -import mvm.rya.indexing.accumulo.ConfigUtils; -import mvm.rya.indexing.accumulo.geo.GeoConstants; -import mvm.rya.indexing.external.tupleSet.PcjTables; -import mvm.rya.indexing.external.tupleSet.PcjTables.PcjException; -import mvm.rya.indexing.external.tupleSet.PcjTables.PcjVarOrderFactory; - import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Connector; @@ -62,6 +52,17 @@ import org.openrdf.sail.Sail; import com.google.common.base.Optional; +import mvm.rya.accumulo.AccumuloRdfConfiguration; +import mvm.rya.api.RdfCloudTripleStoreConfiguration; +import mvm.rya.api.persist.RyaDAOException; +import mvm.rya.indexing.accumulo.ConfigUtils; +import mvm.rya.indexing.accumulo.geo.GeoConstants; +import mvm.rya.indexing.external.tupleSet.PcjTables; +import mvm.rya.indexing.external.tupleSet.PcjTables.PcjException; +import mvm.rya.indexing.external.tupleSet.PcjTables.PcjVarOrderFactory; +import mvm.rya.rdftriplestore.inference.InferenceEngineException; +import mvm.rya.sail.config.RyaSailFactory; + public class RyaDirectExample { private static final Logger log = Logger.getLogger(RyaDirectExample.class); @@ -723,7 +724,7 @@ public class RyaDirectExample { private static void createPCJ(Configuration conf) throws RepositoryException, AccumuloException, - AccumuloSecurityException, TableExistsException, PcjException { + AccumuloSecurityException, TableExistsException, PcjException, InferenceEngineException { final Configuration config = new AccumuloRdfConfiguration(conf);