示例#1
0
 @Override
 public Comparator<Object> getComparator(
     final PrestoContextRules rules, final PrestoField field, final Projection projection) {
   if (projection != null && projection.isSorted() && field.isReferenceField()) {
     return new FieldProjectionComparator(getPresto(), rules, field, projection);
   } else {
     return new FieldComparator(field, rules.isSortedAscendingField(field));
   }
 }
示例#2
0
    private FieldProjectionComparator(
        Presto presto, PrestoContextRules rules, PrestoField field, Projection projection) {
      this.presto = presto;
      this.rules = rules;
      this.field = field;
      this.projection = projection;

      boolean isAscending = rules.isSortedAscendingField(field);
      String orderFieldId = null;
      String orderBy = projection.getOrderBy();
      if (orderBy != null) {
        String[] split = orderBy.split(" ");
        orderFieldId = split[0];
        String orderDirection = split[1];
        if (orderDirection != null) {
          isAscending = !orderDirection.equals("desc");
        }
      }
      this.ascending = isAscending;
      this.orderField = orderFieldId;
    }