use of com.xiaomi.linden.thrift.common.LindenType in project linden by XiaoMi.
the class LindenQueryParser method getRangeQuery.
@Override
protected Query getRangeQuery(String field, String min, String max, boolean startInclusive, boolean endInclusive) {
LindenFieldSchema fieldSchema = config.getFieldSchema(field);
String name = fieldSchema.getName();
LindenType indexFieldType = fieldSchema.getType();
Query query = null;
switch(indexFieldType) {
case STRING:
query = new TermRangeQuery(name, bytesRefVal(min), bytesRefVal(max), startInclusive, endInclusive);
break;
case INTEGER:
query = NumericRangeQuery.newIntRange(name, intVal(min), intVal(max), startInclusive, endInclusive);
break;
case LONG:
query = NumericRangeQuery.newLongRange(name, longVal(min), longVal(max), startInclusive, endInclusive);
break;
case DOUBLE:
query = NumericRangeQuery.newDoubleRange(name, doubleVal(min), doubleVal(max), startInclusive, endInclusive);
break;
case FLOAT:
query = NumericRangeQuery.newFloatRange(name, floatVal(min), floatVal(max), startInclusive, endInclusive);
break;
default:
break;
}
return query;
}
use of com.xiaomi.linden.thrift.common.LindenType in project linden by XiaoMi.
the class BQLCompilerAnalyzer method exitSnippet_clause.
@Override
public void exitSnippet_clause(BQLParser.Snippet_clauseContext ctx) {
if (ctx.selection_list() != null) {
List<String> selections = (List<String>) valProperty.get(ctx.selection_list());
if (selections != null && !selections.isEmpty()) {
SnippetParam snippet = new SnippetParam();
for (String selection : selections) {
Map.Entry<String, LindenType> fieldNameAndType = getFieldNameAndType(selection);
LindenType type = fieldNameAndType.getValue();
String col = fieldNameAndType.getKey();
if (type == LindenType.STRING) {
snippet.addToFields(new SnippetField(col));
} else {
throw new ParseCancellationException("Snippet doesn't support this type " + type);
}
}
valProperty.put(ctx, snippet);
}
}
}
use of com.xiaomi.linden.thrift.common.LindenType in project linden by XiaoMi.
the class BQLCompilerAnalyzer method exitFlexible_field.
@Override
public void exitFlexible_field(BQLParser.Flexible_fieldContext ctx) {
String col = unescapeColumnName(ctx.column_name());
Map.Entry<String, LindenType> fieldNameAndType = getFieldNameAndType(col);
col = fieldNameAndType.getKey();
LindenSearchField field = new LindenSearchField().setName(col);
if (ctx.boost != null && ctx.boost.PLACEHOLDER() == null) {
field.setBoost(Double.valueOf(ctx.boost.getText()));
}
valProperty.put(ctx, field);
}
use of com.xiaomi.linden.thrift.common.LindenType in project linden by XiaoMi.
the class BQLCompilerAnalyzer method exitNull_predicate.
@Override
public void exitNull_predicate(BQLParser.Null_predicateContext ctx) {
String col = unescapeColumnName(ctx.column_name());
Map.Entry<String, LindenType> fieldNameAndType = getFieldNameAndType(col);
col = fieldNameAndType.getKey();
LindenFilter filter;
if (ctx.NOT() != null) {
filter = LindenNotNullFieldFilterBuilder.buildNotNullFieldFilterBuilder(col, false);
} else {
filter = LindenNotNullFieldFilterBuilder.buildNotNullFieldFilterBuilder(col, true);
}
if (inQueryWhere) {
LindenQuery query = LindenQueryBuilder.buildFilteredQuery(LindenQueryBuilder.buildMatchAllQuery(), filter);
queryProperty.put(ctx, query);
} else {
filterProperty.put(ctx, filter);
}
}
use of com.xiaomi.linden.thrift.common.LindenType 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);
}
Aggregations