use of org.apache.asterix.lang.common.expression.ListConstructor in project asterixdb by apache.
the class FunctionMapUtil method normalizedListInputFunctions.
/**
* Rewrites a variable-arg, user-surface function call into an internal, list-arg function.
*
* @param callExpr
* The input call expression.
* @return a new call expression that calls the corresponding AsterixDB internal function.
*/
public static CallExpr normalizedListInputFunctions(CallExpr callExpr) {
FunctionSignature fs = callExpr.getFunctionSignature();
String internalFuncName = LIST_INPUT_FUNCTION_MAP.get(fs.getName().toLowerCase());
if (internalFuncName == null) {
return callExpr;
}
callExpr.setFunctionSignature(new FunctionSignature(FunctionConstants.ASTERIX_NS, internalFuncName, 1));
callExpr.setExprList(new ArrayList<>(Collections.singletonList(new ListConstructor(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR, callExpr.getExprList()))));
return callExpr;
}
use of org.apache.asterix.lang.common.expression.ListConstructor in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(ListConstructor lc, VariableSubstitutionEnvironment env) throws CompilationException {
List<Expression> oldExprList = lc.getExprList();
List<Expression> exprs = VariableCloneAndSubstitutionUtil.visitAndCloneExprList(oldExprList, env, this);
ListConstructor c = new ListConstructor(lc.getType(), exprs);
return new Pair<>(c, env);
}
use of org.apache.asterix.lang.common.expression.ListConstructor in project asterixdb by apache.
the class RangeMapBuilder method parseHint.
public static IRangeMap parseHint(Object hint) throws CompilationException {
ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
DataOutput out = abvs.getDataOutput();
;
abvs.reset();
IParser parser = parserFactory.createParser((String) hint);
List<Statement> hintStatements = parser.parse();
if (hintStatements.size() != 1) {
throw new CompilationException("Only one range statement is allowed for the range hint.");
}
// Translate the query into a Range Map
if (hintStatements.get(0).getKind() != Statement.Kind.QUERY) {
throw new CompilationException("Not a proper query for the range hint.");
}
Query q = (Query) hintStatements.get(0);
if (q.getBody().getKind() != Kind.LIST_CONSTRUCTOR_EXPRESSION) {
throw new CompilationException("The range hint must be a list.");
}
List<Expression> el = ((ListConstructor) q.getBody()).getExprList();
int[] offsets = new int[el.size()];
// Loop over list of literals
for (int i = 0; i < el.size(); ++i) {
Expression item = el.get(i);
if (item.getKind() == Kind.LITERAL_EXPRESSION) {
parseLiteralToBytes(item, out);
offsets[i] = abvs.getLength();
}
// TODO Add support for composite fields.
}
return new RangeMap(1, abvs.getByteArray(), offsets);
}
Aggregations