@Test public void testNewTableName() throws Exception { TableCache tableCache = new TableCache(schemaManager, OVERRIDING_DATABASE_NAME); String newTable = "new_table"; when(schemaManager.getTableColumns(DATABASE_NAME, TABLE_NAME)).thenReturn(TABLE_COLUMNS); List<ColumnDataType> columnTypes = Arrays.asList( ColumnDataType.TINY, ColumnDataType.STRING, ColumnDataType.FLOAT, ColumnDataType.LONG); tableCache.addOrUpdate(TABLE_ID, TABLE_NAME, DATABASE_NAME, columnTypes); verify(schemaManager, times(1)).getTableColumns(DATABASE_NAME, TABLE_NAME); when(schemaManager.getTableColumns(DATABASE_NAME, newTable)).thenReturn(TABLE_COLUMNS_UPDATED); columnTypes = Arrays.asList(ColumnDataType.TINY, ColumnDataType.STRING, ColumnDataType.FLOAT); tableCache.addOrUpdate(TABLE_ID, newTable, DATABASE_NAME, columnTypes); verify(schemaManager, times(1)).getTableColumns(DATABASE_NAME, newTable); verifyZeroInteractions(metrics); }
public void addOrUpdate( @Min(0) final long tableId, @NonNull final String tableName, @NonNull final String database, @NonNull final List<ColumnDataType> columnTypes) throws Exception { final Table table = tableCache.getIfPresent(tableId); if (table == null || !validTable(table, tableName, database, columnTypes)) { tableCache.put(tableId, fetchTable(tableId, database, tableName, columnTypes)); } }
TableCache { public void addOrUpdate( @Min(0) final long tableId, @NonNull final String tableName, @NonNull final String database, @NonNull final List<ColumnDataType> columnTypes) throws Exception { final Table table = tableCache.getIfPresent(tableId); if (table == null || !validTable(table, tableName, database, columnTypes)) { tableCache.put(tableId, fetchTable(tableId, database, tableName, columnTypes)); } } }
TableCache { public void addOrUpdate( @Min(0) final long tableId, @NonNull final String tableName, @NonNull final String database, @NonNull final List<ColumnDataType> columnTypes) throws Exception { final Table table = tableCache.getIfPresent(tableId); if (table == null || !validTable(table, tableName, database, columnTypes)) { tableCache.put(tableId, fetchTable(tableId, database, tableName, columnTypes)); } }  }
TableCache { public void addOrUpdate( @Min(0) final long tableId, @NonNull final String tableName, @NonNull final String database, @NonNull final List<ColumnDataType> columnTypes) throws Exception { final Table table = tableCache.getIfPresent(tableId); if (table == null || !validTable(table, tableName, database, columnTypes)) { tableCache.put(tableId, fetchTable(tableId, database, tableName, columnTypes)); } }  Table get(@Min(0) final long tableId); boolean contains(@Min(0) final long tableId); void addOrUpdate(
      @Min(0) final long tableId,
      @NonNull final String tableName,
      @NonNull final String database,
      @NonNull final List<ColumnDataType> columnTypes); void clear(); }
TableCache { public void addOrUpdate( @Min(0) final long tableId, @NonNull final String tableName, @NonNull final String database, @NonNull final List<ColumnDataType> columnTypes) throws Exception { final Table table = tableCache.getIfPresent(tableId); if (table == null || !validTable(table, tableName, database, columnTypes)) { tableCache.put(tableId, fetchTable(tableId, database, tableName, columnTypes)); } }  Table get(@Min(0) final long tableId); boolean contains(@Min(0) final long tableId); void addOrUpdate(
      @Min(0) final long tableId,
      @NonNull final String tableName,
      @NonNull final String database,
      @NonNull final List<ColumnDataType> columnTypes); void clear();  }