http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java b/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java index 48334d0..18fc1c6 100644 --- a/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java +++ b/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/FluoITBase.java @@ -7,26 +7,6 @@ * "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. - */ -package org.apache.rya.pcj.fluo.test.base; - -/** - * 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, @@ -36,6 +16,7 @@ package org.apache.rya.pcj.fluo.test.base; * specific language governing permissions and limitations * under the License. */ +package org.apache.rya.pcj.fluo.test.base; import static com.google.common.base.Preconditions.checkNotNull; @@ -76,14 +57,14 @@ import org.apache.rya.rdftriplestore.RyaSailRepository; import org.apache.rya.rdftriplestore.inference.InferenceEngineException; import org.apache.rya.sail.config.RyaSailFactory; import org.apache.zookeeper.ClientCnxn; +import org.eclipse.rdf4j.repository.RepositoryConnection; +import org.eclipse.rdf4j.repository.RepositoryException; +import org.eclipse.rdf4j.sail.Sail; +import org.eclipse.rdf4j.sail.SailException; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Rule; -import org.openrdf.repository.RepositoryConnection; -import org.openrdf.repository.RepositoryException; -import org.openrdf.sail.Sail; -import org.openrdf.sail.SailException; +import org.junit.Rule; /** * Integration tests that ensure the Fluo application processes PCJs results
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/KafkaExportITBase.java ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/KafkaExportITBase.java b/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/KafkaExportITBase.java index 465e089..b60b56f 100644 --- a/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/KafkaExportITBase.java +++ b/extras/rya.pcj.fluo/pcj.fluo.test.base/src/main/java/org/apache/rya/pcj/fluo/test/base/KafkaExportITBase.java @@ -70,12 +70,12 @@ import org.apache.rya.indexing.pcj.fluo.app.query.MetadataCacheSupplier; import org.apache.rya.indexing.pcj.fluo.app.query.StatementPatternIdCacheSupplier; import org.apache.rya.rdftriplestore.RyaSailRepository; import org.apache.rya.sail.config.RyaSailFactory; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection; +import org.eclipse.rdf4j.sail.Sail; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.openrdf.model.Statement; -import org.openrdf.repository.sail.SailRepositoryConnection; -import org.openrdf.sail.Sail; import com.google.common.collect.Sets; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.pcj.fluo/rya.pcj.functions.geo/pom.xml ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/rya.pcj.functions.geo/pom.xml b/extras/rya.pcj.fluo/rya.pcj.functions.geo/pom.xml index dc80206..8b04c61 100644 --- a/extras/rya.pcj.fluo/rya.pcj.functions.geo/pom.xml +++ b/extras/rya.pcj.fluo/rya.pcj.functions.geo/pom.xml @@ -47,12 +47,11 @@ under the License. <dependency> <groupId>org.eclipse.rdf4j</groupId> <artifactId>rdf4j-queryalgebra-geosparql</artifactId> - <version>2.2</version> + <version>${org.eclipse.rdf4j.version}</version> </dependency> <dependency> <groupId>org.eclipse.rdf4j</groupId> <artifactId>rdf4j-queryalgebra-evaluation</artifactId> - <version>2.1.6</version> </dependency> <!-- Testing dependencies. --> <dependency> @@ -91,7 +90,7 @@ under the License. <configuration> <excludes> <!-- Trivial listing of classes to be loaded via SPI --> - <exclude>src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function</exclude> + <exclude>src/main/resources/META-INF/services/org.eclipse.rdf4j.query.algebra.evaluation.function.Function</exclude> </excludes> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/java/org/apache/rya/indexing/pcj/functions/geo/FunctionAdapter.java ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/java/org/apache/rya/indexing/pcj/functions/geo/FunctionAdapter.java b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/java/org/apache/rya/indexing/pcj/functions/geo/FunctionAdapter.java index 2fbe334..8c765e2 100644 --- a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/java/org/apache/rya/indexing/pcj/functions/geo/FunctionAdapter.java +++ b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/java/org/apache/rya/indexing/pcj/functions/geo/FunctionAdapter.java @@ -19,13 +19,13 @@ package org.apache.rya.indexing.pcj.functions.geo; import org.eclipse.rdf4j.model.IRI; -import org.openrdf.model.Literal; -import org.openrdf.model.Value; -import org.openrdf.model.ValueFactory; -import org.openrdf.model.impl.BooleanLiteralImpl; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException; -import org.openrdf.query.algebra.evaluation.function.Function; +import org.eclipse.rdf4j.model.Literal; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.model.ValueFactory; +import org.eclipse.rdf4j.model.impl.BooleanLiteralImpl; +import org.eclipse.rdf4j.model.impl.URIImpl; +import org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException; +import org.eclipse.rdf4j.query.algebra.evaluation.function.Function; /** * Make a RDF4J Function look like an openRDF Function. @@ -58,8 +58,8 @@ class FunctionAdapter implements Function { return valueFactory.createLiteral(((org.eclipse.rdf4j.model.impl.BooleanLiteral) v).booleanValue()); else if (v instanceof org.eclipse.rdf4j.model.Literal) { org.eclipse.rdf4j.model.Literal vLiteral = (org.eclipse.rdf4j.model.Literal) v; - org.openrdf.model.URI vType = valueFactory.createURI(vLiteral.getDatatype().stringValue()); - org.openrdf.model.Literal theReturnValue = valueFactory.createLiteral(vLiteral.getLabel(), vType); + org.eclipse.rdf4j.model.URI vType = valueFactory.createIRI(vLiteral.getDatatype().stringValue()); + org.eclipse.rdf4j.model.Literal theReturnValue = valueFactory.createLiteral(vLiteral.getLabel(), vType); return theReturnValue; } // http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/resources/META-INF/services/org.eclipse.rdf4j.query.algebra.evaluation.function.Function ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/resources/META-INF/services/org.eclipse.rdf4j.query.algebra.evaluation.function.Function b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/resources/META-INF/services/org.eclipse.rdf4j.query.algebra.evaluation.function.Function new file mode 100644 index 0000000..ddfb09b --- /dev/null +++ b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/resources/META-INF/services/org.eclipse.rdf4j.query.algebra.evaluation.function.Function @@ -0,0 +1,30 @@ +org.apache.rya.indexing.pcj.functions.geo.DistanceRdf4J +org.apache.rya.indexing.pcj.functions.geo.ConvexHullRdf4J +org.apache.rya.indexing.pcj.functions.geo.BoundaryRdf4J +org.apache.rya.indexing.pcj.functions.geo.EnvelopeRdf4J +org.apache.rya.indexing.pcj.functions.geo.UnionRdf4J +org.apache.rya.indexing.pcj.functions.geo.IntersectionRdf4J +org.apache.rya.indexing.pcj.functions.geo.SymmetricDifferenceRdf4J +org.apache.rya.indexing.pcj.functions.geo.DifferenceRdf4J +org.apache.rya.indexing.pcj.functions.geo.RelateRdf4J +org.apache.rya.indexing.pcj.functions.geo.SfDisjointRdf4J +org.apache.rya.indexing.pcj.functions.geo.SfIntersectsRdf4J +org.apache.rya.indexing.pcj.functions.geo.SfTouchesRdf4J +org.apache.rya.indexing.pcj.functions.geo.SfCrossesRdf4J +org.apache.rya.indexing.pcj.functions.geo.SfWithinRdf4J +org.apache.rya.indexing.pcj.functions.geo.SfContainsRdf4J +org.apache.rya.indexing.pcj.functions.geo.SfOverlapsRdf4J +org.apache.rya.indexing.pcj.functions.geo.EhDisjointRdf4J +org.apache.rya.indexing.pcj.functions.geo.EhMeetRdf4J +org.apache.rya.indexing.pcj.functions.geo.EhOverlapRdf4J +org.apache.rya.indexing.pcj.functions.geo.EhCoversRdf4J +org.apache.rya.indexing.pcj.functions.geo.EhCoveredByRdf4J +org.apache.rya.indexing.pcj.functions.geo.EhInsideRdf4J +org.apache.rya.indexing.pcj.functions.geo.EhContainsRdf4J +org.apache.rya.indexing.pcj.functions.geo.RCC8DCRdf4J +org.apache.rya.indexing.pcj.functions.geo.RCC8ECRdf4J +org.apache.rya.indexing.pcj.functions.geo.RCC8PORdf4J +org.apache.rya.indexing.pcj.functions.geo.RCC8TPPIRdf4J +org.apache.rya.indexing.pcj.functions.geo.RCC8TPPRdf4J +org.apache.rya.indexing.pcj.functions.geo.RCC8NTPPRdf4J +org.apache.rya.indexing.pcj.functions.geo.RCC8NTPPIRdf4J http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function deleted file mode 100644 index ddfb09b..0000000 --- a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function +++ /dev/null @@ -1,30 +0,0 @@ -org.apache.rya.indexing.pcj.functions.geo.DistanceRdf4J -org.apache.rya.indexing.pcj.functions.geo.ConvexHullRdf4J -org.apache.rya.indexing.pcj.functions.geo.BoundaryRdf4J -org.apache.rya.indexing.pcj.functions.geo.EnvelopeRdf4J -org.apache.rya.indexing.pcj.functions.geo.UnionRdf4J -org.apache.rya.indexing.pcj.functions.geo.IntersectionRdf4J -org.apache.rya.indexing.pcj.functions.geo.SymmetricDifferenceRdf4J -org.apache.rya.indexing.pcj.functions.geo.DifferenceRdf4J -org.apache.rya.indexing.pcj.functions.geo.RelateRdf4J -org.apache.rya.indexing.pcj.functions.geo.SfDisjointRdf4J -org.apache.rya.indexing.pcj.functions.geo.SfIntersectsRdf4J -org.apache.rya.indexing.pcj.functions.geo.SfTouchesRdf4J -org.apache.rya.indexing.pcj.functions.geo.SfCrossesRdf4J -org.apache.rya.indexing.pcj.functions.geo.SfWithinRdf4J -org.apache.rya.indexing.pcj.functions.geo.SfContainsRdf4J -org.apache.rya.indexing.pcj.functions.geo.SfOverlapsRdf4J -org.apache.rya.indexing.pcj.functions.geo.EhDisjointRdf4J -org.apache.rya.indexing.pcj.functions.geo.EhMeetRdf4J -org.apache.rya.indexing.pcj.functions.geo.EhOverlapRdf4J -org.apache.rya.indexing.pcj.functions.geo.EhCoversRdf4J -org.apache.rya.indexing.pcj.functions.geo.EhCoveredByRdf4J -org.apache.rya.indexing.pcj.functions.geo.EhInsideRdf4J -org.apache.rya.indexing.pcj.functions.geo.EhContainsRdf4J -org.apache.rya.indexing.pcj.functions.geo.RCC8DCRdf4J -org.apache.rya.indexing.pcj.functions.geo.RCC8ECRdf4J -org.apache.rya.indexing.pcj.functions.geo.RCC8PORdf4J -org.apache.rya.indexing.pcj.functions.geo.RCC8TPPIRdf4J -org.apache.rya.indexing.pcj.functions.geo.RCC8TPPRdf4J -org.apache.rya.indexing.pcj.functions.geo.RCC8NTPPRdf4J -org.apache.rya.indexing.pcj.functions.geo.RCC8NTPPIRdf4J http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsIT.java ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsIT.java b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsIT.java index f540a2e..2ac9f45 100644 --- a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsIT.java +++ b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsIT.java @@ -37,18 +37,18 @@ import org.apache.rya.api.client.accumulo.AccumuloRyaClientFactory; import org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage; import org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage; import org.apache.rya.pcj.fluo.test.base.RyaExportITBase; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.model.ValueFactory; +import org.eclipse.rdf4j.model.impl.SimpleValueFactory; +import org.eclipse.rdf4j.query.BindingSet; +import org.eclipse.rdf4j.query.algebra.evaluation.ValueExprEvaluationException; +import org.eclipse.rdf4j.query.algebra.evaluation.function.Function; +import org.eclipse.rdf4j.query.algebra.evaluation.function.FunctionRegistry; +import org.eclipse.rdf4j.query.impl.MapBindingSet; +import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection; import org.junit.Test; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.ValueFactory; -import org.openrdf.model.impl.ValueFactoryImpl; -import org.openrdf.query.BindingSet; -import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException; -import org.openrdf.query.algebra.evaluation.function.Function; -import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; -import org.openrdf.query.impl.MapBindingSet; -import org.openrdf.repository.sail.SailRepositoryConnection; import com.google.common.collect.Sets; @@ -87,12 +87,12 @@ public class GeoFunctionsIT extends RyaExportITBase { " FILTER(ryageo:ehContains(?wkt, \"POLYGON((-77 39, -76 39, -76 38, -77 38, -77 39))\"^^geo:wktLiteral)) " + "}"; - final ValueFactory vf = new ValueFactoryImpl(); + final ValueFactory vf = SimpleValueFactory.getInstance(); final Set<Statement> statements = Sets.newHashSet( - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#feature"), vf.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createURI("http://www.opengis.net/ont/geosparql#Feature")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#feature"), vf.createURI("http://www.opengis.net/ont/geosparql#hasGeometry"), vf.createURI("tag:rya.apache.org,2017:ex#test_point")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#test_point"), vf.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createURI("http://www.opengis.net/ont/geosparql#Point")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#test_point"), vf.createURI("http://www.opengis.net/ont/geosparql#asWKT"), vf.createLiteral("Point(-77.03524 38.889468)", vf.createURI("http://www.opengis.net/ont/geosparql#wktLiteral")))); + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#feature"), vf.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createIRI("http://www.opengis.net/ont/geosparql#Feature")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#feature"), vf.createIRI("http://www.opengis.net/ont/geosparql#hasGeometry"), vf.createIRI("tag:rya.apache.org,2017:ex#test_point")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#test_point"), vf.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createIRI("http://www.opengis.net/ont/geosparql#Point")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#test_point"), vf.createIRI("http://www.opengis.net/ont/geosparql#asWKT"), vf.createLiteral("Point(-77.03524 38.889468)", vf.createIRI("http://www.opengis.net/ont/geosparql#wktLiteral")))); // Create a Geo function. final Function geoFunction = new Function() { @@ -116,9 +116,9 @@ public class GeoFunctionsIT extends RyaExportITBase { // The expected results of the SPARQL query once the PCJ has been computed. final Set<BindingSet> expectedResults = new HashSet<>(); final MapBindingSet bs = new MapBindingSet(); - bs.addBinding("wkt", vf.createLiteral("Point(-77.03524 38.889468)", vf.createURI("http://www.opengis.net/ont/geosparql#wktLiteral"))); - bs.addBinding("feature", vf.createURI("tag:rya.apache.org,2017:ex#feature")); - bs.addBinding("point", vf.createURI("tag:rya.apache.org,2017:ex#test_point")); + bs.addBinding("wkt", vf.createLiteral("Point(-77.03524 38.889468)", vf.createIRI("http://www.opengis.net/ont/geosparql#wktLiteral"))); + bs.addBinding("feature", vf.createIRI("tag:rya.apache.org,2017:ex#feature")); + bs.addBinding("point", vf.createIRI("tag:rya.apache.org,2017:ex#test_point")); expectedResults.add(bs); runTest(sparql, statements, expectedResults); @@ -141,41 +141,41 @@ public class GeoFunctionsIT extends RyaExportITBase { " FILTER ( !sameTerm (?cityA, ?cityB) ) " + "}"; - final ValueFactory vf = new ValueFactoryImpl(); - final URI wktTypeUri = vf.createURI("http://www.opengis.net/ont/geosparql#wktLiteral"); - final URI asWKT = vf.createURI("http://www.opengis.net/ont/geosparql#asWKT"); + final ValueFactory vf = SimpleValueFactory.getInstance(); + final IRI wktTypeUri = vf.createIRI("http://www.opengis.net/ont/geosparql#wktLiteral"); + final IRI asWKT = vf.createIRI("http://www.opengis.net/ont/geosparql#asWKT"); final Set<Statement> statements = Sets.newHashSet( - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#dakar"), asWKT, vf.createLiteral("Point(-17.45 14.69)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#dakar2"), asWKT, vf.createLiteral("Point(-17.45 14.69)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#canberra"), asWKT, vf.createLiteral("Point(149.12 -35.31)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#brussels"), asWKT, vf.createLiteral("Point(4.35 50.85)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#amsterdam"), asWKT, vf.createLiteral("Point(4.9 52.37)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#amsterdam"), vf.createURI("urn:containedIn"), vf.createLiteral("Europe")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#dakar"), vf.createURI("urn:containedIn"), vf.createLiteral("Africa")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#dakar2"), vf.createURI("urn:containedIn"), vf.createLiteral("Africa")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#brussels"), vf.createURI("urn:containedIn"), vf.createLiteral("Europe"))); - - // The expected results of the SPARQL query once the PCJ has been computed.l + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#dakar"), asWKT, vf.createLiteral("Point(-17.45 14.69)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#dakar2"), asWKT, vf.createLiteral("Point(-17.45 14.69)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#canberra"), asWKT, vf.createLiteral("Point(149.12 -35.31)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#brussels"), asWKT, vf.createLiteral("Point(4.35 50.85)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam"), asWKT, vf.createLiteral("Point(4.9 52.37)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam"), vf.createIRI("urn:containedIn"), vf.createLiteral("Europe")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#dakar"), vf.createIRI("urn:containedIn"), vf.createLiteral("Africa")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#dakar2"), vf.createIRI("urn:containedIn"), vf.createLiteral("Africa")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#brussels"), vf.createIRI("urn:containedIn"), vf.createLiteral("Europe"))); + + // The expected results of the SPARQL query once the PCJ has been computed. final Set<BindingSet> expectedResults = new HashSet<>(); MapBindingSet bs = new MapBindingSet(); - bs.addBinding("cityA", vf.createURI("tag:rya.apache.org,2017:ex#dakar")); - bs.addBinding("cityB", vf.createURI("tag:rya.apache.org,2017:ex#dakar2")); + bs.addBinding("cityA", vf.createIRI("tag:rya.apache.org,2017:ex#dakar")); + bs.addBinding("cityB", vf.createIRI("tag:rya.apache.org,2017:ex#dakar2")); expectedResults.add(bs); bs = new MapBindingSet(); - bs.addBinding("cityA", vf.createURI("tag:rya.apache.org,2017:ex#dakar2")); - bs.addBinding("cityB", vf.createURI("tag:rya.apache.org,2017:ex#dakar")); + bs.addBinding("cityA", vf.createIRI("tag:rya.apache.org,2017:ex#dakar2")); + bs.addBinding("cityB", vf.createIRI("tag:rya.apache.org,2017:ex#dakar")); expectedResults.add(bs); bs = new MapBindingSet(); - bs.addBinding("cityA", vf.createURI("tag:rya.apache.org,2017:ex#brussels")); - bs.addBinding("cityB", vf.createURI("tag:rya.apache.org,2017:ex#amsterdam")); + bs.addBinding("cityA", vf.createIRI("tag:rya.apache.org,2017:ex#brussels")); + bs.addBinding("cityB", vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam")); expectedResults.add(bs); bs = new MapBindingSet(); - bs.addBinding("cityA", vf.createURI("tag:rya.apache.org,2017:ex#amsterdam")); - bs.addBinding("cityB", vf.createURI("tag:rya.apache.org,2017:ex#brussels")); + bs.addBinding("cityA", vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam")); + bs.addBinding("cityB", vf.createIRI("tag:rya.apache.org,2017:ex#brussels")); expectedResults.add(bs); runTest(sparql, statements, expectedResults); @@ -209,22 +209,22 @@ public class GeoFunctionsIT extends RyaExportITBase { "FILTER(geof:sfWithin(?wkt, \"POLYGON((-78 39, -76 39, -76 38, -78 38, -78 39))\"^^geo:wktLiteral)) " + "}"; - final ValueFactory vf = new ValueFactoryImpl(); + final ValueFactory vf = SimpleValueFactory.getInstance(); final Set<Statement> statements = Sets.newHashSet( - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#feature"), vf.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createURI("http://www.opengis.net/ont/geosparql#Feature")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#feature"), vf.createURI("http://www.opengis.net/ont/geosparql#hasGeometry"), vf.createURI("tag:rya.apache.org,2017:ex#test_point")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#test_point"), vf.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createURI("http://www.opengis.net/ont/geosparql#Point")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#test_point"), vf.createURI("http://www.opengis.net/ont/geosparql#asWKT"), vf.createLiteral("Point(-77.03524 38.889468)", vf.createURI("http://www.opengis.net/ont/geosparql#wktLiteral"))), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#skip_point"), vf.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createURI("http://www.opengis.net/ont/geosparql#Point")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#skip_point"), vf.createURI("http://www.opengis.net/ont/geosparql#asWKT"), vf.createLiteral("Point(-10 10)", vf.createURI("http://www.opengis.net/ont/geosparql#wktLiteral")))); + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#feature"), vf.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createIRI("http://www.opengis.net/ont/geosparql#Feature")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#feature"), vf.createIRI("http://www.opengis.net/ont/geosparql#hasGeometry"), vf.createIRI("tag:rya.apache.org,2017:ex#test_point")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#test_point"), vf.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createIRI("http://www.opengis.net/ont/geosparql#Point")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#test_point"), vf.createIRI("http://www.opengis.net/ont/geosparql#asWKT"), vf.createLiteral("Point(-77.03524 38.889468)", vf.createIRI("http://www.opengis.net/ont/geosparql#wktLiteral"))), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#skip_point"), vf.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createIRI("http://www.opengis.net/ont/geosparql#Point")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#skip_point"), vf.createIRI("http://www.opengis.net/ont/geosparql#asWKT"), vf.createLiteral("Point(-10 10)", vf.createIRI("http://www.opengis.net/ont/geosparql#wktLiteral")))); // Register geo functions from RDF4J is done automatically via SPI. // The expected results of the SPARQL query once the PCJ has been computed. final Set<BindingSet> expectedResults = new HashSet<>(); final MapBindingSet bs = new MapBindingSet(); - bs.addBinding("wkt", vf.createLiteral("Point(-77.03524 38.889468)", vf.createURI("http://www.opengis.net/ont/geosparql#wktLiteral"))); - bs.addBinding("feature", vf.createURI("tag:rya.apache.org,2017:ex#feature")); - bs.addBinding("point", vf.createURI("tag:rya.apache.org,2017:ex#test_point")); + bs.addBinding("wkt", vf.createLiteral("Point(-77.03524 38.889468)", vf.createIRI("http://www.opengis.net/ont/geosparql#wktLiteral"))); + bs.addBinding("feature", vf.createIRI("tag:rya.apache.org,2017:ex#feature")); + bs.addBinding("point", vf.createIRI("tag:rya.apache.org,2017:ex#test_point")); expectedResults.add(bs); runTest(sparql, statements, expectedResults); @@ -248,29 +248,29 @@ public class GeoFunctionsIT extends RyaExportITBase { " FILTER ( !sameTerm (?cityA, ?cityB) ) " + "}"; - final ValueFactory vf = new ValueFactoryImpl(); - final URI wktTypeUri = vf.createURI("http://www.opengis.net/ont/geosparql#wktLiteral"); - final URI asWKT = vf.createURI("http://www.opengis.net/ont/geosparql#asWKT"); + final ValueFactory vf = SimpleValueFactory.getInstance(); + final IRI wktTypeUri = vf.createIRI("http://www.opengis.net/ont/geosparql#wktLiteral"); + final IRI asWKT = vf.createIRI("http://www.opengis.net/ont/geosparql#asWKT"); final Set<Statement> statements = Sets.newHashSet( - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#dakar"), asWKT, vf.createLiteral("Point(-17.45 14.69)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#canberra"), asWKT, vf.createLiteral("Point(149.12 -35.31)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#brussels"), asWKT, vf.createLiteral("Point(4.35 50.85)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#amsterdam"), asWKT, vf.createLiteral("Point(4.9 52.37)", wktTypeUri)), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#amsterdam"), vf.createURI("urn:containedIn"), vf.createLiteral("Europe")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#amsterdam2"), vf.createURI("urn:containedIn"), vf.createLiteral("Europe")), - vf.createStatement(vf.createURI("tag:rya.apache.org,2017:ex#amsterdam2"), asWKT, vf.createLiteral("Point(4.9 52.37)", wktTypeUri))); + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#dakar"), asWKT, vf.createLiteral("Point(-17.45 14.69)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#canberra"), asWKT, vf.createLiteral("Point(149.12 -35.31)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#brussels"), asWKT, vf.createLiteral("Point(4.35 50.85)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam"), asWKT, vf.createLiteral("Point(4.9 52.37)", wktTypeUri)), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam"), vf.createIRI("urn:containedIn"), vf.createLiteral("Europe")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam2"), vf.createIRI("urn:containedIn"), vf.createLiteral("Europe")), + vf.createStatement(vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam2"), asWKT, vf.createLiteral("Point(4.9 52.37)", wktTypeUri))); // The expected results of the SPARQL query once the PCJ has been computed. final Set<BindingSet> expectedResults = new HashSet<>(); MapBindingSet bs = new MapBindingSet(); - bs.addBinding("cityA", vf.createURI("tag:rya.apache.org,2017:ex#amsterdam")); - bs.addBinding("cityB", vf.createURI("tag:rya.apache.org,2017:ex#amsterdam2")); + bs.addBinding("cityA", vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam")); + bs.addBinding("cityB", vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam2")); expectedResults.add(bs); bs = new MapBindingSet(); - bs.addBinding("cityA", vf.createURI("tag:rya.apache.org,2017:ex#amsterdam2")); - bs.addBinding("cityB", vf.createURI("tag:rya.apache.org,2017:ex#amsterdam")); + bs.addBinding("cityA", vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam2")); + bs.addBinding("cityB", vf.createIRI("tag:rya.apache.org,2017:ex#amsterdam")); expectedResults.add(bs); runTest(sparql, statements, expectedResults); @@ -290,14 +290,14 @@ public class GeoFunctionsIT extends RyaExportITBase { "}"; // create some resources and literals to make statements out of - final ValueFactory vf = new ValueFactoryImpl(); + final ValueFactory vf = SimpleValueFactory.getInstance(); final DatatypeFactory dtf = DatatypeFactory.newInstance(); - final URI dtPredUri = vf.createURI("http://www.w3.org/2006/time#inXSDDateTime"); - final URI eventz = vf.createURI("<http://eventz>"); + final IRI dtPredUri = vf.createIRI("http://www.w3.org/2006/time#inXSDDateTime"); + final IRI eventz = vf.createIRI("<http://eventz>"); final Set<Statement> statements = Sets.newHashSet( - vf.createStatement(eventz, vf.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createURI("<http://www.w3.org/2006/time#Instant>")), + vf.createStatement(eventz, vf.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), vf.createIRI("<http://www.w3.org/2006/time#Instant>")), vf.createStatement(eventz, dtPredUri, vf.createLiteral(dtf.newXMLGregorianCalendar("2001-01-01T01:01:01-08:00"))), // 1 second vf.createStatement(eventz, dtPredUri, vf.createLiteral(dtf.newXMLGregorianCalendar("2001-01-01T04:01:02.000-05:00"))), // 2 seconds vf.createStatement(eventz, dtPredUri, vf.createLiteral(dtf.newXMLGregorianCalendar("2001-01-01T01:01:03-08:00"))), // 3 seconds http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsTest.java b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsTest.java index f73fa8f..7ed6246 100644 --- a/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsTest.java +++ b/extras/rya.pcj.fluo/rya.pcj.functions.geo/src/test/java/org/apache/rya/indexing/pcj/functions/geo/GeoFunctionsTest.java @@ -26,9 +26,9 @@ import java.util.HashSet; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.zookeeper.ClientCnxn; +import org.eclipse.rdf4j.query.algebra.evaluation.function.FunctionRegistry; import org.junit.Before; import org.junit.Test; -import org.openrdf.query.algebra.evaluation.function.FunctionRegistry; /** * Verifies that the geoFunctions are registered via SPI. @@ -45,7 +45,7 @@ public class GeoFunctionsTest { /** * Thirty-some functions are registered via SPI. Make sure they are registered. * This file lists functions to load: - * src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function + * src/main/resources/META-INF/services/ org.eclipse.rdf4j.query.algebra.evaluation.function.Function */ @Test public void verifySpiLoadedGeoFunctions() { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAO.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAO.java b/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAO.java index e9a2ccc..382266b 100644 --- a/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAO.java +++ b/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAO.java @@ -19,8 +19,6 @@ package org.apache.rya.joinselect; * under the License. */ - - import static com.google.common.base.Preconditions.checkNotNull; import java.util.ArrayList; @@ -30,13 +28,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.rya.accumulo.AccumuloRdfUtils; -import org.apache.rya.api.RdfCloudTripleStoreConfiguration; -import org.apache.rya.api.layout.TableLayoutStrategy; -import org.apache.rya.api.persist.RdfDAOException; -import org.apache.rya.api.persist.RdfEvalStatsDAO; -import org.apache.rya.api.persist.joinselect.SelectivityEvalDAO; - import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Connector; @@ -50,22 +41,24 @@ import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.security.Authorizations; import org.apache.hadoop.io.Text; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.StatementPattern; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.Var; -import org.openrdf.query.algebra.evaluation.impl.ExternalSet; -import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; +import org.apache.rya.accumulo.AccumuloRdfUtils; +import org.apache.rya.api.RdfCloudTripleStoreConfiguration; +import org.apache.rya.api.layout.TableLayoutStrategy; +import org.apache.rya.api.persist.RdfDAOException; +import org.apache.rya.api.persist.RdfEvalStatsDAO; +import org.apache.rya.api.persist.joinselect.SelectivityEvalDAO; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.StatementPattern; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.Var; +import org.eclipse.rdf4j.query.algebra.evaluation.impl.ExternalSet; +import org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor; import com.google.common.collect.Lists; import com.google.common.collect.Sets; - - - - public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTripleStoreConfiguration> { private boolean initialized = false; @@ -76,7 +69,7 @@ public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTr private boolean denormalized = false; private int FullTableCardinality = 0; private static final String DELIM = "\u0000"; - private Map<String,Long> joinMap = new HashMap<String,Long>();; + private Map<String,Long> joinMap = new HashMap<String,Long>(); private RdfEvalStatsDAO<RdfCloudTripleStoreConfiguration> resd; @Override @@ -458,13 +451,6 @@ public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTr - - - - - - - // obtains cardinality for StatementPattern. Returns cardinality of 0 // if no instances of constants occur in table. @@ -475,9 +461,9 @@ public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTr Var subjectVar = sp.getSubjectVar(); Resource subj = (Resource) getConstantValue(subjectVar); Var predicateVar = sp.getPredicateVar(); - URI pred = (URI) getConstantValue(predicateVar); + IRI pred = (IRI) getConstantValue(predicateVar); Var objectVar = sp.getObjectVar(); - org.openrdf.model.Value obj = getConstantValue(objectVar); + org.eclipse.rdf4j.model.Value obj = getConstantValue(objectVar); Resource context = (Resource) getConstantValue(sp.getContextVar()); /** @@ -492,7 +478,7 @@ public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTr } try { if (subj != null) { - List<org.openrdf.model.Value> values = new ArrayList<org.openrdf.model.Value>(); + List<org.eclipse.rdf4j.model.Value> values = new ArrayList<org.eclipse.rdf4j.model.Value>(); CARDINALITY_OF card = RdfEvalStatsDAO.CARDINALITY_OF.SUBJECT; values.add(subj); @@ -514,7 +500,7 @@ public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTr cardinality = 0; } } else if (pred != null) { - List<org.openrdf.model.Value> values = new ArrayList<org.openrdf.model.Value>(); + List<org.eclipse.rdf4j.model.Value> values = new ArrayList<org.eclipse.rdf4j.model.Value>(); CARDINALITY_OF card = RdfEvalStatsDAO.CARDINALITY_OF.PREDICATE; values.add(pred); @@ -531,7 +517,7 @@ public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTr cardinality = 0; } } else if (obj != null) { - List<org.openrdf.model.Value> values = new ArrayList<org.openrdf.model.Value>(); + List<org.eclipse.rdf4j.model.Value> values = new ArrayList<org.eclipse.rdf4j.model.Value>(); values.add(obj); double evalCard = this.getCardinality(conf, RdfEvalStatsDAO.CARDINALITY_OF.OBJECT, values, context); if (evalCard >= 0) { @@ -550,18 +536,18 @@ public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTr return (long) cardinality; } - private org.openrdf.model.Value getConstantValue(Var var) { + private org.eclipse.rdf4j.model.Value getConstantValue(Var var) { if (var != null) return var.getValue(); else return null; } - public double getCardinality(RdfCloudTripleStoreConfiguration conf, CARDINALITY_OF card, List<org.openrdf.model.Value> val) throws RdfDAOException { + public double getCardinality(RdfCloudTripleStoreConfiguration conf, CARDINALITY_OF card, List<org.eclipse.rdf4j.model.Value> val) throws RdfDAOException { return resd.getCardinality(conf, card, val); } - public double getCardinality(RdfCloudTripleStoreConfiguration conf, CARDINALITY_OF card, List<org.openrdf.model.Value> val, Resource context) throws RdfDAOException { + public double getCardinality(RdfCloudTripleStoreConfiguration conf, CARDINALITY_OF card, List<org.eclipse.rdf4j.model.Value> val, Resource context) throws RdfDAOException { return resd.getCardinality(conf, card, val, context); @@ -613,7 +599,7 @@ public class AccumuloSelectivityEvalDAO implements SelectivityEvalDAO<RdfCloudTr - private static class SpExternalCollector extends QueryModelVisitorBase<RuntimeException> { + private static class SpExternalCollector extends AbstractQueryModelVisitor<RuntimeException> { private List<QueryModelNode> eSet = Lists.newArrayList(); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/CardinalityCalcUtil.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/CardinalityCalcUtil.java b/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/CardinalityCalcUtil.java index c0453ba..c836ac9 100644 --- a/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/CardinalityCalcUtil.java +++ b/extras/rya.prospector/src/main/java/org/apache/rya/joinselect/CardinalityCalcUtil.java @@ -19,14 +19,12 @@ package org.apache.rya.joinselect; * under the License. */ - - import java.util.ArrayList; import java.util.List; import org.apache.accumulo.core.data.Key; -import org.openrdf.query.algebra.StatementPattern; -import org.openrdf.query.algebra.Var; +import org.eclipse.rdf4j.query.algebra.StatementPattern; +import org.eclipse.rdf4j.query.algebra.Var; public class CardinalityCalcUtil { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/IndexWorkPlan.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/IndexWorkPlan.java b/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/IndexWorkPlan.java index 77955e4..db99523 100644 --- a/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/IndexWorkPlan.java +++ b/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/IndexWorkPlan.java @@ -33,7 +33,7 @@ import org.apache.rya.prospector.domain.IndexEntry; import org.apache.rya.prospector.domain.IntermediateProspect; import org.apache.rya.prospector.mr.ProspectorCombiner; import org.apache.rya.prospector.mr.ProspectorMapper; -import org.openrdf.model.vocabulary.XMLSchema; +import org.eclipse.rdf4j.model.vocabulary.XMLSchema; /** * Contains the methods that perform each of the Map Reduce functions that result http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/impl/CountPlan.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/impl/CountPlan.java b/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/impl/CountPlan.java index f408b7d..251c784 100644 --- a/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/impl/CountPlan.java +++ b/extras/rya.prospector/src/main/java/org/apache/rya/prospector/plans/impl/CountPlan.java @@ -53,8 +53,8 @@ import org.apache.rya.prospector.domain.TripleValueType; import org.apache.rya.prospector.plans.IndexWorkPlan; import org.apache.rya.prospector.utils.CustomEntry; import org.apache.rya.prospector.utils.ProspectorUtils; -import org.openrdf.model.util.URIUtil; -import org.openrdf.model.vocabulary.XMLSchema; +import org.eclipse.rdf4j.model.util.URIUtil; +import org.eclipse.rdf4j.model.vocabulary.XMLSchema; /** * An implementation of {@link IndexWorkPlan} that counts the number of times http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/main/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAO.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/main/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAO.java b/extras/rya.prospector/src/main/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAO.java index 3e45781..95e9f19 100644 --- a/extras/rya.prospector/src/main/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAO.java +++ b/extras/rya.prospector/src/main/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAO.java @@ -37,8 +37,8 @@ import org.apache.rya.api.persist.RdfEvalStatsDAO; import org.apache.rya.prospector.domain.IndexEntry; import org.apache.rya.prospector.domain.TripleValueType; import org.apache.rya.prospector.utils.ProspectorConstants; -import org.openrdf.model.Resource; -import org.openrdf.model.Value; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Value; /** * An ${@link org.apache.rya.api.persist.RdfEvalStatsDAO} that uses the Prospector Service underneath return counts. http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAOTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAOTest.java b/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAOTest.java index 25b0dc3..8e58894 100644 --- a/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAOTest.java +++ b/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/AccumuloSelectivityEvalDAOTest.java @@ -19,8 +19,6 @@ package org.apache.rya.joinselect; * under the License. */ - - import java.math.BigDecimal; import java.math.MathContext; import java.util.ArrayList; @@ -29,13 +27,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import org.apache.rya.accumulo.AccumuloRdfConfiguration; -import org.apache.rya.api.RdfCloudTripleStoreConfiguration; -import org.apache.rya.api.layout.TablePrefixLayoutStrategy; -import org.apache.rya.api.persist.RdfEvalStatsDAO; -import org.apache.rya.joinselect.AccumuloSelectivityEvalDAO; -import org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO; - import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.BatchWriter; @@ -54,15 +45,20 @@ import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.security.Authorizations; import org.apache.hadoop.io.Text; +import org.apache.rya.accumulo.AccumuloRdfConfiguration; +import org.apache.rya.api.RdfCloudTripleStoreConfiguration; +import org.apache.rya.api.layout.TablePrefixLayoutStrategy; +import org.apache.rya.api.persist.RdfEvalStatsDAO; +import org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO; +import org.eclipse.rdf4j.query.MalformedQueryException; +import org.eclipse.rdf4j.query.algebra.StatementPattern; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.helpers.StatementPatternCollector; +import org.eclipse.rdf4j.query.parser.ParsedQuery; +import org.eclipse.rdf4j.query.parser.sparql.SPARQLParser; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.algebra.StatementPattern; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.helpers.StatementPatternCollector; -import org.openrdf.query.parser.ParsedQuery; -import org.openrdf.query.parser.sparql.SPARQLParser; import com.google.common.collect.Lists; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/mr/JoinSelectProspectOutputTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/mr/JoinSelectProspectOutputTest.java b/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/mr/JoinSelectProspectOutputTest.java index a698676..25e3bce 100644 --- a/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/mr/JoinSelectProspectOutputTest.java +++ b/extras/rya.prospector/src/test/java/org/apache/rya/joinselect/mr/JoinSelectProspectOutputTest.java @@ -1,5 +1,3 @@ -package org.apache.rya.joinselect.mr; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -18,24 +16,17 @@ package org.apache.rya.joinselect.mr; * specific language governing permissions and limitations * under the License. */ - - -import static org.junit.Assert.*; - -import org.junit.Test; +package org.apache.rya.joinselect.mr; import java.io.IOException; -import org.apache.rya.joinselect.mr.JoinSelectProspectOutput; -import org.apache.rya.joinselect.mr.utils.CardinalityType; -import org.apache.rya.joinselect.mr.utils.CompositeType; -import org.apache.rya.joinselect.mr.utils.TripleCard; - import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; -import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mrunit.mapreduce.MapDriver; +import org.apache.rya.joinselect.mr.utils.CardinalityType; +import org.apache.rya.joinselect.mr.utils.CompositeType; +import org.apache.rya.joinselect.mr.utils.TripleCard; import org.junit.Test; public class JoinSelectProspectOutputTest { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/test/java/org/apache/rya/prospector/mr/ProspectorTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/test/java/org/apache/rya/prospector/mr/ProspectorTest.java b/extras/rya.prospector/src/test/java/org/apache/rya/prospector/mr/ProspectorTest.java index eac7aab..96f2685 100644 --- a/extras/rya.prospector/src/test/java/org/apache/rya/prospector/mr/ProspectorTest.java +++ b/extras/rya.prospector/src/test/java/org/apache/rya/prospector/mr/ProspectorTest.java @@ -45,8 +45,8 @@ import org.apache.rya.prospector.domain.IndexEntry; import org.apache.rya.prospector.domain.TripleValueType; import org.apache.rya.prospector.service.ProspectorService; import org.apache.rya.prospector.utils.ProspectorConstants; +import org.eclipse.rdf4j.model.vocabulary.XMLSchema; import org.junit.Test; -import org.openrdf.model.vocabulary.XMLSchema; import com.google.common.collect.Lists; @@ -239,7 +239,7 @@ public class ProspectorTest { * debugging the test. */ private void debugTable(Connector connector, String table) throws TableNotFoundException { - final Iterator<Entry<Key, Value>> it = connector.createScanner(table, new Authorizations(new String[]{"U", "FOUO"})).iterator(); + final Iterator<Entry<Key, Value>> it = connector.createScanner(table, new Authorizations("U", "FOUO")).iterator(); while(it.hasNext()) { final Entry<Key, Value> entry = it.next(); System.out.println( entry ); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.prospector/src/test/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAOTest.java ---------------------------------------------------------------------- diff --git a/extras/rya.prospector/src/test/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAOTest.java b/extras/rya.prospector/src/test/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAOTest.java index f048742..b94ed8d 100644 --- a/extras/rya.prospector/src/test/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAOTest.java +++ b/extras/rya.prospector/src/test/java/org/apache/rya/prospector/service/ProspectorServiceEvalStatsDAOTest.java @@ -43,11 +43,11 @@ import org.apache.rya.api.domain.RyaURI; import org.apache.rya.api.persist.RdfEvalStatsDAO; import org.apache.rya.api.persist.RdfEvalStatsDAO.CARDINALITY_OF; import org.apache.rya.prospector.mr.Prospector; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.model.ValueFactory; +import org.eclipse.rdf4j.model.impl.SimpleValueFactory; +import org.eclipse.rdf4j.model.vocabulary.XMLSchema; import org.junit.Test; -import org.openrdf.model.Value; -import org.openrdf.model.impl.LiteralImpl; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.model.vocabulary.XMLSchema; /** * Tests that show when the {@link Prospector} job is run, the @@ -55,6 +55,7 @@ import org.openrdf.model.vocabulary.XMLSchema; * information from the prospect table. */ public class ProspectorServiceEvalStatsDAOTest { + private static final ValueFactory VF = SimpleValueFactory.getInstance(); @Test public void testCount() throws Exception { @@ -95,19 +96,19 @@ public class ProspectorServiceEvalStatsDAOTest { // Get the cardinality of the 'urn:gem#pred' predicate. List<Value> values = new ArrayList<Value>(); - values.add( new URIImpl("urn:gem#pred") ); + values.add( VF.createIRI("urn:gem#pred") ); double count = evalDao.getCardinality(rdfConf, CARDINALITY_OF.PREDICATE, values); assertEquals(4.0, count, 0.001); // Get the cardinality of the 'mydata1' object. values = new ArrayList<Value>(); - values.add( new LiteralImpl("mydata1")); + values.add( VF.createLiteral("mydata1")); count = evalDao.getCardinality(rdfConf, RdfEvalStatsDAO.CARDINALITY_OF.OBJECT, values); assertEquals(1.0, count, 0.001); // Get the cardinality of the 'mydata3' object. values = new ArrayList<Value>(); - values.add( new LiteralImpl("mydata3")); + values.add( VF.createLiteral("mydata3")); count = evalDao.getCardinality(rdfConf, RdfEvalStatsDAO.CARDINALITY_OF.OBJECT, values); assertEquals(-1.0, count, 0.001); } @@ -151,19 +152,19 @@ public class ProspectorServiceEvalStatsDAOTest { // Get the cardinality of the 'urn:gem#pred' predicate. List<Value> values = new ArrayList<Value>(); - values.add( new URIImpl("urn:gem#pred")); + values.add( VF.createIRI("urn:gem#pred")); double count = evalDao.getCardinality(rdfConf, RdfEvalStatsDAO.CARDINALITY_OF.PREDICATE, values); assertEquals(4.0, count, 0.001); // Get the cardinality of the 'mydata1' object. values = new ArrayList<Value>(); - values.add( new LiteralImpl("mydata1")); + values.add( VF.createLiteral("mydata1")); count = evalDao.getCardinality(rdfConf, RdfEvalStatsDAO.CARDINALITY_OF.OBJECT, values); assertEquals(1.0, count, 0.001); // Get the cardinality of the 'mydata3' object. values = new ArrayList<Value>(); - values.add( new LiteralImpl("mydata3")); + values.add( VF.createLiteral("mydata3")); count = evalDao.getCardinality(rdfConf, RdfEvalStatsDAO.CARDINALITY_OF.OBJECT, values); assertEquals(-1.0, count, 0.001); } @@ -173,7 +174,7 @@ public class ProspectorServiceEvalStatsDAOTest { * debugging the test. */ private void debugTable(Connector connector, String table) throws TableNotFoundException { - final Iterator<Entry<Key, org.apache.accumulo.core.data.Value>> it = connector.createScanner(table, new Authorizations(new String[]{"U", "FOUO"})).iterator(); + final Iterator<Entry<Key, org.apache.accumulo.core.data.Value>> it = connector.createScanner(table, new Authorizations("U", "FOUO")).iterator(); while(it.hasNext()) { System.out.println( it.next() ); } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/README.md ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/README.md b/extras/rya.reasoning/README.md index 533c903..812542d 100644 --- a/extras/rya.reasoning/README.md +++ b/extras/rya.reasoning/README.md @@ -668,12 +668,12 @@ processType(fact): The main reasoning logic is located in **org.apache.rya.reasoning**, while MapReduce tools and utilities for interacting with Accumulo are located in **org.apache.rya.reasoning.mr**. Reasoning logic makes use of RDF constructs in the -**org.openrdf.model** API, in particular: Statement, URI, Resource, and Value. +**org.eclipse.rdf4j.model** API, in particular: Statement, URI, Resource, and Value. ### org.apache.rya.reasoning - **OWL2**: - In general, the Sesame/openrdf API is used to represent RDF constructs and + In general, the RDF4J API is used to represent RDF constructs and refer to the RDF, RDFS, and OWL vocabularies. However, the API only covers OWL 1 constructs. The OWL2 class contains static URIs for new OWL 2 vocabulary resources: owl:IrreflexiveProperty, owl:propertyDisjointWith, @@ -710,7 +710,7 @@ tools and utilities for interacting with Accumulo are located in - An **OwlProperty** or **OwlClass** represents a property or a class, respectively. Each object holds a reference to the RDF entity that identifies it (using to - the openrdf api): a URI for each OwlProperty, and a Resource for each class + the RDF4J api): a URI for each OwlProperty, and a Resource for each class (because a class is more general; it can be a URI or a bnode). Both maintain connections to other schema constructs, according to the @@ -850,7 +850,7 @@ output/input, takes in `<Fact, NullWritable>` or `<Derivation, NullWritable>`). jobs (using those parameters). - **ResourceWritable**: - WritableComparable wrapper for org.openrdf.model.Resource, so it can be used as + WritableComparable wrapper for org.eclipse.rdf4j.model.Resource, so it can be used as a key/value in MapReduce tasks. Also contains an integer field to enable arbitrary secondary sort. Provides static classes **PrimaryComparator** to use the Resource alone, and **SecondaryComparator** to use resource followed by key. http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/pom.xml ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/pom.xml b/extras/rya.reasoning/pom.xml index 864cac8..44042bc 100644 --- a/extras/rya.reasoning/pom.xml +++ b/extras/rya.reasoning/pom.xml @@ -62,22 +62,22 @@ under the License. </dependency> <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-rio-rdfxml</artifactId> + <groupId>org.eclipse.rdf4j</groupId> + <artifactId>rdf4j-rio-rdfxml</artifactId> </dependency> <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-rio-ntriples</artifactId> + <groupId>org.eclipse.rdf4j</groupId> + <artifactId>rdf4j-rio-ntriples</artifactId> </dependency> <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-rio-turtle</artifactId> - <version>${openrdf.sesame.version}</version> + <groupId>org.eclipse.rdf4j</groupId> + <artifactId>rdf4j-rio-turtle</artifactId> + <version>${org.eclipse.rdf4j.version}</version> </dependency> <dependency> - <groupId>org.openrdf.sesame</groupId> - <artifactId>sesame-runtime</artifactId> + <groupId>org.eclipse.rdf4j</groupId> + <artifactId>rdf4j-runtime</artifactId> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/AbstractReasoner.java ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/AbstractReasoner.java b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/AbstractReasoner.java index 22a277e..75313a2 100644 --- a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/AbstractReasoner.java +++ b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/AbstractReasoner.java @@ -22,9 +22,9 @@ package org.apache.rya.reasoning; import java.util.HashSet; import java.util.Set; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; -import org.openrdf.model.Value; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Value; /** * Abstract class for reasoning in the neighborhood of a particular resource. @@ -162,7 +162,7 @@ public abstract class AbstractReasoner { * @param rule The specific rule rule that yielded the inference * @param source One (might be the only) fact used in the derivation */ - protected Fact triple(Resource s, URI p, Value o, OwlRule rule, + protected Fact triple(Resource s, IRI p, Value o, OwlRule rule, Fact source) { Fact fact = new Fact(s, p, o, this.currentIteration, rule, this.node); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Derivation.java ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Derivation.java b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Derivation.java index d2eb547..ae8e6da 100644 --- a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Derivation.java +++ b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Derivation.java @@ -27,12 +27,11 @@ import java.util.Iterator; import java.util.Set; import java.util.TreeSet; -import org.apache.rya.reasoning.mr.ResourceWritable; - import org.apache.hadoop.io.WritableComparable; import org.apache.hadoop.io.WritableUtils; -import org.openrdf.model.Resource; -import org.openrdf.model.Value; +import org.apache.rya.reasoning.mr.ResourceWritable; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Value; /** * Represents the derivation of a fact. @@ -133,7 +132,7 @@ public class Derivation implements WritableComparable<Derivation>, Cloneable { * in any step of the derivation. */ public boolean hasSourceNode(Value v) { - return v instanceof Resource && sourceNodes.contains((Resource) v); + return v instanceof Resource && sourceNodes.contains(v); } /** @@ -284,11 +283,8 @@ public class Derivation implements WritableComparable<Derivation>, Cloneable { || (rule != null && !rule.equals(other.rule))) { return false; } - if ((sources == null && other.sources != null) - || (sources != null && !sources.equals(other.sources))) { - return false; - } - return true; + return (sources != null || other.sources == null) + && (sources == null || sources.equals(other.sources)); } /** http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Fact.java ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Fact.java b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Fact.java index e168f5a..ad0ba14 100644 --- a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Fact.java +++ b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/Fact.java @@ -24,25 +24,24 @@ import java.io.DataOutput; import java.io.IOException; import java.nio.charset.StandardCharsets; +import org.apache.hadoop.io.WritableComparable; import org.apache.rya.api.domain.RyaStatement; import org.apache.rya.api.resolver.RyaToRdfConversions; - -import org.apache.hadoop.io.WritableComparable; -import org.openrdf.model.Literal; -import org.openrdf.model.Resource; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.ValueFactory; -import org.openrdf.model.impl.ContextStatementImpl; -import org.openrdf.model.impl.StatementImpl; -import org.openrdf.model.impl.ValueFactoryImpl; -import org.openrdf.model.vocabulary.RDF; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Literal; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.model.ValueFactory; +import org.eclipse.rdf4j.model.impl.SimpleValueFactory; +import org.eclipse.rdf4j.model.vocabulary.RDF; /** * Represents a fact used and/or generated by the reasoner. */ public class Fact implements WritableComparable<Fact>, Cloneable { + private static final ValueFactory VF = SimpleValueFactory.getInstance(); + Statement triple; // If this is a derived fact: @@ -71,17 +70,17 @@ public class Fact implements WritableComparable<Fact>, Cloneable { /** * A fact containing a triple and no generating rule. */ - public Fact(Resource s, URI p, Value o) { - this.triple = new StatementImpl(s, p, o); + public Fact(Resource s, IRI p, Value o) { + this.triple = VF.createStatement(s, p, o); } /** * A fact which contains a triple and was generated using a * particular rule by a reasoner for a particular node. */ - public Fact(Resource s, URI p, Value o, int iteration, + public Fact(Resource s, IRI p, Value o, int iteration, OwlRule rule, Resource node) { - this.triple = new StatementImpl(s, p, o); + this.triple = VF.createStatement(s, p, o); this.derivation = new Derivation(iteration, rule, node); } @@ -98,7 +97,7 @@ public class Fact implements WritableComparable<Fact>, Cloneable { } } - public URI getPredicate() { + public IRI getPredicate() { if (triple == null) { return null; } @@ -211,7 +210,7 @@ public class Fact implements WritableComparable<Fact>, Cloneable { } else { Resource s = getSubject(); - URI p = getPredicate(); + IRI p = getPredicate(); Value o = getObject(); sb.append("<").append(s.toString()).append(">").append(sep); sb.append("<").append(p.toString()).append(">").append(sep); @@ -293,17 +292,17 @@ public class Fact implements WritableComparable<Fact>, Cloneable { in.readFully(tripleBytes); String tripleString = new String(tripleBytes, StandardCharsets.UTF_8); String[] parts = tripleString.split(SEP); - ValueFactory factory = ValueFactoryImpl.getInstance(); + ValueFactory factory = SimpleValueFactory.getInstance(); String context = parts[0]; Resource s = null; - URI p = factory.createURI(parts[2]); + IRI p = factory.createIRI(parts[2]); Value o = null; // Subject: either bnode or URI if (parts[1].startsWith("_")) { s = factory.createBNode(parts[1].substring(2)); } else { - s = factory.createURI(parts[1]); + s = factory.createIRI(parts[1]); } // Object: literal, bnode, or URI if (parts[3].startsWith("_")) { @@ -325,20 +324,20 @@ public class Fact implements WritableComparable<Fact>, Cloneable { o = factory.createLiteral(label, lang); } else if (data.startsWith("^^<")) { - o = factory.createLiteral(label, factory.createURI( + o = factory.createLiteral(label, factory.createIRI( data.substring(3, data.length() - 1))); } } } else { - o = factory.createURI(parts[3]); + o = factory.createIRI(parts[3]); } // Create a statement with or without context if (context.isEmpty()) { - triple = new StatementImpl(s, p, o); + triple = VF.createStatement(s, p, o); } else { - triple = new ContextStatementImpl(s, p, o, factory.createURI(context)); + triple = VF.createStatement(s, p, o, factory.createIRI(context)); } } useful = in.readBoolean(); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/LocalReasoner.java ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/LocalReasoner.java b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/LocalReasoner.java index 13a21c4..921d0cf 100644 --- a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/LocalReasoner.java +++ b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/LocalReasoner.java @@ -25,12 +25,12 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.openrdf.model.Literal; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.vocabulary.OWL; -import org.openrdf.model.vocabulary.RDF; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Literal; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.model.vocabulary.OWL; +import org.eclipse.rdf4j.model.vocabulary.RDF; /** * Perform reasoning with respect to a particular node, given a global schema. @@ -112,7 +112,7 @@ public class LocalReasoner extends AbstractReasoner { } // Otherwise, consider the semantics of the statement: Resource subject = fact.getSubject(); - URI predURI = fact.getPredicate(); + IRI predURI = fact.getPredicate(); Value object = fact.getObject(); boolean relevantToSubject = false; boolean relevantToObject = false; @@ -185,7 +185,7 @@ public class LocalReasoner extends AbstractReasoner { return Relevance.NONE; } // Otherwise, consider the semantics of the statement: - URI predURI = fact.getPredicate(); + IRI predURI = fact.getPredicate(); Value object = fact.getObject(); boolean relevantToSubject = false; boolean relevantToObject = false; @@ -289,9 +289,9 @@ public class LocalReasoner extends AbstractReasoner { TypeReasoner types; // Keep track of statements whose properties might make them relevant later - Map<URI, List<Fact>> transitiveIncoming = new HashMap<>(); - Map<URI, List<Fact>> asymmetricIncoming = new HashMap<>(); - Map<URI, List<Fact>> disjointOutgoing = new HashMap<>(); + Map<IRI, List<Fact>> transitiveIncoming = new HashMap<>(); + Map<IRI, List<Fact>> asymmetricIncoming = new HashMap<>(); + Map<IRI, List<Fact>> disjointOutgoing = new HashMap<>(); // Only combine transitive paths of a certain size, based on the current // iteration, to avoid duplicate derivations and unnecessary memory use. @@ -326,7 +326,7 @@ public class LocalReasoner extends AbstractReasoner { */ public void processFact(Fact fact) { Resource subject = fact.getSubject(); - URI pred = fact.getPredicate(); + IRI pred = fact.getPredicate(); Value object = fact.getObject(); // Whether this is a recursive call on a fact that's just been inferred boolean recursive = fact.getIteration() == currentIteration; @@ -360,11 +360,11 @@ public class LocalReasoner extends AbstractReasoner { * Process a triple in which this node is the subject. */ private void processOutgoing(Fact fact) { - URI predURI = fact.getPredicate(); + IRI predURI = fact.getPredicate(); Value object = fact.getObject(); OwlProperty prop = schema.getProperty(predURI); Set<Resource> restrictions = prop.getRestrictions(); - Set<URI> disjointProps = prop.getDisjointProperties(); + Set<IRI> disjointProps = prop.getDisjointProperties(); // RL rule prp-dom: Apply domain(s), if appropriate for (Resource type : prop.getDomain()) { types.processType(type, OwlRule.PRP_DOM, fact); @@ -374,7 +374,7 @@ public class LocalReasoner extends AbstractReasoner { // if the input fact was derived using this rule, we must have gotten // all the superproperties and don't need to apply them again. if (!fact.hasRule(OwlRule.PRP_SPO1)) { - for (URI superProp : prop.getSuperProperties()) { + for (IRI superProp : prop.getSuperProperties()) { // (everything is its own superproperty) if (superProp.equals(predURI)) { continue; @@ -384,7 +384,7 @@ public class LocalReasoner extends AbstractReasoner { } // RL rule prp-pdw: Check if this conflicts with any disjoint properties if (!disjointProps.isEmpty()) { - for (URI disjointProp : disjointProps) { + for (IRI disjointProp : disjointProps) { if (disjointOutgoing.containsKey(disjointProp)) { for (Fact other : disjointOutgoing.get(disjointProp)) { if (object.equals(other.getObject())) { @@ -474,14 +474,14 @@ public class LocalReasoner extends AbstractReasoner { */ private void processIncoming(Fact fact) { Resource subject = fact.getSubject(); - URI predURI = fact.getPredicate(); + IRI predURI = fact.getPredicate(); OwlProperty prop = schema.getProperty(predURI); // RL rule prp-rng: Apply range(s), if appropriate for (Resource type : prop.getRange()) { types.processType(type, OwlRule.PRP_RNG, fact); } // RL rules prp-inv1, prp-inv2: assert any inverse properties - for (URI inverseProp : prop.getInverseProperties()) { + for (IRI inverseProp : prop.getInverseProperties()) { collect(triple(node, inverseProp, subject, OwlRule.PRP_INV, fact)); } // RL rule prp-symp: Assert the symmetric statement if appropriate @@ -583,10 +583,10 @@ public class LocalReasoner extends AbstractReasoner { int sumOutgoingDisjoint = 0; int sumIncomingTransitive = 0; for (List<Fact> l : asymmetricIncoming.values()) { - sumIncomingAsymmetric += l.size();; + sumIncomingAsymmetric += l.size(); } for (List<Fact> l : disjointOutgoing.values()) { - sumOutgoingDisjoint += l.size();; + sumOutgoingDisjoint += l.size(); } int maxTransitiveSpan = (int) Math.pow(2, currentIteration); int[] distribution = new int[maxTransitiveSpan+1]; @@ -632,10 +632,10 @@ public class LocalReasoner extends AbstractReasoner { public int getNumStored() { int total = 0; for (List<Fact> l : asymmetricIncoming.values()) { - total += l.size();; + total += l.size(); } for (List<Fact> l : disjointOutgoing.values()) { - total += l.size();; + total += l.size(); } for (List<Fact> l : transitiveIncoming.values()) { total += l.size(); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OWL2.java ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OWL2.java b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OWL2.java index a24e8e8..eeab8b0 100644 --- a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OWL2.java +++ b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OWL2.java @@ -19,20 +19,20 @@ package org.apache.rya.reasoning; * under the License. */ -import org.openrdf.model.URI; -import org.openrdf.model.impl.ValueFactoryImpl; -import org.openrdf.model.vocabulary.OWL; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.impl.SimpleValueFactory; +import org.eclipse.rdf4j.model.vocabulary.OWL; /** - * Some useful OWL 2 URIs not in Sesame API. + * Some useful OWL 2 URIs not in RDF4J API. */ public class OWL2 { - private static URI uri(String local) { - return ValueFactoryImpl.getInstance().createURI(OWL.NAMESPACE, local); + private static IRI uri(String local) { + return SimpleValueFactory.getInstance().createIRI(OWL.NAMESPACE, local); } - public static final URI ASYMMETRICPROPERTY = uri("AsymmetricProperty"); - public static final URI IRREFLEXIVEPROPERTY = uri("IrreflexiveProperty"); - public static final URI PROPERTYDISJOINTWITH = uri("propertyDisjointWith"); - public static final URI ONCLASS = uri("onClass"); - public static final URI MAXQUALIFIEDCARDINALITY = uri("maxQualifiedCardinality"); + public static final IRI ASYMMETRICPROPERTY = uri("AsymmetricProperty"); + public static final IRI IRREFLEXIVEPROPERTY = uri("IrreflexiveProperty"); + public static final IRI PROPERTYDISJOINTWITH = uri("propertyDisjointWith"); + public static final IRI ONCLASS = uri("onClass"); + public static final IRI MAXQUALIFIEDCARDINALITY = uri("maxQualifiedCardinality"); } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlClass.java ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlClass.java b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlClass.java index 6da82ac..c3c60a8 100644 --- a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlClass.java +++ b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlClass.java @@ -23,10 +23,10 @@ import java.io.Serializable; import java.util.HashSet; import java.util.Set; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.vocabulary.OWL; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.model.vocabulary.OWL; /** * Contains all the schema information we might need about a class. @@ -318,8 +318,8 @@ public class OwlClass implements Serializable { /** * Get the onProperty relation(s) for this property restriction. */ - public Set<URI> getOnProperty() { - Set<URI> onp = new HashSet<>(); + public Set<IRI> getOnProperty() { + Set<IRI> onp = new HashSet<>(); for (OwlProperty prop : properties) { onp.add(prop.getURI()); } @@ -411,9 +411,9 @@ public class OwlClass implements Serializable { * is a subproperty of the other's. */ boolean onSubProperty(OwlClass other) { - Set<URI> otherProp = other.getOnProperty(); + Set<IRI> otherProp = other.getOnProperty(); for (OwlProperty prop : this.properties) { - Set<URI> intersection = prop.getSuperProperties(); + Set<IRI> intersection = prop.getSuperProperties(); intersection.retainAll(otherProp); if (!intersection.isEmpty()) { return true; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlProperty.java ---------------------------------------------------------------------- diff --git a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlProperty.java b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlProperty.java index 5443d7d..e745532 100644 --- a/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlProperty.java +++ b/extras/rya.reasoning/src/main/java/org/apache/rya/reasoning/OwlProperty.java @@ -23,8 +23,8 @@ import java.io.Serializable; import java.util.HashSet; import java.util.Set; -import org.openrdf.model.Resource; -import org.openrdf.model.URI; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Resource; /** * Contains all the schema information we might need about a property. @@ -65,7 +65,7 @@ import org.openrdf.model.URI; public class OwlProperty implements Serializable { private static final long serialVersionUID = 1L; - private URI uri; + private IRI uri; // Boolean qualities the property might have private boolean transitive = false; @@ -87,7 +87,7 @@ public class OwlProperty implements Serializable { // Restrictions on this property private Set<OwlClass> restrictions = new HashSet<OwlClass>(); - OwlProperty(URI uri) { + OwlProperty(IRI uri) { this.uri = uri; } @@ -115,7 +115,7 @@ public class OwlProperty implements Serializable { } boolean addRestriction(OwlClass r) { return restrictions.add(r); } - public void setURI(URI uri) { this.uri = uri; } + public void setURI(IRI uri) { this.uri = uri; } void setTransitive() { transitive = true; } void setSymmetric() { symmetric = true; } void setAsymmetric() { asymmetric = true; } @@ -123,7 +123,7 @@ public class OwlProperty implements Serializable { void setInverseFunctional() { inverseFunctional = true; } void setIrreflexive() { irreflexive = true; } - public URI getURI() { return uri; } + public IRI getURI() { return uri; } public boolean isTransitive() { return transitive; } public boolean isSymmetric() { return symmetric; } public boolean isAsymmetric() { return asymmetric; } @@ -185,8 +185,8 @@ public class OwlProperty implements Serializable { /** * Get all the superproperties of this subproperty. */ - public Set<URI> getSuperProperties() { - Set<URI> ancestors = new HashSet<>(); + public Set<IRI> getSuperProperties() { + Set<IRI> ancestors = new HashSet<>(); for (OwlProperty ancestor : superProperties) { ancestors.add(ancestor.uri); } @@ -199,8 +199,8 @@ public class OwlProperty implements Serializable { * Get all the equivalent properties for this property. * Apply RL rules scm-op and scm-dp: Every property is its own equivalent. */ - public Set<URI> getEquivalentProperties() { - Set<URI> equivalents = new HashSet<>(); + public Set<IRI> getEquivalentProperties() { + Set<IRI> equivalents = new HashSet<>(); for (OwlProperty other : superProperties) { if (other.superProperties.contains(this)) { equivalents.add(other.uri); @@ -214,8 +214,8 @@ public class OwlProperty implements Serializable { /** * Get all properties declared disjoint with this one. */ - public Set<URI> getDisjointProperties() { - Set<URI> disjoint = new HashSet<>(); + public Set<IRI> getDisjointProperties() { + Set<IRI> disjoint = new HashSet<>(); for (OwlProperty other : disjointProperties) { disjoint.add(other.uri); } @@ -225,8 +225,8 @@ public class OwlProperty implements Serializable { /** * Get all properties declared inverse of this one. */ - public Set<URI> getInverseProperties() { - Set<URI> inverse = new HashSet<>(); + public Set<IRI> getInverseProperties() { + Set<IRI> inverse = new HashSet<>(); for (OwlProperty other : inverseProperties) { inverse.add(other.uri); }