Skip to main content
Common Reference

shardbytable.js Filter

An alternative to shardbyseqno sharding by sequence number is to create a shard ID based on the individual database and table. The shardbytable filter achieves this at a row level by combining the schema and table information to form the shard ID. For all other events, including statement based events, the shard ID #UNKNOWN is used.

Pre-configured filter nameshardbytable
JavaScript Filter Filetungsten-replicator/support/filters-javascript/shardbytable.js
Property prefixreplicator.filter.shardbytable
Stage compatibilityremote-to-thl
tpm Option compatibilitysvc-remote-filters
Data compatibilityRow Events Only
note

For this filter to function, you will need to ensure your database is configured for ROW based binary logging

The key part of the filter is the extraction and construction of the ID, which occurs during row processing:

oneRowChange = rowChanges.get(j);
schemaName = oneRowChange.getSchemaName();
tableName = oneRowChange.getTableName();

id = schemaName + "_" + tableName;
if (proposedShardId == null)
{
proposedShardId = id;
}