use of org.apache.asterix.om.constants.AsterixConstantValue in project asterixdb by apache.
the class AccessMethodUtils method addStringArg.
private static void addStringArg(String argument, List<Mutable<ILogicalExpression>> funcArgs) {
Mutable<ILogicalExpression> stringRef = new MutableObject<>(new ConstantExpression(new AsterixConstantValue(new AString(argument))));
funcArgs.add(stringRef);
}
use of org.apache.asterix.om.constants.AsterixConstantValue in project asterixdb by apache.
the class InvertedIndexAccessMethod method isContainsFuncSelectOptimizable.
private boolean isContainsFuncSelectOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) {
AsterixConstantValue strConstVal = (AsterixConstantValue) ((ConstantExpression) optFuncExpr.getConstantExpr(0)).getValue();
IAObject strObj = strConstVal.getObject();
ATypeTag typeTag = strObj.getType().getTypeTag();
if (!isContainsFuncCompatible(typeTag, index.getIndexType())) {
return false;
}
// Check that the constant search string has at least gramLength characters.
if (strObj.getType().getTypeTag() == ATypeTag.STRING) {
AString astr = (AString) strObj;
if (astr.getStringValue().length() >= index.getGramLength()) {
return true;
}
}
return false;
}
use of org.apache.asterix.om.constants.AsterixConstantValue in project asterixdb by apache.
the class InvertedIndexAccessMethod method isFullTextContainsFuncSelectOptimizable.
// Checks whether the given index is compatible with full-text search and
// the type of the constant search predicate is STRING, ARRAY, or MULTISET
private boolean isFullTextContainsFuncSelectOptimizable(Index index, IOptimizableFuncExpr optFuncExpr) {
AsterixConstantValue strConstVal = (AsterixConstantValue) ((ConstantExpression) optFuncExpr.getConstantExpr(0)).getValue();
IAObject strObj = strConstVal.getObject();
ATypeTag typeTag = strObj.getType().getTypeTag();
return isFullTextContainsFuncCompatible(typeTag, index.getIndexType());
}
use of org.apache.asterix.om.constants.AsterixConstantValue in project asterixdb by apache.
the class InlineAllNtsInSubplanVisitor method createFieldAccessAssignOperator.
private ILogicalOperator createFieldAccessAssignOperator(LogicalVariable recordVar, Set<LogicalVariable> inputLiveVars) {
List<LogicalVariable> fieldAccessVars = new ArrayList<>();
List<Mutable<ILogicalExpression>> fieldAccessExprs = new ArrayList<>();
// Adds field access by name.
for (LogicalVariable inputLiveVar : inputLiveVars) {
if (!correlatedKeyVars.contains(inputLiveVar)) {
// field Var
LogicalVariable newVar = context.newVar();
fieldAccessVars.add(newVar);
// fieldAcess expr
List<Mutable<ILogicalExpression>> argRefs = new ArrayList<>();
argRefs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(recordVar)));
argRefs.add(new MutableObject<ILogicalExpression>(new ConstantExpression(new AsterixConstantValue(new AString(Integer.toString(inputLiveVar.getId()))))));
fieldAccessExprs.add(new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.FIELD_ACCESS_BY_NAME), argRefs)));
// Updates variable mapping for ancestor operators.
updateInputToOutputVarMapping(inputLiveVar, newVar, false);
}
}
AssignOperator fieldAccessAssignOp = new AssignOperator(fieldAccessVars, fieldAccessExprs);
return fieldAccessAssignOp;
}
use of org.apache.asterix.om.constants.AsterixConstantValue in project asterixdb by apache.
the class LangExpressionToPlanTranslator method visit.
@Override
public Pair<ILogicalOperator, LogicalVariable> visit(CallExpr fcall, Mutable<ILogicalOperator> tupSource) throws CompilationException {
LogicalVariable v = context.newVar();
FunctionSignature signature = fcall.getFunctionSignature();
List<Mutable<ILogicalExpression>> args = new ArrayList<>();
Mutable<ILogicalOperator> topOp = tupSource;
for (Expression expr : fcall.getExprList()) {
switch(expr.getKind()) {
case VARIABLE_EXPRESSION:
LogicalVariable var = context.getVar(((VariableExpr) expr).getVar().getId());
args.add(new MutableObject<>(new VariableReferenceExpression(var)));
break;
case LITERAL_EXPRESSION:
LiteralExpr val = (LiteralExpr) expr;
args.add(new MutableObject<>(new ConstantExpression(new AsterixConstantValue(ConstantHelper.objectFromLiteral(val.getValue())))));
break;
default:
Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = langExprToAlgExpression(expr, topOp);
AbstractLogicalOperator o1 = (AbstractLogicalOperator) eo.second.getValue();
args.add(new MutableObject<>(eo.first));
if (o1 != null && !(o1.getOperatorTag() == LogicalOperatorTag.ASSIGN && hasOnlyChild(o1, topOp))) {
topOp = eo.second;
}
break;
}
}
AbstractFunctionCallExpression f;
if ((f = lookupUserDefinedFunction(signature, args)) == null) {
f = lookupBuiltinFunction(signature.getName(), signature.getArity(), args);
}
if (f == null) {
throw new CompilationException(" Unknown function " + signature.getName() + "@" + signature.getArity());
}
// Put hints into function call expr.
if (fcall.hasHints()) {
for (IExpressionAnnotation hint : fcall.getHints()) {
f.getAnnotations().put(hint, hint);
}
}
AssignOperator op = new AssignOperator(v, new MutableObject<>(f));
if (topOp != null) {
op.getInputs().add(topOp);
}
return new Pair<>(op, v);
}
Aggregations