lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject [07/10] lucene-solr:feature/autoscaling: LUCENE-7892: Add "slow" to factory methods of doc-values queries.
Date Wed, 05 Jul 2017 00:10:22 GMT
LUCENE-7892: Add "slow" to factory methods of doc-values queries.


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

Branch: refs/heads/feature/autoscaling
Commit: 1e6e4022cf6b8f927ec6a10f4d4c4b866fce8f0f
Parents: db71c56
Author: Adrien Grand <jpountz@gmail.com>
Authored: Tue Jul 4 16:44:13 2017 +0200
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Tue Jul 4 16:44:13 2017 +0200

----------------------------------------------------------------------
 lucene/CHANGES.txt                              |  4 ++++
 .../lucene/document/NumericDocValuesField.java  |  6 ++---
 .../document/SortedNumericDocValuesField.java   |  6 ++---
 .../lucene/search/TestDocValuesQueries.java     | 24 ++++++++++----------
 .../search/TestIndexOrDocValuesQuery.java       |  4 ++--
 .../lucene/document/LatLonDocValuesField.java   |  4 ++--
 .../search/TestLatLonDocValuesQueries.java      |  4 ++--
 .../java/org/apache/solr/schema/EnumField.java  |  2 +-
 .../solr/schema/LatLonPointSpatialField.java    |  6 ++---
 .../apache/solr/schema/NumericFieldType.java    |  4 ++--
 10 files changed, 34 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 9226eb3..475a361 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -100,6 +100,10 @@ API Changes
   DoubleValuesSource extensions, or with the new ShapeValuesSource and
   ShapeValuesPredicate classes (Alan Woodward, David Smiley)
 
+* LUCENE-7892: Doc-values query factory methods have been renamed so that their
+  name contains "slow" in order to cleary indicate that they would usually be a
+  bad choice. (Adrien Grand)
+
 Bug Fixes
 
 * LUCENE-7626: IndexWriter will no longer accept broken token offsets

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java b/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java
index 6d84492..89210db 100644
--- a/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/NumericDocValuesField.java
@@ -78,7 +78,7 @@ public class NumericDocValuesField extends Field {
    * alongside a range query that executes on points, such as
    * {@link LongPoint#newRangeQuery}.
    */
-  public static Query newRangeQuery(String field, long lowerValue, long upperValue) {
+  public static Query newSlowRangeQuery(String field, long lowerValue, long upperValue) {
     return new SortedNumericDocValuesRangeQuery(field, lowerValue, upperValue) {
       @Override
       SortedNumericDocValues getValues(LeafReader reader, String field) throws IOException
{
@@ -99,7 +99,7 @@ public class NumericDocValuesField extends Field {
    * alongside a range query that executes on points, such as
    * {@link LongPoint#newExactQuery}.
    */
-  public static Query newExactQuery(String field, long value) {
-    return newRangeQuery(field, value, value);
+  public static Query newSlowExactQuery(String field, long value) {
+    return newSlowRangeQuery(field, value, value);
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesField.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesField.java
b/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesField.java
index 6f9a271..bbb1da7 100644
--- a/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesField.java
+++ b/lucene/core/src/java/org/apache/lucene/document/SortedNumericDocValuesField.java
@@ -89,7 +89,7 @@ public class SortedNumericDocValuesField extends Field {
    * alongside a range query that executes on points, such as
    * {@link LongPoint#newRangeQuery}.
    */
-  public static Query newRangeQuery(String field, long lowerValue, long upperValue) {
+  public static Query newSlowRangeQuery(String field, long lowerValue, long upperValue) {
     return new SortedNumericDocValuesRangeQuery(field, lowerValue, upperValue) {
       @Override
       SortedNumericDocValues getValues(LeafReader reader, String field) throws IOException
{
@@ -114,7 +114,7 @@ public class SortedNumericDocValuesField extends Field {
    * alongside a range query that executes on points, such as
    * {@link LongPoint#newExactQuery}.
    */
-  public static Query newExactQuery(String field, long value) {
-    return newRangeQuery(field, value, value);
+  public static Query newSlowExactQuery(String field, long value) {
+    return newSlowRangeQuery(field, value, value);
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/lucene/core/src/test/org/apache/lucene/search/TestDocValuesQueries.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestDocValuesQueries.java b/lucene/core/src/test/org/apache/lucene/search/TestDocValuesQueries.java
index 6cb0460..0591278 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestDocValuesQueries.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestDocValuesQueries.java
@@ -80,9 +80,9 @@ public class TestDocValuesQueries extends LuceneTestCase {
         final Query q1 = LongPoint.newRangeQuery("idx", min, max);
         final Query q2;
         if (sortedNumeric) {
-          q2 = SortedNumericDocValuesField.newRangeQuery("dv", min, max);
+          q2 = SortedNumericDocValuesField.newSlowRangeQuery("dv", min, max);
         } else {
-          q2 = NumericDocValuesField.newRangeQuery("dv", min, max);
+          q2 = NumericDocValuesField.newSlowRangeQuery("dv", min, max);
         }
         assertSameMatches(searcher, q1, q2, false);
       }
@@ -185,11 +185,11 @@ public class TestDocValuesQueries extends LuceneTestCase {
   }
 
   public void testEquals() {
-    Query q1 = SortedNumericDocValuesField.newRangeQuery("foo", 3, 5);
-    QueryUtils.checkEqual(q1, SortedNumericDocValuesField.newRangeQuery("foo", 3, 5));
-    QueryUtils.checkUnequal(q1, SortedNumericDocValuesField.newRangeQuery("foo", 3, 6));
-    QueryUtils.checkUnequal(q1, SortedNumericDocValuesField.newRangeQuery("foo", 4, 5));
-    QueryUtils.checkUnequal(q1, SortedNumericDocValuesField.newRangeQuery("bar", 3, 5));
+    Query q1 = SortedNumericDocValuesField.newSlowRangeQuery("foo", 3, 5);
+    QueryUtils.checkEqual(q1, SortedNumericDocValuesField.newSlowRangeQuery("foo", 3, 5));
+    QueryUtils.checkUnequal(q1, SortedNumericDocValuesField.newSlowRangeQuery("foo", 3, 6));
+    QueryUtils.checkUnequal(q1, SortedNumericDocValuesField.newSlowRangeQuery("foo", 4, 5));
+    QueryUtils.checkUnequal(q1, SortedNumericDocValuesField.newSlowRangeQuery("bar", 3, 5));
 
     Query q2 = SortedSetDocValuesField.newRangeQuery("foo", new BytesRef("bar"), new BytesRef("baz"),
true, true);
     QueryUtils.checkEqual(q2, SortedSetDocValuesField.newRangeQuery("foo", new BytesRef("bar"),
new BytesRef("baz"), true, true));
@@ -199,7 +199,7 @@ public class TestDocValuesQueries extends LuceneTestCase {
   }
 
   public void testToString() {
-    Query q1 = SortedNumericDocValuesField.newRangeQuery("foo", 3, 5);
+    Query q1 = SortedNumericDocValuesField.newSlowRangeQuery("foo", 3, 5);
     assertEquals("foo:[3 TO 5]", q1.toString());
     assertEquals("[3 TO 5]", q1.toString("foo"));
     assertEquals("foo:[3 TO 5]", q1.toString("bar"));
@@ -226,8 +226,8 @@ public class TestDocValuesQueries extends LuceneTestCase {
     iw.close();
     IndexSearcher searcher = newSearcher(reader);
     for (Query query : Arrays.asList(
-        NumericDocValuesField.newRangeQuery("foo", 2, 4),
-        SortedNumericDocValuesField.newRangeQuery("foo", 2, 4),
+        NumericDocValuesField.newSlowRangeQuery("foo", 2, 4),
+        SortedNumericDocValuesField.newSlowRangeQuery("foo", 2, 4),
         SortedDocValuesField.newRangeQuery("foo", new BytesRef("abc"), new BytesRef("bcd"),
random().nextBoolean(), random().nextBoolean()),
         SortedSetDocValuesField.newRangeQuery("foo", new BytesRef("abc"), new BytesRef("bcd"),
random().nextBoolean(), random().nextBoolean()))) {
       Weight w = searcher.createNormalizedWeight(query, random().nextBoolean());
@@ -255,12 +255,12 @@ public class TestDocValuesQueries extends LuceneTestCase {
     final long lo = NumericUtils.doubleToSortableLong(8.701032080293731E-226);
     final long hi = NumericUtils.doubleToSortableLong(2.0801416404385346E-41);
     
-    Query query = SortedNumericDocValuesField.newRangeQuery("dv", lo, hi);
+    Query query = SortedNumericDocValuesField.newSlowRangeQuery("dv", lo, hi);
     // TODO: assert expected matches
     searcher.search(query, searcher.reader.maxDoc(), Sort.INDEXORDER);
 
     // swap order, should still work
-    query = SortedNumericDocValuesField.newRangeQuery("dv", hi, lo);
+    query = SortedNumericDocValuesField.newSlowRangeQuery("dv", hi, lo);
     // TODO: assert expected matches
     searcher.search(query, searcher.reader.maxDoc(), Sort.INDEXORDER);
     

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/lucene/core/src/test/org/apache/lucene/search/TestIndexOrDocValuesQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/search/TestIndexOrDocValuesQuery.java
b/lucene/core/src/test/org/apache/lucene/search/TestIndexOrDocValuesQuery.java
index 8b81822..7f3e599 100644
--- a/lucene/core/src/test/org/apache/lucene/search/TestIndexOrDocValuesQuery.java
+++ b/lucene/core/src/test/org/apache/lucene/search/TestIndexOrDocValuesQuery.java
@@ -64,7 +64,7 @@ public class TestIndexOrDocValuesQuery extends LuceneTestCase {
     // The term query is more selective, so the IndexOrDocValuesQuery should use doc values
     final Query q1 = new BooleanQuery.Builder()
         .add(new TermQuery(new Term("f1", "foo")), Occur.MUST)
-        .add(new IndexOrDocValuesQuery(LongPoint.newExactQuery("f2", 2), NumericDocValuesField.newRangeQuery("f2",
2L, 2L)), Occur.MUST)
+        .add(new IndexOrDocValuesQuery(LongPoint.newExactQuery("f2", 2), NumericDocValuesField.newSlowRangeQuery("f2",
2L, 2L)), Occur.MUST)
         .build();
 
     final Weight w1 = searcher.createNormalizedWeight(q1, random().nextBoolean());
@@ -74,7 +74,7 @@ public class TestIndexOrDocValuesQuery extends LuceneTestCase {
     // The term query is less selective, so the IndexOrDocValuesQuery should use points
     final Query q2 = new BooleanQuery.Builder()
         .add(new TermQuery(new Term("f1", "bar")), Occur.MUST)
-        .add(new IndexOrDocValuesQuery(LongPoint.newExactQuery("f2", 42), NumericDocValuesField.newRangeQuery("f2",
42L, 42L)), Occur.MUST)
+        .add(new IndexOrDocValuesQuery(LongPoint.newExactQuery("f2", 42), NumericDocValuesField.newSlowRangeQuery("f2",
42L, 42L)), Occur.MUST)
         .build();
 
     final Weight w2 = searcher.createNormalizedWeight(q2, random().nextBoolean());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
index 10e90b4..6bcc394 100644
--- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
+++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonDocValuesField.java
@@ -143,7 +143,7 @@ public class LatLonDocValuesField extends Field {
    * best used wrapped in an {@link IndexOrDocValuesQuery} alongside a
    * {@link LatLonPoint#newBoxQuery}.
    */
-  public static Query newBoxQuery(String field, double minLatitude, double maxLatitude, double
minLongitude, double maxLongitude) {
+  public static Query newSlowBoxQuery(String field, double minLatitude, double maxLatitude,
double minLongitude, double maxLongitude) {
     // exact double values of lat=90.0D and lon=180.0D must be treated special as they are
not represented in the encoding
     // and should not drag in extra bogus junk! TODO: should encodeCeil just throw ArithmeticException
to be less trappy here?
     if (minLatitude == 90.0) {
@@ -175,7 +175,7 @@ public class LatLonDocValuesField extends Field {
    * @return query matching points within this distance
    * @throws IllegalArgumentException if {@code field} is null, location has invalid coordinates,
or radius is invalid.
    */
-  public static Query newDistanceQuery(String field, double latitude, double longitude, double
radiusMeters) {
+  public static Query newSlowDistanceQuery(String field, double latitude, double longitude,
double radiusMeters) {
     return new LatLonDocValuesDistanceQuery(field, latitude, longitude, radiusMeters);
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonDocValuesQueries.java
----------------------------------------------------------------------
diff --git a/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonDocValuesQueries.java
b/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonDocValuesQueries.java
index 3c8bf4e..bf1b8cb 100644
--- a/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonDocValuesQueries.java
+++ b/lucene/sandbox/src/test/org/apache/lucene/search/TestLatLonDocValuesQueries.java
@@ -36,12 +36,12 @@ public class TestLatLonDocValuesQueries extends BaseGeoPointTestCase {
 
   @Override
   protected Query newRectQuery(String field, double minLat, double maxLat, double minLon,
double maxLon) {
-    return LatLonDocValuesField.newBoxQuery(field, minLat, maxLat, minLon, maxLon);
+    return LatLonDocValuesField.newSlowBoxQuery(field, minLat, maxLat, minLon, maxLon);
   }
 
   @Override
   protected Query newDistanceQuery(String field, double centerLat, double centerLon, double
radiusMeters) {
-    return LatLonDocValuesField.newDistanceQuery(field, centerLat, centerLon, radiusMeters);
+    return LatLonDocValuesField.newSlowDistanceQuery(field, centerLat, centerLon, radiusMeters);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/solr/core/src/java/org/apache/solr/schema/EnumField.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/EnumField.java b/solr/core/src/java/org/apache/solr/schema/EnumField.java
index f023805..60e65d5 100644
--- a/solr/core/src/java/org/apache/solr/schema/EnumField.java
+++ b/solr/core/src/java/org/apache/solr/schema/EnumField.java
@@ -266,7 +266,7 @@ public class EnumField extends PrimitiveFieldType {
           --upperValue;
         }
       }
-      query = new ConstantScoreQuery(NumericDocValuesField.newRangeQuery(field.getName(),
lowerValue, upperValue));
+      query = new ConstantScoreQuery(NumericDocValuesField.newSlowRangeQuery(field.getName(),
lowerValue, upperValue));
     } else {
       query = LegacyNumericRangeQuery.newIntRange(field.getName(), DEFAULT_PRECISION_STEP,
           min == null ? null : minValue,

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java b/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java
index 87f32d9..773e8a7 100644
--- a/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java
+++ b/solr/core/src/java/org/apache/solr/schema/LatLonPointSpatialField.java
@@ -155,16 +155,16 @@ public class LatLonPointSpatialField extends AbstractSpatialFieldType
implements
       if (shape instanceof Circle) {
         Circle circle = (Circle) shape;
         double radiusMeters = circle.getRadius() * DistanceUtils.DEG_TO_KM * 1000;
-        return LatLonDocValuesField.newDistanceQuery(getFieldName(),
+        return LatLonDocValuesField.newSlowDistanceQuery(getFieldName(),
             circle.getCenter().getY(), circle.getCenter().getX(),
             radiusMeters);
       } else if (shape instanceof Rectangle) {
         Rectangle rect = (Rectangle) shape;
-        return LatLonDocValuesField.newBoxQuery(getFieldName(),
+        return LatLonDocValuesField.newSlowBoxQuery(getFieldName(),
             rect.getMinY(), rect.getMaxY(), rect.getMinX(), rect.getMaxX());
       } else if (shape instanceof Point) {
         Point point = (Point) shape;
-        return LatLonDocValuesField.newDistanceQuery(getFieldName(),
+        return LatLonDocValuesField.newSlowDistanceQuery(getFieldName(),
             point.getY(), point.getX(), 0);
       } else {
         throw new UnsupportedOperationException("Shape " + shape.getClass() + " is not supported
by " + getClass());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1e6e4022/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java b/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java
index cf17aaf..c79f465 100644
--- a/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java
+++ b/solr/core/src/java/org/apache/solr/schema/NumericFieldType.java
@@ -164,9 +164,9 @@ public abstract class NumericFieldType extends PrimitiveFieldType {
     }
     if (multiValued) {
       // In multiValued case use SortedNumericDocValuesField, this won't work for Trie*Fields
wince they use BinaryDV in the multiValue case
-      return SortedNumericDocValuesField.newRangeQuery(field, actualLowerValue, actualUpperValue);
+      return SortedNumericDocValuesField.newSlowRangeQuery(field, actualLowerValue, actualUpperValue);
     } else {
-      return NumericDocValuesField.newRangeQuery(field, actualLowerValue, actualUpperValue);
+      return NumericDocValuesField.newSlowRangeQuery(field, actualLowerValue, actualUpperValue);
     }
   }
   


Mime
View raw message