lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pj...@apache.org
Subject svn commit: r783517 - in /lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier: CartesianShapeFilter.java DistanceFieldComparatorSource.java LatLongDistanceFilter.java
Date Wed, 10 Jun 2009 20:59:27 GMT
Author: pjaol
Date: Wed Jun 10 20:59:26 2009
New Revision: 783517

URL: http://svn.apache.org/viewvc?rev=783517&view=rev
Log:
Fixed doc id's to bitset id for sorting with a multi segmented index FieldSourceComparator
still uses bitset id's

Modified:
    lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java
    lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.java
    lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/LatLongDistanceFilter.java

Modified: lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java?rev=783517&r1=783516&r2=783517&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java
(original)
+++ lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianShapeFilter.java
Wed Jun 10 20:59:26 2009
@@ -51,7 +51,7 @@
     TermDocs termDocs = reader.termDocs();
     List<Double> area = shape.getArea();
     int sz = area.size();
-    log.info("Area size "+ sz);
+    log.fine("Area size "+ sz);
     
     // iterate through each boxid
     for (int i =0; i< sz; i++) {
@@ -68,7 +68,7 @@
     }
     
     long end = System.currentTimeMillis();
-    log.info("BoundaryBox Time Taken: "+ (end - start) + " found: "+bits.cardinality()+"
candidates");
+    log.fine("BoundaryBox Time Taken: "+ (end - start) + " found: "+bits.cardinality()+"
candidates");
     return bits;
   }
 

Modified: lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.java?rev=783517&r1=783516&r2=783517&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.java
(original)
+++ lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.java
Wed Jun 10 20:59:26 2009
@@ -48,8 +48,8 @@
 	}
 
 	@Override
-	public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean
reversed)
-			throws IOException {
+	public FieldComparator newComparator(String fieldname, int numHits,
+			int sortPos, boolean reversed) throws IOException {
 		dsdlc = new DistanceScoreDocLookupComparator(distanceFilter, numHits);
 		return dsdlc;
 	}
@@ -59,8 +59,10 @@
 		private DistanceFilter distanceFilter;
 		private double[] values;
 		private double bottom;
-
-		public DistanceScoreDocLookupComparator(DistanceFilter distanceFilter, int numHits) {
+		private int offset =0;
+		
+		public DistanceScoreDocLookupComparator(DistanceFilter distanceFilter,
+				int numHits) {
 			this.distanceFilter = distanceFilter;
 			values = new double[numHits];
 			return;
@@ -78,26 +80,25 @@
 			return 0;
 		}
 
-	
-
 		public void cleanUp() {
 			distanceFilter = null;
 		}
 
 		@Override
 		public int compareBottom(int doc) {
-			final double v2 = distanceFilter.getDistance(doc);
-      if (bottom > v2) {
-        return 1;
-      } else if (bottom < v2) {
-        return -1;
-      } 
+			double v2 = distanceFilter.getDistance(doc+ offset);
+			
+			if (bottom > v2) {
+				return 1;
+			} else if (bottom < v2) {
+				return -1;
+			}
 			return 0;
 		}
 
 		@Override
 		public void copy(int slot, int doc) {
-			values[slot] = distanceFilter.getDistance(doc);
+			values[slot] = distanceFilter.getDistance(doc + offset);
 		}
 
 		@Override
@@ -107,10 +108,12 @@
 		}
 
 		@Override
-		public void setNextReader(IndexReader reader, int docBase, int numSlotsFull)
-				throws IOException {
-			// TODO Auto-generated method stub
-
+		public void setNextReader(IndexReader reader, int docBase,
+				int numSlotsFull) throws IOException {
+			
+			// each reader in a segmented base
+			// has an offset based on the maxDocs of previous readers
+			offset = docBase;
 		}
 
 		@Override
@@ -120,7 +123,7 @@
 
 		@Override
 		public int sortType() {
-			
+
 			return SortField.DOUBLE;
 		}
 	}

Modified: lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/LatLongDistanceFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/LatLongDistanceFilter.java?rev=783517&r1=783516&r2=783517&view=diff
==============================================================================
--- lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/LatLongDistanceFilter.java
(original)
+++ lucene/java/trunk/contrib/spatial/src/java/org/apache/lucene/spatial/tier/LatLongDistanceFilter.java
Wed Jun 10 20:59:26 2009
@@ -45,7 +45,7 @@
   String latField;
   String lngField;
   Logger log = Logger.getLogger(getClass().getName());
-  int offset =0;
+
   int nextOffset = 0;
   
   Map<Integer,Double> distances = null;
@@ -89,12 +89,18 @@
     //   distances for the same point 
     //   TODO: Why is this a WeakHashMap? 
     WeakHashMap<String,Double> cdistance = new WeakHashMap<String,Double>(maxdocs);
-    
+    long start = System.currentTimeMillis();
     String[] latIndex = FieldCache.DEFAULT.getStrings(reader, latField);
     String[] lngIndex = FieldCache.DEFAULT.getStrings(reader, lngField);
 
     /* store calculated distances for reuse by other components */
     distances = new HashMap<Integer,Double>(maxdocs);
+    
+    
+    if (distances == null){
+    	distances = new HashMap<Integer,Double>();
+    }
+    
     for (int i = 0 ; i < maxdocs; i++) {
       
       String sx = latIndex[i];
@@ -121,11 +127,22 @@
       }
       distances.put(i, d);
       
+   // why was i storing all distances again?
       if (d < distance){
         bits.set(i);
+        distances.put(i+ nextOffset, d); // include nextOffset for multi segment reader 

       }
+      i = bits.nextSetBit(i+1);
       
     }
+    int size = bits.cardinality();
+    nextOffset += reader.maxDoc();  // this should be something that's part of indexReader
+    long end = System.currentTimeMillis();
+    log.fine("Bits 1: Time taken : "+ (end - start) + 
+            ", results : "+ distances.size() + 
+            ", cached : "+ cdistance.size() +
+            ", incoming size: "+ size+
+            ", nextOffset: "+ nextOffset);
     
     return bits;
   }
@@ -146,13 +163,9 @@
     HashMap<String,Double> cdistance = new HashMap<String,Double>(size);
     
 
-    /* store calculated distances for reuse by other components */
-    boolean db = false;
-    offset += reader.maxDoc();
+    
     if (distances == null){
     	distances = new HashMap<Integer,Double>();
-    }else {
-    	db=true;
     }
     
     long start = System.currentTimeMillis();
@@ -193,20 +206,24 @@
       // why was i storing all distances again?
       if (d < distance){
         result.set(i);
-        distances.put(i+ nextOffset, d); // include nextOffset for multireader  
+        int did = i + nextOffset;
+        distances.put(did, d); // include nextOffset for multi segment reader  
+        
       }
       i = bits.nextSetBit(i+1);
     }
     
     long end = System.currentTimeMillis();
+    nextOffset += reader.maxDoc();  // this should be something that's part of indexReader
     log.fine("Time taken : "+ (end - start) + 
         ", results : "+ distances.size() + 
         ", cached : "+ cdistance.size() +
-        ", incoming size: "+ size);
+        ", incoming size: "+ size+
+        ", nextOffset: "+ nextOffset);
   
 
     cdistance = null;
-    nextOffset += offset;  // this should be something that's part of indexReader
+    
     
     return result;
   }



Mime
View raw message