You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2012/06/22 18:28:46 UTC
svn commit: r1352959 - in
/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine:
index/HashIndexTable.java index/IndexFactory.java index/IndexTable.java
index/LinearIndex.java iterator/QueryIter2.java
Author: rvesse
Date: Fri Jun 22 16:28:45 2012
New Revision: 1352959
URL: http://svn.apache.org/viewvc?rev=1352959&view=rev
Log:
Applied Paul Gearon's further patch for JENA-266 to add test cases for new data structures introduced to speed up MINUS evaluation
Modified:
jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java
jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java
jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java
jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java
jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java
Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java?rev=1352959&r1=1352958&r2=1352959&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/HashIndexTable.java Fri Jun 22 16:28:45 2012
@@ -29,6 +29,12 @@ 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.
+ * @author Paul Gearon
+ */
public class HashIndexTable implements IndexTable {
final private Set<Key> table ;
Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java?rev=1352959&r1=1352958&r2=1352959&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexFactory.java Fri Jun 22 16:28:45 2012
@@ -24,6 +24,11 @@ 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}.
+ * @author Paul Gearon
+ */
public class IndexFactory {
public static IndexTable createIndex(Set<Var> commonVars, QueryIterator data)
Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java?rev=1352959&r1=1352958&r2=1352959&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/IndexTable.java Fri Jun 22 16:28:45 2012
@@ -20,6 +20,13 @@ package com.hp.hpl.jena.sparql.engine.in
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.
+ * @author Paul Gearon
+ */
public interface IndexTable {
public abstract boolean containsCompatibleWithSharedDomain(Binding binding);
Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java?rev=1352959&r1=1352958&r2=1352959&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/index/LinearIndex.java Fri Jun 22 16:28:45 2012
@@ -30,6 +30,24 @@ import com.hp.hpl.jena.sparql.engine.Que
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.
+ * @author Paul Gearon
+ */
+
public class LinearIndex implements IndexTable {
final Set<Var> commonVars ;
@@ -79,7 +97,7 @@ public class LinearIndex implements Inde
return false;
}
- private static Binding toBinding(HashIndexTable.Key key, Map<Var,Integer> mappings)
+ static Binding toBinding(HashIndexTable.Key key, Map<Var,Integer> mappings)
{
Node[] values = key.getNodes() ;
BindingHashMap b = new BindingHashMap() ;
Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java?rev=1352959&r1=1352958&r2=1352959&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/iterator/QueryIter2.java Fri Jun 22 16:28:45 2012
@@ -27,7 +27,7 @@ import com.hp.hpl.jena.sparql.serializer
import com.hp.hpl.jena.sparql.util.Utils ;
/**
- * This class makrs a QueryIter that takes one QueryIterator as input. */
+ * This class makrs a QueryIter that takes two QueryIterators as input. */
public abstract class QueryIter2 extends QueryIter
{
private QueryIterator leftInput ;