use of org.apache.asterix.lang.common.literal.DoubleLiteral 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