You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2015/04/23 21:56:55 UTC
[39/51] [partial] jena git commit: Rename com.hp.hpl.jena.* as
org.apache.jena.*
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java
deleted file mode 100644
index 96ed513..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPattern2Join.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.optimize;
-
-import java.util.List ;
-
-import com.hp.hpl.jena.graph.Triple ;
-import com.hp.hpl.jena.sparql.algebra.Op ;
-import com.hp.hpl.jena.sparql.algebra.TransformCopy ;
-import com.hp.hpl.jena.sparql.algebra.op.* ;
-import com.hp.hpl.jena.sparql.core.BasicPattern ;
-import com.hp.hpl.jena.sparql.core.Quad ;
-import com.hp.hpl.jena.sparql.core.QuadPattern ;
-
-/** Expand to joins of triples and quads. */
-public class TransformPattern2Join extends TransformCopy
-{
- /*
- * Get standard shaped trees?
- * Alternative is hard flatteniing to (sequence of all the quads, triples)
- */
-
- @Override
- public Op transform(OpBGP opBGP) { return expand(opBGP.getPattern()) ; }
-
- @Override
- public Op transform(OpQuadPattern quadPattern) { return expand(quadPattern.getPattern()) ; }
-
- @Override
- public Op transform(OpSequence opSeq, List<Op> elts) { return expand(opSeq, elts) ; }
-
-// @Override
-// public Op transform(OpJoin opJoin, Op left, Op right)
-// { return super.transform(opJoin, left, right) ; }
-
- private static Op expand(BasicPattern bgp)
- {
- if ( bgp.getList().isEmpty() )
- return OpTable.unit() ;
- Op op = null ;
- for ( Triple t : bgp.getList() )
- {
- OpTriple x = new OpTriple(t) ;
- op = join(op, x) ;
- }
- return op ;
- }
-
- private static Op expand(QuadPattern quads)
- {
- if ( quads.getList().isEmpty() )
- return OpTable.unit() ;
- Op op = null ;
- for ( Quad q : quads.getList() )
- {
- OpQuad x = new OpQuad(q) ;
- op = join(op, x) ;
- }
- return op ;
- }
-
- private static Op expand(OpSequence opSeq, List<Op> elts)
- {
- Op x = null ;
- // shape choices.
- for ( Op op : elts )
- x = join(x, op) ;
- return x ;
- }
-
- private static Op join(Op left, Op right)
- {
- return OpJoin.createReduce(left, right) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPromoteTableEmpty.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPromoteTableEmpty.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPromoteTableEmpty.java
deleted file mode 100644
index 84aec62..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPromoteTableEmpty.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.optimize;
-
-import com.hp.hpl.jena.sparql.algebra.Op;
-import com.hp.hpl.jena.sparql.algebra.TransformCopy;
-import com.hp.hpl.jena.sparql.algebra.op.OpAssign;
-import com.hp.hpl.jena.sparql.algebra.op.OpExtend;
-import com.hp.hpl.jena.sparql.algebra.op.OpGraph;
-import com.hp.hpl.jena.sparql.algebra.op.OpJoin;
-import com.hp.hpl.jena.sparql.algebra.op.OpLeftJoin;
-import com.hp.hpl.jena.sparql.algebra.op.OpMinus;
-import com.hp.hpl.jena.sparql.algebra.op.OpTable;
-import com.hp.hpl.jena.sparql.algebra.op.OpUnion;
-
-/**
- * Optimizer that ensures that <strong>table empty</strong> is promoted as high
- * up a query as is possible
- * <p>
- * <strong>table empty</strong> is an operator that may be introduced into the
- * algebra by other optimizations and represents the case where the optimizer
- * can a priori determine that some portion of a query will produce no results.
- * The classic example of this are {@code FILTER} clauses that may be determined
- * to always return false and thus negate the need to evaluate their inner
- * operations.
- * </p>
- * <p>
- * Other optimizers introduce <strong>table empty</strong> at the point in the
- * query where they are optimizing, often its presence in a query may render a
- * larger portion of even the entire query superfluous so this optimizer is
- * designed to promote it up through the query as necessary.
- * </p>
- * <p>
- * As detailed below this is not guaranteed to eliminate all portions of a query
- * rather it aims to eliminate portions where not doing so can cause expensive
- * and unnecessary evaluation to happen e.g. evaluating the left hand side of a
- * join (which may itself be a deeply nested operator) only to join it with
- * table empty and thus discard all the work that had been done.
- * </p>
- * <h3>Table Empty Promotions</h3>
- * <p>
- * The optimizer makes the following promotions:
- * </p>
- * <ul>
- * <li>Graph over table empty => table empty</li>
- * <li>Assign/Extend over table empty => table empty</li>
- * <li>Join where either side is table empty => table empty</li>
- * <li>Left Join:
- * <ul>
- * <li>If LHS is table empty => table empty</li>
- * <li>If RHS is table empty => LHS</li>
- * </ul>
- * </li>
- * <li>Union:
- * <ul>
- * <li>If both sides are table empty => table empty</li>
- * <li>If one side is table empty => other side</li>
- * </ul>
- * </li>
- * <li>Minus:
- * <ul>
- * <li>If LHS is table empty => table empty</li>
- * <li>If RHS is table empty => LHS</li>
- * </ul>
- * </li>
- * </ul>
- * <p>
- * All other operators are left untouched either because it cannot be promoted
- * through them or because doing so has no clear benefit since applying them
- * over table empty should be minimal work anyway.
- * </p>
- */
-public class TransformPromoteTableEmpty extends TransformCopy {
-
- @Override
- public Op transform(OpGraph opGraph, Op subOp) {
- if (isTableEmpty(subOp)) {
- return subOp;
- }
- return super.transform(opGraph, subOp);
- }
-
- @Override
- public Op transform(OpAssign opAssign, Op subOp) {
- if (isTableEmpty(subOp)) {
- return subOp;
- }
- return super.transform(opAssign, subOp);
- }
-
- @Override
- public Op transform(OpExtend opExtend, Op subOp) {
- if (isTableEmpty(subOp)) {
- return subOp;
- }
- return super.transform(opExtend, subOp);
- }
-
- @Override
- public Op transform(OpJoin opJoin, Op left, Op right) {
- // If either side is table empty return table empty
- if (isTableEmpty(left) || isTableEmpty(right)) {
- return OpTable.empty();
- }
- return super.transform(opJoin, left, right);
- }
-
- @Override
- public Op transform(OpLeftJoin opLeftJoin, Op left, Op right) {
- // If LHS is table empty return table empty
- // If RHS is table empty can eliminate left join and just leave LHS
- if (isTableEmpty(left)) {
- return OpTable.empty();
- } else if (isTableEmpty(right)) {
- return left;
- }
- return super.transform(opLeftJoin, left, right);
- }
-
- @Override
- public Op transform(OpMinus opMinus, Op left, Op right) {
- // If LHS is table empty return table empty
- // If RHS is table empty can eliminate minus and just leave LHS since no
- // shared variables means no effect
- if (isTableEmpty(left)) {
- return OpTable.empty();
- } else if (isTableEmpty(right)) {
- return left;
- }
- return super.transform(opMinus, left, right);
- }
-
- @Override
- public Op transform(OpUnion opUnion, Op left, Op right) {
- // If one and only one side is table empty return other side
- // If both are table empty return table empty
- if (isTableEmpty(left)) {
- if (isTableEmpty(right)) {
- return OpTable.empty();
- } else {
- return right;
- }
- } else if (isTableEmpty(right)) {
- return left;
- }
- return super.transform(opUnion, left, right);
- }
-
- private boolean isTableEmpty(Op op) {
- if (op instanceof OpTable) {
- return ((OpTable) op).getTable().isEmpty();
- } else {
- return false;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java
deleted file mode 100644
index 7a5e0cc..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.optimize;
-
-import com.hp.hpl.jena.query.ARQ ;
-import com.hp.hpl.jena.sparql.algebra.Op ;
-import com.hp.hpl.jena.sparql.algebra.PropertyFunctionGenerator ;
-import com.hp.hpl.jena.sparql.algebra.TransformCopy ;
-import com.hp.hpl.jena.sparql.algebra.op.OpBGP ;
-import com.hp.hpl.jena.sparql.algebra.op.OpTriple ;
-import com.hp.hpl.jena.sparql.pfunction.PropertyFunctionRegistry ;
-import com.hp.hpl.jena.sparql.util.Context ;
-
-/** Rewrite to replace a property function property with the call to the property function implementation */
-public class TransformPropertyFunction extends TransformCopy
-{
- private final Context context ;
- private final boolean doingMagicProperties ;
- private final PropertyFunctionRegistry registry ;
-
- public TransformPropertyFunction(Context context)
- {
- this.context = context ;
- doingMagicProperties = context.isTrue(ARQ.enablePropertyFunctions) ;
- registry = PropertyFunctionRegistry.chooseRegistry(context) ;
- }
-
- @Override
- public Op transform(OpTriple opTriple)
- {
- if ( ! doingMagicProperties )
- return opTriple ;
-
- Op x = transform(opTriple.asBGP()) ;
- if ( ! ( x instanceof OpBGP ) )
- return x ;
-
- if ( opTriple.equivalent((OpBGP)x) )
- return opTriple ;
- return x ;
-
- }
-
- @Override
- public Op transform(OpBGP opBGP)
- {
- if ( ! doingMagicProperties )
- return opBGP ;
-
- return PropertyFunctionGenerator.buildPropertyFunctions(registry, opBGP, context) ;
- }
-
- // Normally, property functionprocessing is done before quad conversion
- // we could convert back to OpGraph and so handle quads
-
- // For the moment, leave in old mode.
-
-// @Override
-// public Op transform(OpQuad opQuad)
-// {
-// if ( ! doingMagicProperties )
-// return super.transform(opQuad) ; ;
-// check(opQuad.getQuad().getPredicate()) ;
-// return super.transform(opQuad) ;
-// }
-//
-// private void check(Node p)
-// {
-// if ( p.isURI() )
-// {
-// if ( registry.manages(p.getURI()) )
-// Log.warn(this, "Property function in quad: "+p) ;
-// }
-// }
-//
-// @Override
-// public Op transform(OpQuadPattern opQuadPattern)
-// {
-// if ( ! doingMagicProperties )
-// return super.transform(opQuadPattern) ; ;
-//
-// for ( Triple t : opQuadPattern.getBasicPattern().getList() )
-// check(t.getPredicate()) ;
-//
-// return super.transform(opQuadPattern) ;
-// }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformRemoveLabels.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformRemoveLabels.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformRemoveLabels.java
deleted file mode 100644
index b902878..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformRemoveLabels.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.optimize;
-
-import com.hp.hpl.jena.sparql.algebra.Op ;
-import com.hp.hpl.jena.sparql.algebra.TransformCopy ;
-import com.hp.hpl.jena.sparql.algebra.op.OpLabel ;
-
-public class TransformRemoveLabels extends TransformCopy
-{
- // Strip labels
- @Override
- public Op transform(OpLabel opLabel, Op subOp)
- {
- return subOp ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformReorder.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformReorder.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformReorder.java
deleted file mode 100644
index b50dd9a..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformReorder.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.optimize;
-
-import com.hp.hpl.jena.sparql.algebra.Op;
-import com.hp.hpl.jena.sparql.algebra.TransformCopy;
-import com.hp.hpl.jena.sparql.algebra.op.OpBGP;
-import com.hp.hpl.jena.sparql.algebra.op.OpQuadPattern;
-import com.hp.hpl.jena.sparql.core.BasicPattern;
-import com.hp.hpl.jena.sparql.engine.optimizer.reorder.ReorderLib;
-import com.hp.hpl.jena.sparql.engine.optimizer.reorder.ReorderTransformation;
-
-/**
- * A Transformer that applies a reordering to all BGPs and Quad Patterns present in the algebra
- * <p>
- * This transformer may be slightly naive in that it only leverages the
- * {@link ReorderTransformation#reorder(BasicPattern)} method and does not use
- * the {@link ReorderTransformation#reorderIndexes(BasicPattern)} method at all
- * so may not achieve the best reordering
- * </p>
- */
-public class TransformReorder extends TransformCopy {
-
- private ReorderTransformation reorder;
-
- /**
- * Creates a Transformer that uses the fixed reordering provided by {@link ReorderLib#fixed()}
- */
- public TransformReorder() {
- this(ReorderLib.fixed());
- }
-
- /**
- * Creates a Transformer that uses the given reordering
- */
- public TransformReorder(ReorderTransformation reorder) {
- if (reorder == null) throw new IllegalArgumentException("reorder cannot be null");
- this.reorder = reorder;
- }
-
- /**
- * Transforms BGPs with the reordering
- */
- @Override
- public Op transform(OpBGP opBGP) {
- BasicPattern pattern = opBGP.getPattern();
- if ( pattern.size() < 2 )
- return opBGP ;
- BasicPattern pattern2 = reorder.reorder(pattern);
- return new OpBGP(pattern2);
- }
-
- /**
- * Transforms Quad Patterns with the reordering
- */
- @Override
- public Op transform(OpQuadPattern opQuadPattern) {
- BasicPattern pattern = opQuadPattern.getBasicPattern();
- if ( pattern.size() < 2 )
- return opQuadPattern ;
- BasicPattern pattern2 = reorder.reorder(pattern);
- return new OpQuadPattern(opQuadPattern.getGraphNode(), pattern2);
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformScopeRename.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformScopeRename.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformScopeRename.java
deleted file mode 100644
index ca23c2b..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformScopeRename.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.optimize;
-
-import com.hp.hpl.jena.sparql.algebra.Op ;
-import com.hp.hpl.jena.sparql.algebra.OpVisitorByTypeBase ;
-import com.hp.hpl.jena.sparql.algebra.TransformCopy ;
-import com.hp.hpl.jena.sparql.algebra.Transformer ;
-import com.hp.hpl.jena.sparql.algebra.op.OpModifier ;
-import com.hp.hpl.jena.sparql.algebra.op.OpProject ;
-import com.hp.hpl.jena.sparql.engine.Rename ;
-
-/** Rename variables so that names can be treated globally.
- * (project) and (group) can hide variables, but we only
- * need to account for OpProject because group is never
- * executed linearly.
- */
-
-public class TransformScopeRename
-{
- // Is there an OpProject before any pattern algebra operators?
- // We don't need to rename through this one.
-
- // Track OpProject
-
- public static Op transform(Op op)
- {
- return new TransformScopeRename$(op).work() ;
- }
-
- private static class TransformScopeRename$
- {
- private boolean outerMostOpProject = false ;
- private int projectRenameDepth = 0 ;
- private int projectCount = 0 ;
-
- private Op op ;
-
- public TransformScopeRename$(Op op)
- {
- this.op = op ;
- {
- Op op2 = op ;
- while( op2 instanceof OpModifier )
- {
- // If already true ...
- if ( op2 instanceof OpProject )
- {
- outerMostOpProject = true ;
- break ;
- }
- op2 = ((OpModifier)op2).getSubOp() ;
- }
- }
- // Set the project counter: renaming begins when this hits one.
- // Set 2 to there is a project in the top-most OpModifers.
- // This does not cause a rename so start renaming at depth .
- // otherwise rename from depth 1.
- if ( outerMostOpProject )
- projectRenameDepth = 2 ;
- else
- projectRenameDepth = 1;
- }
-
- public Op work()
- {
- return Transformer.transform(new RenameByScope(), op, new BeforeWalk(), new AfterWalk()) ;
- }
-
-
- private class BeforeWalk extends OpVisitorByTypeBase
- {
- @Override
- public void visit(OpProject opProject)
- {
- projectCount++ ;
- }
- }
-
- private class AfterWalk extends OpVisitorByTypeBase
- {
- @Override
- public void visit(OpProject opProject)
- {
- --projectCount ;
- }
- }
-
- private class RenameByScope extends TransformCopy
- {
- @Override
- public Op transform(OpProject opProject, Op subOp)
- {
- // Need to find the right project
- // We already stripped outer modifier.
- if ( projectCount >= projectRenameDepth )
- // Inner ones already done.
- subOp = Rename.renameVars(subOp, opProject.getVars()) ;
- return super.transform(opProject, subOp) ;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformSimplify.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformSimplify.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformSimplify.java
deleted file mode 100644
index 7d15f3a..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformSimplify.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.optimize;
-
-import java.util.ArrayList ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import com.hp.hpl.jena.sparql.algebra.Op ;
-import com.hp.hpl.jena.sparql.algebra.TransformCopy ;
-import com.hp.hpl.jena.sparql.algebra.op.OpJoin ;
-import com.hp.hpl.jena.sparql.algebra.op.OpSequence ;
-
-public class TransformSimplify extends TransformCopy
-{
- @Override
- public Op transform(OpSequence opSequence, List<Op> elts)
- {
- List<Op> x = new ArrayList<>(elts) ;
- for ( Iterator<Op> iter = x.iterator() ; iter.hasNext() ; )
- {
- Op sub = iter.next() ;
- if ( OpJoin.isJoinIdentify(sub) )
- iter.remove();
- }
- return super.transform(opSequence, x) ;
- }
-
- @Override
- public Op transform(OpJoin opJoin, Op left, Op right)
- {
- if ( OpJoin.isJoinIdentify(left) )
- return right ;
- if ( OpJoin.isJoinIdentify(right) )
- return left ;
- // Merge adjacent BGPs
- // Also works on nested subqueries that turned out to be simple BGPs.
-
-// if ( OpBGP.isBGP(left) && OpBGP.isBGP(right) )
-// {
-// BasicPattern pattern = new BasicPattern() ;
-// pattern.addAll( ((OpBGP)left).getPattern() ) ;
-// pattern.addAll( ((OpBGP)right).getPattern() ) ;
-// return new OpBGP(pattern) ;
-// }
-
- return super.transform(opJoin, left, right) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformTopN.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformTopN.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformTopN.java
deleted file mode 100644
index 9adb8d7..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformTopN.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.optimize;
-
-import java.util.List ;
-import java.util.Set ;
-
-import com.hp.hpl.jena.query.ARQ ;
-import com.hp.hpl.jena.query.Query ;
-import com.hp.hpl.jena.query.SortCondition ;
-import com.hp.hpl.jena.sparql.ARQConstants ;
-import com.hp.hpl.jena.sparql.algebra.Op ;
-import com.hp.hpl.jena.sparql.algebra.TransformCopy ;
-import com.hp.hpl.jena.sparql.algebra.op.* ;
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.expr.ExprVars ;
-import com.hp.hpl.jena.sparql.util.Symbol ;
-
-
-/**
- * Optimization that changes queries that uses <tt>OFFSET/LIMIT</tt> and <tt>ORDER BY</tt>
- * to execute using <tt>Top N</tt>: i.e. while executing, keep only the top N items seen.
- * This avoids full sort of the whole results, saving space and time.
- */
-public class TransformTopN extends TransformCopy {
-
- private static final int defaultTopNSortingThreshold = 1000;
- public static final Symbol externalSortBufferSize = ARQConstants.allocSymbol("topNSortingThreshold") ;
-
- /* For reference: from the algebra generation of a query, the order of operations is:
- * Limit/Offset
- * Distinct/reduce
- * Project
- * OrderBy
- * Values
- * Having
- * Select Expressions
- * Group
- * but note that a subquery can be used to create other orders.
- */
-
- @Override
- public Op transform(final OpSlice opSlice, final Op inSubOp) {
- /*
- * This looks for all the following cases of slice with optionally
- * distinct and/or project follow by order. It is quicker to execute
- * by avoiding the full sort, just track the top items.
- *
- * + slice-order => topN
- * + slice-distinct|reduced-order => top-distinct
- * + slice-project-order => project-top
- * + slice distinct project order => topN distinct project (only some cases)
- *
- * If the slice has an offset, a (slice X _) is added. (slice 0 _) is a no-op and it not added.
- *
- * In detail:
- *
- * Case 1:
- * (slice X N
- * (order (cond) PATTERN) )
- * ==>
- * (slice X _
- * (top (X+N cond) PATTERN) )
- *
- * Case 2:
- * (slice X N
- * (distinct or reduced
- * (order (cond) PATTERN) ))
- * ==>
- * (slice X _
- * (top (X+N cond) (distinct PATTERN))
- *
- * Case 3:
- * (slice X N
- * (project (vars)
- * (order (cond)
- * PATTERN ))))
- * ==>
- * (slice X _
- * (project (vars)
- * (top (X+N cond) PATTERN) ))
- *
- * Case 4:
- * (slice X N
- * (distinct
- * (project (vars)
- * (order (cond) PATTERN) )))
- * ==>
- * If project-order can be swapped,
- * (slice X N
- * (top (X+N) (cond)
- * (distinct
- * (project (vars)
- * PATTERN) )))
- *
- * Care needed: because of the need to keep distinct, we can't
- * process like case 3. Reversing (order) and (project) can only
- * be done if the projection variables include all variables used
- * by the sort conditions.
- *
- * When there is no project, we can push the distinct under the topN,
- * but, when there is, the sort variables may include one projected away,
- * it's not possible to do this with project. The key is that
- * distinct-project can change the number of rows in ways that mean
- * we can not predict the topN slice.
- */
-
- /* Algorthm:
- * Test to see if the slice is small enough.
- * Extract distinct/reduce, and projection details.
- * Is it an (order)? If no - not applicable.
- *
- * If slice-project-order
- * Treat as project-slice-order
- * Output project-top
- * If slice-distinct-project-order
- * Test to see if project and order can swap
- * If they can, output top-distinct-project
- * else no action.
- *
- * Add a slice if there was an OFFSET.
- * Distinct and reduce are treated as distinct.
- */
-
- Op subOp = inSubOp ;
-
- if ( opSlice.getLength() == Query.NOLIMIT )
- return doNothing(opSlice, inSubOp) ;
- long limit = opSlice.getLength() ;
- long offset = ( opSlice.getStart() != Query.NOLIMIT ) ? opSlice.getStart() : 0L ;
- long N = limit+offset ;
-
- int threshold = (Integer)ARQ.getContext().get(externalSortBufferSize, defaultTopNSortingThreshold) ;
-
- if ( N >= threshold )
- return doNothing(opSlice, inSubOp) ;
-
- boolean distinct = false ;
- boolean reduce = false ;
- // Extract any distinct/reduce.
- if ( subOp instanceof OpDistinct ) {
- distinct = true ;
- subOp = ((Op1)subOp).getSubOp() ;
- } else if ( subOp instanceof OpReduced ) {
- distinct = true ;
- subOp = ((Op1)subOp).getSubOp() ;
- }
-
- // Extract any projection.
- List<Var> projection = null ;
- if ( subOp instanceof OpProject ) {
- OpProject opProject = (OpProject)subOp ;
- projection = opProject.getVars() ;
- subOp = opProject.getSubOp() ;
- }
-
- if ( ! ( subOp instanceof OpOrder ) )
- return doNothing(opSlice, inSubOp) ;
- // We have found an (order)
- OpOrder opOrder = (OpOrder)subOp ;
- subOp = opOrder.getSubOp() ;
-
- // Check safety for the distinct/reduce case
-
- if ( (reduce || distinct) && projection != null ) {
- List<SortCondition> sortConditions = opOrder.getConditions() ;
- Set<Var> orderVars = ExprVars.getVarsMentioned(sortConditions) ;
-
- // Slice and distinct interact.
-
- // Is the ordering stable with respect to the project?
- // i.e. can we swap them and put a (top) for slice-order
- // All project vars must be in the order so we can have:
- // slice-distinct-project-order => top-distinct-project
-
- // If the projection is narrower than the order it is not safe.
-
- if ( ! projection.containsAll(orderVars) )
- return doNothing(opSlice, inSubOp) ;
- }
-
- Op newOp = subOp ;
-
- if ( ( reduce || distinct ) && projection != null )
- newOp = new OpProject(newOp, projection) ;
-
- if ( distinct )
- newOp = OpDistinct.create(newOp) ;
- if ( reduce )
- newOp = OpReduced.create(newOp) ;
-
- newOp = new OpTopN( newOp, (int)N, opOrder.getConditions() ) ;
-
- if ( ! reduce && ! distinct && projection != null )
- newOp = new OpProject(newOp, projection) ;
-
- if ( opSlice.getStart() > 0 )
- newOp = new OpSlice(newOp, opSlice.getStart(), Query.NOLIMIT) ;
-
- return newOp ;
- }
-
- /** Marker to indicate that this transform is not applied at this point */
- private Op doNothing(OpSlice opSlice, Op subOp) {
- return super.transform(opSlice, subOp) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/Table1.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/Table1.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/Table1.java
deleted file mode 100644
index dbdf586..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/Table1.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.table ;
-
-import java.util.ArrayList ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import org.apache.jena.atlas.iterator.Iter ;
-import org.apache.jena.riot.out.NodeFmtLib ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-import com.hp.hpl.jena.sparql.engine.binding.BindingFactory ;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIterSingleton ;
-
-/** A table of one row of one binding */
-public class Table1 extends TableBase {
- private Var var ;
- private Node value ;
-
- public Table1(Var var, Node value) {
- this.var = var ;
- this.value = value ;
- }
-
- @Override
- public Iterator<Binding> rows() {
- Binding b = BindingFactory.binding(var, value) ;
- return Iter.singleton(b) ;
- }
-
- @Override
- public QueryIterator iterator(ExecutionContext execCxt) {
- // Root binding?
- Binding binding = BindingFactory.binding(var, value) ;
- QueryIterator qIter = QueryIterSingleton.create(binding, var, value, execCxt) ;
- return qIter ;
- }
-
- @Override
- public void closeTable() {}
-
- @Override
- public List<Var> getVars() {
- List<Var> x = new ArrayList<>() ;
- x.add(var) ;
- return x ;
- }
-
- @Override
- public List<String> getVarNames() {
- List<String> x = new ArrayList<>() ;
- x.add(var.getVarName()) ;
- return x ;
- }
-
- @Override
- public int size() {
- return 1 ;
- }
-
- @Override
- public boolean isEmpty() {
- return false ;
- }
-
- @Override
- public String toString() {
- return "Table1(" + var + "," + NodeFmtLib.displayStr(value) + ")" ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableBase.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableBase.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableBase.java
deleted file mode 100644
index dfa8f56..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableBase.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.table ;
-
-import com.hp.hpl.jena.query.ResultSet ;
-import com.hp.hpl.jena.query.ResultSetFactory ;
-import com.hp.hpl.jena.sparql.algebra.Table ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.engine.ResultSetStream ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-import com.hp.hpl.jena.sparql.engine.binding.BindingBase ;
-import com.hp.hpl.jena.sparql.engine.binding.BindingUtils ;
-import com.hp.hpl.jena.sparql.engine.ref.Evaluator ;
-
-public abstract class TableBase implements Table {
- protected TableBase() {}
-
- @Override
- final public void close() {
- closeTable() ;
- }
-
- protected abstract void closeTable() ;
-
- final public Table eval(Evaluator evaluator) {
- return this ;
- }
-
- @Override
- public void addBinding(Binding binding) {
- throw new UnsupportedOperationException("Table.add") ;
- }
-
- @Override
- public boolean contains(Binding b) {
- QueryIterator qIter = iterator(null) ;
- try {
- for (; qIter.hasNext();) {
- Binding b2 = qIter.nextBinding() ;
- if ( BindingUtils.equals(b, b2) )
- return true ;
- }
- return false ;
- } finally {
- qIter.close() ;
- }
- }
-
- @Override
- public abstract int size() ;
-
- @Override
- public abstract boolean isEmpty() ;
-
- @Override
- public ResultSet toResultSet() {
- QueryIterator qIter = iterator(null) ;
- ResultSet rs = new ResultSetStream(getVarNames(), null, qIter) ;
- rs = ResultSetFactory.makeRewindable(rs) ;
- qIter.close() ;
- return rs ;
- }
-
- @Override
- public String toString() {
- return TableWriter.asSSE(this) ;
- }
-
- @Override
- public int hashCode() {
- int hash = 0 ;
- QueryIterator qIter = iterator(null) ;
- try {
- for (; qIter.hasNext();) {
- Binding binding = qIter.nextBinding() ;
- hash ^= binding.hashCode() ;
- }
- return hash ;
- } finally {
- qIter.close() ;
- }
- }
-
- @Override
- public boolean equals(Object other) {
- if ( this == other )
- return true ;
- if ( !(other instanceof Table) )
- return false ;
- Table table = (Table)other ;
- if ( table.size() != this.size() )
- return false ;
- QueryIterator qIter1 = iterator(null) ;
- QueryIterator qIter2 = table.iterator(null) ;
- try {
- for (; qIter1.hasNext();) {
- Binding bind1 = qIter1.nextBinding() ;
- Binding bind2 = qIter2.nextBinding() ;
- if ( !BindingBase.equals(bind1, bind2) )
- return false ;
- }
- return true ;
- } finally {
- qIter1.close() ;
- qIter2.close() ;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableData.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableData.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableData.java
deleted file mode 100644
index 2ea9b2b..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableData.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.table ;
-
-import java.util.List ;
-
-import com.hp.hpl.jena.sparql.ARQException ;
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-
-public class TableData extends TableN {
- public TableData(List<Var> variables, List<Binding> rows) {
- super(variables, rows) ;
- }
-
- @Override
- public void addBinding(Binding binding) {
- throw new ARQException("Can't add bindings to an existing data table") ;
- }
-
- public List<Binding> getRows() {
- return rows ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableEmpty.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableEmpty.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableEmpty.java
deleted file mode 100644
index 36af313..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableEmpty.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.table;
-
-import java.util.ArrayList ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import org.apache.jena.atlas.iterator.Iter ;
-
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIterNullIterator ;
-
-public class TableEmpty extends TableBase
-{
- public TableEmpty()
- { }
-
- @Override
- public Iterator<Binding> rows() {
- return Iter.nullIterator() ;
- }
-
- @Override
- public QueryIterator iterator(ExecutionContext execCxt) {
- return QueryIterNullIterator.create(execCxt) ;
- }
-
- @Override
- public boolean contains(Binding binding) { return false ; }
-
- @Override
- public void closeTable() { }
-
- @Override
- public List<String> getVarNames() { return new ArrayList<>() ; }
-
- @Override
- public List<Var> getVars() { return new ArrayList<>() ; }
-
- @Override
- public String toString() { return "TableEmpty" ; }
-
- @Override
- public int size() { return 0 ; }
- @Override
- public boolean isEmpty() { return true ; }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableN.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableN.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableN.java
deleted file mode 100644
index bc0e92b..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableN.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.table ;
-
-import java.util.ArrayList ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIterPlainWrapper ;
-
-public class TableN extends TableBase {
- protected List<Binding> rows = new ArrayList<>() ;
- protected List<Var> vars = new ArrayList<>() ;
-
- public TableN() {}
-
- public TableN(List<Var> vars) {
- if ( vars != null )
- this.vars = vars ;
- }
-
- public TableN(QueryIterator qIter) {
- materialize(qIter) ;
- }
-
- protected TableN(List<Var> variables, List<Binding> rows) {
- this.vars = variables ;
- this.rows = rows ;
- }
-
- private void materialize(QueryIterator qIter) {
- while (qIter.hasNext()) {
- Binding binding = qIter.nextBinding() ;
- addBinding(binding) ;
- }
- qIter.close() ;
- }
-
- @Override
- public void addBinding(Binding binding) {
- for (Iterator<Var> names = binding.vars(); names.hasNext();) {
- Var v = names.next() ;
- if ( !vars.contains(v) )
- vars.add(v) ;
- }
- rows.add(binding) ;
- }
-
- @Override
- public int size() {
- return rows.size() ;
- }
-
- @Override
- public boolean isEmpty() {
- return rows.isEmpty() ;
- }
-
- @Override
- public Iterator<Binding> rows() {
- return rows.iterator() ;
- }
-
- @Override
- public QueryIterator iterator(ExecutionContext execCxt) {
- return new QueryIterPlainWrapper(rows.iterator(), execCxt) ;
- }
-
- @Override
- public void closeTable() {
- rows = null ;
- // Don't clear the vars in case code later asks for the variables.
- }
-
- @Override
- public List<String> getVarNames() {
- return Var.varNames(vars) ;
- }
-
- @Override
- public List<Var> getVars() {
- return vars ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableUnit.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableUnit.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableUnit.java
deleted file mode 100644
index 7740568..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableUnit.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.table;
-
-import java.util.ArrayList ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import org.apache.jena.atlas.iterator.Iter ;
-
-import com.hp.hpl.jena.sparql.algebra.Table ;
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-import com.hp.hpl.jena.sparql.engine.binding.BindingFactory ;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIterSingleton ;
-
-public class TableUnit extends TableBase
-{
- static public boolean isTableUnit(Table table)
- { return (table instanceof TableUnit) ; }
-
- public TableUnit() {}
-
- @Override
- public Iterator<Binding> rows() {
- Binding binding = BindingFactory.binding() ;
- return Iter.singleton(binding) ;
- }
-
- @Override
- public QueryIterator iterator(ExecutionContext execCxt)
- {
- // BindingRoot?
- Binding binding = BindingFactory.binding() ;
- return QueryIterSingleton.create(binding, execCxt) ;
- }
-
- @Override
- public void closeTable() { }
-
- @Override
- public int size() { return 1 ; }
- @Override
- public boolean isEmpty() { return false ; }
-
- @Override
- public List<String> getVarNames() { return new ArrayList<>() ; }
-
- @Override
- public List<Var> getVars() { return new ArrayList<>() ; }
-
- @Override
- public String toString() { return "TableUnit" ; }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableWriter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableWriter.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableWriter.java
deleted file mode 100644
index 661a196..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/table/TableWriter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.algebra.table ;
-
-import java.util.Iterator ;
-
-import org.apache.jena.atlas.io.IndentedLineBuffer ;
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.sparql.algebra.Table ;
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.engine.Plan ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-import com.hp.hpl.jena.sparql.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.util.FmtUtils ;
-
-public class TableWriter {
- public static String asSSE(Table table) {
- IndentedLineBuffer out = new IndentedLineBuffer() ;
- TableWriter.output(table, out) ;
- return out.asString() ;
- }
-
- public static void output(Table table, IndentedWriter out) {
- output(table, out, null) ;
- }
-
- public static void output(Table table, IndentedWriter out, SerializationContext sCxt) {
- if ( sCxt != null ) {} // Prefix. But then qnames are wrong.
- out.print("(table") ;
- out.incIndent() ;
- QueryIterator qIter = table.iterator(null) ;
- for (; qIter.hasNext();) {
- out.println() ;
- Binding binding = qIter.nextBinding() ;
- output(binding, out, sCxt) ;
- }
- out.decIndent() ;
-
- out.print(")") ;
- }
-
- private static void output(Binding binding, IndentedWriter out, SerializationContext sCxt) {
- out.print("(row") ;
- for (Iterator<Var> iter = binding.vars(); iter.hasNext();) {
- Var v = iter.next() ;
- Node n = binding.get(v) ;
- out.print(" ") ;
- out.print(Plan.startMarker2) ;
- out.print(FmtUtils.stringForNode(v)) ;
- out.print(" ") ;
- out.print(FmtUtils.stringForNode(n)) ;
- out.print(Plan.finishMarker2) ;
- }
- out.print(")") ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/BasicPattern.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/BasicPattern.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/BasicPattern.java
deleted file mode 100644
index b737cbe..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/BasicPattern.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.core;
-
-import java.util.ArrayList ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import org.apache.jena.atlas.io.IndentedLineBuffer ;
-
-import com.hp.hpl.jena.graph.Triple ;
-import com.hp.hpl.jena.sparql.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.sse.SSE ;
-import com.hp.hpl.jena.sparql.sse.writers.WriterNode ;
-import com.hp.hpl.jena.sparql.util.Iso ;
-import com.hp.hpl.jena.sparql.util.NodeIsomorphismMap ;
-
-/** A class whose purpose is to give a name to a collection of triples.
- * Reduces the use of bland "List" in APIs (Java 1.4)
- */
-
-public class BasicPattern implements Iterable<Triple>
-{
- private List<Triple> triples ;
-
- public BasicPattern() { this(new ArrayList<Triple>()) ; }
- public BasicPattern(BasicPattern other)
- {
- this() ;
- // Copy.
- triples.addAll(other.triples) ;
- }
- private BasicPattern(List<Triple> triples) { this.triples = triples ; }
-
- /** Wrap a list of triples up as a BasicPattern. Chnaging the list, changes the BasicPattern */
- public static BasicPattern wrap(List<Triple> triples)
- {
- return new BasicPattern(triples) ;
- }
-
-
- public void add(Triple t) { triples.add(t) ; }
- public void addAll(BasicPattern other) { triples.addAll(other.triples) ; }
- public void add(int i, Triple t) { triples.add(i, t) ; }
-
- public Triple get(int i) { return triples.get(i) ; }
- @Override
- public Iterator<Triple> iterator() { return triples.listIterator() ; }
- public int size() { return triples.size() ; }
- public boolean isEmpty() { return triples.isEmpty() ; }
-
- public List<Triple> getList() { return triples ; }
-
- @Override
- public int hashCode() { return triples.hashCode() ; }
-
- @Override
- public boolean equals(Object other)
- {
- if ( this == other ) return true ;
- if ( ! ( other instanceof BasicPattern) )
- return false ;
- BasicPattern bp = (BasicPattern)other ;
- return triples.equals(bp.triples) ;
- }
-
- public boolean equiv(BasicPattern other, NodeIsomorphismMap isoMap)
- {
- if ( this.triples.size() != other.triples.size() )
- return false ;
-
- for ( int i = 0 ; i < this.triples.size() ; i++ )
- {
- Triple t1 = get(i) ;
- Triple t2 = other.get(i) ;
-
- if ( ! Iso.tripleIso(t1, t2, isoMap) )
- return false ;
- }
- return true ;
- }
-
- @Override
- public String toString()
- {
- IndentedLineBuffer out = new IndentedLineBuffer() ;
-
- SerializationContext sCxt = SSE.sCxt(SSE.defaultPrefixMapWrite) ;
-
- boolean first = true ;
- for ( Triple t : triples )
- {
- if ( !first )
- out.print("\n") ;
- else
- first = false ;
- // Adds (triple ...)
- // SSE.write(buff.getIndentedWriter(), t) ;
- out.print("(") ;
- WriterNode.outputPlain(out, t, sCxt) ;
- out.print(")") ;
- }
- out.flush();
- return out.toString() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/ComparisonException.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/ComparisonException.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/ComparisonException.java
deleted file mode 100644
index 5da40fe..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/ComparisonException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.core;
-
-
-public class ComparisonException extends RuntimeException
-{
- ComparisonException(String msg) { super(msg) ; }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChanges.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChanges.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChanges.java
deleted file mode 100644
index 4d812b0..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChanges.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.core;
-
-import com.hp.hpl.jena.graph.Node ;
-
-/** Interface for notification of changes
- * (adds and deletes of quads) to a DatasetGraph
- */
-public interface DatasetChanges
-{
- /** Indicator that a sequence of changes is about to start */
- public void start() ;
-
- /** A change has occurred
- * @see QuadAction
- */
- public void change(QuadAction qaction, Node g, Node s, Node p, Node o) ;
-
- /** Indicator that a sequence of changes has now finished */
- public void finish() ;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesBatched.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesBatched.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesBatched.java
deleted file mode 100644
index c0030f4..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesBatched.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.core;
-
-import java.util.ArrayList ;
-import java.util.List ;
-
-import org.apache.jena.atlas.lib.Lib ;
-
-import com.hp.hpl.jena.graph.Node ;
-
-/** Collect a stream of DatasetChanges into batches.
- * A batch is adjacent quads changes with
- * (same graph, same subject, same action).
- */
-public abstract class DatasetChangesBatched implements DatasetChanges
-{
- private QuadAction currentAction = null ;
- private Node currentSubject = null ;
- private Node currentGraph = null ;
- private List<Quad> batchQuads = null ;
- private boolean mergeBlankNodes = false ;
-
- protected DatasetChangesBatched()
- {
- this(false) ;
- }
-
- /* Merge bNodes in a batch - i.e. include them in the current batch, not as new entities */
- protected DatasetChangesBatched(boolean mergeBNodes)
- {
- this.mergeBlankNodes = mergeBNodes ;
- }
-
- @Override public final void start()
- {
- startBatched() ;
- startBatch() ;
- }
-
- @Override public final void finish()
- {
- finishBatch() ;
- finishBatched() ;
- }
-
- @Override
- public void change(QuadAction qaction, Node g, Node s, Node p, Node o)
- {
- if ( mergeBlankNodes && s.isBlank() )
- {
- if ( batchQuads == null )
- // No active batch.
- startBatch() ;
- // Drop and through and include in the current batch.
- }
- else if ( ! Lib.equal(currentAction, qaction) ||
- ! Lib.equal(currentGraph, g) ||
- ! Lib.equal(currentSubject, s) )
- {
- finishBatch() ;
- startBatch() ;
- currentAction = qaction ;
- currentGraph = g ;
- currentSubject = s ;
- }
-
- batchQuads.add(new Quad(g,s,p,o)) ;
- }
-
- private void startBatch()
- {
- if ( batchQuads == null )
- batchQuads = new ArrayList<>() ;
- }
-
- protected void finishBatch()
- {
- if ( batchQuads == null || batchQuads.size() == 0 )
- return ;
- dispatch(currentAction, batchQuads) ;
- batchQuads = null ;
- }
-
- protected abstract void dispatch(QuadAction quadAction, List<Quad> batch) ;
-
- protected abstract void startBatched() ;
-
- protected abstract void finishBatched() ;
-
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesCapture.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesCapture.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesCapture.java
deleted file mode 100644
index e76999a..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesCapture.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.core;
-
-import java.util.Collections ;
-import java.util.LinkedList ;
-import java.util.List ;
-
-import org.apache.jena.atlas.lib.Pair ;
-
-import com.hp.hpl.jena.graph.Node ;
-
-/** Capture a record of quad actions */
-public class DatasetChangesCapture implements DatasetChanges
-{
- // ArrayLists have an annoying issue that they grow by copying the internal []-array.
- // This growth is by a fixed factor of adding 50% which for an array
- // with little guidance as to likely size, can lead to undesirable GC
- // and copy-time issues.
- // Using a LinkedList avoids this although it adds overhead for list entries.
- final private List<Pair<QuadAction, Quad>> actions = new LinkedList<>() ;
- //new ArrayList<Pair<QuadAction, Quad>>() ;
-
- final private boolean captureAdd ;
- final private boolean captureDelete ;
- final private boolean captureNoAdd ;
- final private boolean captureNoDelete ;
-
- /** Capture quad actions, excluding no-ops */
- public DatasetChangesCapture()
- { this(true, true, false, false) ; }
-
- /** Capture quad actions, either including or excluding the "no ops"
- * @param recordNoOps Whether to record {@link QuadAction#NO_ADD} and {@link QuadAction#NO_DELETE}
- */
- public DatasetChangesCapture(boolean recordNoOps)
- { this(true, true, recordNoOps, recordNoOps) ; }
-
-
- /** Capture quad actions, selectively by category */
- public DatasetChangesCapture(boolean captureAdd, boolean captureDelete, boolean captureNoAdd, boolean captureNoDelete)
- {
- this.captureAdd = captureAdd ;
- this.captureDelete = captureDelete ;
- this.captureNoAdd = captureNoAdd ;
- this.captureNoDelete = captureNoDelete ;
- }
-
- public List<Pair<QuadAction, Quad>> getActions()
- {
- return Collections.unmodifiableList(actions) ;
- }
-
- @Override public void start() { }
-
- @Override
- public void change(QuadAction qaction, Node g, Node s, Node p, Node o)
- {
- Quad q = new Quad(g,s,p,o) ;
- Pair<QuadAction, Quad> pair = Pair.create(qaction, q) ;
-
- switch(qaction) {
- case ADD :
- if ( captureAdd ) actions.add(pair) ;
- break ;
- case DELETE :
- if ( captureDelete ) actions.add(pair) ;
- break ;
- case NO_ADD :
- if ( captureNoAdd ) actions.add(pair) ;
- break ;
- case NO_DELETE :
- if ( captureNoDelete ) actions.add(pair) ;
- break ;
- }
- }
-
- @Override public void finish() { }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesCounter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesCounter.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesCounter.java
deleted file mode 100644
index 2804c4f..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetChangesCounter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.core;
-
-import com.hp.hpl.jena.graph.Node ;
-
-/** Count changes, or simply note if a change has been made. */
-public class DatasetChangesCounter implements DatasetChanges
-{
- long countStart = 0 ;
- long countFinish = 0 ;
-
- long countAdd = 0 ;
- long countDelete = 0 ;
- long countNoAdd = 0 ;
- long countNoDelete = 0 ;
-
- @Override
- public void start() {
- countStart++ ;
- }
-
- @Override
- public void change(QuadAction qaction, Node g, Node s, Node p, Node o) {
- if ( qaction == null )
- throw new NullPointerException() ;
- switch (qaction) {
- case ADD: countAdd++ ; break ;
- case DELETE: countDelete++ ; break ;
- case NO_ADD: countNoAdd++ ; break ;
- case NO_DELETE: countNoDelete++ ; break ;
- //default : break ;
- }
- }
-
- @Override
- public void finish() {
- countFinish++ ;
- }
-
- public boolean hasChanged() {
- return countAdd > 0 || countDelete > 0 ;
- }
-
- public void reset() {
- countStart = 0 ;
- countFinish = 0 ;
-
- countAdd = 0 ;
- countDelete = 0 ;
- countNoAdd = 0 ;
- countNoDelete = 0 ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetDescription.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetDescription.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetDescription.java
deleted file mode 100644
index 1fc83fd..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetDescription.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.core;
-
-import java.util.ArrayList ;
-import java.util.Collection ;
-import java.util.Iterator ;
-import java.util.List ;
-
-import com.hp.hpl.jena.query.Dataset ;
-import com.hp.hpl.jena.query.Query ;
-import com.hp.hpl.jena.sparql.ARQConstants ;
-import com.hp.hpl.jena.sparql.ARQException ;
-import com.hp.hpl.jena.sparql.util.Context ;
-import com.hp.hpl.jena.sparql.util.DatasetUtils ;
-
-// TODO Integrate this further
-// use in FROM/FROM NAMED and change Query class.
-// use in DatasetUtils
-// use in tests
-
-public class DatasetDescription
-{
- private List<String> defaultGraphURIs = new ArrayList<>() ;
- private List<String> namedGraphURIs = new ArrayList<>() ;
-
- public static DatasetDescription create(List<String> defaultGraphURIs , List<String> namedGraphURIs)
- {
- return new DatasetDescription(defaultGraphURIs, namedGraphURIs) ;
- }
-
- /** Create a dataset description, given a query.
- * If the query does not have a dataset description, return null.
- */
- public static DatasetDescription create(Query query) { return create(query, null) ; }
-
- /** Create a dataset description, given a context.
- * If the context does not have a dataset description, return null.
- * The context uses the key {@link ARQConstants#sysDatasetDescription}.
- */
- public static DatasetDescription create(Context context) { return create(null, context) ; }
-
- /** Create a dataset description, given a query and context.
- * The context overrides the query FROM/FROM NAMED.
- * If neither the context nor query has a dataset description, return null.
- * The context uses the key {@link ARQConstants#sysDatasetDescription}.
- */
- public static DatasetDescription create(Query query, Context context)
- {
- if ( context != null && context.isDefined(ARQConstants.sysDatasetDescription) )
- {
- try {
- return (DatasetDescription)context.get(ARQConstants.sysDatasetDescription) ;
- } catch (ClassCastException ex)
- {
- throw new ARQException("Unexpected type (expected DatasetDescription): "+ex.getMessage()) ;
- }
- }
-
- if ( query != null && query.hasDatasetDescription() )
- return query.getDatasetDescription() ;
-
- return null ;
- }
-
- public DatasetDescription() {}
- public DatasetDescription(List<String> defaultGraphURIs , List<String> namedGraphURIs)
- {
- this() ;
- addAllDefaultGraphURIs(defaultGraphURIs) ;
- addAllNamedGraphURIs(namedGraphURIs) ;
- }
-
- public boolean isEmpty() { return defaultGraphURIs.isEmpty() && namedGraphURIs.isEmpty() ; }
-
- public void addDefaultGraphURI(String uri) { defaultGraphURIs.add(uri) ; }
- public void addAllDefaultGraphURIs(Collection<String> uris) { defaultGraphURIs.addAll(uris) ; }
-
- public void addNamedGraphURI(String uri) { namedGraphURIs.add(uri) ; }
- public void addAllNamedGraphURIs(Collection<String> uris) { namedGraphURIs.addAll(uris) ; }
-
- public List<String> getDefaultGraphURIs() { return defaultGraphURIs ; }
- public List<String> getNamedGraphURIs() { return namedGraphURIs ; }
-
- public Iterator<String> eachDefaultGraphURI() { return defaultGraphURIs.iterator() ; }
- public Iterator<String> eachNamedGraphURI() { return namedGraphURIs.iterator() ; }
-
- /** Create a dataset from the description - reads URLs into an in-memory dataset */
- public Dataset createDataset() { return DatasetUtils.createDataset(this) ; }
-
- /** Create a DatasetGraph from the description - reads URLs into an in-memory DatasetGraph */
- public DatasetGraph createDatasetGraph() { return DatasetUtils.createDatasetGraph(this) ; }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraph.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraph.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraph.java
deleted file mode 100644
index bdc26b2..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/core/DatasetGraph.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.
- */
-
-package com.hp.hpl.jena.sparql.core ;
-
-import java.util.Iterator ;
-
-import org.apache.jena.atlas.lib.Closeable ;
-
-import com.hp.hpl.jena.graph.Graph ;
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.graph.Triple ;
-import com.hp.hpl.jena.query.Dataset ;
-import com.hp.hpl.jena.shared.Lock ;
-import com.hp.hpl.jena.sparql.util.Context ;
-
-/** DatasetGraph: The graph representation of an RDF Dataset. See {@link Dataset}
- * for the Model level of an RDF dataset.
- * <p>
- * Whether a dataset contains a graph if there are no triples
- * is not defined; see the specific implementation.
- */
-
-public interface DatasetGraph extends Closeable
-{
- // ---- Graph container view
-
- /** Get the default graph as a Jena Graph */
- public Graph getDefaultGraph() ;
-
- /** Get the graph named by graphNode : returns null on no graph
- * NB Whether a dataset contains a graph if there are no triples is not defined - see the specifc implementation.
- * Some datasets are "open" - they have all graphs even if no triples,
- * */
- public Graph getGraph(Node graphNode) ;
-
- public boolean containsGraph(Node graphNode) ;
-
- /** Set the default graph. Set the active graph if it was null.
- * This replaces the contents default graph, not merge data into it.
- * Do not assume that the same object is returned by {@link #getDefaultGraph}
- */
- public void setDefaultGraph(Graph g) ;
-
- /**
- * Add the given graph to the dataset.
- * <em>Replaces</em> any existing data for the named graph; to add data,
- * get the graph and add triples to it, or add quads to the dataset.
- * Do not assume that the same Java object is returned by {@link #getGraph}
- */
-
- public void addGraph(Node graphName, Graph graph) ;
-
- /** Remove all data associated with the named graph */
- public void removeGraph(Node graphName) ;
-
- /** Iterate over all names of named graphs */
- public Iterator<Node> listGraphNodes() ;
-
- // ---- Quad view
-
- /** Add a quad */
- public void add(Quad quad) ;
-
- /** Delete a quad */
- public void delete(Quad quad) ;
-
- /** Add a quad */
- public void add(Node g, Node s, Node p, Node o) ;
-
- /** Delete a quad */
- public void delete(Node g, Node s, Node p, Node o) ;
-
- /** Delete any quads matching the pattern */
- public void deleteAny(Node g, Node s, Node p, Node o) ;
-
- /** Iterate over all quads in the dataset graph */
- public Iterator<Quad> find() ;
-
- /** Find matching quads in the dataset - may include wildcards, Node.ANY or null
- * @see Graph#find(Triple)
- */
- public Iterator<Quad> find(Quad quad) ;
-
- /** Find matching quads in the dataset (including default graph) - may include wildcards, Node.ANY or null
- * @see Graph#find(Node,Node,Node)
- */
- public Iterator<Quad> find(Node g, Node s, Node p , Node o) ;
-
- /** Find matching quads in the dataset in named graphs only - may include wildcards, Node.ANY or null
- * @see Graph#find(Node,Node,Node)
- */
- public Iterator<Quad> findNG(Node g, Node s, Node p , Node o) ;
-
- /** Test whether the dataset (including default graph) contains a quad - may include wildcards, Node.ANY or null */
- public boolean contains(Node g, Node s, Node p , Node o) ;
-
- /** Test whether the dataset contains a quad (including default graph)- may include wildcards, Node.ANY or null */
- public boolean contains(Quad quad) ;
-
- /** Remove everything - remove all named graphs, clear the default graph */
- public void clear() ;
-
- /** Test whether the dataset is empty */
- public boolean isEmpty() ;
-
- /** Return a lock for the dataset to help with concurrency control
- * @see Lock
- */
- public Lock getLock() ;
-
- /** Get the context associated with this object - may be null */
- public Context getContext() ;
-
- /** Get the size (number of named graphs) - may be -1 for unknown */
- public long size() ;
-
- /** Close the dataset */
- @Override
- public void close() ;
-}