@Override public TableMeta deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { Preconditions.checkNotNull(json); JsonObject jsonObject = json.getAsJsonObject(); String dataFormat = CommonGsonHelper.getOrDie(jsonObject, "store").getAsString(); KeyValueSet keyValueSet = context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "options"), KeyValueSet.class); return new TableMeta(dataFormat, keyValueSet); }
@Override public TableMeta deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { Preconditions.checkNotNull(json); JsonObject jsonObject = json.getAsJsonObject(); String dataFormat = CommonGsonHelper.getOrDie(jsonObject, "store").getAsString(); KeyValueSet keyValueSet = context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "options"), KeyValueSet.class); return new TableMeta(dataFormat, keyValueSet); }
@Override public Function deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String className = CommonGsonHelper.getOrDie(jsonObject, "class").getAsJsonPrimitive().getAsString(); Class clazz; try { clazz = Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); throw new JsonParseException(e); } return context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "body"), clazz); } }
@Override public Function deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String className = CommonGsonHelper.getOrDie(jsonObject, "class").getAsJsonPrimitive().getAsString(); Class clazz; try { clazz = Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); throw new JsonParseException(e); } return context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "body"), clazz); } }
@Override public Schema deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); int version = CommonGsonHelper.getOrDie(jsonObject, "version").getAsJsonPrimitive().getAsInt(); if (version == 1) { return context.deserialize(CommonGsonHelper.getOrDie(jsonObject, "body"), SchemaLegacy.class); } else { throw new TajoInternalError("Schema version 2 is not supported yet"); } } }
@Override public org.apache.tajo.type.Type deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject obj = (JsonObject) json; return TypeStringEncoder.decode(CommonGsonHelper.getOrDie(obj, "type").getAsString()); }
@Override public EvalNode deserialize(JsonElement json, Type type, JsonDeserializationContext ctx) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String nodeName = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); Class clazz = EvalType.valueOf(nodeName).getBaseClass(); return ctx.deserialize(jsonObject.get("body"), clazz); }
@Override public EvalNode deserialize(JsonElement json, Type type, JsonDeserializationContext ctx) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String nodeName = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); Class clazz = EvalType.valueOf(nodeName).getBaseClass(); return ctx.deserialize(jsonObject.get("body"), clazz); }
@Override public PartitionMethodDescExpr deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); PartitionType type = PartitionType.valueOf( CommonGsonHelper.getOrDie(jsonObject, "PartitionType").getAsString()); switch (type) { case RANGE: return context.deserialize(json, RangePartition.class); case HASH: return context.deserialize(json, HashPartition.class); case LIST: return context.deserialize(json, ListPartition.class); case COLUMN: return context.deserialize(json, ColumnPartition.class); } return null; }
@Override public LogicalNode deserialize(JsonElement src, Type type, JsonDeserializationContext ctx) throws JsonParseException { JsonObject jsonObject = src.getAsJsonObject(); String nodeName = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); Class clazz = NodeType.valueOf(nodeName).getBaseClass(); return ctx.deserialize(jsonObject.get("body"), clazz); }
@Override public PartitionMethodDescExpr deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); PartitionType type = PartitionType.valueOf( CommonGsonHelper.getOrDie(jsonObject, "PartitionType").getAsString()); switch (type) { case RANGE: return context.deserialize(json, RangePartition.class); case HASH: return context.deserialize(json, HashPartition.class); case LIST: return context.deserialize(json, ListPartition.class); case COLUMN: return context.deserialize(json, ColumnPartition.class); } return null; }
@Override public LogicalNode deserialize(JsonElement src, Type type, JsonDeserializationContext ctx) throws JsonParseException { JsonObject jsonObject = src.getAsJsonObject(); String nodeName = CommonGsonHelper.getOrDie(jsonObject, "type").getAsString(); Class clazz = NodeType.valueOf(nodeName).getBaseClass(); return ctx.deserialize(jsonObject.get("body"), clazz); }
@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()))); } }
@Override public Expr deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String opType = CommonGsonHelper.getOrDie(jsonObject, SERIALIZED_NAME_OF_OP_TYPE).getAsString(); if (OpType.valueOf(opType).equals(OpType.Literal)) { String value = CommonGsonHelper.getOrDie(jsonObject, "Value").getAsString(); JsonElement valueTypeElem = jsonObject.get("ValueType"); if (valueTypeElem != null) { return new LiteralValue(value, LiteralType.valueOf(valueTypeElem.getAsString())); } else { return new LiteralValue(value, LiteralValue.getLiteralType(value)); } } else { return context.deserialize(json, OpType.valueOf(opType).getBaseClass()); } }
@Override public Expr deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = json.getAsJsonObject(); String opType = CommonGsonHelper.getOrDie(jsonObject, SERIALIZED_NAME_OF_OP_TYPE).getAsString(); if (OpType.valueOf(opType).equals(OpType.Literal)) { String value = CommonGsonHelper.getOrDie(jsonObject, "Value").getAsString(); JsonElement valueTypeElem = jsonObject.get("ValueType"); if (valueTypeElem != null) { return new LiteralValue(value, LiteralType.valueOf(valueTypeElem.getAsString())); } else { return new LiteralValue(value, LiteralValue.getLiteralType(value)); } } else { return context.deserialize(json, OpType.valueOf(opType).getBaseClass()); } }
@Override public DataType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject obj = (JsonObject) json; DataType.Builder builder = DataType.newBuilder(); TajoDataTypes.Type type = TajoDataTypes.Type.valueOf(CommonGsonHelper.getOrDie(obj, "type").getAsString()); builder.setType(type); JsonElement len = obj.get("len"); if (len != null) { builder.setLength(len.getAsInt()); } JsonElement code = obj.get("code"); if (code != null) { builder.setCode(code.getAsString()); } return builder.build(); }
@Override public DataType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject obj = (JsonObject) json; DataType.Builder builder = DataType.newBuilder(); TajoDataTypes.Type type = TajoDataTypes.Type.valueOf(CommonGsonHelper.getOrDie(obj, "type").getAsString()); builder.setType(type); JsonElement len = obj.get("len"); if (len != null) { builder.setLength(len.getAsInt()); } JsonElement code = obj.get("code"); if (code != null) { builder.setCode(code.getAsString()); } return builder.build(); }