private JsonLimit computeSort(@Nullable Integer fetch, List<Integer> collationIndexes,
List<Direction> collationDirections, ImmutableBitSet numericCollationIndexes,
List<String> queryOutputFieldNames) {
final List<JsonCollation> collations;
if (collationIndexes != null) {
assert collationDirections != null;
ImmutableList.Builder<JsonCollation> colBuilder = ImmutableList.builder();
for (Pair<Integer, Direction> p : Pair.zip(collationIndexes, collationDirections)) {
final String dimensionOrder = numericCollationIndexes.get(p.left)
? "numeric"
: "lexicographic";
colBuilder.add(
new JsonCollation(queryOutputFieldNames.get(p.left),
p.right == Direction.DESCENDING ? "descending" : "ascending", dimensionOrder));
}
collations = colBuilder.build();
} else {
collations = null;
}
return new JsonLimit("default", fetch, collations);
}