switch(type) {
case INT:
return new FieldComparator.IntComparator(numHits, getField(), null, (Integer) missingValue) {
@Override
protected FieldCache.Ints getIntValues(AtomicReaderContext context, String field) throws IOException {
final NumericDocValues dv = SortedNumericSelector.wrap(DocValues.getSortedNumeric(context.reader(), field), selector, type);
return new FieldCache.Ints() {
@Override
public int get(int docID) {
return (int) dv.get(docID);
}
};
}
};
case FLOAT:
return new FieldComparator.FloatComparator(numHits, getField(), null, (Float) missingValue) {
@Override
protected FieldCache.Floats getFloatValues(AtomicReaderContext context, String field) throws IOException {
final NumericDocValues dv = SortedNumericSelector.wrap(DocValues.getSortedNumeric(context.reader(), field), selector, type);
return new FieldCache.Floats() {
@Override
public float get(int docID) {
return Float.intBitsToFloat((int)dv.get(docID));
}
};
}
};
case LONG:
return new FieldComparator.LongComparator(numHits, getField(), null, (Long) missingValue) {
@Override
protected FieldCache.Longs getLongValues(AtomicReaderContext context, String field) throws IOException {
final NumericDocValues dv = SortedNumericSelector.wrap(DocValues.getSortedNumeric(context.reader(), field), selector, type);
return new FieldCache.Longs() {
@Override
public long get(int docID) {
return dv.get(docID);
}
};
}
};
case DOUBLE:
return new FieldComparator.DoubleComparator(numHits, getField(), null, (Double) missingValue) {
@Override
protected FieldCache.Doubles getDoubleValues(AtomicReaderContext context, String field) throws IOException {
final NumericDocValues dv = SortedNumericSelector.wrap(DocValues.getSortedNumeric(context.reader(), field), selector, type);
return new FieldCache.Doubles() {
@Override
public double get(int docID) {
return Double.longBitsToDouble(dv.get(docID));
}
};
}
};
default: