lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpou...@apache.org
Subject lucene-solr git commit: LUCENE-6793: Make LegacyNumericRangeQuery and point queries less subject to hash collisions.
Date Fri, 26 Feb 2016 15:48:13 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 6c0846107 -> 509c6a0ac


LUCENE-6793: Make LegacyNumericRangeQuery and point queries less subject to hash collisions.


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

Branch: refs/heads/master
Commit: 509c6a0acbeaee6291bb80a5f9537aaff55599c4
Parents: 6c08461
Author: Adrien Grand <jpountz@gmail.com>
Authored: Fri Feb 26 16:47:11 2016 +0100
Committer: Adrien Grand <jpountz@gmail.com>
Committed: Fri Feb 26 16:47:11 2016 +0100

----------------------------------------------------------------------
 lucene/CHANGES.txt                                      |  3 +++
 .../apache/lucene/search/LegacyNumericRangeQuery.java   | 12 ++++++------
 .../java/org/apache/lucene/search/PointInSetQuery.java  |  6 +++---
 .../java/org/apache/lucene/search/PointRangeQuery.java  | 12 ++++++------
 4 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/509c6a0a/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 88f92d1..3e98a45 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -115,6 +115,9 @@ Optimizations
   merging to merge sort the already sorted segments instead of
   re-indexing (Mike McCandless)
 
+* LUCENE-6793: LegacyNumericRangeQuery.hashCode() is now less subject to hash
+  collisions. (J.B. Langston via Adrien Grand)
+
 Changes in Runtime Behavior
 
 * LUCENE-6789: IndexSearcher's default Similarity is changed to BM25Similarity.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/509c6a0a/lucene/core/src/java/org/apache/lucene/search/LegacyNumericRangeQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/LegacyNumericRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/LegacyNumericRangeQuery.java
index 9b47845..5e0506f 100644
--- a/lucene/core/src/java/org/apache/lucene/search/LegacyNumericRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/LegacyNumericRangeQuery.java
@@ -348,12 +348,12 @@ public final class LegacyNumericRangeQuery<T extends Number> extends
MultiTermQu
   @Override
   public final int hashCode() {
     int hash = super.hashCode();
-    hash += precisionStep^0x64365465;
-    if (min != null) hash += min.hashCode()^0x14fa55fb;
-    if (max != null) hash += max.hashCode()^0x733fa5fe;
-    return hash +
-      (Boolean.valueOf(minInclusive).hashCode()^0x14fa55fb)+
-      (Boolean.valueOf(maxInclusive).hashCode()^0x733fa5fe);
+    hash = 31 * hash + precisionStep;
+    hash = 31 * hash + Objects.hashCode(min);
+    hash = 31 * hash + Objects.hashCode(max);
+    hash = 31 * hash + Objects.hashCode(minInclusive);
+    hash = 31 * hash + Objects.hashCode(maxInclusive);
+    return hash;
   }
 
   // members (package private, to be also fast accessible by NumericRangeTermEnum)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/509c6a0a/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java
index 348f598..e695cf7 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PointInSetQuery.java
@@ -301,9 +301,9 @@ public class PointInSetQuery extends Query {
   @Override
   public int hashCode() {
     int hash = super.hashCode();
-    hash += sortedPackedPointsHashCode^0x14fa55fb;
-    hash += numDims^0x14fa55fb;
-    hash += bytesPerDim^0x14fa55fb;
+    hash = 31 * hash + sortedPackedPointsHashCode;
+    hash = 31 * hash + numDims;
+    hash = 31 * hash + bytesPerDim;
     return hash;
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/509c6a0a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
index 59f8f0f..be52e61 100644
--- a/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java
@@ -287,12 +287,12 @@ public abstract class PointRangeQuery extends Query {
   @Override
   public int hashCode() {
     int hash = super.hashCode();
-    hash += Arrays.hashCode(lowerPoint)^0x14fa55fb;
-    hash += Arrays.hashCode(upperPoint)^0x733fa5fe;
-    hash += Arrays.hashCode(lowerInclusive)^0x14fa55fb;
-    hash += Arrays.hashCode(upperInclusive)^0x733fa5fe;
-    hash += numDims^0x14fa55fb;
-    hash += Objects.hashCode(bytesPerDim);
+    hash = 31 * hash + Arrays.hashCode(lowerPoint);
+    hash = 31 * hash + Arrays.hashCode(upperPoint);
+    hash = 31 * hash + Arrays.hashCode(lowerInclusive);
+    hash = 31 * hash + Arrays.hashCode(upperInclusive);
+    hash = 31 * hash + numDims;
+    hash = 31 * hash + Objects.hashCode(bytesPerDim);
     return hash;
   }
 


Mime
View raw message