Package io.debezium.relational.ddl
Class DdlChanges
- java.lang.Object
-
- io.debezium.relational.ddl.DdlChanges
-
- All Implemented Interfaces:
DdlParserListener
@NotThreadSafe public class DdlChanges extends Object implements DdlParserListener
ADdlParserListener
that accumulates changes, allowing them to be consumed in the same order by database.- Author:
- Randall Hauch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DdlChanges.DatabaseEventConsumer
static interface
DdlChanges.DatabaseStatementConsumer
static interface
DdlChanges.DatabaseStatementStringConsumer
-
Nested classes/interfaces inherited from interface io.debezium.relational.ddl.DdlParserListener
DdlParserListener.DatabaseAlteredEvent, DdlParserListener.DatabaseCreatedEvent, DdlParserListener.DatabaseDroppedEvent, DdlParserListener.DatabaseEvent, DdlParserListener.DatabaseSwitchedEvent, DdlParserListener.Event, DdlParserListener.EventType, DdlParserListener.SetVariableEvent, DdlParserListener.TableAlteredEvent, DdlParserListener.TableCreatedEvent, DdlParserListener.TableDroppedEvent, DdlParserListener.TableEvent, DdlParserListener.TableIndexCreatedEvent, DdlParserListener.TableIndexDroppedEvent, DdlParserListener.TableIndexEvent, DdlParserListener.TableTruncatedEvent
-
-
Field Summary
Fields Modifier and Type Field Description private Set<String>
databaseNames
private List<DdlParserListener.Event>
events
private String
terminator
-
Constructor Summary
Constructors Constructor Description DdlChanges()
Create a new changes object with ';' as the terminator token.DdlChanges(String terminator)
Create a new changes object with the designated terminator token.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
addTable(Set<TableId> tables, DdlParserListener.Event event)
boolean
anyMatch(RelationalTableFilters filters)
boolean
anyMatch(Predicate<String> databaseFilter, Predicate<TableId> tableFilter)
Deprecated.boolean
applyToMoreDatabasesThan(String name)
protected String
getDatabase(DdlParserListener.Event event)
void
getEventsByDatabase(DdlChanges.DatabaseEventConsumer consumer)
Consume the events in the same order they wererecorded
, but grouped by database name.void
groupEventsByDatabase(DdlChanges.DatabaseEventConsumer consumer)
Consume the events in the same order they wererecorded
, but grouped by database name.void
groupStatementsByDatabase(DdlChanges.DatabaseStatementConsumer consumer)
Consume the events in the same order they wererecorded
, but grouped by database name.void
groupStatementStringsByDatabase(DdlChanges.DatabaseStatementStringConsumer consumer)
Consume the events in the same order they wererecorded
, but grouped by database name.void
handle(DdlParserListener.Event event)
Handle a DDL event.boolean
isEmpty()
DdlChanges
reset()
Clear all accumulated changes.String
toString()
-
-
-
Field Detail
-
terminator
private final String terminator
-
events
private final List<DdlParserListener.Event> events
-
-
Constructor Detail
-
DdlChanges
public DdlChanges()
Create a new changes object with ';' as the terminator token.
-
DdlChanges
public DdlChanges(String terminator)
Create a new changes object with the designated terminator token.- Parameters:
terminator
- the token used to terminate each statement; may be null
-
-
Method Detail
-
reset
public DdlChanges reset()
Clear all accumulated changes.- Returns:
- this object for method chaining; never null
-
handle
public void handle(DdlParserListener.Event event)
Description copied from interface:DdlParserListener
Handle a DDL event.- Specified by:
handle
in interfaceDdlParserListener
- Parameters:
event
- the DDL event; never null
-
groupStatementStringsByDatabase
public void groupStatementStringsByDatabase(DdlChanges.DatabaseStatementStringConsumer consumer)
Consume the events in the same order they wererecorded
, but grouped by database name. Multiple sequential statements that were applied to the same database are grouped together.- Parameters:
consumer
- the consumer
-
addTable
private void addTable(Set<TableId> tables, DdlParserListener.Event event)
-
groupStatementsByDatabase
public void groupStatementsByDatabase(DdlChanges.DatabaseStatementConsumer consumer)
Consume the events in the same order they wererecorded
, but grouped by database name. Multiple sequential statements that were applied to the same database are grouped together.- Parameters:
consumer
- the consumer
-
groupEventsByDatabase
public void groupEventsByDatabase(DdlChanges.DatabaseEventConsumer consumer)
Consume the events in the same order they wererecorded
, but grouped by database name. Multiple sequential statements that were applied to the same database are grouped together.- Parameters:
consumer
- the consumer
-
getEventsByDatabase
public void getEventsByDatabase(DdlChanges.DatabaseEventConsumer consumer)
Consume the events in the same order they wererecorded
, but grouped by database name. Multiple sequential statements that were applied to the same database are grouped together.- Parameters:
consumer
- the consumer
-
getDatabase
protected String getDatabase(DdlParserListener.Event event)
-
isEmpty
public boolean isEmpty()
-
applyToMoreDatabasesThan
public boolean applyToMoreDatabasesThan(String name)
-
anyMatch
@Deprecated public boolean anyMatch(Predicate<String> databaseFilter, Predicate<TableId> tableFilter)
Deprecated.- Returns:
- true if any event stored is one of
- database-wide events and affects included/excluded database
- table related events and the table is included
- events that set a variable and either affects included database or is a system-wide variable
-
anyMatch
public boolean anyMatch(RelationalTableFilters filters)
- Returns:
- true if any event stored is one of
- database-wide events and affects included/excluded database
- table related events and the table is included
- events that set a variable and either affects included database or is a system-wide variable
-
-