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

This commit is contained in:
Adrien Grand 2016-02-26 16:47:11 +01:00
parent 6c0846107a
commit 509c6a0acb
4 changed files with 18 additions and 15 deletions

View File

@ -115,6 +115,9 @@ Optimizations
merging to merge sort the already sorted segments instead of merging to merge sort the already sorted segments instead of
re-indexing (Mike McCandless) 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 Changes in Runtime Behavior
* LUCENE-6789: IndexSearcher's default Similarity is changed to BM25Similarity. * LUCENE-6789: IndexSearcher's default Similarity is changed to BM25Similarity.

View File

@ -348,12 +348,12 @@ public final class LegacyNumericRangeQuery<T extends Number> extends MultiTermQu
@Override @Override
public final int hashCode() { public final int hashCode() {
int hash = super.hashCode(); int hash = super.hashCode();
hash += precisionStep^0x64365465; hash = 31 * hash + precisionStep;
if (min != null) hash += min.hashCode()^0x14fa55fb; hash = 31 * hash + Objects.hashCode(min);
if (max != null) hash += max.hashCode()^0x733fa5fe; hash = 31 * hash + Objects.hashCode(max);
return hash + hash = 31 * hash + Objects.hashCode(minInclusive);
(Boolean.valueOf(minInclusive).hashCode()^0x14fa55fb)+ hash = 31 * hash + Objects.hashCode(maxInclusive);
(Boolean.valueOf(maxInclusive).hashCode()^0x733fa5fe); return hash;
} }
// members (package private, to be also fast accessible by NumericRangeTermEnum) // members (package private, to be also fast accessible by NumericRangeTermEnum)

View File

@ -301,9 +301,9 @@ public class PointInSetQuery extends Query {
@Override @Override
public int hashCode() { public int hashCode() {
int hash = super.hashCode(); int hash = super.hashCode();
hash += sortedPackedPointsHashCode^0x14fa55fb; hash = 31 * hash + sortedPackedPointsHashCode;
hash += numDims^0x14fa55fb; hash = 31 * hash + numDims;
hash += bytesPerDim^0x14fa55fb; hash = 31 * hash + bytesPerDim;
return hash; return hash;
} }

View File

@ -287,12 +287,12 @@ public abstract class PointRangeQuery extends Query {
@Override @Override
public int hashCode() { public int hashCode() {
int hash = super.hashCode(); int hash = super.hashCode();
hash += Arrays.hashCode(lowerPoint)^0x14fa55fb; hash = 31 * hash + Arrays.hashCode(lowerPoint);
hash += Arrays.hashCode(upperPoint)^0x733fa5fe; hash = 31 * hash + Arrays.hashCode(upperPoint);
hash += Arrays.hashCode(lowerInclusive)^0x14fa55fb; hash = 31 * hash + Arrays.hashCode(lowerInclusive);
hash += Arrays.hashCode(upperInclusive)^0x733fa5fe; hash = 31 * hash + Arrays.hashCode(upperInclusive);
hash += numDims^0x14fa55fb; hash = 31 * hash + numDims;
hash += Objects.hashCode(bytesPerDim); hash = 31 * hash + Objects.hashCode(bytesPerDim);
return hash; return hash;
} }