Skip to content

Commit

Permalink
apply commments
Browse files Browse the repository at this point in the history
Signed-off-by: panguixin <panguixin@bytedance.com>
  • Loading branch information
bugmakerrrrrr committed Jan 8, 2025
1 parent c011176 commit 33a2319
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,8 @@ private static Sort createSort(TopFieldDocs[] topFieldDocs) {
}

private static SortField.Type getSortType(SortField sortField) {
if (sortField.getComparatorSource() != null) {
IndexFieldData.XFieldComparatorSource comparatorSource = (IndexFieldData.XFieldComparatorSource) sortField
.getComparatorSource();
return comparatorSource.reducedType();
if (sortField.getComparatorSource() instanceof IndexFieldData.XFieldComparatorSource) {
return ((IndexFieldData.XFieldComparatorSource) sortField.getComparatorSource()).reducedType();
} else {
return sortField instanceof SortedNumericSortField
? ((SortedNumericSortField) sortField).getNumericType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ public class SortedWiderNumericSortField extends SortedNumericSortField {
*/
public SortedWiderNumericSortField(String field, Type type, boolean reverse) {
super(field, type, reverse);
byteCounts = type == Type.LONG ? Long.BYTES : Double.BYTES;
comparator = type == Type.LONG ? Comparator.comparingLong(Number::longValue) : Comparator.comparingDouble(Number::doubleValue);
if (type == Type.LONG) {
byteCounts = Long.BYTES;
comparator = Comparator.comparingLong(Number::longValue);
} else if (type == Type.DOUBLE) {
byteCounts = Double.BYTES;
comparator = Comparator.comparingDouble(Number::doubleValue);
} else {
throw new IllegalArgumentException("Unsupported numeric type: " + type);
}
}

/**
Expand Down

0 comments on commit 33a2319

Please sign in to comment.