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:49 UTC
[33/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/engine/http/Service.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/http/Service.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/http/Service.java
deleted file mode 100644
index e651f38..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/http/Service.java
+++ /dev/null
@@ -1,287 +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.engine.http;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.jena.atlas.io.IO;
-import org.apache.jena.riot.WebContent;
-
-import com.hp.hpl.jena.query.Query;
-import com.hp.hpl.jena.query.QueryExecException;
-import com.hp.hpl.jena.query.ResultSet;
-import com.hp.hpl.jena.query.ResultSetFactory;
-import com.hp.hpl.jena.sparql.ARQConstants;
-import com.hp.hpl.jena.sparql.algebra.Op;
-import com.hp.hpl.jena.sparql.algebra.OpAsQuery;
-import com.hp.hpl.jena.sparql.algebra.OpVars;
-import com.hp.hpl.jena.sparql.algebra.op.OpService;
-import com.hp.hpl.jena.sparql.core.Var;
-import com.hp.hpl.jena.sparql.engine.QueryIterator;
-import com.hp.hpl.jena.sparql.engine.Rename;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIter;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorResultSet;
-import com.hp.hpl.jena.sparql.mgt.Explain;
-import com.hp.hpl.jena.sparql.util.Context;
-import com.hp.hpl.jena.sparql.util.Symbol;
-
-/** Execution of OpService */
-
-public class Service {
- /* define the symbols that Service will use to set the HttpQuery parameters */
- public static final String base = "http://jena.hpl.hp.com/Service#";
-
- /**
- * Use to set the HttpQuery.allowDeflate flag.
- */
- public static final Symbol queryDeflate = ARQConstants.allocSymbol(base, "queryDeflate");
-
- /**
- * Use to set the HttpQuery.allowGZip flag.
- */
- public static final Symbol queryGzip = ARQConstants.allocSymbol(base, "queryGzip");
-
- /**
- * Use to set the user id for basic auth.
- */
- public static final Symbol queryAuthUser = ARQConstants.allocSymbol(base, "queryAuthUser");
-
- /**
- * Use to set the user password for basic auth.
- */
- public static final Symbol queryAuthPwd = ARQConstants.allocSymbol(base, "queryAuthPwd");
-
- /**
- * Use this Symbol to allow passing additional service context variables
- * SERVICE <IRI> call. Parameters need to be grouped by SERVICE <IRI>, a
- * Map<String, Context> is assumed. The key of the first map is the SERVICE
- * IRI, the value is a Context who's values will override any defaults in
- * the original context.
- *
- * @see com.hp.hpl.jena.sparql.engine.http.Service
- */
- public static final Symbol serviceContext = ARQConstants.allocSymbol(base, "serviceContext");
-
- /**
- * Control whether SERVICE processing is allowed.
- * If the context contains this, and it is set to "false",
- * then SERVICE is not allowed.
- */
-
- public static final Symbol serviceAllowed = ARQConstants.allocSymbol(base, "serviceAllowed");
-
- /**
- * Set timeout. The value of this symbol gives the value of the timeout in
- * milliseconds
- * <ul>
- * <li>A Number; the long value is used</li>
- * <li>A string, e.g. "1000", parsed as a number</li>
- * <li>A string, as two numbers separated by a comma, e.g. "500,10000"
- * parsed as two numbers</li>
- * </ul>
- * The first value is passed to HttpQuery.setConnectTimeout() the second, if
- * it exists, is passed to HttpQuery.setReadTimeout()
- */
- public static final Symbol queryTimeout = ARQConstants.allocSymbol(base, "queryTimeout");
-
- /**
- * Executes a service operator
- *
- * @param op
- * Service
- * @param context
- * Context
- * @return Query iterator of service results
- */
- public static QueryIterator exec(OpService op, Context context) {
- if ( context != null && context.isFalse(serviceAllowed) )
- throw new QueryExecException("SERVICE execution disabled") ;
-
- if (!op.getService().isURI())
- throw new QueryExecException("Service URI not bound: " + op.getService());
-
- // This relies on the observation that the query was originally correct,
- // so reversing the scope renaming is safe (it merely restores the
- // algebra expression).
- // Any variables that reappear should be internal ones that were hidden
- // by renaming in the first place.
- // Any substitution is also safe because it replaced variables by
- // values.
- Op opRemote = Rename.reverseVarRename(op.getSubOp(), true);
-
- // JENA-494 There is a bug here that the renaming means that if this is
- // deeply nested and joined to other things at the same level of you end
- // up with the variables being disjoint and the same results
- // The naive fix for this is to map the variables visible in the inner
- // operator to those visible in the rewritten operator
- // There may be some cases where the re-mapping is incorrect due to
- // deeply nested SERVICE clauses
- Map<Var, Var> varMapping = new HashMap<>();
- Set<Var> originalVars = OpVars.visibleVars(op);
- Set<Var> remoteVars = OpVars.visibleVars(opRemote);
-
- boolean requiresRemapping = false;
- for (Var v : originalVars) {
- if (v.getName().contains("/")) {
- // A variable which was scope renamed so has a different name
- String origName = v.getName().substring(v.getName().lastIndexOf('/') + 1);
- Var remoteVar = Var.alloc(origName);
- if (remoteVars.contains(remoteVar)) {
- varMapping.put(remoteVar, v);
- requiresRemapping = true;
- }
- } else {
- // A variable which does not have a different name
- if (remoteVars.contains(v))
- varMapping.put(v, v);
- }
- }
-
- // Explain.explain("HTTP", opRemote, context) ;
-
- Query query;
-
- //@formatter:off
- // Comment (for the future?)
-// if ( false )
-// {
-// // ***** Interacts with substitution.
-// Element el = op.getServiceElement().getElement() ;
-// if ( el instanceof ElementSubQuery )
-// query = ((ElementSubQuery)el).getQuery() ;
-// else
-// {
-// query = QueryFactory.create() ;
-// query.setQueryPattern(el) ;
-// query.setResultVars() ;
-// }
-// }
-// else
- //@formatter:on
- query = OpAsQuery.asQuery(opRemote);
-
- Explain.explain("HTTP", query, context);
- String uri = op.getService().getURI();
- HttpQuery httpQuery = configureQuery(uri, context, query);
- InputStream in = httpQuery.exec();
-
- // Read the whole of the results now.
- // Avoids the problems with calling back into the same system e.g.
- // Fuseki+SERVICE <http://localhost:3030/...>
-
- ResultSet rs = ResultSetFactory.fromXML(in);
- QueryIterator qIter = QueryIter.materialize(new QueryIteratorResultSet(rs));
- // And close connection now, not when qIter is closed.
- IO.close(in);
-
- // In some cases we may need to apply a re-mapping
- // This solves JENA-494 the naive way and may be brittle for complex
- // nested SERVICE clauses
- if (requiresRemapping) {
- qIter = QueryIter.map(qIter, varMapping);
- }
-
- return qIter;
- }
-
- /**
- * Create and configure the HttpQuery object.
- *
- * The parentContext is not modified but is used to create a new context
- * copy.
- *
- * @param uri
- * The uri of the endpoint
- * @param parentContext
- * The initial context.
- * @param Query
- * the Query to execute.
- * @return An HttpQuery configured as per the context.
- */
- private static HttpQuery configureQuery(String uri, Context parentContext, Query query) {
- HttpQuery httpQuery = new HttpQuery(uri);
- Context context = new Context(parentContext);
-
- // add the context settings from the service context
- @SuppressWarnings("unchecked")
- Map<String, Context> serviceContextMap = (Map<String, Context>) context.get(serviceContext);
- if (serviceContextMap != null) {
- Context serviceContext = serviceContextMap.get(uri);
- if (serviceContext != null)
- context.putAll(serviceContext);
- }
-
- // configure the query object.
- httpQuery.merge(QueryEngineHTTP.getServiceParams(uri, context));
- httpQuery.addParam(HttpParams.pQuery, query.toString());
- httpQuery.setAccept(WebContent.contentTypeResultsXML);
- httpQuery.setAllowGZip(context.isTrueOrUndef(queryGzip));
- httpQuery.setAllowDeflate(context.isTrueOrUndef(queryDeflate));
-
- String user = context.getAsString(queryAuthUser);
- String pwd = context.getAsString(queryAuthPwd);
-
- if (user != null || pwd != null) {
- user = user == null ? "" : user;
- pwd = pwd == null ? "" : pwd;
- httpQuery.setBasicAuthentication(user, pwd.toCharArray());
- }
-
- setAnyTimeouts(httpQuery, context);
-
- return httpQuery;
- }
-
- /**
- * Modified from QueryExecutionBase
- *
- * @see com.hp.hpl.jena.sparql.engine.QueryExecutionBase
- */
- private static void setAnyTimeouts(HttpQuery query, Context context) {
- if (context.isDefined(queryTimeout)) {
- Object obj = context.get(queryTimeout);
- if (obj instanceof Number) {
- int x = ((Number) obj).intValue();
- query.setConnectTimeout(x);
- } else if (obj instanceof String) {
- try {
- String str = obj.toString();
- if (str.contains(",")) {
-
- String[] a = str.split(",");
- int x1 = Integer.parseInt(a[0]);
- int x2 = Integer.parseInt(a[1]);
- query.setConnectTimeout(x1);
- query.setReadTimeout(x2);
- } else {
- int x = Integer.parseInt(str);
- query.setConnectTimeout(x);
- }
- } catch (NumberFormatException ex) {
- throw new QueryExecException("Can't interpret string for timeout: " + obj);
- }
- } else {
- throw new QueryExecException("Can't interpret timeout: " + obj);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java
deleted file mode 100644
index 98a24d3..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java
+++ /dev/null
@@ -1,219 +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.engine.index;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.sparql.core.Var;
-import com.hp.hpl.jena.sparql.engine.QueryIterator;
-import com.hp.hpl.jena.sparql.engine.binding.Binding;
-
-/**
- * Indexes bindings so that they can be search for quickly when a binding to all the
- * variables is provided. If a binding to only some of the known variables is provided
- * then the index still works, but will search linearly.
- * Contribution from Paul Gearon (quoll)
- */
-public class HashIndexTable implements IndexTable {
-
- final private Set<Key> table ;
- private Map<Var,Integer> varColumns ;
- private boolean missingValue ;
-
- public HashIndexTable(Set<Var> commonVars, QueryIterator data) throws MissingBindingException
- {
- initColumnMappings(commonVars) ;
- if ( commonVars.size() == 0 )
- {
- table = null ;
- return ;
- }
-
- table = new HashSet<>() ;
- missingValue = false ;
-
- while ( data.hasNext() )
- {
- Binding binding = data.nextBinding() ;
- addBindingToTable(binding) ;
- }
- data.close() ;
- }
-
- @Override
- public boolean containsCompatibleWithSharedDomain(Binding binding)
- {
- // no shared variables means no shared domain, and should be ignored
- if ( table == null )
- return false ;
-
- Key indexKey ;
- indexKey = convertToKey(binding) ;
-
- if ( table.contains(indexKey) )
- return true ;
-
- if ( anyUnbound(indexKey) )
- return exhaustiveSearch(indexKey) ;
- return false ;
- }
-
- private boolean anyUnbound(Key mappedBinding)
- {
- for ( Node n: mappedBinding.getNodes() )
- {
- if ( n == null )
- return true ;
- }
- return false ;
- }
-
- private void initColumnMappings(Set<Var> commonVars)
- {
- varColumns = new HashMap<>() ;
- int c = 0 ;
- for ( Var var: commonVars )
- varColumns.put(var, c++) ;
- }
-
- private void addBindingToTable(Binding binding) throws MissingBindingException
- {
- Key key = convertToKey(binding) ;
- table.add(key) ;
- if ( missingValue )
- throw new MissingBindingException(table, varColumns) ;
- }
-
- private Key convertToKey(Binding binding)
- {
- Node[] indexKey = new Node[varColumns.size()] ;
-
- for ( Map.Entry<Var,Integer> varCol : varColumns.entrySet() )
- {
- Node value = binding.get(varCol.getKey()) ;
- if ( value == null )
- missingValue = true ;
- indexKey[varCol.getValue()] = value ;
- }
- return new Key(indexKey) ;
- }
-
- private boolean exhaustiveSearch(Key mappedBindingLeft)
- {
- for ( Key mappedBindingRight: table )
- {
- if ( mappedBindingLeft.compatibleAndSharedDomain(mappedBindingRight) )
- return true ;
- }
- return false ;
- }
-
- static class MissingBindingException extends Exception {
- private final Set<Key> data ;
- private final Map<Var,Integer> varMappings ;
-
- public MissingBindingException(Set<Key> data, Map<Var,Integer> varMappings)
- {
- this.data = data ;
- this.varMappings = varMappings ;
- }
-
- public Set<Key> getData() { return data ; }
- public Map<Var,Integer> getMap() { return varMappings ; }
- }
-
- static class Key
- {
- final Node[] nodes;
-
- Key(Node[] nodes)
- {
- this.nodes = nodes ;
- }
-
- public Node[] getNodes()
- {
- return nodes;
- }
-
- @Override
- public String toString()
- {
- return Arrays.asList(nodes).toString() ;
- }
-
- @Override
- public int hashCode()
- {
- int result = 0 ;
- for ( Node n: nodes )
- result ^= (n == null) ? 0 : n.hashCode() ;
- return result ;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if ( ! (o instanceof Key) )
- return false ;
- Node[] other = ((Key)o).nodes ;
-
- for ( int i = 0 ; i < nodes.length ; i++ )
- {
- if ( nodes[i] == null)
- {
- if ( other[i] != null )
- return false ;
- }
- else
- {
- if ( ! nodes[i].equals(other[i]) )
- return false ;
- }
- }
- return true ;
- }
-
- public boolean compatibleAndSharedDomain(Key mappedBindingR)
- {
- Node[] nodesRight = mappedBindingR.getNodes() ;
-
- boolean sharedDomain = false ;
- for ( int c = 0 ; c < nodes.length ; c++ )
- {
- Node nLeft = nodes[c] ;
- Node nRight = nodesRight[c] ;
-
- if ( nLeft != null && nRight != null )
- {
- if ( nLeft.equals(nRight) )
- return false ;
- sharedDomain = true ;
- }
- }
- return sharedDomain ;
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java
deleted file mode 100644
index 6a7d6d4..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java
+++ /dev/null
@@ -1,46 +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.engine.index;
-
-import java.util.Set;
-
-import com.hp.hpl.jena.sparql.core.Var;
-import com.hp.hpl.jena.sparql.engine.QueryIterator;
-import com.hp.hpl.jena.sparql.engine.index.HashIndexTable.MissingBindingException;
-
-/**
- * Creates {@link com.hp.hpl.jena.sparql.engine.index.IndexTable}s for use by
- * {@link com.hp.hpl.jena.sparql.engine.iterator.QueryIterMinus}.
- * <p>
- * Contribution from Paul Gearon
- */
-public class IndexFactory {
-
- public static IndexTable createIndex(Set<Var> commonVars, QueryIterator data) {
- try {
- if (commonVars.size() == 1) {
- return new SetIndexTable(commonVars, data);
- } else {
- return new HashIndexTable(commonVars, data);
- }
- } catch (MissingBindingException e) {
- return new LinearIndex(commonVars, data, e.getData(), e.getMap());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java
deleted file mode 100644
index b99d6f5..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java
+++ /dev/null
@@ -1,35 +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.engine.index;
-
-import com.hp.hpl.jena.sparql.engine.binding.Binding;
-
-/**
- * Interface for indexes that are used for identifying matching
- * {@link com.hp.hpl.jena.sparql.engine.binding.Binding}s when
- * {@link com.hp.hpl.jena.sparql.engine.iterator.QueryIterMinus} is trying to determine
- * which Bindings need to be removed.
- * <p>
- * Contribution from Paul Gearon
- */
-public interface IndexTable {
-
- public abstract boolean containsCompatibleWithSharedDomain(Binding binding);
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java
deleted file mode 100644
index ee2a7e9..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java
+++ /dev/null
@@ -1,113 +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.engine.index;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.sparql.algebra.Algebra;
-import com.hp.hpl.jena.sparql.core.Var;
-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.BindingHashMap;
-
-/**
- * A slow "index" that looks for data by searching linearly through a set.
- * Only used when the indexed data contains fewer bound variables than expected.
- * Note that this class is only used for a MINUS operation that is removing data
- * with potentially unbound values, and is therefore rarely used.
- *
- * TODO: If this index starts to be used more often then consider various options for
- * indexing on the known bound variables.
- * One possibility is for each variable (found in commonVars) to take
- * the value of a var/value pair and TreeMap this to a set of Bindings that it occurs in.
- * This would offer a reduced set to search, and set intersections may also work
- * (intersections like this could be done on Binding reference equality rather than value).
- * TreeMap is suggested here, since there would be commonVars.size() maps, which would take
- * a lot of heap, particularly since performance of this class is only an issue when the
- * data to search is significant.
- * <p>Contribution from Paul Gearon
- */
-
-public class LinearIndex implements IndexTable {
-
- final Set<Var> commonVars ;
- List<Binding> table = new ArrayList<>() ;
-
- public LinearIndex(Set<Var> commonVars, QueryIterator data)
- {
- this.commonVars = commonVars ;
- while ( data.hasNext() )
- table.add(data.next()) ;
- data.close() ;
- }
-
- public LinearIndex(Set<Var> commonVars, QueryIterator data, Set<HashIndexTable.Key> loadedData, Map<Var,Integer> mappings)
- {
- this.commonVars = commonVars ;
- for ( HashIndexTable.Key key: loadedData )
- table.add(toBinding(key, mappings)) ;
-
- while ( data.hasNext() )
- table.add(data.next()) ;
- data.close() ;
- }
-
- @Override
- public boolean containsCompatibleWithSharedDomain(Binding bindingLeft)
- {
- if ( commonVars.size() == 0 )
- return false ;
-
- for ( Binding bindingRight: table )
- {
- if ( hasCommonVars(bindingLeft, bindingRight)
- && Algebra.compatible(bindingLeft, bindingRight) )
- return true ;
- }
- return false ;
- }
-
- private boolean hasCommonVars(Binding left, Binding right)
- {
- for ( Var v: commonVars )
- {
- if ( left.contains(v) && right.contains(v) )
- return true ;
- }
- return false;
- }
-
- static Binding toBinding(HashIndexTable.Key key, Map<Var,Integer> mappings)
- {
- Node[] values = key.getNodes() ;
- BindingHashMap b = new BindingHashMap() ;
- for (Map.Entry<Var,Integer> mapping: mappings.entrySet())
- {
- Node value = values[mapping.getValue()] ;
- if ( value != null )
- b.add(mapping.getKey(), value) ;
- }
- return b ;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/SetIndexTable.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/SetIndexTable.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/SetIndexTable.java
deleted file mode 100644
index f5664fb..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/SetIndexTable.java
+++ /dev/null
@@ -1,70 +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.engine.index;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.sparql.core.Var;
-import com.hp.hpl.jena.sparql.engine.QueryIterator;
-import com.hp.hpl.jena.sparql.engine.binding.Binding;
-
-/**
- * An {@link IndexTable} implementation optimized for the case where there is
- * only a single common variable
- *
- */
-public class SetIndexTable implements IndexTable {
-
- private Var var;
- private Set<Node> values = new HashSet<>();
-
- /**
- * Creates a new index table
- *
- * @param commonVars
- * Common Variables
- * @param data
- * Data
- */
- public SetIndexTable(Set<Var> commonVars, QueryIterator data) {
- if (commonVars.size() != 1)
- throw new IllegalArgumentException("Common Variables must be of size 1");
-
- this.var = commonVars.iterator().next();
- while (data.hasNext()) {
- Binding binding = data.next();
- Node value = binding.get(this.var);
-
- if (value == null)
- continue;
- this.values.add(value);
- }
- }
-
- @Override
- public boolean containsCompatibleWithSharedDomain(Binding binding) {
- Node value = binding.get(this.var);
- if (value == null)
- return true;
- return this.values.contains(value);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.java
deleted file mode 100644
index 47ea947..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter.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.engine.iterator;
-
-import java.util.Map;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-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.serializer.SerializationContext ;
-
-/**
- * This class provides the general machinary for iterators. */
-public abstract class QueryIter extends QueryIteratorBase
-{
- // Volatile just to make it safe to concurrent updates
- // It does not matter too much if it is wrong - it's used as a label.
- volatile static int iteratorCounter = 0 ;
- private int iteratorNumber = (iteratorCounter++) ;
-
- private ExecutionContext tracker ;
-
- public QueryIter(ExecutionContext execCxt)
- {
- tracker = execCxt ;
- register() ;
- }
-
- public static QueryIter makeTracked(QueryIterator qIter, ExecutionContext execCxt)
- {
- if ( qIter instanceof QueryIter )
- return (QueryIter)qIter ;
- return new QueryIterTracked(qIter, execCxt) ;
- }
-
- public static QueryIter materialize(QueryIterator qIter, ExecutionContext execCxt)
- {
- return makeTracked(materialize(qIter), execCxt) ;
- }
-
- public static QueryIterator materialize(QueryIterator qIter)
- {
- return new QueryIteratorCopy(qIter) ;
- }
-
- public static QueryIterator map(QueryIterator qIter, Map<Var, Var> varMapping)
- {
- return new QueryIteratorMapped(qIter, varMapping);
- }
-
- @Override
- public final void close()
- {
- super.close() ;
- deregister() ;
- }
-
- public ExecutionContext getExecContext() { return tracker ; }
-
- public int getIteratorNumber() { return iteratorNumber ; }
-
- @Override
- public void output(IndentedWriter out)
- {
- output(out, null) ;
-// out.print(Plan.startMarker) ;
-// out.print(Utils.className(this)) ;
-// out.print(Plan.finishMarker) ;
- }
-
- @Override
- public void output(IndentedWriter out, SerializationContext sCxt)
- { out.println(getIteratorNumber()+"/"+debug()) ; }
-
- private void register()
- {
- if ( tracker != null )
- tracker.openIterator(this) ;
- }
-
- private void deregister()
- {
- if ( tracker != null )
- tracker.closedIterator(this) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter1.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter1.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter1.java
deleted file mode 100644
index 561927d..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter1.java
+++ /dev/null
@@ -1,88 +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.engine.iterator;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.util.Utils ;
-
-/**
- * This class supports a QueryIter that takes one QueryIterator as input. */
-public abstract class QueryIter1 extends QueryIter
-{
- private QueryIterator input ;
-
- public QueryIter1(QueryIterator input, ExecutionContext execCxt)
- {
- super(execCxt) ;
- this.input = input ;
- }
-
- protected QueryIterator getInput() { return input ; }
-
- @Override
- protected final
- void closeIterator()
- {
- closeSubIterator() ;
- performClose(input) ;
- input = null ;
- }
-
- @Override
- protected final
- void requestCancel()
- {
- requestSubCancel() ;
- performRequestCancel(input) ;
- }
-
- /** Cancellation of the query execution is happening */
- protected abstract void requestSubCancel() ;
-
- /** Pass on the close method - no need to close the QueryIterator passed to the QueryIter1 constructor */
- protected abstract void closeSubIterator() ;
-
- // Do better
- @Override
- public void output(IndentedWriter out, SerializationContext sCxt)
- {
- // Linear form.
- getInput().output(out, sCxt) ;
- out.ensureStartOfLine() ;
- details(out, sCxt) ;
- out.ensureStartOfLine() ;
-
-// details(out, sCxt) ;
-// out.ensureStartOfLine() ;
-// out.incIndent() ;
-// getInput().output(out, sCxt) ;
-// out.decIndent() ;
-// out.ensureStartOfLine() ;
- }
-
- protected void details(IndentedWriter out, SerializationContext sCxt)
- {
- out.println(Utils.className(this)) ;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java
deleted file mode 100644
index e5b96ec..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java
+++ /dev/null
@@ -1,94 +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.engine.iterator;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
-import com.hp.hpl.jena.sparql.engine.Plan ;
-import com.hp.hpl.jena.sparql.engine.QueryIterator ;
-import com.hp.hpl.jena.sparql.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.util.Utils ;
-
-/**
- * This class marks a QueryIter that takes two QueryIterators as input. */
-public abstract class QueryIter2 extends QueryIter
-{
- private QueryIterator leftInput ;
- private QueryIterator rightInput ;
-
- public QueryIter2(QueryIterator left, QueryIterator right, ExecutionContext execCxt)
- {
- super(execCxt) ;
- this.leftInput = left ;
- this.rightInput = right ;
- }
-
- protected QueryIterator getLeft() { return leftInput ; }
- protected QueryIterator getRight() { return rightInput ; }
-
- @Override
- protected final
- void closeIterator()
- {
- closeSubIterator() ;
- performClose(leftInput) ;
- performClose(rightInput) ;
- leftInput = null ;
- rightInput = null ;
- }
-
- @Override
- protected final
- void requestCancel()
- {
- performRequestCancel(leftInput) ;
- performRequestCancel(rightInput) ;
- }
-
- /** Cancellation of the query execution is happening */
- protected abstract void requestSubCancel() ;
-
- /** Pass on the close method - no need to close the left or right QueryIterators passed to the QueryIter1 constructor */
- protected abstract void closeSubIterator() ;
-
- // Do better
- @Override
- public void output(IndentedWriter out, SerializationContext sCxt)
- {
- out.println(Utils.className(this)) ;
- out.incIndent() ;
-
- out.print(Plan.startMarker) ;
- out.incIndent() ;
- getLeft().output(out, sCxt) ;
- out.decIndent() ;
- //out.ensureStartOfLine() ;
- out.println(Plan.finishMarker) ;
-
- out.print(Plan.startMarker) ;
- out.incIndent() ;
- getRight().output(out, sCxt) ;
- out.decIndent() ;
- //out.ensureStartOfLine() ;
- out.println(Plan.finishMarker) ;
-
- out.decIndent() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2LoopOnLeft.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2LoopOnLeft.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2LoopOnLeft.java
deleted file mode 100644
index 909aa5a..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2LoopOnLeft.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.engine.iterator;
-
-import com.hp.hpl.jena.sparql.algebra.Table ;
-import com.hp.hpl.jena.sparql.algebra.TableFactory ;
-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 ;
-
-/** Binary operation done by looping on the left, and materializing the right - this is not streamed on the right
- * See also QueryIterRepeatApply */
-public abstract class QueryIter2LoopOnLeft extends QueryIter2
-{
- Table tableRight ;
- Binding slot = null ;
-
- public QueryIter2LoopOnLeft(QueryIterator left, QueryIterator right, ExecutionContext qCxt)
- {
- super(left, right, qCxt) ;
-
- // Materialized right.
- tableRight = TableFactory.create(getRight()) ;
- getRight().close();
- }
-
- @Override
- protected final void closeSubIterator()
- { tableRight.close(); }
-
- @Override
- protected void requestSubCancel()
- { tableRight.close() ; }
-
- @Override
- protected final boolean hasNextBinding()
- {
- if ( slot != null )
- return true ;
-
- while ( getLeft().hasNext() )
- {
- Binding bindingLeft = getLeft().nextBinding() ;
- slot = getNextSlot(bindingLeft) ;
- if ( slot != null )
- {
- slot = bindingLeft ;
- return true ;
- }
- }
- getLeft().close() ;
- return false ;
- }
-
- protected abstract Binding getNextSlot(Binding bindingLeft) ;
-
- @Override
- protected final Binding moveToNextBinding()
- {
- if ( ! hasNextBinding() )
- return null ;
- Binding x = slot ;
- slot = null ;
- return x ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterAssign.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterAssign.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterAssign.java
deleted file mode 100644
index 9e7e80e..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterAssign.java
+++ /dev/null
@@ -1,101 +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.engine.iterator;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.query.QueryExecException ;
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.core.VarExprList ;
-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.binding.BindingMap ;
-import com.hp.hpl.jena.sparql.expr.Expr ;
-import com.hp.hpl.jena.sparql.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.util.Utils ;
-
-/** Extend each solution by a (var, expression) */
-
-public class QueryIterAssign extends QueryIterProcessBinding
-{
- private VarExprList exprs ;
- private final boolean mustBeNewVar ;
-
- public QueryIterAssign(QueryIterator input, Var var, Expr expr, ExecutionContext qCxt)
- {
- this(input, new VarExprList(var, expr) , qCxt, false) ;
- }
-
- public QueryIterAssign(QueryIterator input, VarExprList exprs, ExecutionContext qCxt, boolean mustBeNewVar)
- {
- // mustBeNewVar : any variable introduced must not already exist.
- // true => BIND
- // false => LET
- // Syntax checking of BIND should have assured this.
- super(input, qCxt) ;
- this.exprs = exprs ;
- this.mustBeNewVar = mustBeNewVar ;
- }
-
- @Override
- public Binding accept(Binding binding)
- {
- BindingMap b = BindingFactory.create(binding) ;
- for ( Var v : exprs.getVars() )
- {
- // Not this, where expressions do not see the new bindings.
- // Node n = exprs.get(v, bind, funcEnv) ;
- // which gives (Lisp) "let" semantics, not "let*" semantics
- Node n = exprs.get(v, b, getExecContext()) ;
-
- if ( n == null )
- // Expression failed to evaluate - no assignment
- continue ;
-
- // Check is already has a value; if so, must be sameValueAs
- if ( b.contains(v) )
- {
- // Optimization may linearize to push a stream through an (extend).
- if ( false && mustBeNewVar )
- throw new QueryExecException("Already set: "+v) ;
-
- Node n2 = b.get(v) ;
- if ( ! n2.sameValueAs(n) )
- //throw new QueryExecException("Already set: "+v) ;
- // Error in single assignment.
- return null ;
- continue ;
- }
- b.add(v, n) ;
- }
- return b ;
- }
-
- @Override
- protected void details(IndentedWriter out, SerializationContext cxt)
- {
- out.print(Utils.className(this)) ;
- out.print(" ") ;
- out.print(exprs.toString()) ;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterAssignVarValue.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterAssignVarValue.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterAssignVarValue.java
deleted file mode 100644
index 1051ac5..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterAssignVarValue.java
+++ /dev/null
@@ -1,84 +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.engine.iterator;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.query.QueryExecException ;
-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.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.util.FmtUtils ;
-import com.hp.hpl.jena.sparql.util.Utils ;
-
-/** Extend each solution by a (var, node)
- * When used with mustBeNewVar=false, this is a join.
- * If the input already has the variable assigned, then
- * it must be the same (.equals) node and if it is not,
- * the input row is rejected.
- * @see QueryIterAssign
- */
-
-public class QueryIterAssignVarValue extends QueryIterProcessBinding
-{
- private final Var var ;
- private final Node node ;
- private final boolean mustBeNewVar ;
-
- public QueryIterAssignVarValue(QueryIterator input, Var var, Node node, ExecutionContext qCxt)
- {
- this(input, var, node, qCxt, false) ;
- }
-
- public QueryIterAssignVarValue(QueryIterator input, Var var, Node node, ExecutionContext qCxt, boolean mustBeNewVar)
- {
- super(input, qCxt) ;
- this.var = var ;
- this.node = node ;
- this.mustBeNewVar = mustBeNewVar ;
- }
-
- @Override
- public Binding accept(Binding binding)
- {
- if ( binding.contains(var) )
- {
- if ( mustBeNewVar )
- throw new QueryExecException("Already set: "+var) ;
-
- Node n2 = binding.get(var) ;
- if ( ! n2.equals(node) )
- // And filter out.
- return null ;
- }
-
- return BindingFactory.binding(binding, var, node) ;
- }
-
- @Override
- protected void details(IndentedWriter out, SerializationContext cxt)
- {
- out.print(Utils.className(this)) ;
- out.print(" ?"+var.toString()+" = "+FmtUtils.stringForNode(node, cxt)) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterBlockTriples.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterBlockTriples.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterBlockTriples.java
deleted file mode 100644
index a60ff83..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterBlockTriples.java
+++ /dev/null
@@ -1,97 +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.engine.iterator;
-
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-import com.hp.hpl.jena.graph.Graph ;
-import com.hp.hpl.jena.graph.Triple ;
-import com.hp.hpl.jena.sparql.core.BasicPattern ;
-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.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.util.FmtUtils ;
-import com.hp.hpl.jena.sparql.util.Utils ;
-
-public class QueryIterBlockTriples extends QueryIter1
-{
- private BasicPattern pattern ;
- private Graph graph ;
- private QueryIterator output ;
-
- public static QueryIterator create(QueryIterator input,
- BasicPattern pattern ,
- ExecutionContext execContext)
- {
- return new QueryIterBlockTriples(input, pattern, execContext) ;
- }
-
- private QueryIterBlockTriples(QueryIterator input,
- BasicPattern pattern ,
- ExecutionContext execContext)
- {
- super(input, execContext) ;
- this.pattern = pattern ;
- graph = execContext.getActiveGraph() ;
- // Create a chain of triple iterators.
- QueryIterator chain = getInput() ;
- for (Triple triple : pattern)
- chain = new QueryIterTriplePattern(chain, triple, execContext) ;
- output = chain ;
- }
-
- @Override
- protected boolean hasNextBinding()
- {
- return output.hasNext() ;
- }
-
- @Override
- protected Binding moveToNextBinding()
- {
- return output.nextBinding() ;
- }
-
- @Override
- protected void closeSubIterator()
- {
- if ( output != null )
- output.close() ;
- output = null ;
- }
-
- @Override
- protected void requestSubCancel()
- {
- if ( output != null )
- output.cancel();
- }
-
- @Override
- protected void details(IndentedWriter out, SerializationContext sCxt)
- {
- out.print(Utils.className(this)) ;
- out.println() ;
- out.incIndent() ;
- FmtUtils.formatPattern(out, pattern, sCxt) ;
- out.decIndent() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterCommonParent.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterCommonParent.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterCommonParent.java
deleted file mode 100644
index 977ceda..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterCommonParent.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.engine.iterator;
-
-import java.util.Iterator ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.sparql.ARQInternalErrorException ;
-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.binding.BindingMap ;
-
-import org.apache.jena.atlas.logging.Log ;
-
-/**
- * Yield new bindings, with a fixed parent, with values from an iterator.
- * Parent must not have variables in common with the iterator stream.
- */
-public class QueryIterCommonParent extends QueryIterConvert
-{
- public QueryIterCommonParent(QueryIterator input, Binding binding, ExecutionContext execCxt)
- {
- super(input, new ConverterExtend(binding) , execCxt) ;
- }
-
- // Extend (with checking) an iterator stream of binding to have a common parent.
- static class ConverterExtend implements QueryIterConvert.Converter
- {
- private Binding parentBinding ;
-
- ConverterExtend(Binding parent) { parentBinding = parent ; }
-
- @Override
- public Binding convert(Binding b)
- {
- if ( parentBinding == null || parentBinding.isEmpty() )
- return b ;
-
- // This is the result. Could have BindingBase.setParent etc.
- BindingMap b2 = BindingFactory.create(parentBinding) ;
-
- // Copy the resultSet bindings to the combined result binding with checking.
- for ( Iterator<Var> iter = b.vars() ; iter.hasNext(); )
- {
- Var v = iter.next();
- Node n = b.get(v) ;
- if ( b2.contains(v) )
- {
- Node n2 = b2.get(v) ;
- if ( n2.equals(n) )
- Log.warn(this, "Binding already for "+v+" (same value)" ) ;
- else
- {
- Log.fatal(this, "Binding already for "+v+" (different values)" ) ;
- throw new ARQInternalErrorException("Incompatible bindings for "+v) ;
- }
- }
- b2.add(v, n) ;
- }
- return b2 ;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterConcat.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterConcat.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterConcat.java
deleted file mode 100644
index c24de38..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterConcat.java
+++ /dev/null
@@ -1,144 +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.engine.iterator;
-
-import java.util.ArrayList ;
-import java.util.Iterator ;
-import java.util.List ;
-import java.util.NoSuchElementException ;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-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.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.util.Utils ;
-
-
-/**
- * A query iterator that joins two or more iterators into a single iterator. */
-
-public class QueryIterConcat extends QueryIter
-{
- boolean initialized = false ;
- List<QueryIterator> iteratorList = new ArrayList<>() ;
- Iterator<QueryIterator> iterator ;
- QueryIterator currentQIter = null ;
-
- Binding binding ;
- boolean doneFirst = false ;
-
- public QueryIterConcat(ExecutionContext context)
- {
- super(context) ;
- }
-
- private void init()
- {
- if ( ! initialized )
- {
- currentQIter = null ;
- if ( iterator == null )
- iterator = iteratorList.listIterator() ;
- if ( iterator.hasNext() )
- currentQIter = iterator.next() ;
- initialized = true ;
- }
- }
-
- public void add(QueryIterator qIter)
- {
- if ( qIter != null )
- iteratorList.add(qIter) ;
- }
-
-
- @Override
- protected boolean hasNextBinding()
- {
- if ( isFinished() )
- return false ;
-
- init() ;
- if ( currentQIter == null )
- return false ;
-
- while ( ! currentQIter.hasNext() )
- {
- // End sub iterator
- //currentQIter.close() ;
- currentQIter = null ;
- if ( iterator.hasNext() )
- currentQIter = iterator.next() ;
- if ( currentQIter == null )
- {
- // No more.
- //close() ;
- return false ;
- }
- }
-
- return true ;
- }
-
- @Override
- protected Binding moveToNextBinding()
- {
- if ( ! hasNextBinding() )
- throw new NoSuchElementException(Utils.className(this)) ;
- if ( currentQIter == null )
- throw new NoSuchElementException(Utils.className(this)) ;
-
- Binding binding = currentQIter.nextBinding() ;
- return binding ;
- }
-
-
- @Override
- protected void closeIterator()
- {
- for ( QueryIterator qIter : iteratorList )
- {
- performClose( qIter );
- }
- }
-
- @Override
- protected void requestCancel()
- {
- for ( QueryIterator qIter : iteratorList )
- {
- performRequestCancel( qIter );
- }
- }
-
- @Override
- public void output(IndentedWriter out, SerializationContext sCxt)
- {
- out.println(Utils.className(this)) ;
- out.incIndent() ;
- for ( QueryIterator qIter : iteratorList )
- {
- qIter.output( out, sCxt );
- }
- out.decIndent() ;
- out.ensureStartOfLine() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterConvert.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterConvert.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterConvert.java
deleted file mode 100644
index ac6c09b..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterConvert.java
+++ /dev/null
@@ -1,73 +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.engine.iterator;
-
-import org.apache.jena.atlas.io.IndentedWriter ;
-
-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.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.util.Utils ;
-
-
-/** Iterator over another QueryIterator, applying a converter function
- * to each object that is returned by .next() */
-
-public class QueryIterConvert extends QueryIter1
-{
- public interface Converter
- {
- public Binding convert(Binding obj) ;
- }
-
- Converter converter ;
-
- public QueryIterConvert(QueryIterator iter, Converter c, ExecutionContext context)
- {
- super(iter, context) ;
- converter = c ;
- }
-
- @Override
- protected void
- closeSubIterator() {}
-
- @Override
- protected void
- requestSubCancel() {}
-
- @Override
- public boolean hasNextBinding()
- {
- return getInput().hasNext() ;
- }
-
- @Override
- public Binding moveToNextBinding()
- {
- return converter.convert(getInput().nextBinding()) ;
- }
-
- @Override
- protected void details(IndentedWriter out, SerializationContext cxt)
- {
- out.println(Utils.className(this)) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDefaulting.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDefaulting.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDefaulting.java
deleted file mode 100644
index 9df61c9..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDefaulting.java
+++ /dev/null
@@ -1,99 +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.engine.iterator;
-
-import java.util.NoSuchElementException ;
-
-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.util.Utils ;
-
-/** An iterator that returns at least one element from another iterator
- * or a default value (once) if the wrapped iterator returns nothing. */
-
-public class QueryIterDefaulting extends QueryIterSub
-{
- Binding defaultObject ;
-
- boolean returnDefaultObject = false ;
- boolean haveReturnedSomeObject = false ;
-
- public QueryIterDefaulting(QueryIterator cIter, Binding _defaultObject, ExecutionContext qCxt)
- {
- super(cIter, qCxt) ;
- defaultObject = _defaultObject ;
- }
-
- /** Returns true if the returned binding was the default object. Undef if before the iterator's first .hasNext() */
- public boolean wasDefaultObject()
- { return returnDefaultObject ; }
-
- @Override
- protected boolean hasNextBinding()
- {
- if ( isFinished() )
- return false ;
-
- if ( iter != null && iter.hasNext() )
- return true ;
-
- // Wrapped iterator has ended (or does not exist). Have we returned anything yet?
-
- if ( haveReturnedSomeObject )
- return false ;
-
- returnDefaultObject = true ;
- return true ;
- }
-
- @Override
- protected Binding moveToNextBinding()
- {
- if ( isFinished() )
- throw new NoSuchElementException(Utils.className(this)) ;
-
- if ( returnDefaultObject )
- {
- haveReturnedSomeObject = true ;
- return defaultObject ;
- }
-
- Binding binding = null ;
- if ( iter != null && iter.hasNext() )
- binding = iter.next() ;
- else
- {
- if ( haveReturnedSomeObject )
- throw new NoSuchElementException("DefaultingIterator - without hasNext call first") ;
- binding = defaultObject ;
- }
-
- haveReturnedSomeObject = true ;
- return binding ;
- }
-
- @Override
- protected void requestSubCancel()
- {}
-
- @Override
- protected void closeSubIterator()
- {}
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDiff.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDiff.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDiff.java
deleted file mode 100644
index dcf98a5..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDiff.java
+++ /dev/null
@@ -1,55 +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.engine.iterator;
-
-import java.util.Iterator ;
-
-import com.hp.hpl.jena.sparql.algebra.Algebra ;
-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 ;
-
-/** Diff by materializing the RHS - this is not streamed on the right */
-public class QueryIterDiff extends QueryIter2LoopOnLeft
-{
- public QueryIterDiff(QueryIterator left, QueryIterator right, ExecutionContext qCxt)
- {
- super(left, right, qCxt) ;
- }
-
- @Override
- protected Binding getNextSlot(Binding bindingLeft)
- {
- boolean accept = true ;
-
- for ( Iterator<Binding> iter = tableRight.iterator(null) ; iter.hasNext() ; )
- {
- Binding bindingRight = iter.next() ;
- if ( Algebra.compatible(bindingLeft, bindingRight) )
- {
- accept = false ;
- break ;
- }
- }
-
- if ( accept )
- return bindingLeft ;
- return null ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinct.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinct.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinct.java
deleted file mode 100644
index c207156..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinct.java
+++ /dev/null
@@ -1,68 +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.engine.iterator ;
-
-import java.util.ArrayList ;
-import java.util.Comparator ;
-
-import org.apache.jena.atlas.data.BagFactory ;
-import org.apache.jena.atlas.data.DistinctDataNet ;
-import org.apache.jena.atlas.data.ThresholdPolicy ;
-import org.apache.jena.atlas.data.ThresholdPolicyFactory ;
-import org.apache.jena.riot.system.SerializationFactoryFinder ;
-
-import com.hp.hpl.jena.query.SortCondition ;
-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.BindingComparator ;
-
-/**
- * A QueryIterator that suppresses items already seen. This will stream results
- * until the spill to disk threshold is passed. At that point, it will not
- * return any results until the input iterator has been exhausted.
- *
- * @see DistinctDataNet
- */
-public class QueryIterDistinct extends QueryIterDistinctReduced
-{
- final DistinctDataNet<Binding> db ;
-
- public QueryIterDistinct(QueryIterator qIter, ExecutionContext context)
- {
- super(qIter, context) ;
- ThresholdPolicy<Binding> policy = ThresholdPolicyFactory.policyFromContext(context.getContext()) ;
- Comparator<Binding> comparator = new BindingComparator(new ArrayList<SortCondition>(), context) ;
- this.db = BagFactory.newDistinctNet(policy, SerializationFactoryFinder.bindingSerializationFactory(), comparator) ;
- }
-
- @Override
- protected void closeSubIterator()
- { db.close() ; }
-
- @Override
- protected void requestSubCancel()
- { db.close() ; }
-
- @Override
- protected boolean isFreshSighting(Binding binding)
- {
- return db.netAdd(binding) ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinctMem.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinctMem.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinctMem.java
deleted file mode 100644
index d426d96..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinctMem.java
+++ /dev/null
@@ -1,50 +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.engine.iterator ;
-
-import java.util.HashSet ;
-import java.util.Set ;
-
-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 ;
-
-/** Memory limited QueryIterDistinct */
-public class QueryIterDistinctMem extends QueryIterDistinctReduced
-{
- private Set<Binding> seen = new HashSet<>() ;
-
- public QueryIterDistinctMem(QueryIterator iter, ExecutionContext context)
- {
- super(iter, context) ;
- }
-
- @Override
- protected void closeSubIterator()
- {
- seen = null ;
- super.closeSubIterator() ;
- }
-
- @Override
- protected boolean isFreshSighting(Binding binding)
- {
- return seen.contains(binding) ;
- }
-}
\ 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/engine/iterator/QueryIterDistinctReduced.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinctReduced.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinctReduced.java
deleted file mode 100644
index 1333216..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinctReduced.java
+++ /dev/null
@@ -1,80 +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.engine.iterator;
-
-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.BindingProjectNamed ;
-
-/** Implementation skeleton for DISTINCT and REDUCED. */
-
-public abstract class QueryIterDistinctReduced extends QueryIter1
-{
- private Binding slot = null ; // ready to go.
-
- public QueryIterDistinctReduced(QueryIterator iter, ExecutionContext context)
- { super(iter, context) ; }
-
- // Subclasses will want to implement this as well.
- @Override
- protected void closeSubIterator()
- { slot = null ; }
-
- // Subclasses may want to implement this as well.
- @Override
- protected void requestSubCancel()
- { closeSubIterator() ; }
-
- @Override
- final
- protected boolean hasNextBinding()
- {
- // Already waiting to go.
- if ( slot != null )
- return true ;
-
- // Always moves.
- for ( ; getInput().hasNext() ; )
- {
- Binding b = getInput().nextBinding() ;
- // Hide unnamed and internal variables.
- // Don't need to worry about rename scope vars
- // (they are projected away in sub-SELECT ?var { ... })
- b = new BindingProjectNamed(b) ;
- if ( isFreshSighting(b) )
- {
- slot = b ;
- return true ;
- }
- }
- return false ;
- }
-
- @Override
- final
- protected Binding moveToNextBinding()
- {
- Binding r = slot ;
- slot = null ;
- return r ;
- }
-
- protected abstract boolean isFreshSighting(Binding binding) ;
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinguishedVars.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinguishedVars.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinguishedVars.java
deleted file mode 100644
index d9abf89..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterDistinguishedVars.java
+++ /dev/null
@@ -1,47 +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.engine.iterator;
-
-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.BindingProjectNamed ;
-
-/** Filter bindings for distinguished variables only
- * Currently unused. */
-
-public class QueryIterDistinguishedVars extends QueryIterConvert
-{
-
- public QueryIterDistinguishedVars(QueryIterator iter, ExecutionContext context)
- {
- super(iter, conv, context) ;
- }
-
- static Converter conv = new ProjectWrap() ;
-
- static class ProjectWrap implements Converter
- {
- @Override
- public Binding convert(Binding binding)
- {
- return new BindingProjectNamed(binding) ;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/56534eac/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterExtendByVar.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterExtendByVar.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterExtendByVar.java
deleted file mode 100644
index d15185d..0000000
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIterExtendByVar.java
+++ /dev/null
@@ -1,73 +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.engine.iterator;
-
-import java.util.Iterator ;
-
-import com.hp.hpl.jena.graph.Node ;
-import com.hp.hpl.jena.sparql.ARQInternalErrorException ;
-import com.hp.hpl.jena.sparql.core.Var ;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
-import com.hp.hpl.jena.sparql.engine.binding.BindingFactory ;
-
-/**
- * Yield new bindings, with a fixed parent, with values from an iterator.
- */
-public class QueryIterExtendByVar extends QueryIter
-{
- // Use QueryIterProcessBinding?
- private Binding binding ;
- private Var var ;
- private Iterator<Node> members ;
-
- public QueryIterExtendByVar(Binding binding, Var var, Iterator<Node> members, ExecutionContext execCxt)
- {
- super(execCxt) ;
- if ( true ) { // Assume not too costly.
- if ( binding.contains(var) )
- throw new ARQInternalErrorException("Var "+var+" already set in "+binding) ;
- }
- this.binding = binding ;
- this.var = var ;
- this.members = members ;
- }
-
- @Override
- protected boolean hasNextBinding()
- {
- return members.hasNext() ;
- }
-
- @Override
- protected Binding moveToNextBinding()
- {
- Node n = members.next() ;
- Binding b = BindingFactory.binding(binding, var, n) ;
- return b ;
- }
-
- @Override
- protected void closeIterator()
- { }
-
- @Override
- protected void requestCancel()
- { }
-}