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 2012/04/08 21:37:16 UTC
svn commit: r1311075 -
/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleIndexRecord.java
Author: andy
Date: Sun Apr 8 19:37:16 2012
New Revision: 1311075
URL: http://svn.apache.org/viewvc?rev=1311075&view=rev
Log:
Fix use of indexes with partial scans (not used in TDB release).
Modified:
incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleIndexRecord.java
Modified: incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleIndexRecord.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleIndexRecord.java?rev=1311075&r1=1311074&r2=1311075&view=diff
==============================================================================
--- incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleIndexRecord.java (original)
+++ incubator/jena/Jena2/TDB/trunk/src/main/java/com/hp/hpl/jena/tdb/index/TupleIndexRecord.java Sun Apr 8 19:37:16 2012
@@ -94,16 +94,16 @@ public class TupleIndexRecord extends Tu
return findWorker(pattern, false, false) ;
}
- private Iterator<Tuple<NodeId>> findWorker(Tuple<NodeId> pattern, boolean partialScanAllowed, boolean fullScanAllowed)
+ private Iterator<Tuple<NodeId>> findWorker(Tuple<NodeId> patternNaturalOrder, boolean partialScanAllowed, boolean fullScanAllowed)
{
if ( Check )
{
- if ( tupleLength != pattern.size() )
- throw new TDBException(String.format("Mismatch: tuple length %d / index for length %d", pattern.size(), tupleLength)) ;
+ if ( tupleLength != patternNaturalOrder.size() )
+ throw new TDBException(String.format("Mismatch: tuple length %d / index for length %d", patternNaturalOrder.size(), tupleLength)) ;
}
// Convert to index order.
- pattern = colMap.map(pattern) ;
+ Tuple<NodeId> pattern = colMap.map(patternNaturalOrder) ;
// Canonical form.
int numSlots = 0 ;
@@ -114,25 +114,25 @@ public class TupleIndexRecord extends Tu
Record minRec = factory.createKeyOnly() ;
Record maxRec = factory.createKeyOnly() ;
+ // Set the prefixes.
for ( int i = 0 ; i < pattern.size() ; i++ )
{
NodeId X = pattern.get(i) ;
if ( NodeId.isAny(X) )
+ {
X = null ;
-
- if ( X != null )
+ // No longer seting leading key slots.
+ leading = false ;
+ continue ;
+ }
+
+ numSlots++ ;
+ if ( leading )
{
- numSlots++ ;
- if ( leading )
- {
- leadingIdx = i ;
- Bytes.setLong(X.getId(), minRec.getKey(), i*SizeOfNodeId) ;
- Bytes.setLong(X.getId(), maxRec.getKey(), i*SizeOfNodeId) ;
- }
+ leadingIdx = i ;
+ Bytes.setLong(X.getId(), minRec.getKey(), i*SizeOfNodeId) ;
+ Bytes.setLong(X.getId(), maxRec.getKey(), i*SizeOfNodeId) ;
}
- else
- // Not leading key slots.
- leading = false ;
}
// Is it a simple existence test?
@@ -170,11 +170,10 @@ public class TupleIndexRecord extends Tu
{
if ( ! partialScanAllowed )
return null ;
-
- //System.out.println("Partial scan") ;
// Didn't match all defined slots in request.
// Partial or full scan needed.
- tuples = scan(tuples, pattern) ;
+ //pattern.unmap(colMap) ;
+ tuples = scan(tuples, patternNaturalOrder) ;
}
return tuples ;
@@ -204,13 +203,13 @@ public class TupleIndexRecord extends Tu
@Override
public boolean accept(Tuple<NodeId> item)
{
- // Check on pattern
+ // Check on pattern and item (both in natural order)
for ( int i = 0 ; i < tupleLength ; i++ )
{
NodeId n = pattern.get(i) ;
// The pattern must be null/Any or match the tuple being tested.
if ( ! NodeId.isAny(n) )
- if ( ! item.get(i).equals(pattern.get(i)) )
+ if ( ! item.get(i).equals(n) )
return false ;
}
return true ;