Remove unnecessary NaN checks from LongRange#verifyAndEncode (#12008)

This commit is contained in:
Greg Miller 2022-12-11 12:55:21 -08:00 committed by GitHub
parent 8671e29929
commit e34234ca6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 9 deletions

View File

@ -157,6 +157,8 @@ Improvements
* GITHUB#11860: Improve storage efficiency of connections in the HNSW graph that Lucene uses for
vector search. (Ben Trent)
* GITHUB#12008: Clean up LongRange#verifyAndEncode logic to remove unnecessary NaN checks. (Greg Miller)
* GITHUB#12003: Minor cleanup/improvements to IndexSortSortedNumericDocValuesRangeQuery. (Greg Miller)
Bug Fixes

View File

@ -127,20 +127,12 @@ public class LongRange extends Field {
}
/**
* encode the ranges into a sortable byte array ({@code Double.NaN} not allowed)
* encode the ranges into a sortable byte array
*
* <p>example for 4 dimensions (8 bytes per dimension value): minD1 ... minD4 | maxD1 ... maxD4
*/
static void verifyAndEncode(long[] min, long[] max, byte[] bytes) {
for (int d = 0, i = 0, j = min.length * BYTES; d < min.length; ++d, i += BYTES, j += BYTES) {
if (Double.isNaN(min[d])) {
throw new IllegalArgumentException(
"invalid min value (" + Double.NaN + ")" + " in LongRange");
}
if (Double.isNaN(max[d])) {
throw new IllegalArgumentException(
"invalid max value (" + Double.NaN + ")" + " in LongRange");
}
if (min[d] > max[d]) {
throw new IllegalArgumentException(
"min value (" + min[d] + ") is greater than max value (" + max[d] + ")");