private PrestoContextRules getValueTopicContextRules(PrestoTopic valueTopic) { PrestoContext context = rules.getContext(); PrestoContext subcontext = PrestoContext.createSubContext(context, field, valueTopic); PrestoContextRules subrules = presto.getPrestoContextRules(subcontext); return subrules; }
@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)); } }
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; }