@Override public boolean equals(Object obj) { if (!(obj instanceof ConstantExpression)) { return false; } else { return value.equals(((ConstantExpression) obj).getValue()); } }
/** * Whether the condition expression always returns true. * * @param cond * @return true if the condition always holds; false otherwise. */ private boolean alwaysHold(ILogicalExpression cond) { if (cond.equals(ConstantExpression.TRUE)) { return true; } if (cond.equals(new ConstantExpression(new AsterixConstantValue(ABoolean.TRUE)))) { return true; } return false; } }
@Override public AbstractLogicalExpression cloneExpression() { Map<Object, IExpressionAnnotation> m = new HashMap<>(); annotationMap.forEach((key, value1) -> m.put(key, value1.copy())); ConstantExpression c = new ConstantExpression(value); c.annotationMap = m; c.setSourceLocation(sourceLoc); return c; }
@Override public ILogicalExpression visitConstantExpression(ConstantExpression expr, Void arg) throws AlgebricksException { ConstantExpression exprCopy = new ConstantExpression(expr.getValue()); copySourceLocation(expr, exprCopy); return exprCopy; }
@Override public String visitConstantExpression(ConstantExpression expr, Integer indent) throws AlgebricksException { return expr.toString(); }
AsterixConstantValue constantValue = null; if (constantAtRuntimeExpression.getExpressionTag() == LogicalExpressionTag.CONSTANT) { constantValue = (AsterixConstantValue) ((ConstantExpression) constantAtRuntimeExpression).getValue(); return new Triple<>(new ConstantExpression(replacedConstantValue), null, realTypeConvertedToIntegerType); return new Triple<>(new ConstantExpression(replacedConstantValue), new ConstantExpression(replacedConstantValueForEQCase), realTypeConvertedToIntegerType); } else {
@Override public Object getType(ILogicalExpression expr, IMetadataProvider<?, ?> metadataProvider, IVariableTypeEnvironment env) throws AlgebricksException { if (expr.getExpressionTag() == LogicalExpressionTag.CONSTANT) { ConstantExpression ce = (ConstantExpression) expr; IAlgebricksConstantValue acv = ce.getValue(); if (acv == ConstantExpression.TRUE.getValue() || acv == ConstantExpression.FALSE.getValue()) { return SequenceType.create(BuiltinTypeRegistry.XS_BOOLEAN, Quantifier.QUANT_ONE); } VXQueryConstantValue cv = (VXQueryConstantValue) acv; return cv.getType(); } return null; } });
private static Mutable<ILogicalExpression> constantToMutableLogicalExpression(IAObject constantObject) { return new MutableObject<>(new ConstantExpression(new AsterixConstantValue(constantObject))); }
private ConstantExpression createConstantExpression(IAObject value, SourceLocation sourceLoc) { ConstantExpression constExpr = new ConstantExpression(new AsterixConstantValue(value)); constExpr.setSourceLocation(sourceLoc); return constExpr; } }
case CONSTANT: haveConst = true; AsterixConstantValue value = (AsterixConstantValue) ((ConstantExpression) argExpr).getValue(); if (valType == null) { valType = value.getObject().getType(); context.computeAndSetTypeEnvironmentForOperator(ets); ILogicalExpression cExp = new ConstantExpression(new AsterixConstantValue(list)); Mutable<ILogicalExpression> mutCExp = new MutableObject<>(cExp); IFunctionInfo scanFctInfo = BuiltinFunctions.getAsterixFunctionInfo(BuiltinFunctions.SCAN_COLLECTION);
private int readKeyInclusives(List<Mutable<ILogicalExpression>> funcArgs, int index) { lowKeyInclusive = ((ConstantExpression) funcArgs.get(index).getValue()).getValue().isTrue(); // Read the next function argument at index + 1. highKeyInclusive = ((ConstantExpression) funcArgs.get(index + 1).getValue()).getValue().isTrue(); // We have read two of the function arguments, so the next index is at index + 2. return index + 2; }
protected void writeVarList(List<LogicalVariable> varList, List<Mutable<ILogicalExpression>> funcArgs) { Mutable<ILogicalExpression> numKeysRef = new MutableObject<>(new ConstantExpression(new AsterixConstantValue(new AInt32(varList.size())))); funcArgs.add(numKeysRef); for (LogicalVariable keyVar : varList) { VariableReferenceExpression keyVarRef = new VariableReferenceExpression(keyVar); funcArgs.add(new MutableObject<>(keyVarRef)); } }
private AbstractFunctionCallExpression createPrimaryKeyRecordExpression(List<String> pkFieldName, SourceLocation sourceLoc) { //Create lowest level of nested uuid AbstractFunctionCallExpression uuidFn = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.CREATE_UUID)); uuidFn.setSourceLocation(sourceLoc); List<Mutable<ILogicalExpression>> openRecordConsArgs = new ArrayList<>(); ConstantExpression pkFieldNameExpression = new ConstantExpression(new AsterixConstantValue(new AString(pkFieldName.get(pkFieldName.size() - 1)))); pkFieldNameExpression.setSourceLocation(sourceLoc); openRecordConsArgs.add(new MutableObject<>(pkFieldNameExpression)); openRecordConsArgs.add(new MutableObject<>(uuidFn)); AbstractFunctionCallExpression openRecFn = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR), openRecordConsArgs); openRecFn.setSourceLocation(sourceLoc); //Create higher levels for (int i = pkFieldName.size() - 2; i > -1; i--) { AString fieldName = new AString(pkFieldName.get(i)); openRecordConsArgs = new ArrayList<>(); openRecordConsArgs.add( new MutableObject<ILogicalExpression>(new ConstantExpression(new AsterixConstantValue(fieldName)))); openRecordConsArgs.add(new MutableObject<ILogicalExpression>(openRecFn)); openRecFn = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR), openRecordConsArgs); openRecFn.setSourceLocation(sourceLoc); } return openRecFn; }
private void readIsEqCondition(List<Mutable<ILogicalExpression>> funcArgs, int index) { isEqCondition = ((ConstantExpression) funcArgs.get(index).getValue()).getValue().isTrue(); }
public static ConstantExpression createBooleanConstant(boolean b) { return new ConstantExpression(new AsterixConstantValue(ABoolean.valueOf(b))); }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(LiteralExpr l, Mutable<ILogicalOperator> tupSource) { SourceLocation sourceLoc = l.getSourceLocation(); LogicalVariable var = context.newVar(); AsterixConstantValue cValue = new AsterixConstantValue(ConstantHelper.objectFromLiteral(l.getValue())); ConstantExpression cExpr = new ConstantExpression(cValue); cExpr.setSourceLocation(sourceLoc); AssignOperator a = new AssignOperator(var, new MutableObject<>(cExpr)); a.setSourceLocation(sourceLoc); if (tupSource != null) { a.getInputs().add(tupSource); } return new Pair<>(a, var); }
public static boolean isAlwaysTrueCond(ILogicalExpression cond) { if (cond.getExpressionTag() == LogicalExpressionTag.CONSTANT) { return ((ConstantExpression) cond).getValue().isTrue(); } return false; }
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); }
private ILogicalExpression translateConstantValue(IAObject value, SourceLocation sourceLoc) throws CompilationException { ConstantExpression constExpr = new ConstantExpression(new AsterixConstantValue(value)); constExpr.setSourceLocation(sourceLoc); IAType valueType = value.getType(); if (valueType.getTypeTag().isDerivedType()) { ScalarFunctionCallExpression castExpr = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.CAST_TYPE)); castExpr.setSourceLocation(sourceLoc); castExpr.getArguments().add(new MutableObject<>(constExpr)); TypeCastUtils.setRequiredAndInputTypes(castExpr, BuiltinType.ANY, valueType); return castExpr; } else { return constExpr; } }