/** Adds the partition to its HdfsTable. Returns the table with an updated catalog version. */ public Table addPartition(HdfsPartition partition) throws CatalogException { Preconditions.checkNotNull(partition); HdfsTable hdfsTable = partition.getTable(); Db db = getDb(hdfsTable.getDb().getName()); // Locking the catalog here because this accesses the hdfsTable's partition list and // updates its catalog version. // TODO: Fix this locking pattern. catalogLock_.writeLock().lock(); try { hdfsTable.addPartition(partition); hdfsTable.setCatalogVersion(incrementAndGetCatalogVersion()); db.addTable(hdfsTable); } finally { catalogLock_.writeLock().unlock(); } return hdfsTable; }