assert inputs.size() == 1;
final Input functionInput = inputs.get(0);
@SuppressWarnings("unchecked")
final List<LuceneCollectorExpression> expressions = inputContext.docLevelExpressions();
final SortField.Type type = luceneTypeMap.get(function.valueType());
final SortOrder sortOrder = new SortOrder(context.reverseFlag, context.nullFirst);
assert type != null : "Could not get lucene sort type for " + function.valueType();
return new SortField(function.toString(), new IndexFieldData.XFieldComparatorSource() {
@Override
public FieldComparator<?> newComparator(String fieldName, int numHits, int sortPos, boolean reversed) throws IOException {
return new InputFieldComparator(
numHits,
context.context,
expressions,
functionInput,
function.valueType(),
missingObject(sortOrder.missing(), reversed)
);
}
@Override
public SortField.Type reducedType() {