10.4.9. dbselector.js Filter

Filtering only a single database schema can be useful when you want to extract a single schema for external processing, or for sharding information across multiple replication targets. The dbselector filter deletes all statement and row changes, except those for the selected table. To configure, the db parameter to the filter configuration specifies the schema to be replicated.

Pre-configured filter name dbselector
JavaScript Filter File tungsten-replicator/support/filters-javascript/dbselector.js
Property prefix replicator.filter.dbselector
Stage compatibility binlog-to-q, q-to-thl, q-to-dbms
tpm Option compatibility --svc-extractor-filters, --svc-applier-filters
Data compatibility Any event
Parameter Type Default Description
db string (none) Database to be selected

Within the filter, statement changes look for the schema in the StatementData object and remove it from the array:

if (d instanceof com.continuent.tungsten.replicator.dbms.StatementData)

Because entries are being removed from the list of statements, the iterator used to process each item must be explicitly decremented by 1 to reset the counter back to the new position.

Similarly, when looking at row changes in the RowChangeData:

else if(d instanceof com.continuent.tungsten.replicator.dbms.RowChangeData)
    rowChanges = data.get(i).getRowChanges();

        oneRowChange = rowChanges.get(j);