Package io.debezium.relational
Class Tables
- java.lang.Object
-
- io.debezium.relational.Tables
-
@ThreadSafe public final class Tables extends Object
Structural definitions for a set of tables in a JDBC database.- Author:
- Randall Hauch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTables.ColumnNameFilterA filter for columns.static classTables.ColumnNameFilterFactorystatic interfaceTables.TableFilterA filter for tables.private static classTables.TableIdsA set of table ids.private static classTables.TablesByIdA map of tables by id.
-
Field Summary
Fields Modifier and Type Field Description private Tables.TableIdschangesprivate FunctionalReadWriteLocklockprivate booleantableIdCaseInsensitiveprivate Tables.TablesByIdtablesByTableId
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Tablesclone()Set<TableId>drainChanges()TableEditoreditOrCreateTable(TableId tableId)Obtain an editor for the table with the given ID.TableEditoreditTable(TableId tableId)Obtain an editor for the table with the given ID.booleanequals(Object obj)TableforTable(TableId tableId)Obtain the definition of the identified table.TableforTable(String catalogName, String schemaName, String tableName)Obtain the definition of the identified table.inthashCode()TableoverwriteTable(Table table)Add or update the definition for the identified table.TableoverwriteTable(TableId tableId, List<Column> columnDefs, List<String> primaryKeyColumnNames, String defaultCharsetName)Add or update the definition for the identified table.TableremoveTable(TableId tableId)Remove the definition of the identified table.voidremoveTablesForDatabase(String schemaName)voidremoveTablesForDatabase(String catalogName, String schemaName)TablerenameTable(TableId existingTableId, TableId newTableId)Rename an existing table.intsize()Get the number of tables that are in this object.Tablessubset(Tables.TableFilter filter)Set<TableId>tableIds()Get the set ofTableIds for which there is aSchema.StringtoString()TableupdateTable(TableId tableId, Function<Table,Table> changer)Add or update the definition for the identified table.
-
-
-
Field Detail
-
lock
private final FunctionalReadWriteLock lock
-
tablesByTableId
private final Tables.TablesById tablesByTableId
-
changes
private final Tables.TableIds changes
-
tableIdCaseInsensitive
private final boolean tableIdCaseInsensitive
-
-
Constructor Detail
-
Tables
public Tables(boolean tableIdCaseInsensitive)
Create an empty set of definitions.- Parameters:
tableIdCaseInsensitive- - true if lookup is case insensitive (typical for MySQL on Windows)
-
Tables
public Tables()
Create case sensitive empty set of definitions.
-
Tables
protected Tables(Tables other, boolean tableIdCaseInsensitive)
-
-
Method Detail
-
clear
public void clear()
-
size
public int size()
Get the number of tables that are in this object.- Returns:
- the table count
-
overwriteTable
public Table overwriteTable(TableId tableId, List<Column> columnDefs, List<String> primaryKeyColumnNames, String defaultCharsetName)
Add or update the definition for the identified table.- Parameters:
tableId- the identifier of the tablecolumnDefs- the list of column definitions; may not be null or emptyprimaryKeyColumnNames- the list of the column names that make up the primary key; may be null or emptydefaultCharsetName- the name of the character set that should be used by default- Returns:
- the previous table definition, or null if there was no prior table definition
-
overwriteTable
public Table overwriteTable(Table table)
Add or update the definition for the identified table.- Parameters:
table- the definition for the table; may not be null- Returns:
- the previous table definition, or null if there was no prior table definition
-
removeTablesForDatabase
public void removeTablesForDatabase(String schemaName)
-
renameTable
public Table renameTable(TableId existingTableId, TableId newTableId)
Rename an existing table.- Parameters:
existingTableId- the identifier of the existing table to be renamed; may not be nullnewTableId- the new identifier for the table; may not be null- Returns:
- the previous table definition, or null if there was no prior table definition
-
updateTable
public Table updateTable(TableId tableId, Function<Table,Table> changer)
Add or update the definition for the identified table.
-
removeTable
public Table removeTable(TableId tableId)
Remove the definition of the identified table.- Parameters:
tableId- the identifier of the table- Returns:
- the existing table definition that was removed, or null if there was no prior table definition
-
forTable
public Table forTable(TableId tableId)
Obtain the definition of the identified table.- Parameters:
tableId- the identifier of the table- Returns:
- the table definition, or null if there was no definition for the identified table
-
forTable
public Table forTable(String catalogName, String schemaName, String tableName)
Obtain the definition of the identified table.- Parameters:
catalogName- the name of the database catalog that contains the table; may be null if the JDBC driver does not show a schema for this tableschemaName- the name of the database schema that contains the table; may be null if the JDBC driver does not show a schema for this tabletableName- the name of the table- Returns:
- the table definition, or null if there was no definition for the identified table
-
tableIds
public Set<TableId> tableIds()
Get the set ofTableIds for which there is aSchema.- Returns:
- the immutable set of table identifiers; never null
-
editTable
public TableEditor editTable(TableId tableId)
Obtain an editor for the table with the given ID. This method does not lock the set of table definitions, so use with caution. The resulting editor can be used to modify the table definition, but when completed the newTableneeds to be added back to this object viaoverwriteTable(Table).- Parameters:
tableId- the identifier of the table- Returns:
- the editor for the table, or null if there is no table with the specified ID
-
editOrCreateTable
public TableEditor editOrCreateTable(TableId tableId)
Obtain an editor for the table with the given ID. This method does not lock or modify the set of table definitions, so use with caution. The resulting editor can be used to modify the table definition, but when completed the newTableneeds to be added back to this object viaoverwriteTable(Table).- Parameters:
tableId- the identifier of the table- Returns:
- the editor for the table, or null if there is no table with the specified ID
-
subset
public Tables subset(Tables.TableFilter filter)
-
-