Search in sources :

Example 1 with LindenSortType

use of com.xiaomi.linden.thrift.common.LindenSortType in project linden by XiaoMi.

the class BQLCompilerAnalyzer method exitSort_spec.

@Override
public void exitSort_spec(BQLParser.Sort_specContext ctx) {
    LindenSortField sortField;
    if (ctx.DISTANCE() != null) {
        sortField = new LindenSortField().setName("").setType(LindenSortType.DISTANCE);
    } else if (ctx.SCORE() != null) {
        sortField = new LindenSortField().setName("").setType(LindenSortType.SCORE);
    } else {
        String col = unescapeColumnName(ctx.column_name());
        Map.Entry<String, LindenType> fieldNameAndType = getFieldNameAndType(col);
        LindenType type = fieldNameAndType.getValue();
        col = fieldNameAndType.getKey();
        LindenSortType sortType = LindenSortType.findByValue(type.getValue());
        sortField = new LindenSortField().setName(col).setType(sortType).setReverse(true);
    }
    if (ctx.ASC() != null) {
        sortField.setReverse(false);
    } else if (ctx.DESC() != null) {
        sortField.setReverse(true);
    }
    valProperty.put(ctx, sortField);
}
Also used : LindenType(com.xiaomi.linden.thrift.common.LindenType) LindenSortField(com.xiaomi.linden.thrift.common.LindenSortField) LindenSortType(com.xiaomi.linden.thrift.common.LindenSortType)

Aggregations

LindenSortField (com.xiaomi.linden.thrift.common.LindenSortField)1 LindenSortType (com.xiaomi.linden.thrift.common.LindenSortType)1 LindenType (com.xiaomi.linden.thrift.common.LindenType)1