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 2016/02/25 19:42:02 UTC

[09/18] lucene-solr git commit: Merge branch 'master' into point_set_query

Merge branch 'master' into point_set_query

Conflicts:
	lucene/sandbox/src/java/org/apache/lucene/document/LatLonPoint.java


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/dfbcbf96
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/dfbcbf96
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/dfbcbf96

Branch: refs/heads/master
Commit: dfbcbf96cd3b6142fcc829944015f8de0014f575
Parents: 30fcafd 77e6227
Author: Mike McCandless <mi...@apache.org>
Authored: Wed Feb 24 08:48:48 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Wed Feb 24 08:48:48 2016 -0500

----------------------------------------------------------------------
 .../org/apache/lucene/document/BinaryPoint.java |   9 +-
 .../org/apache/lucene/document/DoublePoint.java |   9 +-
 .../org/apache/lucene/document/FloatPoint.java  |   9 +-
 .../org/apache/lucene/document/IntPoint.java    |   9 +-
 .../org/apache/lucene/document/LongPoint.java   |   9 +-
 .../apache/lucene/search/PointRangeQuery.java   |   7 +-
 .../apache/lucene/search/TestPointQueries.java  |   5 +-
 .../apache/lucene/document/BigIntegerPoint.java |   9 +-
 .../lucene/document/InetAddressPoint.java       |   9 +-
 .../org/apache/lucene/document/LatLonPoint.java | 138 ++++++++++++-
 .../lucene/search/PointInPolygonQuery.java      |   2 +-
 .../apache/lucene/search/PointInRectQuery.java  | 200 -------------------
 .../apache/lucene/document/TestLatLonPoint.java |  56 ++++++
 .../lucene/search/TestLatLonPointQueries.java   |   9 +-
 .../SolrStopwordsCarrot2LexicalDataFactory.java |   6 +-
 .../carrot2/EchoClusteringAlgorithm.java        |   6 +-
 .../carrot2/EchoStemsClusteringAlgorithm.java   |   8 +-
 .../carrot2/EchoTokensClusteringAlgorithm.java  |   6 +-
 ...exicalResourcesCheckClusteringAlgorithm.java |   6 +-
 .../carrot2/MockClusteringAlgorithm.java        |  12 +-
 .../org/apache/solr/handler/BlobHandler.java    |  38 ----
 .../apache/solr/handler/SolrConfigHandler.java  |   3 +-
 .../solr/handler/admin/CollectionsHandler.java  |  20 +-
 .../src/resources/SystemCollectionSchema.xml    |  17 ++
 .../resources/SystemCollectionSolrConfig.xml    |  20 ++
 .../apache/solr/core/TestSolrConfigHandler.java |   4 +-
 26 files changed, 315 insertions(+), 311 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dfbcbf96/lucene/core/src/java/org/apache/lucene/document/DoublePoint.java
----------------------------------------------------------------------
diff --cc lucene/core/src/java/org/apache/lucene/document/DoublePoint.java
index 53973c9,2db2d85..e69d0b9
--- a/lucene/core/src/java/org/apache/lucene/document/DoublePoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/DoublePoint.java
@@@ -16,13 -16,9 +16,14 @@@
   */
  package org.apache.lucene.document;
  
 +import java.io.IOException;
 +import java.util.Arrays;
 +
 +import org.apache.lucene.search.PointInSetQuery;
  import org.apache.lucene.search.PointRangeQuery;
+ import org.apache.lucene.search.Query;
  import org.apache.lucene.util.BytesRef;
 +import org.apache.lucene.util.BytesRefIterator;
  import org.apache.lucene.util.NumericUtils;
  
  /** 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dfbcbf96/lucene/core/src/java/org/apache/lucene/document/FloatPoint.java
----------------------------------------------------------------------
diff --cc lucene/core/src/java/org/apache/lucene/document/FloatPoint.java
index d262c18,027dc66..1f39a9f
--- a/lucene/core/src/java/org/apache/lucene/document/FloatPoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/FloatPoint.java
@@@ -16,13 -16,9 +16,14 @@@
   */
  package org.apache.lucene.document;
  
 +import java.io.IOException;
 +import java.util.Arrays;
 +
 +import org.apache.lucene.search.PointInSetQuery;
  import org.apache.lucene.search.PointRangeQuery;
+ import org.apache.lucene.search.Query;
  import org.apache.lucene.util.BytesRef;
 +import org.apache.lucene.util.BytesRefIterator;
  import org.apache.lucene.util.NumericUtils;
  
  /** 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dfbcbf96/lucene/core/src/java/org/apache/lucene/document/IntPoint.java
----------------------------------------------------------------------
diff --cc lucene/core/src/java/org/apache/lucene/document/IntPoint.java
index cdd10c7,2d411e9..a78c30d
--- a/lucene/core/src/java/org/apache/lucene/document/IntPoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/IntPoint.java
@@@ -16,13 -16,9 +16,14 @@@
   */
  package org.apache.lucene.document;
  
 +import java.io.IOException;
 +import java.util.Arrays;
 +
 +import org.apache.lucene.search.PointInSetQuery;
  import org.apache.lucene.search.PointRangeQuery;
+ import org.apache.lucene.search.Query;
  import org.apache.lucene.util.BytesRef;
 +import org.apache.lucene.util.BytesRefIterator;
  import org.apache.lucene.util.NumericUtils;
  
  /** 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dfbcbf96/lucene/core/src/java/org/apache/lucene/document/LongPoint.java
----------------------------------------------------------------------
diff --cc lucene/core/src/java/org/apache/lucene/document/LongPoint.java
index 9c0ba3f,69b511d..d0c5655
--- a/lucene/core/src/java/org/apache/lucene/document/LongPoint.java
+++ b/lucene/core/src/java/org/apache/lucene/document/LongPoint.java
@@@ -16,13 -16,9 +16,14 @@@
   */
  package org.apache.lucene.document;
  
 +import java.io.IOException;
 +import java.util.Arrays;
 +
 +import org.apache.lucene.search.PointInSetQuery;
  import org.apache.lucene.search.PointRangeQuery;
+ import org.apache.lucene.search.Query;
  import org.apache.lucene.util.BytesRef;
 +import org.apache.lucene.util.BytesRefIterator;
  import org.apache.lucene.util.NumericUtils;
  
  /** 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dfbcbf96/lucene/core/src/test/org/apache/lucene/search/TestPointQueries.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dfbcbf96/lucene/sandbox/src/java/org/apache/lucene/document/BigIntegerPoint.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dfbcbf96/lucene/sandbox/src/java/org/apache/lucene/document/InetAddressPoint.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/dfbcbf96/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPoint.java
----------------------------------------------------------------------
diff --cc lucene/sandbox/src/java/org/apache/lucene/document/LatLonPoint.java
index 9e18c19,0ea9efb..dca5f97
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPoint.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonPoint.java
@@@ -83,6 -128,89 +128,91 @@@ public class LatLonPoint extends Field 
    public static double decodeLon(int x) {
      return x / LON_SCALE;
    }
 +
 +  // nocommit newSetQuery
+   
+   /** Turns quantized value from byte array back into a double. */
+   public static double decodeLon(byte[] src, int offset) {
+     return decodeLon(NumericUtils.bytesToInt(src, offset));
+   }
+   
+   /** sugar encodes a single point as a 2D byte array */
+   private static byte[][] encode(double lat, double lon) {
+     byte[][] bytes = new byte[2][];
+     bytes[0] = new byte[4];
+     NumericUtils.intToBytes(encodeLat(lat), bytes[0], 0);
+     bytes[1] = new byte[4];
+     NumericUtils.intToBytes(encodeLon(lon), bytes[1], 0);
+     return bytes;
+   }
+    
+   // static methods for generating queries
+ 
+   /**
+    * Create a query for matching a bounding box.
+    * <p>
+    * The box may cross over the dateline.
+    */
+   public static Query newBoxQuery(String field, double minLat, double maxLat, double minLon, double maxLon) {
+     if (GeoUtils.isValidLat(minLat) == false) {
+       throw new IllegalArgumentException("minLat=" + minLat + " is not a valid latitude");
+     }
+     if (GeoUtils.isValidLat(maxLat) == false) {
+       throw new IllegalArgumentException("maxLat=" + maxLat + " is not a valid latitude");
+     }
+     if (GeoUtils.isValidLon(minLon) == false) {
+       throw new IllegalArgumentException("minLon=" + minLon + " is not a valid longitude");
+     }
+     if (GeoUtils.isValidLon(maxLon) == false) {
+       throw new IllegalArgumentException("maxLon=" + maxLon + " is not a valid longitude");
+     }
+     
+     byte[][] lower = encode(minLat, minLon);
+     byte[][] upper = encode(maxLat, maxLon);
+     // Crosses date line: we just rewrite into OR of two bboxes, with longitude as an open range:
+     if (maxLon < minLon) {
+       // Disable coord here because a multi-valued doc could match both rects and get unfairly boosted:
+       BooleanQuery.Builder q = new BooleanQuery.Builder();
+       q.setDisableCoord(true);
+ 
+       // E.g.: maxLon = -179, minLon = 179
+       byte[][] leftOpen = new byte[2][];
+       leftOpen[0] = lower[0];
+       // leave longitude open (null)
+       Query left = newBoxInternal(field, leftOpen, upper);
+       q.add(new BooleanClause(left, BooleanClause.Occur.SHOULD));
+       byte[][] rightOpen = new byte[2][];
+       rightOpen[0] = upper[0];
+       // leave longitude open (null)
+       Query right = newBoxInternal(field, lower, rightOpen);
+       q.add(new BooleanClause(right, BooleanClause.Occur.SHOULD));
+       return new ConstantScoreQuery(q.build());
+     } else {
+       return newBoxInternal(field, lower, upper);
+     }
+   }
+   
+   private static Query newBoxInternal(String field, byte[][] min, byte[][] max) {
+     return new PointRangeQuery(field, min, new boolean[] { true, true }, max, new boolean[] { false, false }) {
+       @Override
+       protected String toString(int dimension, byte[] value) {
+         if (dimension == 0) {
+           return Double.toString(decodeLat(value, 0));
+         } else if (dimension == 1) {
+           return Double.toString(decodeLon(value, 0));
+         } else {
+           throw new AssertionError();
+         }
+       }
+     };
+   }
+   
+   /** 
+    * Create a query for matching a polygon.
+    * <p>
+    * The supplied {@code polyLats}/{@code polyLons} must be clockwise or counter-clockwise.
+    */
+   public static Query newPolygonQuery(String field, double[] polyLats, double[] polyLons) {
+     return new PointInPolygonQuery(field, polyLats, polyLons);
+   }
  }