Sort missing wrongly sorts negative values, closes #772.

This commit is contained in:
kimchy 2011-05-03 16:16:30 +03:00
parent 98dbb46b3c
commit 1d2f95857d
2 changed files with 4 additions and 4 deletions

View File

@ -43,14 +43,14 @@ public class DoubleFieldDataType implements FieldDataType<DoubleFieldData> {
if (missing.equals("_last")) { if (missing.equals("_last")) {
return new FieldComparatorSource() { return new FieldComparatorSource() {
@Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.MIN_VALUE : Double.MAX_VALUE); return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY);
} }
}; };
} }
if (missing.equals("_first")) { if (missing.equals("_first")) {
return new FieldComparatorSource() { return new FieldComparatorSource() {
@Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.MAX_VALUE : Double.MIN_VALUE); return new DoubleFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY);
} }
}; };
} }

View File

@ -43,14 +43,14 @@ public class FloatFieldDataType implements FieldDataType<FloatFieldData> {
if (missing.equals("_last")) { if (missing.equals("_last")) {
return new FieldComparatorSource() { return new FieldComparatorSource() {
@Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.MIN_VALUE : Float.MAX_VALUE); return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY);
} }
}; };
} }
if (missing.equals("_first")) { if (missing.equals("_first")) {
return new FieldComparatorSource() { return new FieldComparatorSource() {
@Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException { @Override public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.MAX_VALUE : Float.MIN_VALUE); return new FloatFieldDataMissingComparator(numHits, fieldname, cache, reversed ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY);
} }
}; };
} }