lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1693702 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/util/ lucene/sandbox/ lucene/sandbox/src/java/org/apache/lucene/util/ lucene/sandbox/src/test/org/apache/lucene/search/ lucene/sand...
Date Sat, 01 Aug 2015 10:13:10 GMT
Author: mikemccand
Date: Sat Aug  1 10:13:10 2015
New Revision: 1693702

URL: http://svn.apache.org/r1693702
Log:
LUCENE-6647: add GeoHash string utility APIs

Added:
    lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/util/GeoHashUtils.java
      - copied unchanged from r1693700, lucene/dev/trunk/lucene/sandbox/src/java/org/apache/lucene/util/GeoHashUtils.java
    lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/util/
      - copied from r1693700, lucene/dev/trunk/lucene/sandbox/src/test/org/apache/lucene/util/
Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/lucene/core/   (props changed)
    lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/BitUtil.java
    lucene/dev/branches/branch_5x/lucene/sandbox/   (props changed)
    lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java

Modified: lucene/dev/branches/branch_5x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/CHANGES.txt?rev=1693702&r1=1693701&r2=1693702&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/lucene/CHANGES.txt Sat Aug  1 10:13:10 2015
@@ -111,6 +111,9 @@ New Features
   filtering.  Range trees can also handle values larger than 64 bits.
   (Adrien Grand, Mike McCandless)
 
+* LUCENE-6647: Add GeoHash string utility APIs (Nick Knize, Mike
+  McCandless).
+
 API Changes
 
 * LUCENE-6508: Simplify Lock api, there is now just 

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/BitUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/BitUtil.java?rev=1693702&r1=1693701&r2=1693702&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/BitUtil.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/BitUtil.java
Sat Aug  1 10:13:10 2015
@@ -94,7 +94,8 @@ public final class BitUtil {
   private static final long MAGIC[] = {
       0x5555555555555555L, 0x3333333333333333L,
       0x0F0F0F0F0F0F0F0FL, 0x00FF00FF00FF00FFL,
-      0x0000FFFF0000FFFFL, 0x00000000FFFFFFFFL
+      0x0000FFFF0000FFFFL, 0x00000000FFFFFFFFL,
+      0xAAAAAAAAAAAAAAAAL
   };
   // shift values for bit interleaving
   private static final short SHIFT[] = {1, 2, 4, 8, 16};
@@ -235,6 +236,13 @@ public final class BitUtil {
     return b;
   }
 
+  /**
+   * flip flops odd with even bits
+   */
+  public static final long flipFlop(final long b) {
+    return ((b & MAGIC[6]) >>> 1) | ((b & MAGIC[0]) << 1 );
+  }
+
    /** Same as {@link #zigZagEncode(long)} but on integers. */
    public static int zigZagEncode(int i) {
      return (i >> 31) ^ (i << 1);

Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java?rev=1693702&r1=1693701&r2=1693702&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
(original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/test/org/apache/lucene/search/TestGeoPointQuery.java
Sat Aug  1 10:13:10 2015
@@ -46,6 +46,7 @@ import org.apache.lucene.util.GeoUtils;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.SloppyMath;
+import org.apache.lucene.util.TestGeoUtils;
 import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -68,37 +69,10 @@ public class TestGeoPointQuery extends L
   // determining the possible haversine error
   private static final int DISTANCE_ERR = 1000;
 
-  // Global bounding box we will "cover" in the random test; we have to make this "smallish"
else the queries take very long:
-  private static double originLat;
-  private static double originLon;
-//  private static double range;
-  private static double lonRange;
-  private static double latRange;
-
   @BeforeClass
   public static void beforeClass() throws Exception {
     directory = newDirectory();
 
-    // when we randomly test the full lat/lon space it can result in very very slow query
times, this is due to the
-    // number of ranges that can be created in degenerate cases.
-
-    // Between 1.0 and 3.0:
-//    range = 2*(random().nextDouble() + 0.5);
-    // Between 1.0 and 90.0
-    //lonRange = 1.0 + (90.0 - 1.0) * random().nextDouble();
-    //latRange = 1.0 + (45.0 - 1.0) * random().nextDouble();
-
-    // Between 1.0 and 3.0:
-    lonRange = 2*(random().nextDouble() + 0.5);
-    latRange = 2*(random().nextDouble() + 0.5);
-
-    originLon = GeoUtils.MIN_LON_INCL + lonRange + (GeoUtils.MAX_LON_INCL - GeoUtils.MIN_LON_INCL
- 2*lonRange) * random().nextDouble();
-    originLon = GeoUtils.normalizeLon(originLon);
-    originLat = GeoUtils.MIN_LAT_INCL + latRange + (GeoUtils.MAX_LAT_INCL - GeoUtils.MIN_LAT_INCL
- 2*latRange) * random().nextDouble();
-    originLat = GeoUtils.normalizeLat(originLat);
-    if (VERBOSE) {
-      System.out.println("TEST: originLon=" + originLon + " lonRange= " + lonRange + " originLat="
+ originLat + " latRange=" + latRange);
-    }
     RandomIndexWriter writer = new RandomIndexWriter(random(), directory,
             newIndexWriterConfig(new MockAnalyzer(random()))
                     .setMaxBufferedDocs(TestUtil.nextInt(random(), 100, 1000))
@@ -306,13 +280,13 @@ public class TestGeoPointQuery extends L
         if (x == 0) {
           // Identical lat to old point
           lats[docID] = lats[oldDocID];
-          lons[docID] = randomLon();
+          lons[docID] = TestGeoUtils.randomLon();
           if (VERBOSE) {
             //System.out.println("  doc=" + docID + " lat=" + lats[docID] + " lon=" + lons[docID]
+ " (same lat as doc=" + oldDocID + ")");
           }
         } else if (x == 1) {
           // Identical lon to old point
-          lats[docID] = randomLat();
+          lats[docID] = TestGeoUtils.randomLat();
           lons[docID] = lons[oldDocID];
           if (VERBOSE) {
             //System.out.println("  doc=" + docID + " lat=" + lats[docID] + " lon=" + lons[docID]
+ " (same lon as doc=" + oldDocID + ")");
@@ -327,8 +301,8 @@ public class TestGeoPointQuery extends L
           }
         }
       } else {
-        lats[docID] = randomLat();
-        lons[docID] = randomLon();
+        lats[docID] = TestGeoUtils.randomLat();
+        lons[docID] = TestGeoUtils.randomLon();
         haveRealDoc = true;
         if (VERBOSE) {
           //System.out.println("  doc=" + docID + " lat=" + lats[docID] + " lon=" + lons[docID]);
@@ -618,19 +592,11 @@ public class TestGeoPointQuery extends L
          || (tMaxLon - tLon) == 0 || (tMaxLat - tLat) == 0);
   }
 
-  private static double randomLat() {
-    return GeoUtils.normalizeLat(originLat + latRange * (random().nextDouble() - 0.5));
-  }
-
-  private static double randomLon() {
-    return GeoUtils.normalizeLon(originLon + lonRange * (random().nextDouble() - 0.5));
-  }
-
   private static GeoBoundingBox randomBBox() {
-    double lat0 = randomLat();
-    double lat1 = randomLat();
-    double lon0 = randomLon();
-    double lon1 = randomLon();
+    double lat0 = TestGeoUtils.randomLat();
+    double lat1 = TestGeoUtils.randomLat();
+    double lon0 = TestGeoUtils.randomLon();
+    double lon1 = TestGeoUtils.randomLon();
 
     if (lat1 < lat0) {
       double x = lat0;



Mime
View raw message