Package io.debezium.data
Class KeyValueStore
- java.lang.Object
-
- io.debezium.data.KeyValueStore
-
public class KeyValueStore extends Object
A test utility for accumulating theSourceRecords that represent change events on rows. This store applies the changes and maintains the current state of the rows.- Author:
- Randall Hauch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeyValueStore.Collection
-
Field Summary
Fields Modifier and Type Field Description private Map<io.debezium.relational.TableId,KeyValueStore.Collection>collectionsByTableIdprivate List<org.apache.kafka.connect.source.SourceRecord>sourceRecordsprivate Function<String,io.debezium.relational.TableId>tableIdFromTopic
-
Constructor Summary
Constructors Modifier Constructor Description protectedKeyValueStore(Function<String,io.debezium.relational.TableId> tableIdFromTopic)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(org.apache.kafka.connect.source.SourceRecord record)KeyValueStore.Collectioncollection(io.debezium.relational.TableId tableId)KeyValueStore.Collectioncollection(String fullyQualifiedName)KeyValueStore.Collectioncollection(String catalog, String tableName)intcollectionCount()Set<io.debezium.relational.TableId>collections()static KeyValueStorecreateForTopicsBeginningWith(String prefix)Create a KeyValueStore that removes from the topic names the supplied prefix to obtain theTableId.static KeyValueStorecreateForTopicsMatching(String regex, int groupNumber)Create a KeyValueStore that uses the supplied regular expression and group number to extract theTableIdfrom the topic name.Set<String>databases()protected static Function<String,io.debezium.relational.TableId>fromRegex(String regex, int groupNumber)KeyValueStore.CollectiongetOrCreate(io.debezium.relational.TableId tableId)protected static org.apache.kafka.connect.data.StructkeyFor(org.apache.kafka.connect.source.SourceRecord record)protected static Function<String,io.debezium.relational.TableId>prefixedWith(String prefix)protected static org.apache.kafka.connect.data.StructsourceFor(org.apache.kafka.connect.source.SourceRecord record)List<org.apache.kafka.connect.source.SourceRecord>sourceRecords()protected static org.apache.kafka.connect.data.StructvalueFor(org.apache.kafka.connect.source.SourceRecord record)
-
-
-
Field Detail
-
sourceRecords
private final List<org.apache.kafka.connect.source.SourceRecord> sourceRecords
-
collectionsByTableId
private final Map<io.debezium.relational.TableId,KeyValueStore.Collection> collectionsByTableId
-
-
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 theTableIdfrom the topic name.- Parameters:
regex- the regular expression that identifies the table ID within the topic name; may not be nullgroupNumber- 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 theTableId.- 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()
-
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)
-
-