public static Table getTableObj(ObjectNode jsonTree) throws Exception { TDeserializer deSerializer = new TDeserializer(new TJSONProtocol.Factory()); Table tableObj = new Table(); String tableJson = jsonTree.get("tableObjJson").asText(); deSerializer.deserialize(tableObj, tableJson, "UTF-8"); return tableObj; }
@Override public HCatTable deserializeTable(String hcatTableStringRep) throws HCatException { try { Table table = new Table(); new TDeserializer(new TJSONProtocol.Factory()).deserialize(table, hcatTableStringRep, "UTF-8"); return new HCatTable(table); } catch(TException exception) { if (LOG.isDebugEnabled()) LOG.debug("Could not de-serialize from: " + hcatTableStringRep); throw new HCatException("Could not de-serialize HCatTable.", exception); } }
@Override public HCatPartition deserializePartition(String hcatPartitionStringRep) throws HCatException { try { Partition partition = new Partition(); new TDeserializer(new TJSONProtocol.Factory()).deserialize(partition, hcatPartitionStringRep, "UTF-8"); return new HCatPartition(null, partition); } catch(TException exception) { if (LOG.isDebugEnabled()) LOG.debug("Could not de-serialize partition from: " + hcatPartitionStringRep); throw new HCatException("Could not de-serialize HCatPartition.", exception); } }
@Override public void writeTo(JsonWriter writer, ReplicationSpec additionalPropertiesProvider) throws SemanticException, IOException { dbObject.putToParameters( ReplicationSpec.KEY.CURR_STATE_ID.toString(), additionalPropertiesProvider.getCurrentReplicationState() ); TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); try { String value = serializer.toString(dbObject, UTF_8); writer.jsonGenerator.writeStringField(FIELD_NAME, value); } catch (TException e) { throw new SemanticException(ErrorMsg.ERROR_SERIALIZE_METASTORE.getMsg(), e); } } }
@Override @InterfaceAudience.LimitedPrivate({"Hive"}) @InterfaceStability.Evolving public List<String> serializePartitionSpec(HCatPartitionSpec hcatPartitionSpec) throws HCatException { try { List<String> stringReps = new ArrayList<String>(); TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); for (PartitionSpec partitionSpec : hcatPartitionSpec.partitionSpecProxy.toPartitionSpec()) { stringReps.add(serializer.toString(partitionSpec, "UTF-8")); } return stringReps; } catch (TException serializationException) { throw new HCatException("Failed to serialize!", serializationException); } }
public static String createFunctionObjJson(Function functionObj) throws TException { TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(functionObj, "UTF-8"); }
public static String createCatalogObjJson(Catalog catObj) throws TException { TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(catObj, "UTF-8"); }
public static String createPrimaryKeyObjJson(SQLPrimaryKey primaryKeyObj) throws TException { TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(primaryKeyObj, "UTF-8"); }
public static String createTableColumnStatJson(ColumnStatistics tableColumnStat) throws TException { TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(tableColumnStat, "UTF-8"); }
public static String createForeignKeyObjJson(SQLForeignKey foreignKeyObj) throws TException { TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(foreignKeyObj, "UTF-8"); }
public static String createDatabaseObjJson(Database dbObj) throws TException { TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(dbObj, "UTF-8"); }
public static String createPartitionObjJson(Partition partitionObj) throws TException { //Note: The parameters of the Partition object will be removed in the filter if it matches // any pattern provided through EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS filterMapkeys(partitionObj.getParameters(), paramsFilter); TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(partitionObj, "UTF-8"); }
public static String createUniqueConstraintObjJson(SQLUniqueConstraint uniqueConstraintObj) throws TException { TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(uniqueConstraintObj, "UTF-8"); }
@Override public String serializePartition(HCatPartition hcatPartition) throws HCatException { try { return new TSerializer(new TJSONProtocol.Factory()) .toString(hcatPartition.toHivePartition(), "UTF-8"); } catch (TException exception) { throw new HCatException("Could not serialize HCatPartition: " + hcatPartition, exception); } }
public static String createTableObjJson(Table tableObj) throws TException { //Note: The parameters of the Table object will be removed in the filter if it matches // any pattern provided through EVENT_NOTIFICATION_PARAMETERS_EXCLUDE_PATTERNS filterMapkeys(tableObj.getParameters(), paramsFilter); TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(tableObj, "UTF-8"); }
public MetadataJson(String message) throws JSONException, SemanticException { deserializer = new TDeserializer(new TJSONProtocol.Factory()); json = new JSONObject(message); checkCompatibility(); tableDesc = jsonEntry(TableSerializer.FIELD_NAME); }
public static TBase getTObj(String tSerialized, Class<? extends TBase> objClass) throws Exception { TDeserializer thriftDeSerializer = new TDeserializer(new TJSONProtocol.Factory()); TBase obj = objClass.newInstance(); thriftDeSerializer.deserialize(obj, tSerialized, "UTF-8"); return obj; }
public static String createNotNullConstraintObjJson(SQLNotNullConstraint notNullConstaintObj) throws TException { TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); return serializer.toString(notNullConstaintObj, "UTF-8"); }
@Override public String serializeTable(HCatTable hcatTable) throws HCatException { try { return new TSerializer(new TJSONProtocol.Factory()) .toString(hcatTable.toHiveTable(), "UTF-8"); } catch (TException exception) { throw new HCatException("Could not serialize HCatTable: " + hcatTable, exception); } }
@Override protected TDeserializer initialValue() { return new TDeserializer(new TJSONProtocol.Factory()); } };