You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/09/18 11:37:09 UTC

svn commit: r1703793 - in /lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene: bkdtree/BKDTreeReader.java util/GeoUtils.java

Author: mikemccand
Date: Fri Sep 18 09:37:09 2015
New Revision: 1703793

URL: http://svn.apache.org/viewvc?rev=1703793&view=rev
Log:
LUCENE-6780: code style / nocommits

Modified:
    lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java
    lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java

Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java?rev=1703793&r1=1703792&r2=1703793&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java Fri Sep 18 09:37:09 2015
@@ -132,7 +132,7 @@ final class BKDTreeReader implements Acc
   }
 
   private boolean accept(QueryState state, int docID) throws IOException {
-    //System.out.println("    check accept docID=" + docID);
+    System.out.println("    check accept docID=" + docID);
     state.sndv.setDocument(docID);
     // How many values this doc has:
     int count = state.sndv.count();
@@ -141,6 +141,7 @@ final class BKDTreeReader implements Acc
 
       int latEnc = (int) ((enc>>32) & 0xffffffffL);
       int lonEnc = (int) (enc & 0xffffffffL);
+      System.out.println("      lat=" + BKDTreeWriter.decodeLat(latEnc) + " lon=" + BKDTreeWriter.decodeLon(lonEnc));
 
       if (latEnc >= state.latMinEnc &&
           latEnc < state.latMaxEnc &&
@@ -187,8 +188,8 @@ final class BKDTreeReader implements Acc
       state.docs.grow(count);
       for(int i=0;i<count;i++) {
         int docID = state.in.readInt();
-        assert accept(state, docID);
         //System.out.println("  docID=" + docID);
+        assert accept(state, docID);
         state.docs.add(docID);
       }
 
@@ -216,12 +217,13 @@ final class BKDTreeReader implements Acc
                         int cellLatMinEnc, int cellLatMaxEnc, int cellLonMinEnc, int cellLonMaxEnc)
     throws IOException {
 
-    //System.out.println("BKD: intersect nodeID=" + nodeID);
+    System.out.println("\nBKD: intersect nodeID=" + nodeID + " lat=" + BKDTreeWriter.decodeLat(state.latMinEnc) + " TO " + BKDTreeWriter.decodeLat(state.latMaxEnc) +
+                       " lon=" + BKDTreeWriter.decodeLon(state.lonMinEnc) + " TO " + BKDTreeWriter.decodeLon(state.lonMaxEnc));
 
     // 2.06 sec -> 1.52 sec for 225 OSM London queries:
     if (state.latLonFilter != null) {
 
-      // Only call the filter when the current cell does not fully contain the bbox:
+      // Don't check the filter if the current cell fully contains the query bbox (just keep recursing in that case):
       if (cellLatMinEnc > state.latMinEnc || cellLatMaxEnc < state.latMaxEnc ||
           cellLonMinEnc > state.lonMinEnc || cellLonMaxEnc < state.lonMaxEnc) {
 
@@ -239,6 +241,8 @@ final class BKDTreeReader implements Acc
         } else {
           // The cell crosses the shape boundary, so we fall through and do full filtering
         }
+      } else {
+        System.out.println("  straight recurse");
       }
     // TODO: clean this up: the bbox case should also just be a filter, and we should assert filter != null at the start
     } else if (state.latMinEnc <= cellLatMinEnc && state.latMaxEnc >= cellLatMaxEnc && state.lonMinEnc <= cellLonMinEnc && state.lonMaxEnc >= cellLonMaxEnc) {
@@ -260,13 +264,13 @@ final class BKDTreeReader implements Acc
     //System.out.println("\nintersect node=" + nodeID + " vs " + leafNodeOffset);
 
     if (nodeID >= leafNodeOffset) {
-      //System.out.println("  intersect leaf");
 
       // Leaf node; scan and filter all points in this block:
       //System.out.println("    intersect leaf nodeID=" + nodeID + " vs leafNodeOffset=" + leafNodeOffset + " fp=" + leafBlockFPs[nodeID-leafNodeOffset]);
       int hitCount = 0;
 
       long fp = leafBlockFPs[nodeID-leafNodeOffset];
+      System.out.println("  intersect leaf fp=" + fp);
       if (fp == 0) {
         // Dead end node (adversary case):
         //System.out.println("    dead-end leaf");
@@ -312,49 +316,57 @@ final class BKDTreeReader implements Acc
 
       if (dim == 0) {
 
-        //System.out.println("  split on lat=" + splitValue);
+        System.out.println("  split on lat=" + BKDTreeWriter.decodeLat(splitValue));
 
         // Inner node split on lat:
 
         // Left node:
         if (state.latMinEnc < splitValue) {
-          //System.out.println("  recurse left");
+          System.out.println("  recurse left");
           count += intersect(state,
                              2*nodeID,
                              cellLatMinEnc, splitValue, cellLonMinEnc, cellLonMaxEnc);
+        } else {
+          System.out.println("  no recurse left");
         }
 
         // Right node:
         if (state.latMaxEnc >= splitValue) {
-          //System.out.println("  recurse right");
+          System.out.println("  recurse right");
           count += intersect(state,
                              2*nodeID+1,
                              splitValue, cellLatMaxEnc, cellLonMinEnc, cellLonMaxEnc);
+        } else {
+          System.out.println("  no recurse right");
         }
 
       } else {
         // Inner node split on lon:
         assert dim == 1;
 
-        // System.out.println("  split on lon=" + splitValue);
+        System.out.println("  split on lon=" + BKDTreeWriter.decodeLon(splitValue));
 
         // Left node:
         if (state.lonMinEnc < splitValue) {
-          // System.out.println("  recurse left");
+          System.out.println("  recurse left");
           count += intersect(state,
                              2*nodeID,
                              cellLatMinEnc, cellLatMaxEnc, cellLonMinEnc, splitValue);
+        } else {
+          System.out.println("  no recurse left");
         }
 
         // Right node:
         if (state.lonMaxEnc >= splitValue) {
-          // System.out.println("  recurse right");
+          System.out.println("  recurse right");
           count += intersect(state,
                              2*nodeID+1,
                              cellLatMinEnc, cellLatMaxEnc, splitValue, cellLonMaxEnc);
+        } else {
+          System.out.println("  no recurse right");
         }
       }
-
+      System.out.println("  return nodeID=" + nodeID);
       return count;
     }
   }

Modified: lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java?rev=1703793&r1=1703792&r2=1703793&view=diff
==============================================================================
--- lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java (original)
+++ lucene/dev/branches/lucene6780/lucene/sandbox/src/java/org/apache/lucene/util/GeoUtils.java Fri Sep 18 09:37:09 2015
@@ -159,7 +159,7 @@ public final class GeoUtils {
   }
 
   /**
-   * Computes whether a rectangle is wholly within another rectangle (shared boundaries allowed)
+   * Computes whether the first (a) rectangle is wholly within another (b) rectangle (shared boundaries allowed)
    */
   public static boolean rectWithin(final double aMinX, final double aMinY, final double aMaxX, final double aMaxY,
                                    final double bMinX, final double bMinY, final double bMaxX, final double bMaxY) {
@@ -290,28 +290,29 @@ public final class GeoUtils {
 
   private static boolean rectAnyCornersOutsideCircle(final double rMinX, final double rMinY, final double rMaxX, final double rMaxY,
                                                      final double centerLon, final double centerLat, final double radiusMeters) {
-    return (SloppyMath.haversin(centerLat, centerLon, rMinY, rMinX)*1000.0 > radiusMeters
-        || SloppyMath.haversin(centerLat, centerLon, rMaxY, rMinX)*1000.0 > radiusMeters
-        || SloppyMath.haversin(centerLat, centerLon, rMaxY, rMaxX)*1000.0 > radiusMeters
-        || SloppyMath.haversin(centerLat, centerLon, rMinY, rMaxX)*1000.0 > radiusMeters);
+    return SloppyMath.haversin(centerLat, centerLon, rMinY, rMinX)*1000.0 > radiusMeters
+      || SloppyMath.haversin(centerLat, centerLon, rMaxY, rMinX)*1000.0 > radiusMeters
+      || SloppyMath.haversin(centerLat, centerLon, rMaxY, rMaxX)*1000.0 > radiusMeters
+      || SloppyMath.haversin(centerLat, centerLon, rMinY, rMaxX)*1000.0 > radiusMeters;
   }
 
   private static boolean rectAnyCornersInCircle(final double rMinX, final double rMinY, final double rMaxX, final double rMaxY,
                                                 final double centerLon, final double centerLat, final double radiusMeters) {
-    return (SloppyMath.haversin(centerLat, centerLon, rMinY, rMinX)*1000.0 <= radiusMeters
+    return SloppyMath.haversin(centerLat, centerLon, rMinY, rMinX)*1000.0 <= radiusMeters
         || SloppyMath.haversin(centerLat, centerLon, rMaxY, rMinX)*1000.0 <= radiusMeters
         || SloppyMath.haversin(centerLat, centerLon, rMaxY, rMaxX)*1000.0 <= radiusMeters
-        || SloppyMath.haversin(centerLat, centerLon, rMinY, rMaxX)*1000.0 <= radiusMeters);
+        || SloppyMath.haversin(centerLat, centerLon, rMinY, rMaxX)*1000.0 <= radiusMeters;
   }
 
   public static boolean rectWithinCircle(final double rMinX, final double rMinY, final double rMaxX, final double rMaxY,
                                          final double centerLon, final double centerLat, final double radiusMeters) {
-    return !(rectAnyCornersOutsideCircle(rMinX, rMinY, rMaxX, rMaxY, centerLon, centerLat, radiusMeters));
+    return rectAnyCornersOutsideCircle(rMinX, rMinY, rMaxX, rMaxY, centerLon, centerLat, radiusMeters) == false;
   }
 
   /**
    * Computes whether a rectangle crosses a circle
    */
+  // nocommit if the rect fully contains the circle, what will this return?  and if the circle fully contains the rect, then what?
   public static boolean rectCrossesCircle(final double rMinX, final double rMinY, final double rMaxX, final double rMaxY,
                                           final double centerLon, final double centerLat, final double radiusMeters) {
     return rectAnyCornersInCircle(rMinX, rMinY, rMaxX, rMaxY, centerLon, centerLat, radiusMeters)