Class 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 Detail

      • sourceRecords

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

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

      • KeyValueStore

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

      • 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()
      • collections

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

        public int collectionCount()
      • 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)