Class KeyValueStore

java.lang.Object
io.debezium.data.KeyValueStore

public class KeyValueStore extends Object
A test utility for accumulating the SourceRecords that represent change events on rows. This store applies the changes and maintains the current state of the rows.
Author:
Randall Hauch
  • Field Details

    • sourceRecords

      private final List<org.apache.kafka.connect.source.SourceRecord> sourceRecords
    • collectionsByTableId

      private final Map<io.debezium.relational.TableId,KeyValueStore.Collection> collectionsByTableId
    • tableIdFromTopic

      private final Function<String,io.debezium.relational.TableId> tableIdFromTopic
  • Constructor Details

    • KeyValueStore

      protected KeyValueStore(Function<String,io.debezium.relational.TableId> tableIdFromTopic)
  • Method Details

    • prefixedWith

      protected static Function<String,io.debezium.relational.TableId> prefixedWith(String prefix)
    • fromRegex

      protected static Function<String,io.debezium.relational.TableId> fromRegex(String regex, int groupNumber)
    • createForTopicsMatching

      public static KeyValueStore createForTopicsMatching(String regex, int groupNumber)
      Create a KeyValueStore that uses the supplied regular expression and group number to extract the TableId from the topic name.
      Parameters:
      regex - the regular expression that identifies the table ID within the topic name; may not be null
      groupNumber - the group number in the regex for the table ID string
      Returns:
      the key value store
    • createForTopicsBeginningWith

      public static KeyValueStore createForTopicsBeginningWith(String prefix)
      Create a KeyValueStore that removes from the topic names the supplied prefix to obtain the TableId.
      Parameters:
      prefix - the prefix after which all of the topic name forms the table ID; may not be null
      Returns:
      the key value store
    • add

      public void add(org.apache.kafka.connect.source.SourceRecord record)
    • sourceRecords

      public List<org.apache.kafka.connect.source.SourceRecord> sourceRecords()
    • collection

      public KeyValueStore.Collection collection(String fullyQualifiedName)
    • collection

      public KeyValueStore.Collection collection(String catalog, String tableName)
    • collection

      public KeyValueStore.Collection collection(io.debezium.relational.TableId tableId)
    • collections

      public Set<io.debezium.relational.TableId> collections()
    • databases

      public Set<String> databases()
    • collectionCount

      public int collectionCount()
    • getOrCreate

      public KeyValueStore.Collection getOrCreate(io.debezium.relational.TableId tableId)
    • keyFor

      protected static org.apache.kafka.connect.data.Struct keyFor(org.apache.kafka.connect.source.SourceRecord record)
    • valueFor

      protected static org.apache.kafka.connect.data.Struct valueFor(org.apache.kafka.connect.source.SourceRecord record)
    • sourceFor

      protected static org.apache.kafka.connect.data.Struct sourceFor(org.apache.kafka.connect.source.SourceRecord record)