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 interface
Tables.ColumnNameFilter
A filter for columns.static class
Tables.ColumnNameFilterFactory
static interface
Tables.TableFilter
A filter for tables.private static class
Tables.TableIds
A set of table ids.private static class
Tables.TablesById
A map of tables by id.
-
Field Summary
Fields Modifier and Type Field Description private Tables.TableIds
changes
private FunctionalReadWriteLock
lock
private boolean
tableIdCaseInsensitive
private Tables.TablesById
tablesByTableId
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Tables
clone()
Set<TableId>
drainChanges()
TableEditor
editOrCreateTable(TableId tableId)
Obtain an editor for the table with the given ID.TableEditor
editTable(TableId tableId)
Obtain an editor for the table with the given ID.boolean
equals(Object obj)
Table
forTable(TableId tableId)
Obtain the definition of the identified table.Table
forTable(String catalogName, String schemaName, String tableName)
Obtain the definition of the identified table.int
hashCode()
Table
overwriteTable(Table table)
Add or update the definition for the identified table.Table
overwriteTable(TableId tableId, List<Column> columnDefs, List<String> primaryKeyColumnNames, String defaultCharsetName)
Add or update the definition for the identified table.Table
removeTable(TableId tableId)
Remove the definition of the identified table.void
removeTablesForDatabase(String schemaName)
void
removeTablesForDatabase(String catalogName, String schemaName)
Table
renameTable(TableId existingTableId, TableId newTableId)
Rename an existing table.int
size()
Get the number of tables that are in this object.Tables
subset(Tables.TableFilter filter)
Set<TableId>
tableIds()
Get the set ofTableId
s for which there is aSchema
.String
toString()
Table
updateTable(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 ofTableId
s 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 newTable
needs 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 newTable
needs 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)
-
-