public static AnyDatum createAny(Datum val) { return new AnyDatum(val); }
public static AnyDatum createAny(Datum val) { return new AnyDatum(val); }
@Override public Datum deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String typeName = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); TajoDataTypes.Type type = TajoDataTypes.Type.valueOf(typeName); switch (type) { case DATE: return new DateDatum(CommonGsonHelper.getOrDie(jsonObject, "value").getAsInt()); case TIME: return new TimeDatum(CommonGsonHelper.getOrDie(jsonObject, "value").getAsLong()); case TIMESTAMP: return new TimestampDatum(CommonGsonHelper.getOrDie(jsonObject, "value").getAsLong()); case INTERVAL: String[] values = CommonGsonHelper.getOrDie(jsonObject, "value").getAsString().split(","); return new IntervalDatum(Integer.parseInt(values[0]), Long.parseLong(values[1])); case ANY: return new AnyDatum(deserialize(CommonGsonHelper.getOrDie(jsonObject, "actual"), typeOfT, context)); default: return context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "body"), DatumFactory.getDatumClass(TajoDataTypes.Type.valueOf(typeName))); } }
@Override public Datum deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String typeStr = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); org.apache.tajo.type.Type type = TypeStringEncoder.decode(typeStr); switch (type.kind()) { case DATE: return new DateDatum(CommonGsonHelper.getOrDie(jsonObject, "value").getAsInt()); case TIME: return new TimeDatum(CommonGsonHelper.getOrDie(jsonObject, "value").getAsLong()); case TIMESTAMP: return new TimestampDatum(CommonGsonHelper.getOrDie(jsonObject, "value").getAsLong()); case INTERVAL: String[] values = CommonGsonHelper.getOrDie(jsonObject, "value").getAsString().split(","); return new IntervalDatum(Integer.parseInt(values[0]), Long.parseLong(values[1])); case ANY: return new AnyDatum(deserialize(CommonGsonHelper.getOrDie(jsonObject, "actual"), typeOfT, context)); default: return context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "body"), DatumFactory.getDatumClass(TajoDataTypes.Type.valueOf(type.kind().name()))); } }