@Test public void testDealWithMappingForTable() throws IOException { TableMetadataManager tableMetaManager = TableMetadataManager.getInstance(getTestConfig()); ResourceStore store = tableMetaManager.getStore(); Set<TableDesc> tables = Sets.newHashSet(); for (String tableIdentity : mappings.keySet()) { tables.add(store.getResource(TableDesc.concatResourcePath(tableIdentity, null), TableMetadataManager.TABLE_SERIALIZER)); } for (TableDesc tableDesc : tables) { TableDesc updated = TableSchemaUpdater.dealWithMappingForTable(tableDesc, mappings); updated = reinit(updated, TableMetadataManager.TABLE_SERIALIZER); try (DataInputStream bis = new DataInputStream(new FileInputStream( new File(mappingRootPath + TableDesc.concatResourcePath(updated.getIdentity(), null))))) { TableDesc expected = TableMetadataManager.TABLE_SERIALIZER.deserialize(bis); Assert.assertEquals(expected, updated); } catch (Exception e) { Assert.fail("Table identity is not updated correctly"); } } }
public static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, other.getIdentity()); if (mapping == null) { return other; } TableDesc copy = new TableDesc(other); copy.setDatabase(mapping.getDatabase(other.getDatabase())); copy.setName(mapping.getTableName(other.getName())); copy.setLastModified(0L); return copy; }
TableSchemaUpdater { public static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, other.getIdentity()); if (mapping == null) { return other; } TableDesc copy = new TableDesc(other); copy.setDatabase(mapping.getDatabase(other.getDatabase())); copy.setName(mapping.getTableName(other.getName())); copy.setLastModified(0L); return copy; } }
TableSchemaUpdater { public static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, other.getIdentity()); if (mapping == null) { return other; } TableDesc copy = new TableDesc(other); copy.setDatabase(mapping.getDatabase(other.getDatabase())); copy.setName(mapping.getTableName(other.getName())); copy.setLastModified(0L); return copy; }  }
TableSchemaUpdater { public static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, other.getIdentity()); if (mapping == null) { return other; } TableDesc copy = new TableDesc(other); copy.setDatabase(mapping.getDatabase(other.getDatabase())); copy.setName(mapping.getTableName(other.getName())); copy.setLastModified(0L); return copy; }  static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings); static DataModelDesc dealWithMappingForModel(DataModelDesc other,
            Map<String, TableSchemaUpdateMapping> mappings); static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings); static CubeInstance dealWithMappingForCube(CubeInstance other,
            Map<String, TableSchemaUpdateMapping> mappings); static TableSchemaUpdateMapping getTableSchemaUpdateMapping(Map<String, TableSchemaUpdateMapping> mappings,
            String key); }
TableSchemaUpdater { public static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings) { TableSchemaUpdateMapping mapping = getTableSchemaUpdateMapping(mappings, other.getIdentity()); if (mapping == null) { return other; } TableDesc copy = new TableDesc(other); copy.setDatabase(mapping.getDatabase(other.getDatabase())); copy.setName(mapping.getTableName(other.getName())); copy.setLastModified(0L); return copy; }  static TableDesc dealWithMappingForTable(TableDesc other, Map<String, TableSchemaUpdateMapping> mappings); static DataModelDesc dealWithMappingForModel(DataModelDesc other,
            Map<String, TableSchemaUpdateMapping> mappings); static CubeDesc dealWithMappingForCubeDesc(CubeDesc other, Map<String, TableSchemaUpdateMapping> mappings); static CubeInstance dealWithMappingForCube(CubeInstance other,
            Map<String, TableSchemaUpdateMapping> mappings); static TableSchemaUpdateMapping getTableSchemaUpdateMapping(Map<String, TableSchemaUpdateMapping> mappings,
            String key);  }