@Override public HCatPartition deserializePartition(String hcatPartitionStringRep) throws HCatException { HCatPartition hcatPartition = MetadataSerializer.get().deserializePartition(hcatPartitionStringRep); hcatPartition.hcatTable(getTable(hcatPartition.getDatabaseName(), hcatPartition.getTableName())); return hcatPartition; }
@Override public HCatPartitionSpec deserializePartitionSpec(List<String> hcatPartitionSpecStrings) throws HCatException { HCatPartitionSpec hcatPartitionSpec = MetadataSerializer.get() .deserializePartitionSpec(hcatPartitionSpecStrings); hcatPartitionSpec .hcatTable(getTable(hcatPartitionSpec.getDbName(), hcatPartitionSpec.getTableName())); return hcatPartitionSpec; } }
/** * Getter for HCatCreateTableDesc.Builder instance. By default, ifNotExists is false. * So the attempt to create the table is made even if the table already exists. * @param table Spec for HCatTable to be created. * @return Builder instance. */ public static Builder create(HCatTable table) { return new Builder(table, false); }
HCatPartition getHCatPartition(HCatTable hcatTable) throws HCatException { assert hcatPartition == null : "hcatPartition should have been null at this point."; assert dbName.equalsIgnoreCase(hcatTable.getDbName()) : "DB names don't match."; assert tableName.equalsIgnoreCase(hcatTable.getTableName()) : "Table names don't match."; return new HCatPartition(hcatTable, partitionKeyValues, location); }
public HCatPartition hcatTable(HCatTable hcatTable) { this.hcatTable = hcatTable; this.tableName = hcatTable.getTableName(); this.dbName = hcatTable.getDbName(); return this; }
@Override public String serializeTable(HCatTable hcatTable) throws HCatException { return MetadataSerializer.get().serializeTable(hcatTable); }
@Override public HCatTable deserializeTable(String hcatTableStringRep) throws HCatException { return MetadataSerializer.get().deserializeTable(hcatTableStringRep); }
/** * Gets the partition columns of the table. * * @return the partition columns */ public List<HCatFieldSchema> getPartColumns() { return hcatTable.getPartCols(); }
/** * Method to compare the attributes of 2 HCatTable instances. * Only the {@code DEFAULT_COMPARISON_ATTRIBUTES} are compared. * @param rhs The other table being compared against. Can't be null. * @return {@code EnumSet<TableAttribute>} containing all the attribute that differ between {@code this} and rhs. * Subset of {@code DEFAULT_COMPARISON_ATTRIBUTES}. */ public EnumSet<TableAttribute> diff (HCatTable rhs) { return diff(rhs, DEFAULT_COMPARISON_ATTRIBUTES); }
/** * Setter for HCatTable. Required for deserialization. */ void hcatTable(HCatTable hcatTable) throws HCatException { assert this.hcatTable == null : "Expected hcatTable to be null at this point."; this.hcatTable = hcatTable; assert_invariant(); }
/** * Creates the builder for defining attributes. * * @param dbName the db name * @return the builder */ public static Builder create(String dbName) { return new Builder(dbName); }
@Override public String toString() { return "HCatCreateTableDesc [ " + hcatTable.toString() + ", ifNotExists = " + ifNotExists + "]"; }
/** * Builds the HCatAddPartitionDesc. * * @return the h cat add partition desc * @throws HCatException */ public HCatAddPartitionDesc build() throws HCatException { return hcatPartition == null? new HCatAddPartitionDesc(dbName, tableName, location, partitionSpec) : new HCatAddPartitionDesc(hcatPartition); } }
@Override public void dropPartitions(String dbName, String tableName, Map<String, String> partitionSpec, boolean ifExists) throws HCatException { dropPartitions(dbName, tableName, partitionSpec, ifExists, true); }
/** * Static getter method for the appropriate MetadataSerializer implementation. * @return MetadataSerializer sub-class. * @throws HCatException On failure to construct a concrete MetadataSerializer. */ public static MetadataSerializer get() throws HCatException { return new MetadataJSONSerializer(); }
/** * Constructs a Builder instance, using an HCatPartition object. * @param partition An HCatPartition instance. * @return A Builder object that can build an appropriate HCatAddPartitionDesc. * @throws HCatException */ public static Builder create(HCatPartition partition) throws HCatException { return new Builder(partition); }
/** * Builds the HCatCreateTableDesc. * * @return HCatCreateTableDesc * @throws HCatException */ public HCatCreateTableDesc build() throws HCatException { return new HCatCreateTableDesc(this.hcatTable, this.ifNotExists); }
/** * Getter for HCatCreateTableDesc.Builder instance. * @param table Spec for HCatTable to be created. * @param ifNotExists Only create the table if it doesn't already exist. * @return Builder instance. */ public static Builder create(HCatTable table, boolean ifNotExists) { return new Builder(table, ifNotExists); }
protected HCatPartitionSpec(HCatTable hcatTable, PartitionSpecProxy partitionSpecProxy) throws HCatException { this.hcatTable = hcatTable; this.partitionSpecProxy = partitionSpecProxy; assert_invariant(); }