http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/JoinSegmentMatcher.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/JoinSegmentMatcher.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/JoinSegmentMatcher.java index 8f4e43a..6c5167b 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/JoinSegmentMatcher.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/JoinSegmentMatcher.java @@ -24,8 +24,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.evaluation.impl.ExternalSet; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.evaluation.impl.ExternalSet; import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -38,7 +38,6 @@ import com.google.common.base.Preconditions; * the QueryModelNodes in the JoinSegment. * */ - public class JoinSegmentMatcher<T extends ExternalSet> extends AbstractExternalSetMatcher<T> { private ExternalSetConverter<T> converter;
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/MatcherUtilities.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/MatcherUtilities.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/MatcherUtilities.java index 1f8e287..7c6a20a 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/MatcherUtilities.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/MatcherUtilities.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -17,30 +17,12 @@ * under the License. */ package org.apache.rya.indexing.external.matching; -/* - * 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 org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.Join; -import org.openrdf.query.algebra.LeftJoin; -import org.openrdf.query.algebra.Projection; -import org.openrdf.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.Join; +import org.eclipse.rdf4j.query.algebra.LeftJoin; +import org.eclipse.rdf4j.query.algebra.Projection; +import org.eclipse.rdf4j.query.algebra.TupleExpr; public class MatcherUtilities { http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegment.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegment.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegment.java index 6f3d409..9d79708 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegment.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegment.java @@ -27,13 +27,13 @@ import java.util.Set; import org.apache.rya.indexing.external.tupleSet.ExternalTupleSet; import org.apache.rya.rdftriplestore.inference.DoNotExpandSP; import org.apache.rya.rdftriplestore.utils.FixedStatementPattern; -import org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.Join; -import org.openrdf.query.algebra.LeftJoin; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.ValueExpr; -import org.openrdf.query.algebra.evaluation.impl.ExternalSet; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.Join; +import org.eclipse.rdf4j.query.algebra.LeftJoin; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.ValueExpr; +import org.eclipse.rdf4j.query.algebra.evaluation.impl.ExternalSet; import com.google.common.base.Preconditions; import com.google.common.collect.Sets; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegmentMatcher.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegmentMatcher.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegmentMatcher.java index a359d02..cc1b9d9 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegmentMatcher.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/OptionalJoinSegmentMatcher.java @@ -24,8 +24,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.evaluation.impl.ExternalSet; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.evaluation.impl.ExternalSet; import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -37,7 +37,6 @@ import com.google.common.base.Preconditions; * OptionalJoinSegment and ordered to match the ExternalSet query. * */ - public class OptionalJoinSegmentMatcher<T extends ExternalSet> extends AbstractExternalSetMatcher<T> { private ExternalSetConverter<T> converter; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeConsolidator.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeConsolidator.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeConsolidator.java index 9a2d3be..faf5c27 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeConsolidator.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeConsolidator.java @@ -27,9 +27,9 @@ import java.util.List; import java.util.SortedSet; import java.util.TreeSet; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.ValueExpr; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.ValueExpr; import com.google.common.base.Preconditions; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeListRater.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeListRater.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeListRater.java index e8b1553..7953661 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeListRater.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodeListRater.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -17,28 +17,10 @@ * under the License. */ package org.apache.rya.indexing.external.matching; -/* - * 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.List; -import org.openrdf.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; /** * Class used for determining an optimal query plan. It assigns a score http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodesToTupleExpr.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodesToTupleExpr.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodesToTupleExpr.java index 5bffb63..93dc80d 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodesToTupleExpr.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QueryNodesToTupleExpr.java @@ -24,11 +24,11 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.Join; -import org.openrdf.query.algebra.LeftJoin; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.Join; +import org.eclipse.rdf4j.query.algebra.LeftJoin; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.TupleExpr; import com.google.common.collect.Lists; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegment.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegment.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegment.java index a8f687e..ca492d7 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegment.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegment.java @@ -23,9 +23,9 @@ import java.util.List; import java.util.Set; import org.apache.rya.indexing.external.matching.QueryNodesToTupleExpr.TupleExprAndNodes; -import org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.evaluation.impl.ExternalSet; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.evaluation.impl.ExternalSet; /** * A QuerySegment represents a subset of a query to be compared to ExternalSets for http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegmentFactory.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegmentFactory.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegmentFactory.java index 0c1eb7e..9d1d3fe 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegmentFactory.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/QuerySegmentFactory.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -17,30 +17,12 @@ * under the License. */ package org.apache.rya.indexing.external.matching; -/* - * 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 org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.Join; -import org.openrdf.query.algebra.LeftJoin; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.evaluation.impl.ExternalSet; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.Join; +import org.eclipse.rdf4j.query.algebra.LeftJoin; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.evaluation.impl.ExternalSet; import com.google.common.base.Preconditions; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/TopOfQueryFilterRelocator.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/TopOfQueryFilterRelocator.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/TopOfQueryFilterRelocator.java index 6ebbe39..ada8329 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/TopOfQueryFilterRelocator.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/matching/TopOfQueryFilterRelocator.java @@ -24,11 +24,11 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.Projection; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.ValueExpr; -import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.Projection; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.ValueExpr; +import org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor; /** * Class consisting of a single utility method for relocating filters. @@ -73,7 +73,7 @@ public class TopOfQueryFilterRelocator { } - static class ProjectionAndFilterGatherer extends QueryModelVisitorBase<RuntimeException> { + static class ProjectionAndFilterGatherer extends AbstractQueryModelVisitor<RuntimeException> { Set<ValueExpr> filterCond = new HashSet<>(); Projection projection; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/AccumuloIndexSet.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/AccumuloIndexSet.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/AccumuloIndexSet.java index f1d56b8..20f5768 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/AccumuloIndexSet.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/AccumuloIndexSet.java @@ -44,6 +44,7 @@ import org.apache.rya.accumulo.pcj.iterators.IteratorCombiner; import org.apache.rya.accumulo.pcj.iterators.PCJKeyToCrossProductBindingSetIterator; import org.apache.rya.accumulo.pcj.iterators.PCJKeyToJoinBindingSetIterator; import org.apache.rya.api.RdfCloudTripleStoreConfiguration; +import org.apache.rya.api.domain.VarNameUtils; import org.apache.rya.api.utils.IteratorWrapper; import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.indexing.pcj.matching.PCJOptimizerUtilities; @@ -55,18 +56,19 @@ import org.apache.rya.indexing.pcj.storage.accumulo.BindingSetConverter.BindingS import org.apache.rya.indexing.pcj.storage.accumulo.PcjTables; import org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder; import org.apache.rya.rdftriplestore.evaluation.ExternalBatchingIterator; -import org.openrdf.model.Value; -import org.openrdf.query.Binding; -import org.openrdf.query.BindingSet; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.algebra.Projection; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.evaluation.QueryBindingSet; -import org.openrdf.query.impl.BindingImpl; -import org.openrdf.query.parser.ParsedTupleQuery; -import org.openrdf.query.parser.sparql.SPARQLParser; -import org.openrdf.sail.SailException; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.query.Binding; +import org.eclipse.rdf4j.query.BindingSet; +import org.eclipse.rdf4j.query.MalformedQueryException; +import org.eclipse.rdf4j.query.QueryEvaluationException; +import org.eclipse.rdf4j.query.algebra.Projection; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet; +import org.eclipse.rdf4j.query.impl.SimpleBinding; +import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; +import org.eclipse.rdf4j.query.parser.sparql.SPARQLParser; +import org.eclipse.rdf4j.sail.SailException; import com.google.common.base.Joiner; import com.google.common.base.Optional; @@ -77,8 +79,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; -import info.aduna.iteration.CloseableIteration; - /** * During query planning, this node is inserted into the parsed query to * represent part of the original query (a sub-query). This sub-query is the @@ -290,7 +290,7 @@ public class AccumuloIndexSet extends ExternalTupleSet implements } final List<BindingSet> crossProductBs = new ArrayList<>(); - final Map<String, org.openrdf.model.Value> constantConstraints = new HashMap<>(); + final Map<String, Value> constantConstraints = new HashMap<>(); final Set<Range> hashJoinRanges = new HashSet<>(); final Range EMPTY_RANGE = new Range("", true, "~", false); Range crossProductRange = EMPTY_RANGE; @@ -546,8 +546,8 @@ public class AccumuloIndexSet extends ExternalTupleSet implements final QueryBindingSet constants = new QueryBindingSet(); for (final String s : keys) { - if (s.startsWith("-const-")) { - constants.addBinding(new BindingImpl(s, getConstantValueMap() + if (VarNameUtils.isConstant(s)) { + constants.addBinding(new SimpleBinding(s, getConstantValueMap() .get(s))); } } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ExternalTupleSet.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ExternalTupleSet.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ExternalTupleSet.java index 48dc17e..e029114 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ExternalTupleSet.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ExternalTupleSet.java @@ -18,24 +18,22 @@ package org.apache.rya.indexing.external.tupleSet; * specific language governing permissions and limitations * under the License. */ - - - -import info.aduna.iteration.CloseableIteration; - import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import org.openrdf.query.BindingSet; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.algebra.Projection; -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.api.domain.VarNameUtils; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.query.BindingSet; +import org.eclipse.rdf4j.query.QueryEvaluationException; +import org.eclipse.rdf4j.query.algebra.Projection; +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.base.Joiner; import com.google.common.base.Preconditions; @@ -58,12 +56,16 @@ import com.google.common.collect.Sets; public abstract class ExternalTupleSet extends ExternalSet { public static final String VAR_ORDER_DELIM = ";"; - public static final String CONST_PREFIX = "-const-"; + /** + * @deprecated use {@link VarNameUtils#CONSTANT_PREFIX}. + */ + @Deprecated + public static final String CONST_PREFIX = VarNameUtils.CONSTANT_PREFIX; public static final String VALUE_DELIM = "\u0000"; private Projection tupleExpr; private Map<String, String> tableVarMap = Maps.newHashMap(); //maps vars in tupleExpr to var in stored binding sets private Map<String, Set<String>> supportedVarOrders = Maps.newHashMap(); //indicates supported var orders - private Map<String, org.openrdf.model.Value> valMap; + private Map<String, Value> valMap; public ExternalTupleSet() { } @@ -134,7 +136,7 @@ public abstract class ExternalTupleSet extends ExternalSet { return supportedVarOrders; } - public Map<String, org.openrdf.model.Value> getConstantValueMap() { + public Map<String, Value> getConstantValueMap() { return valMap; } @@ -166,7 +168,7 @@ public abstract class ExternalTupleSet extends ExternalSet { if (bindingNames.contains(s)) { bNames.add(s); bNamesWithConstants.add(s); - } else if(s.startsWith(CONST_PREFIX)) { + } else if(VarNameUtils.isConstant(s)) { bNamesWithConstants.add(s); } } @@ -202,7 +204,7 @@ public abstract class ExternalTupleSet extends ExternalSet { */ private void updateSupportedVarOrderMap() { - Preconditions.checkArgument(supportedVarOrders.size() != 0);; + Preconditions.checkArgument(supportedVarOrders.size() != 0); final Map<String, Set<String>> newSupportedOrders = Maps.newHashMap(); final BiMap<String, String> biMap = HashBiMap.create(tableVarMap) .inverse(); @@ -262,11 +264,7 @@ public abstract class ExternalTupleSet extends ExternalSet { return false; } else { final ExternalTupleSet arg = (ExternalTupleSet) other; - if (this.getTupleExpr().equals(arg.getTupleExpr())) { - return true; - } else { - return false; - } + return this.getTupleExpr().equals(arg.getTupleExpr()); } } @@ -277,7 +275,7 @@ public abstract class ExternalTupleSet extends ExternalSet { return result; } - private Map<String, org.openrdf.model.Value> getValMap() { + private Map<String, Value> getValMap() { ValueMapVisitor valMapVis = new ValueMapVisitor(); tupleExpr.visit(valMapVis); return valMapVis.getValMap(); @@ -290,16 +288,16 @@ public abstract class ExternalTupleSet extends ExternalSet { * create binding sets from range scan */ private class ValueMapVisitor extends - QueryModelVisitorBase<RuntimeException> { - Map<String, org.openrdf.model.Value> valMap = Maps.newHashMap(); + AbstractQueryModelVisitor<RuntimeException> { + Map<String, Value> valMap = Maps.newHashMap(); - public Map<String, org.openrdf.model.Value> getValMap() { + public Map<String, Value> getValMap() { return valMap; } @Override public void meet(Var node) { - if (node.getName().startsWith("-const-")) { + if (VarNameUtils.isConstant(node.getName())) { valMap.put(node.getName(), node.getValue()); } } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ParsedQueryUtil.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ParsedQueryUtil.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ParsedQueryUtil.java index 98d61e7..3c43808 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ParsedQueryUtil.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/ParsedQueryUtil.java @@ -22,15 +22,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.concurrent.atomic.AtomicReference; -import edu.umd.cs.findbugs.annotations.DefaultAnnotation; -import edu.umd.cs.findbugs.annotations.NonNull; - -import org.openrdf.query.algebra.Projection; -import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; -import org.openrdf.query.parser.ParsedQuery; +import org.eclipse.rdf4j.query.algebra.Projection; +import org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor; +import org.eclipse.rdf4j.query.parser.ParsedQuery; import com.google.common.base.Optional; +import edu.umd.cs.findbugs.annotations.DefaultAnnotation; +import edu.umd.cs.findbugs.annotations.NonNull; + /** * Utilities that help applications inspect {@link ParsedQuery} objects. */ @@ -49,7 +49,7 @@ public class ParsedQueryUtil { // When a projection is encountered for the requested index, store it in atomic reference and quit searching. final AtomicReference<Projection> projectionRef = new AtomicReference<>(); - query.getTupleExpr().visit(new QueryModelVisitorBase<RuntimeException>() { + query.getTupleExpr().visit(new AbstractQueryModelVisitor<RuntimeException>() { @Override public void meet(Projection projection) { projectionRef.set(projection); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/SimpleExternalTupleSet.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/SimpleExternalTupleSet.java b/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/SimpleExternalTupleSet.java index 02d0a58..cef49db 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/SimpleExternalTupleSet.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/external/tupleSet/SimpleExternalTupleSet.java @@ -21,14 +21,12 @@ package org.apache.rya.indexing.external.tupleSet; import java.util.ArrayList; import java.util.List; -import org.openrdf.query.BindingSet; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.algebra.Projection; -import org.openrdf.query.algebra.QueryModelVisitor; - import com.google.common.base.Joiner; - -import info.aduna.iteration.CloseableIteration; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; +import org.eclipse.rdf4j.query.BindingSet; +import org.eclipse.rdf4j.query.QueryEvaluationException; +import org.eclipse.rdf4j.query.algebra.Projection; +import org.eclipse.rdf4j.query.algebra.QueryModelVisitor; /** * This a testing class to create mock pre-computed join nodes in order to http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java index 1c4c2fa..36839b3 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java @@ -39,10 +39,11 @@ import org.apache.rya.mongodb.batch.MongoDbBatchWriterConfig; import org.apache.rya.mongodb.batch.MongoDbBatchWriterException; import org.apache.rya.mongodb.batch.MongoDbBatchWriterUtils; import org.apache.rya.mongodb.batch.collection.DbCollectionType; -import org.openrdf.model.Literal; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.query.QueryEvaluationException; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Literal; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.query.QueryEvaluationException; import com.mongodb.DB; import com.mongodb.DBCollection; @@ -51,8 +52,6 @@ import com.mongodb.DBObject; import com.mongodb.MongoClient; import com.mongodb.QueryBuilder; -import info.aduna.iteration.CloseableIteration; - /** * Secondary Indexer using MondoDB * @param <T> - The {@link AbstractMongoIndexingStorageStrategy} this indexer uses. @@ -68,7 +67,7 @@ public abstract class AbstractMongoIndexer<T extends IndexingMongoDBStorageStrat protected String dbName; protected DB db; protected DBCollection collection; - protected Set<URI> predicates; + protected Set<IRI> predicates; protected T storageStrategy; @@ -129,7 +128,7 @@ public abstract class AbstractMongoIndexer<T extends IndexingMongoDBStorageStrat } @Override - public Set<URI> getIndexablePredicates() { + public Set<IRI> getIndexablePredicates() { return predicates; } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/IndexingMongoDBStorageStrategy.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/IndexingMongoDBStorageStrategy.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/IndexingMongoDBStorageStrategy.java index eebc7b7..dd7d47d 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/IndexingMongoDBStorageStrategy.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/IndexingMongoDBStorageStrategy.java @@ -21,14 +21,12 @@ package org.apache.rya.indexing.mongodb; import java.util.Set; -import org.openrdf.model.URI; - import com.mongodb.BasicDBObject; import com.mongodb.DBObject; import com.mongodb.QueryBuilder; - import org.apache.rya.indexing.StatementConstraints; import org.apache.rya.mongodb.dao.SimpleMongoDBStorageStrategy; +import org.eclipse.rdf4j.model.IRI; public class IndexingMongoDBStorageStrategy extends SimpleMongoDBStorageStrategy { public DBObject getQuery(final StatementConstraints contraints) { @@ -38,9 +36,9 @@ public class IndexingMongoDBStorageStrategy extends SimpleMongoDBStorageStrategy } if (contraints.hasPredicates()){ - final Set<URI> predicates = contraints.getPredicates(); + final Set<IRI> predicates = contraints.getPredicates(); if (predicates.size() > 1){ - for (final URI pred : predicates){ + for (final IRI pred : predicates){ final DBObject currentPred = new BasicDBObject(PREDICATE, pred.toString()); queryBuilder.or(currentPred); } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java index a50d293..f392b5e 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java @@ -40,8 +40,8 @@ import org.apache.rya.indexing.smarturi.SmartUriAdapter; import org.apache.rya.indexing.smarturi.SmartUriException; import org.apache.rya.indexing.smarturi.SmartUriStorage; import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration; -import org.openrdf.model.URI; -import org.openrdf.model.Value; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Value; import com.mongodb.MongoClient; import com.mongodb.MongoException; @@ -64,10 +64,10 @@ public class MongoDbSmartUri implements SmartUriStorage { } @Override - public void storeEntity(final RyaURI subject, final Map<URI, Value> map) throws SmartUriException { + public void storeEntity(final RyaURI subject, final Map<IRI, Value> map) throws SmartUriException { checkInit(); - final URI uri = SmartUriAdapter.serializeUri(subject, map); + final IRI uri = SmartUriAdapter.serializeUri(subject, map); final Entity entity = SmartUriAdapter.deserializeUriEntity(uri); // Create it. @@ -116,7 +116,7 @@ public class MongoDbSmartUri implements SmartUriStorage { } @Override - public ConvertingCursor<TypedEntity> queryEntity(final Type type, final Map<URI, Value> map) throws SmartUriException { + public ConvertingCursor<TypedEntity> queryEntity(final Type type, final Map<IRI, Value> map) throws SmartUriException { checkInit(); // Query it. http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java index ebdb914..3ccdc9a 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoIndexingConfiguration.java @@ -29,7 +29,7 @@ import org.apache.rya.indexing.mongodb.temporal.MongoTemporalIndexer; import org.apache.rya.mongodb.AbstractMongoDBRdfConfigurationBuilder; import org.apache.rya.mongodb.MongoDBRdfConfiguration; import org.apache.rya.mongodb.MongoDBRdfConfigurationBuilder; -import org.openrdf.sail.Sail; +import org.eclipse.rdf4j.sail.Sail; import com.google.common.base.Preconditions; @@ -44,7 +44,7 @@ import com.google.common.base.Preconditions; public class MongoIndexingConfiguration extends MongoDBRdfConfiguration { private MongoIndexingConfiguration() { - }; + } private MongoIndexingConfiguration(final Configuration conf) { super(conf); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java index 913a4fd..f13e4c1 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/freetext/MongoFreeTextIndexer.java @@ -25,13 +25,12 @@ import org.apache.rya.indexing.FreeTextIndexer; import org.apache.rya.indexing.StatementConstraints; import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.indexing.mongodb.AbstractMongoIndexer; -import org.openrdf.model.Statement; -import org.openrdf.query.QueryEvaluationException; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.query.QueryEvaluationException; import com.mongodb.QueryBuilder; -import info.aduna.iteration.CloseableIteration; - public class MongoFreeTextIndexer extends AbstractMongoIndexer<TextMongoDBStorageStrategy> implements FreeTextIndexer { private static final String COLLECTION_SUFFIX = "freetext"; private static final Logger logger = Logger.getLogger(MongoFreeTextIndexer.class); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjIndexSetProvider.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjIndexSetProvider.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjIndexSetProvider.java index d3fa07e..274651f 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjIndexSetProvider.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjIndexSetProvider.java @@ -31,7 +31,7 @@ import org.apache.rya.indexing.pcj.storage.mongo.MongoPcjDocuments; import org.apache.rya.indexing.pcj.storage.mongo.MongoPcjStorage; import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration; import org.apache.rya.mongodb.instance.MongoRyaInstanceDetailsRepository; -import org.openrdf.query.MalformedQueryException; +import org.eclipse.rdf4j.query.MalformedQueryException; import com.google.common.collect.Lists; import com.google.common.collect.Maps; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjQueryNode.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjQueryNode.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjQueryNode.java index c03ee99..265158a 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjQueryNode.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/pcj/MongoPcjQueryNode.java @@ -36,13 +36,14 @@ import org.apache.rya.indexing.pcj.storage.PcjException; import org.apache.rya.indexing.pcj.storage.mongo.MongoPcjDocuments; import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration; import org.apache.rya.rdftriplestore.evaluation.ExternalBatchingIterator; -import org.openrdf.query.BindingSet; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.algebra.Projection; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.parser.ParsedTupleQuery; -import org.openrdf.query.parser.sparql.SPARQLParser; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; +import org.eclipse.rdf4j.query.BindingSet; +import org.eclipse.rdf4j.query.MalformedQueryException; +import org.eclipse.rdf4j.query.QueryEvaluationException; +import org.eclipse.rdf4j.query.algebra.Projection; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.parser.ParsedTupleQuery; +import org.eclipse.rdf4j.query.parser.sparql.SPARQLParser; import com.google.common.base.Joiner; import com.google.common.base.Optional; @@ -51,7 +52,6 @@ import com.google.common.base.Strings; import edu.umd.cs.findbugs.annotations.DefaultAnnotation; import edu.umd.cs.findbugs.annotations.NonNull; -import info.aduna.iteration.CloseableIteration; /** * Indexing Node for PCJs expressions to be inserted into execution plans. http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java index fe8a7fa..653844f 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/temporal/MongoTemporalIndexer.java @@ -29,15 +29,14 @@ import org.apache.rya.indexing.TemporalInstant; import org.apache.rya.indexing.TemporalInterval; import org.apache.rya.indexing.accumulo.ConfigUtils; import org.apache.rya.indexing.mongodb.AbstractMongoIndexer; -import org.openrdf.model.Statement; -import org.openrdf.query.QueryEvaluationException; +import org.eclipse.rdf4j.common.iteration.CloseableIteration; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.query.QueryEvaluationException; import com.google.common.annotations.VisibleForTesting; import com.mongodb.DBCollection; import com.mongodb.QueryBuilder; -import info.aduna.iteration.CloseableIteration; - /** * Indexes MongoDB based on time instants or intervals. */ http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizer.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizer.java index 8067a85..adc8a52 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizer.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizer.java @@ -37,14 +37,13 @@ import org.apache.rya.indexing.mongodb.pcj.MongoPcjIndexSetProvider; import org.apache.rya.indexing.pcj.matching.provider.AbstractPcjIndexSetProvider; import org.apache.rya.indexing.pcj.matching.provider.AccumuloIndexSetProvider; import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration; -import org.openrdf.query.BindingSet; -import org.openrdf.query.Dataset; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.evaluation.QueryOptimizer; - -import com.google.common.base.Optional;; +import org.eclipse.rdf4j.query.BindingSet; +import org.eclipse.rdf4j.query.Dataset; +import org.eclipse.rdf4j.query.algebra.QueryModelNode; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.evaluation.QueryOptimizer; +import com.google.common.base.Optional; /** * {@link QueryOptimizer} which matches {@link TupleExpr}s associated with http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizerUtilities.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizerUtilities.java b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizerUtilities.java index 09a2706..274a053 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizerUtilities.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJOptimizerUtilities.java @@ -27,21 +27,21 @@ import java.util.Set; import org.apache.rya.indexing.external.matching.QuerySegment; import org.apache.rya.indexing.external.tupleSet.ExternalTupleSet; import org.apache.rya.indexing.pcj.matching.QueryVariableNormalizer.VarCollector; -import org.openrdf.query.algebra.Difference; -import org.openrdf.query.algebra.EmptySet; -import org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.Intersection; -import org.openrdf.query.algebra.Join; -import org.openrdf.query.algebra.LeftJoin; -import org.openrdf.query.algebra.Projection; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.StatementPattern; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.UnaryTupleOperator; -import org.openrdf.query.algebra.Union; -import org.openrdf.query.algebra.Var; -import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; -import org.openrdf.query.algebra.helpers.VarNameCollector; +import org.eclipse.rdf4j.query.algebra.Difference; +import org.eclipse.rdf4j.query.algebra.EmptySet; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.Intersection; +import org.eclipse.rdf4j.query.algebra.Join; +import org.eclipse.rdf4j.query.algebra.LeftJoin; +import org.eclipse.rdf4j.query.algebra.Projection; +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.UnaryTupleOperator; +import org.eclipse.rdf4j.query.algebra.Union; +import org.eclipse.rdf4j.query.algebra.Var; +import org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor; +import org.eclipse.rdf4j.query.algebra.helpers.VarNameCollector; import com.google.common.collect.Sets; @@ -114,7 +114,7 @@ public class PCJOptimizerUtilities { return visitor.node; } - static class ProjectionVisitor extends QueryModelVisitorBase<RuntimeException> { + static class ProjectionVisitor extends AbstractQueryModelVisitor<RuntimeException> { Projection node = null; @@ -155,7 +155,7 @@ public class PCJOptimizerUtilities { * */ private static class ValidQueryVisitor extends - QueryModelVisitorBase<RuntimeException> { + AbstractQueryModelVisitor<RuntimeException> { private boolean isValid = true; private final Set<QueryModelNode> filterSet = Sets.newHashSet(); @@ -232,7 +232,7 @@ public class PCJOptimizerUtilities { */ protected static class FilterRelocator extends - QueryModelVisitorBase<RuntimeException> { + AbstractQueryModelVisitor<RuntimeException> { protected Filter filter; protected Set<String> filterVars; @@ -356,7 +356,7 @@ public class PCJOptimizerUtilities { return lj.containsLeftJoin; } - protected static class LeftJoinVisitor extends QueryModelVisitorBase<RuntimeException> { + protected static class LeftJoinVisitor extends AbstractQueryModelVisitor<RuntimeException> { boolean containsLeftJoin = false; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJToSegmentConverter.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJToSegmentConverter.java b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJToSegmentConverter.java index 5744f41..4495bed 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJToSegmentConverter.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/PCJToSegmentConverter.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -17,35 +17,17 @@ * under the License. */ package org.apache.rya.indexing.pcj.matching; -/* - * 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 org.apache.rya.indexing.external.matching.ExternalSetConverter; import org.apache.rya.indexing.external.matching.JoinSegment; import org.apache.rya.indexing.external.matching.OptionalJoinSegment; import org.apache.rya.indexing.external.matching.QuerySegment; import org.apache.rya.indexing.external.tupleSet.ExternalTupleSet; -import org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.Join; -import org.openrdf.query.algebra.LeftJoin; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.Join; +import org.eclipse.rdf4j.query.algebra.LeftJoin; +import org.eclipse.rdf4j.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor; import com.google.common.base.Preconditions; @@ -75,11 +57,11 @@ public class PCJToSegmentConverter implements ExternalSetConverter<ExternalTuple * specified PCJ. * */ - static class PCJToJoinSegment extends QueryModelVisitorBase<RuntimeException> { + static class PCJToJoinSegment extends AbstractQueryModelVisitor<RuntimeException> { private JoinSegment<ExternalTupleSet> segment; - private PCJToJoinSegment(){}; + private PCJToJoinSegment(){} public QuerySegment<ExternalTupleSet> getSegment(final ExternalTupleSet pcj) { segment = null; @@ -103,11 +85,11 @@ public class PCJToSegmentConverter implements ExternalSetConverter<ExternalTuple * This class extracts the {@link OptionalJoinSegment} of PCJ query. * */ - static class PCJToOptionalJoinSegment extends QueryModelVisitorBase<RuntimeException> { + static class PCJToOptionalJoinSegment extends AbstractQueryModelVisitor<RuntimeException> { private OptionalJoinSegment<ExternalTupleSet> segment; - private PCJToOptionalJoinSegment(){}; + private PCJToOptionalJoinSegment(){} public QuerySegment<ExternalTupleSet> getSegment(final ExternalTupleSet pcj) { segment = null; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/QueryVariableNormalizer.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/QueryVariableNormalizer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/QueryVariableNormalizer.java index 2ed66c4..b2ed8d7 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/QueryVariableNormalizer.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/QueryVariableNormalizer.java @@ -18,8 +18,6 @@ package org.apache.rya.indexing.pcj.matching; * specific language governing permissions and limitations * under the License. */ - - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -29,20 +27,19 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; -import org.openrdf.model.Literal; -import org.openrdf.model.Value; -import org.openrdf.model.impl.ValueFactoryImpl; -import org.openrdf.query.algebra.Filter; -import org.openrdf.query.algebra.NAryValueOperator; -import org.openrdf.query.algebra.ProjectionElem; -import org.openrdf.query.algebra.ProjectionElemList; -import org.openrdf.query.algebra.QueryModelNode; -import org.openrdf.query.algebra.StatementPattern; -import org.openrdf.query.algebra.TupleExpr; -import org.openrdf.query.algebra.ValueConstant; -import org.openrdf.query.algebra.ValueExpr; -import org.openrdf.query.algebra.Var; -import org.openrdf.query.algebra.helpers.QueryModelVisitorBase; +import org.apache.rya.api.domain.VarNameUtils; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.query.algebra.Filter; +import org.eclipse.rdf4j.query.algebra.NAryValueOperator; +import org.eclipse.rdf4j.query.algebra.ProjectionElem; +import org.eclipse.rdf4j.query.algebra.ProjectionElemList; +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.ValueConstant; +import org.eclipse.rdf4j.query.algebra.ValueExpr; +import org.eclipse.rdf4j.query.algebra.Var; +import org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -72,7 +69,7 @@ public class QueryVariableNormalizer { // if tuples are equal, no need to do anything if (tuple1.equals(tuple2)) { - tupleList.add((TupleExpr) tuple1.clone()); + tupleList.add(tuple1.clone()); return tupleList; } @@ -399,11 +396,7 @@ public class QueryVariableNormalizer { if ((vars1.get(i) instanceof ValueConstant) && (vars2.get(i) instanceof Var)) { ValueConstant vc = (ValueConstant) vars1.get(i); - String s = vc.getValue().toString(); - if(vc.getValue() instanceof Literal) { - s = s.substring(1, s.length() - 1); - } - s = "-const-" + s; + final String s = VarNameUtils.createUniqueConstVarName(vc.getValue()); varList1.add(s); varList2.add(((Var)vars2.get(i)).getName()); } else if(!(vars1.get(i) instanceof ValueConstant)){ @@ -482,10 +475,7 @@ public class QueryVariableNormalizer { return false; } else { - if (hMap.get(key).equals(val)) { - return true; - } else - return false; + return hMap.get(key).equals(val); } @@ -728,7 +718,7 @@ public class QueryVariableNormalizer { - public static class ValueMapVisitor extends QueryModelVisitorBase<Exception> { + public static class ValueMapVisitor extends AbstractQueryModelVisitor<Exception> { private Map<String, Value> valMap = Maps.newHashMap(); @@ -749,13 +739,7 @@ public class QueryVariableNormalizer { public void meet(ValueConstant val) { - String s = val.getValue().toString(); - - if (val.getValue() instanceof Literal) { - s = s.substring(1, s.length() - 1); - } - - s = "-const-" + s; + final String s = VarNameUtils.createUniqueConstVarName(val.getValue()); valMap.put(s, val.getValue()); } @@ -767,7 +751,7 @@ public class QueryVariableNormalizer { - public static class NodeCollector extends QueryModelVisitorBase<Exception> { + public static class NodeCollector extends AbstractQueryModelVisitor<Exception> { private List<QueryModelNode> nodes = Lists.newArrayList(); @@ -784,11 +768,10 @@ public class QueryVariableNormalizer { } - public static class SpVarReNamer extends QueryModelVisitorBase<RuntimeException> { + public static class SpVarReNamer extends AbstractQueryModelVisitor<RuntimeException> { private final HashMap<String, String> hMap; private Map<String, Value> valMap; - private final ValueFactoryImpl vf = new ValueFactoryImpl(); public SpVarReNamer(HashMap<String, String> hMap, Map<String, Value> valMap) { this.valMap = valMap; @@ -798,7 +781,7 @@ public class QueryVariableNormalizer { public void meet(Var var) { if (!var.isConstant() && hMap.containsKey(var.getName())) { String val = hMap.get(var.getName()); - if (val.startsWith("-const-")) { + if (VarNameUtils.isConstant(val)) { var.setName(val); var.setValue(valMap.get(val)); var.setAnonymous(true); //TODO this might be a hack -- when are Vars not anonymous? @@ -813,11 +796,10 @@ public class QueryVariableNormalizer { - public static class FilterVarReNamer extends QueryModelVisitorBase<RuntimeException> { + public static class FilterVarReNamer extends AbstractQueryModelVisitor<RuntimeException> { private final HashMap<String, String> hMap; private Map<String, Value> valMap; - private final ValueFactoryImpl vf = new ValueFactoryImpl(); public FilterVarReNamer(HashMap<String, String> hMap, Map<String, Value> valMap) { this.valMap = valMap; @@ -830,7 +812,7 @@ public class QueryVariableNormalizer { if (!(var.getParentNode() instanceof NAryValueOperator)) { if (!var.isConstant() && hMap.containsKey(var.getName())) { String val = hMap.get(var.getName()); - if (val.startsWith("-const-")) { + if (VarNameUtils.isConstant(val)) { var.replaceWith(new ValueConstant(valMap.get(val))); } else { var.setName(val); @@ -852,7 +834,7 @@ public class QueryVariableNormalizer { Var var = (Var) v; if (!(var.isConstant() && hMap.containsKey(var.getName()))) { String val = hMap.get(var.getName()); - if (val.startsWith("-const-")) { + if (VarNameUtils.isConstant(val)) { newValues.add(new ValueConstant(valMap.get(val))); } else { var.setName(val); @@ -874,7 +856,7 @@ public class QueryVariableNormalizer { - public static class TupleVarRenamer extends QueryModelVisitorBase<RuntimeException> { + public static class TupleVarRenamer extends AbstractQueryModelVisitor<RuntimeException> { private final HashMap<String, String> varChanges; private Map<String, Value> valMap; @@ -918,7 +900,7 @@ public class QueryVariableNormalizer { } - public static class VarCollector extends QueryModelVisitorBase<RuntimeException> { + public static class VarCollector extends AbstractQueryModelVisitor<RuntimeException> { public static List<String> process(QueryModelNode node) { VarCollector collector = new VarCollector(); @@ -952,7 +934,7 @@ public class QueryVariableNormalizer { } } - public static class FilterVarValueCollector extends QueryModelVisitorBase<RuntimeException> { + public static class FilterVarValueCollector extends AbstractQueryModelVisitor<RuntimeException> { public static List<QueryModelNode> process(QueryModelNode node) { FilterVarValueCollector collector = new FilterVarValueCollector(); @@ -986,7 +968,7 @@ public class QueryVariableNormalizer { - public static class NormalizeQueryVisitor extends QueryModelVisitorBase<Exception> { + public static class NormalizeQueryVisitor extends AbstractQueryModelVisitor<Exception> { private TreeMap<String, List<QueryModelNode>> map = new TreeMap<String, List<QueryModelNode>>(); private TreeMap<String, Integer> varMap = new TreeMap<String, Integer>(); http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AbstractPcjIndexSetProvider.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AbstractPcjIndexSetProvider.java b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AbstractPcjIndexSetProvider.java index 984153a..b5dddbd 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AbstractPcjIndexSetProvider.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AbstractPcjIndexSetProvider.java @@ -34,7 +34,7 @@ import org.apache.rya.indexing.external.matching.QuerySegment; import org.apache.rya.indexing.external.tupleSet.ExternalTupleSet; import org.apache.rya.indexing.pcj.matching.PCJOptimizerUtilities; import org.apache.rya.indexing.pcj.matching.PCJToSegmentConverter; -import org.openrdf.query.algebra.TupleExpr; +import org.eclipse.rdf4j.query.algebra.TupleExpr; import com.google.common.annotations.VisibleForTesting; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AccumuloIndexSetProvider.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AccumuloIndexSetProvider.java b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AccumuloIndexSetProvider.java index 1fa3677..96ee75c 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AccumuloIndexSetProvider.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/pcj/matching/provider/AccumuloIndexSetProvider.java @@ -41,9 +41,9 @@ import org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageExce import org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage; import org.apache.rya.indexing.pcj.storage.accumulo.PcjTableNameFactory; import org.apache.rya.indexing.pcj.storage.accumulo.PcjTables; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.sail.SailException; +import org.eclipse.rdf4j.query.MalformedQueryException; +import org.eclipse.rdf4j.query.QueryEvaluationException; +import org.eclipse.rdf4j.sail.SailException; import com.google.common.collect.Lists; import com.google.common.collect.Maps; http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriAdapter.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriAdapter.java b/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriAdapter.java index f637d0d..b6fe556 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriAdapter.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriAdapter.java @@ -41,12 +41,13 @@ import org.apache.rya.api.resolver.RdfToRyaConversions; import org.apache.rya.api.resolver.RyaToRdfConversions; import org.apache.rya.indexing.entity.model.Entity; import org.apache.rya.indexing.entity.model.Property; +import org.eclipse.rdf4j.model.IRI; +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.joda.time.DateTime; import org.joda.time.format.ISODateTimeFormat; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.model.vocabulary.XMLSchema; import com.google.common.base.Charsets; import com.google.common.collect.HashBiMap; @@ -60,8 +61,9 @@ import com.google.common.primitives.Longs; * Interface for serializing and deserializing Smart URIs. */ public class SmartUriAdapter { + private static final ValueFactory VF = SimpleValueFactory.getInstance(); private static final String ENTITY_TYPE_MAP_URN = "urn://entityTypeMap"; - private static final URI RYA_TYPES_URI = new URIImpl("urn://ryaTypes"); + private static final IRI RYA_TYPES_URI = VF.createIRI("urn://ryaTypes"); /** * Private constructor to prevent instantiation. @@ -69,12 +71,12 @@ public class SmartUriAdapter { private SmartUriAdapter() { } - private static URI createTypePropertiesUri(final ImmutableMap<RyaURI, ImmutableMap<RyaURI, Property>> typeProperties) throws SmartUriException { + private static IRI createTypePropertiesUri(final ImmutableMap<RyaURI, ImmutableMap<RyaURI, Property>> typeProperties) throws SmartUriException { final List<NameValuePair> nameValuePairs = new ArrayList<>(); for (final Entry<RyaURI, ImmutableMap<RyaURI, Property>> typeProperty : typeProperties.entrySet()) { final RyaURI type = typeProperty.getKey(); final Map<RyaURI, Property> propertyMap = typeProperty.getValue(); - final URI typeUri = createIndividualTypeWithPropertiesUri(type, propertyMap); + final IRI typeUri = createIndividualTypeWithPropertiesUri(type, propertyMap); final String keyString = type.getDataType().getLocalName(); final String valueString = typeUri.getLocalName(); nameValuePairs.add(new BasicNameValuePair(keyString, valueString)); @@ -92,24 +94,24 @@ public class SmartUriAdapter { throw new SmartUriException("Unable to create type properties for the Smart URI", e); } - return new URIImpl(uriString); + return VF.createIRI(uriString); } private static String getShortNameForType(final RyaURI type) throws SmartUriException { - final String shortName = new URIImpl(type.getData()).getLocalName(); + final String shortName = VF.createIRI(type.getData()).getLocalName(); return shortName; } private static String addTypePrefixToUri(final String uriString, final String typePrefix) { - final String localName = new URIImpl(uriString).getLocalName(); + final String localName = VF.createIRI(uriString).getLocalName(); final String beginning = StringUtils.removeEnd(uriString, localName); final String formattedUriString = beginning + typePrefix + localName; return formattedUriString; } private static String removeTypePrefixFromUri(final String uriString, final String typePrefix) { - final String localName = new URIImpl(uriString).getLocalName(); + final String localName = VF.createIRI(uriString).getLocalName(); final String beginning = StringUtils.removeEnd(uriString, localName); final String replacement = localName.replaceFirst(typePrefix + ".", ""); final String formattedUriString = beginning + replacement; @@ -125,7 +127,7 @@ public class SmartUriAdapter { return map; } - private static URI createTypeMapUri(final List<RyaURI> types) throws SmartUriException { + private static IRI createTypeMapUri(final List<RyaURI> types) throws SmartUriException { final List<NameValuePair> nameValuePairs = new ArrayList<>(); for (final RyaURI type : types) { final String shortName = getShortNameForType(type); @@ -144,10 +146,10 @@ public class SmartUriAdapter { throw new SmartUriException("Unable to create type properties for the Smart URI", e); } - return new URIImpl(uriString); + return VF.createIRI(uriString); } - private static Map<RyaURI, String> convertUriToTypeMap(final URI typeMapUri) throws SmartUriException { + private static Map<RyaURI, String> convertUriToTypeMap(final IRI typeMapUri) throws SmartUriException { final Map<RyaURI, String> map = new HashMap<>(); java.net.URI uri; try { @@ -168,14 +170,14 @@ public class SmartUriAdapter { return map; } - private static URI createIndividualTypeWithPropertiesUri(final RyaURI type, final Map<RyaURI, Property> map) throws SmartUriException { + private static IRI createIndividualTypeWithPropertiesUri(final RyaURI type, final Map<RyaURI, Property> map) throws SmartUriException { final List<NameValuePair> nameValuePairs = new ArrayList<>(); for (final Entry<RyaURI, Property> entry : map.entrySet()) { final RyaURI key = entry.getKey(); final Property property = entry.getValue(); final RyaType ryaType = property.getValue(); - final String keyString = (new URIImpl(key.getData())).getLocalName(); + final String keyString = (VF.createIRI(key.getData())).getLocalName(); final Value value = RyaToRdfConversions.convertValue(ryaType); final String valueString = value.stringValue(); nameValuePairs.add(new BasicNameValuePair(keyString, valueString)); @@ -188,24 +190,24 @@ public class SmartUriAdapter { try { final java.net.URI uri = uriBuilder.build(); final String queryString = uri.getRawSchemeSpecificPart(); - uriString = type.getData()/*new URIImpl(type.getData()).getLocalName()*/ + queryString; + uriString = type.getData()/*VF.createIRI(type.getData()).getLocalName()*/ + queryString; } catch (final URISyntaxException e) { throw new SmartUriException("Unable to create type URI with all its properties for the Smart URI", e); } - return new URIImpl(uriString); + return VF.createIRI(uriString); } - private static Entity convertMapToEntity(final RyaURI subject, final Map<RyaURI, Map<URI, Value>> map) { + private static Entity convertMapToEntity(final RyaURI subject, final Map<RyaURI, Map<IRI, Value>> map) { final Entity.Builder entityBuilder = Entity.builder(); entityBuilder.setSubject(subject); - for (final Entry<RyaURI, Map<URI, Value>> typeEntry : map.entrySet()) { + for (final Entry<RyaURI, Map<IRI, Value>> typeEntry : map.entrySet()) { final RyaURI type = typeEntry.getKey(); - final Map<URI, Value> subMap = typeEntry.getValue(); + final Map<IRI, Value> subMap = typeEntry.getValue(); entityBuilder.setExplicitType(type); - for (final Entry<URI, Value> entry : subMap.entrySet()) { - final URI uri = entry.getKey(); + for (final Entry<IRI, Value> entry : subMap.entrySet()) { + final IRI uri = entry.getKey(); final Value value = entry.getValue(); final RyaURI ryaUri = new RyaURI(uri.stringValue()); final RyaURI ryaName = new RyaURI(uri.stringValue()); @@ -218,7 +220,7 @@ public class SmartUriAdapter { return entity; } - public static RyaURI findSubject(final URI uri) throws SmartUriException { + public static RyaURI findSubject(final IRI uri) throws SmartUriException { final String uriString = uri.stringValue(); return findSubject(uriString); } @@ -256,18 +258,18 @@ public class SmartUriAdapter { /** - * Serializes an {@link Entity} into a Smart {@link URI}. + * Serializes an {@link Entity} into a Smart {@link IRI}. * @param entity the {@link Entity} to serialize into a Smart URI. - * @return the Smart {@link URI}. + * @return the Smart {@link IRI}. * @throws SmartUriException */ - public static URI serializeUriEntity(final Entity entity) throws SmartUriException { - final Map<URI, Value> objectMap = new LinkedHashMap<>(); + public static IRI serializeUriEntity(final Entity entity) throws SmartUriException { + final Map<IRI, Value> objectMap = new LinkedHashMap<>(); // Adds the entity's types to the Smart URI final List<RyaURI> typeIds = entity.getExplicitTypeIds(); final Map<RyaURI, String> ryaTypeMap = createTypeMap(typeIds); - final URI ryaTypeMapUri = createTypeMapUri(typeIds); + final IRI ryaTypeMapUri = createTypeMapUri(typeIds); final RyaType valueRyaType = new RyaType(XMLSchema.ANYURI, ryaTypeMapUri.stringValue()); final Value typeValue = RyaToRdfConversions.convertValue(valueRyaType); objectMap.put(RYA_TYPES_URI, typeValue); @@ -285,7 +287,7 @@ public class SmartUriAdapter { final String valueString = property.getValue().getData(); final RyaType ryaType = property.getValue(); - //final RyaType ryaType = new RyaType(new URIImpl(key.getData()), valueString); + //final RyaType ryaType = new RyaType(VF.createIRI(key.getData()), valueString); final Value value = RyaToRdfConversions.convertValue(ryaType); @@ -293,7 +295,7 @@ public class SmartUriAdapter { if (StringUtils.isNotBlank(typeShortName)) { formattedKey = addTypePrefixToUri(formattedKey, typeShortName); } - final URI uri = new URIImpl(formattedKey); + final IRI uri = VF.createIRI(formattedKey); objectMap.put(uri, value); } } @@ -305,11 +307,11 @@ public class SmartUriAdapter { * Serializes a map into a URI. * @param subject the {@link RyaURI} subject of the Entity. Identifies the * thing that is being represented as an Entity. - * @param map the {@link Map} of {@link URI}s to {@link Value}s. - * @return the Smart {@link URI}. + * @param map the {@link Map} of {@link IRI}s to {@link Value}s. + * @return the Smart {@link IRI}. * @throws SmartUriException */ - public static URI serializeUri(final RyaURI subject, final Map<URI, Value> map) throws SmartUriException { + public static IRI serializeUri(final RyaURI subject, final Map<IRI, Value> map) throws SmartUriException { final String subjectData = subject.getData(); final int fragmentPosition = subjectData.indexOf("#"); String prefix = subjectData; @@ -331,15 +333,15 @@ public class SmartUriAdapter { } final List<NameValuePair> nameValuePairs = new ArrayList<>(); - for (final Entry<URI, Value> entry : map.entrySet()) { - final URI key = entry.getKey(); + for (final Entry<IRI, Value> entry : map.entrySet()) { + final IRI key = entry.getKey(); final Value value = entry.getValue(); nameValuePairs.add(new BasicNameValuePair(key.getLocalName(), value.stringValue())); } uriBuilder.setParameters(nameValuePairs); - URI uri = null; + IRI uri = null; try { if (fragmentPosition > -1) { final java.net.URI partialUri = uriBuilder.build(); @@ -347,10 +349,10 @@ public class SmartUriAdapter { final URIBuilder fragmentUriBuilder = new URIBuilder(new java.net.URI(prefix)); fragmentUriBuilder.setFragment(uriString); final String fragmentUriString = fragmentUriBuilder.build().toString(); - uri = new URIImpl(fragmentUriString); + uri = VF.createIRI(fragmentUriString); } else { final String uriString = uriBuilder.build().toString(); - uri = new URIImpl(uriString); + uri = VF.createIRI(uriString); } } catch (final URISyntaxException e) { throw new SmartUriException("Smart URI could not serialize the property map.", e); @@ -361,11 +363,11 @@ public class SmartUriAdapter { /** * Deserializes a URI into a map of URI's to values. - * @param uri the {@link URI}. - * @return the {@link Map} of {@link URI}s to {@link Value}s. + * @param uri the {@link IRI}. + * @return the {@link Map} of {@link IRI}s to {@link Value}s. * @throws SmartUriException */ - public static Map<URI, Value> deserializeUri(final URI uri) throws SmartUriException { + public static Map<IRI, Value> deserializeUri(final IRI uri) throws SmartUriException { final String uriString = uri.stringValue(); final int fragmentPosition = uriString.indexOf("#"); String prefix = uriString.substring(0, fragmentPosition + 1); @@ -386,28 +388,28 @@ public class SmartUriAdapter { } catch (final URISyntaxException e) { throw new SmartUriException("Unable to deserialize Smart URI", e); } - final Map<URI, Value> map = new HashMap<>(); + final Map<IRI, Value> map = new HashMap<>(); final RyaURI subject = findSubject(uri.stringValue()); final List<NameValuePair> parameters = uriBuilder.getQueryParams(); Map<RyaURI, String> entityTypeMap = new LinkedHashMap<>(); Map<String, RyaURI> invertedEntityTypeMap = new LinkedHashMap<>(); - final Map<RyaURI, Map<URI, Value>> fullMap = new LinkedHashMap<>(); + final Map<RyaURI, Map<IRI, Value>> fullMap = new LinkedHashMap<>(); for (final NameValuePair pair : parameters) { final String keyString = pair.getName(); final String valueString = pair.getValue(); - final URI keyUri = new URIImpl(prefix + keyString); + final IRI keyUri = VF.createIRI(prefix + keyString); final String decoded; try { decoded = URLDecoder.decode(valueString, Charsets.UTF_8.name()); } catch (final UnsupportedEncodingException e) { throw new SmartUriException("", e); } - final URI type = TypeDeterminer.determineType(decoded); + final IRI type = TypeDeterminer.determineType(decoded); if (type == XMLSchema.ANYURI) { if (keyString.equals(RYA_TYPES_URI.getLocalName())) { - entityTypeMap = convertUriToTypeMap(new URIImpl(decoded)); + entityTypeMap = convertUriToTypeMap(VF.createIRI(decoded)); invertedEntityTypeMap = HashBiMap.create(entityTypeMap).inverse(); } } else { @@ -420,7 +422,7 @@ public class SmartUriAdapter { final Value value = RyaToRdfConversions.convertValue(ryaType); final String formattedKeyUriString = removeTypePrefixFromUri(keyUri.stringValue(), keyPrefix); - final URI formattedKeyUri = new URIImpl(formattedKeyUriString); + final IRI formattedKeyUri = VF.createIRI(formattedKeyUriString); map.put(formattedKeyUri, value); } @@ -428,7 +430,7 @@ public class SmartUriAdapter { return map; } - public static Entity deserializeUriEntity(final URI uri) throws SmartUriException { + public static Entity deserializeUriEntity(final IRI uri) throws SmartUriException { final String uriString = uri.stringValue(); final int fragmentPosition = uriString.indexOf("#"); String prefix = uriString.substring(0, fragmentPosition + 1); @@ -455,22 +457,22 @@ public class SmartUriAdapter { final List<NameValuePair> parameters = uriBuilder.getQueryParams(); Map<RyaURI, String> entityTypeMap = new LinkedHashMap<>(); Map<String, RyaURI> invertedEntityTypeMap = new LinkedHashMap<>(); - final Map<RyaURI, Map<URI, Value>> fullMap = new LinkedHashMap<>(); + final Map<RyaURI, Map<IRI, Value>> fullMap = new LinkedHashMap<>(); for (final NameValuePair pair : parameters) { final String keyString = pair.getName(); final String valueString = pair.getValue(); - final URI keyUri = new URIImpl(prefix + keyString); + final IRI keyUri = VF.createIRI(prefix + keyString); final String decoded; try { decoded = URLDecoder.decode(valueString, Charsets.UTF_8.name()); } catch (final UnsupportedEncodingException e) { throw new SmartUriException("", e); } - final URI type = TypeDeterminer.determineType(decoded); + final IRI type = TypeDeterminer.determineType(decoded); if (type == XMLSchema.ANYURI) { if (keyString.equals(RYA_TYPES_URI.getLocalName())) { - entityTypeMap = convertUriToTypeMap(new URIImpl(decoded)); + entityTypeMap = convertUriToTypeMap(VF.createIRI(decoded)); invertedEntityTypeMap = HashBiMap.create(entityTypeMap).inverse(); } } else { @@ -483,11 +485,11 @@ public class SmartUriAdapter { final Value value = RyaToRdfConversions.convertValue(ryaType); final String formattedKeyUriString = removeTypePrefixFromUri(keyUri.stringValue(), keyPrefix); - final URI formattedKeyUri = new URIImpl(formattedKeyUriString); - final Map<URI, Value> map = fullMap.get(keyCorrespondingType); + final IRI formattedKeyUri = VF.createIRI(formattedKeyUriString); + final Map<IRI, Value> map = fullMap.get(keyCorrespondingType); if (map == null) { - final Map<URI, Value> subMap = new HashMap<>(); + final Map<IRI, Value> subMap = new HashMap<>(); subMap.put(formattedKeyUri, value); fullMap.put(keyCorrespondingType, subMap); } else { @@ -507,7 +509,7 @@ public class SmartUriAdapter { private TypeDeterminer() { } - private static URI determineType(final String data) { + private static IRI determineType(final String data) { if (Ints.tryParse(data) != null) { return XMLSchema.INTEGER; } else if (Doubles.tryParse(data) != null) { @@ -564,7 +566,7 @@ public class SmartUriAdapter { private static boolean isUri(final String data) { try { final String decoded = URLDecoder.decode(data, Charsets.UTF_8.name()); - new URIImpl(decoded); + VF.createIRI(decoded); return true; } catch (final IllegalArgumentException | UnsupportedEncodingException e) { // not a URI @@ -573,12 +575,12 @@ public class SmartUriAdapter { } } - public static Map<URI, Value> entityToValueMap(final Entity entity) { - final Map<URI, Value> map = new LinkedHashMap<>(); + public static Map<IRI, Value> entityToValueMap(final Entity entity) { + final Map<IRI, Value> map = new LinkedHashMap<>(); for (final Entry<RyaURI, ImmutableMap<RyaURI, Property>> entry : entity.getProperties().entrySet()) { for (final Entry<RyaURI, Property> property : entry.getValue().entrySet()) { final RyaURI propertyKey = property.getKey(); - final URI uri = new URIImpl(propertyKey.getData()); + final IRI uri = VF.createIRI(propertyKey.getData()); final Property propertyValue = property.getValue(); final Value value = RyaToRdfConversions.convertValue(propertyValue.getValue()); map.put(uri, value); @@ -588,15 +590,15 @@ public class SmartUriAdapter { } /** - * Converts a {@link Map} of {@link URI}/{@link Value}s to a {@link Set} of + * Converts a {@link Map} of {@link IRI}/{@link Value}s to a {@link Set} of * {@link Property}s. - * @param map the {@link Map} of {@link URI}/{@link Value}. + * @param map the {@link Map} of {@link IRI}/{@link Value}. * @return the {@link Set} of {@link Property}s. */ - public static Set<Property> mapToProperties(final Map<URI, Value> map) { + public static Set<Property> mapToProperties(final Map<IRI, Value> map) { final Set<Property> properties = new LinkedHashSet<>(); - for (final Entry<URI, Value> entry : map.entrySet()) { - final URI uri = entry.getKey(); + for (final Entry<IRI, Value> entry : map.entrySet()) { + final IRI uri = entry.getKey(); final Value value = entry.getValue(); final RyaURI ryaUri = new RyaURI(uri.stringValue()); @@ -608,10 +610,10 @@ public class SmartUriAdapter { return properties; } - public static Map<URI, Value> propertiesToMap(final Set<Property> properties) { - final Map<URI, Value> map = new LinkedHashMap<>(); + public static Map<IRI, Value> propertiesToMap(final Set<Property> properties) { + final Map<IRI, Value> map = new LinkedHashMap<>(); for (final Property property : properties) { - final URI uri = new URIImpl(property.getName().getData()); + final IRI uri = VF.createIRI(property.getName().getData()); final Value value = RyaToRdfConversions.convertValue(property.getValue()); map.put(uri, value); } http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/81b99327/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriStorage.java ---------------------------------------------------------------------- diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriStorage.java b/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriStorage.java index 1043d42..03c2dbb 100644 --- a/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriStorage.java +++ b/extras/indexing/src/main/java/org/apache/rya/indexing/smarturi/SmartUriStorage.java @@ -26,8 +26,8 @@ import org.apache.rya.indexing.entity.model.Type; import org.apache.rya.indexing.entity.model.TypedEntity; import org.apache.rya.indexing.entity.storage.mongo.ConvertingCursor; import org.calrissian.mango.collect.CloseableIterator; -import org.openrdf.model.URI; -import org.openrdf.model.Value; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Value; /** * Interface for interacting with a Smart URI's datastore. @@ -37,10 +37,10 @@ public interface SmartUriStorage { * Stores the map into the datastore. * @param subject the {@link RyaURI} subject of the Entity. Identifies the * thing that is being represented as an Entity. - * @param map the {@link Map} of {@link URI}s to {@link Value}s. + * @param map the {@link Map} of {@link IRI}s to {@link Value}s. * @throws SmartUriException */ - public void storeEntity(final RyaURI subject, final Map<URI, Value> map) throws SmartUriException; + public void storeEntity(final RyaURI subject, final Map<IRI, Value> map) throws SmartUriException; /** * Stores the entity into the datastore. @@ -69,10 +69,10 @@ public interface SmartUriStorage { /** * Queries the datastore for the map. * @param type the type associated with the entity values. - * @param map the {@link Map} of {@link URI}s to {@link Value}s. + * @param map the {@link Map} of {@link IRI}s to {@link Value}s. * @return a {@link CloseableIterator} over the {@link TypedEntity}s that * match the search parameters. * @throws SmartUriException */ - public ConvertingCursor<TypedEntity> queryEntity(final Type type, final Map<URI, Value> map) throws SmartUriException; + public ConvertingCursor<TypedEntity> queryEntity(final Type type, final Map<IRI, Value> map) throws SmartUriException; } \ No newline at end of file
