private List<RelFieldCollation> getFieldCollations(IndexDesc desc, Collection<IndexFieldDesc> descCollection) { List<RelFieldCollation> fieldCollations = new ArrayList<>(); int i = 0; for (IndexFieldDesc field : descCollection) { RelFieldCollation.Direction direction = (field.getSortOrder() == IndexFieldDesc.Order.Asc) ? RelFieldCollation.Direction.ASCENDING : (field.getSortOrder() == IndexFieldDesc.Order.Desc ? RelFieldCollation.Direction.DESCENDING : null); if (direction != null) { // assume null direction of NULLS UNSPECIFIED for now until MapR-DB adds that to the APIs RelFieldCollation.NullDirection nulldir = direction == RelFieldCollation.Direction.ASCENDING ? NullDirection.LAST : (direction == RelFieldCollation.Direction.DESCENDING ? NullDirection.FIRST : NullDirection.UNSPECIFIED); RelFieldCollation c = new RelFieldCollation(i++, direction, nulldir); fieldCollations.add(c); } else { // if the direction is not present for a field, no need to examine remaining fields break; } } return fieldCollations; }
private List<RelFieldCollation> getFieldCollations(IndexDesc desc, Collection<IndexFieldDesc> descCollection) { List<RelFieldCollation> fieldCollations = new ArrayList<>(); int i = 0; for (IndexFieldDesc field : descCollection) { RelFieldCollation.Direction direction = (field.getSortOrder() == IndexFieldDesc.Order.Asc) ? RelFieldCollation.Direction.ASCENDING : (field.getSortOrder() == IndexFieldDesc.Order.Desc ? RelFieldCollation.Direction.DESCENDING : null); if (direction != null) { // assume null direction of NULLS UNSPECIFIED for now until MapR-DB adds that to the APIs RelFieldCollation.NullDirection nulldir = direction == RelFieldCollation.Direction.ASCENDING ? NullDirection.LAST : (direction == RelFieldCollation.Direction.DESCENDING ? NullDirection.FIRST : NullDirection.UNSPECIFIED); RelFieldCollation c = new RelFieldCollation(i++, direction, nulldir); fieldCollations.add(c); } else { // if the direction is not present for a field, no need to examine remaining fields break; } } return fieldCollations; }