use of org.apache.asterix.lang.common.literal.StringLiteral in project asterixdb by apache.
the class AqlDeleteRewriteVisitor method visit.
@Override
public Void visit(DeleteStatement deleteStmt, Void visitArg) {
List<Expression> arguments = new ArrayList<>();
Identifier dataverseName = deleteStmt.getDataverseName();
Identifier datasetName = deleteStmt.getDatasetName();
String arg = dataverseName == null ? datasetName.getValue() : dataverseName.getValue() + "." + datasetName.getValue();
LiteralExpr argumentLiteral = new LiteralExpr(new StringLiteral(arg));
arguments.add(argumentLiteral);
CallExpr callExpression = new CallExpr(new FunctionSignature(FunctionConstants.ASTERIX_NS, "dataset", 1), arguments);
List<Clause> clauseList = new ArrayList<>();
VariableExpr var = deleteStmt.getVariableExpr();
Clause forClause = new ForClause(var, callExpression);
clauseList.add(forClause);
Clause whereClause = null;
Expression condition = deleteStmt.getCondition();
if (condition != null) {
whereClause = new WhereClause(condition);
clauseList.add(whereClause);
}
VariableExpr returnExpr = new VariableExpr(var.getVar());
returnExpr.setIsNewVar(false);
FLWOGRExpression flowgr = new FLWOGRExpression(clauseList, returnExpr);
Query query = new Query(false);
query.setBody(flowgr);
deleteStmt.setQuery(query);
return null;
}
use of org.apache.asterix.lang.common.literal.StringLiteral in project asterixdb by apache.
the class RangeMapBuilder method parseLiteralToBytes.
@SuppressWarnings("unchecked")
private static void parseLiteralToBytes(Expression item, DataOutput out) throws CompilationException {
AMutableDouble aDouble = new AMutableDouble(0);
AMutableFloat aFloat = new AMutableFloat(0);
AMutableInt64 aInt64 = new AMutableInt64(0);
AMutableInt32 aInt32 = new AMutableInt32(0);
AMutableString aString = new AMutableString("");
@SuppressWarnings("rawtypes") ISerializerDeserializer serde;
Literal l = ((LiteralExpr) item).getValue();
try {
switch(l.getLiteralType()) {
case DOUBLE:
DoubleLiteral dl = (DoubleLiteral) l;
serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ADOUBLE);
aDouble.setValue(dl.getValue());
serde.serialize(aDouble, out);
break;
case FLOAT:
FloatLiteral fl = (FloatLiteral) l;
serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AFLOAT);
aFloat.setValue(fl.getValue());
serde.serialize(aFloat, out);
break;
case INTEGER:
IntegerLiteral il = (IntegerLiteral) l;
serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT32);
aInt32.setValue(il.getValue());
serde.serialize(aInt32, out);
break;
case LONG:
LongIntegerLiteral lil = (LongIntegerLiteral) l;
serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64);
aInt64.setValue(lil.getValue());
serde.serialize(aInt64, out);
break;
case STRING:
StringLiteral sl = (StringLiteral) l;
serde = SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.ASTRING);
aString.setValue(sl.getValue());
serde.serialize(aString, out);
break;
default:
throw new NotImplementedException("The range map builder has not been implemented for " + item.getKind() + " type of expressions.");
}
} catch (HyracksDataException e) {
throw new CompilationException(e.getMessage());
}
}
Aggregations