Skip to content

Commit

Permalink
apply review comments
Browse files Browse the repository at this point in the history
Signed-off-by: panguixin <[email protected]>
  • Loading branch information
bugmakerrrrrr committed Jul 30, 2024
1 parent f1bc420 commit 896e850
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1080,11 +1080,7 @@ public void testSortMissingNumbers() throws Exception {
SearchRequestBuilder searchRequestBuilder = client().prepareSearch()
.setQuery(matchAllQuery())
.addSort(SortBuilders.fieldSort("u_value").order(SortOrder.ASC).missing(randomBoolean() ? -1 : "-1"));
assertFailures(
searchRequestBuilder,
RestStatus.BAD_REQUEST,
containsString("missing value of type [unsigned_long] must not be negative")
);
assertFailures(searchRequestBuilder, RestStatus.BAD_REQUEST, containsString("Value [-1] is out of range for an unsigned long"));
}

public void testSortMissingNumbersMinMax() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,11 @@ public Object missingObject(Object missingValue, boolean reversed) {
return min ? Numbers.MIN_UNSIGNED_LONG_VALUE : Numbers.MAX_UNSIGNED_LONG_VALUE;
} else {
if (missingValue instanceof Number) {
long ul = ((Number) missingValue).longValue();
if (ul < 0) {
throw new IllegalArgumentException("missing value of type [unsigned_long] must not be negative");
}
return BigInteger.valueOf(ul);
return Numbers.toUnsignedLongExact((Number) missingValue);

Check warning on line 84 in server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/UnsignedLongValuesComparatorSource.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/UnsignedLongValuesComparatorSource.java#L84

Added line #L84 was not covered by tests
} else {
BigInteger missing = new BigInteger(missingValue.toString());

Check warning on line 86 in server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/UnsignedLongValuesComparatorSource.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/UnsignedLongValuesComparatorSource.java#L86

Added line #L86 was not covered by tests
if (missing.signum() < 0) {
throw new IllegalArgumentException("missing value of type [unsigned_long] must not be negative");
throw new IllegalArgumentException("Value [" + missingValue + "] is out of range for an unsigned long");

Check warning on line 88 in server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/UnsignedLongValuesComparatorSource.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/UnsignedLongValuesComparatorSource.java#L88

Added line #L88 was not covered by tests
}
return missing;

Check warning on line 90 in server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/UnsignedLongValuesComparatorSource.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/fielddata/fieldcomparator/UnsignedLongValuesComparatorSource.java#L90

Added line #L90 was not covered by tests
}
Expand Down

0 comments on commit 896e850

Please sign in to comment.