Package io.debezium.relational
Class AbstractCachedTableMappingStorage<V>
java.lang.Object
io.debezium.relational.AbstractCachedTableMappingStorage<V>
- Type Parameters:
V- the type of values stored (must be Serializable)
- All Implemented Interfaces:
TableMappingStorage<V>,AutoCloseable
public abstract class AbstractCachedTableMappingStorage<V>
extends Object
implements TableMappingStorage<V>
Abstract base class for
TableMappingStorage implementations that provides caching functionality.
Subclasses need only implement the actual storage operations.- Author:
- Debezium Authors
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.debezium.relational.TableMappingStorage
TableMappingStorage.Type -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final intprivate static final org.slf4j.Loggerprotected booleanFields inherited from interface io.debezium.relational.TableMappingStorage
STORAGE_PREFIX, STORAGE_PREFIX_SCHEMAS, STORAGE_PREFIX_TABLES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all mappings from this storage.protected abstract voidClears all entries from the underlying storage.voidconfigure(RelationalDatabaseConnectorConfig config, boolean tableIdCaseInsensitive, TableMappingStorage.Type type) Configures this storage instance with connector configuration.protected abstract voidConfigures the underlying storage implementation.abstract voidforEach(BiConsumer<? super TableId, ? super V> action) Performs the given action for each entry in this storage until all entries have been processed or the action throws an exception.Retrieves the value associated with the given table identifier.protected abstract VgetFromStorage(TableId tableId) Retrieves a value from the underlying storage.abstract booleanisEmpty()Returns true if this storage contains no mappings.keySet()Returns a set view of the table identifiers contained in this storage.protected TableIdnormalizeTableId(TableId tableId) Normalizes the table identifier based on case sensitivity settings.Associates the specified value with the specified table identifier.protected abstract voidputToStorage(TableId tableId, V value) Stores a value in the underlying storage.Removes the mapping for the specified table identifier.protected abstract voidremoveFromStorage(TableId tableId) Removes a value from the underlying storage.abstract intsize()Returns the number of table identifier-value mappings in this storage.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.debezium.relational.TableMappingStorage
close
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
CACHE_SIZE_CONFIG
- See Also:
-
DEFAULT_CACHE_SIZE
protected static final int DEFAULT_CACHE_SIZE- See Also:
-
tableIdCaseInsensitive
protected boolean tableIdCaseInsensitive -
cache
-
-
Constructor Details
-
AbstractCachedTableMappingStorage
public AbstractCachedTableMappingStorage()
-
-
Method Details
-
configure
public void configure(RelationalDatabaseConnectorConfig config, boolean tableIdCaseInsensitive, TableMappingStorage.Type type) Description copied from interface:TableMappingStorageConfigures this storage instance with connector configuration. This method is called once after instantiation and before any other methods.- Specified by:
configurein interfaceTableMappingStorage<V>- Parameters:
config- the connector configurationtableIdCaseInsensitive- whether table identifiers should be treated case-insensitivelytype- the type of storage (schemas or tables)
-
get
Description copied from interface:TableMappingStorageRetrieves the value associated with the given table identifier.- Specified by:
getin interfaceTableMappingStorage<V>- Parameters:
tableId- the table identifier- Returns:
- the associated value, or null if not present
-
put
Description copied from interface:TableMappingStorageAssociates the specified value with the specified table identifier.- Specified by:
putin interfaceTableMappingStorage<V>- Parameters:
tableId- the table identifiervalue- the value to be associated- Returns:
- the previous value associated with the table identifier, or null if there was no mapping
-
remove
Description copied from interface:TableMappingStorageRemoves the mapping for the specified table identifier.- Specified by:
removein interfaceTableMappingStorage<V>- Parameters:
tableId- the table identifier- Returns:
- the previous value associated with the table identifier, or null if there was no mapping
-
clear
public void clear()Description copied from interface:TableMappingStorageRemoves all mappings from this storage.- Specified by:
clearin interfaceTableMappingStorage<V>
-
normalizeTableId
Normalizes the table identifier based on case sensitivity settings. -
configureStorage
protected abstract void configureStorage(RelationalDatabaseConnectorConfig config, TableMappingStorage.Type type) Configures the underlying storage implementation. Called duringconfigure(RelationalDatabaseConnectorConfig, boolean, TableMappingStorage.Type).- Parameters:
config- the connector configurationtype- the type of storage (schemas or tables)
-
getFromStorage
Retrieves a value from the underlying storage.- Parameters:
tableId- the normalized table identifier- Returns:
- the value, or null if not found
-
putToStorage
Stores a value in the underlying storage.- Parameters:
tableId- the normalized table identifiervalue- the value to store
-
removeFromStorage
Removes a value from the underlying storage.- Parameters:
tableId- the normalized table identifier
-
clearStorage
protected abstract void clearStorage()Clears all entries from the underlying storage. -
size
public abstract int size()Description copied from interface:TableMappingStorageReturns the number of table identifier-value mappings in this storage.- Specified by:
sizein interfaceTableMappingStorage<V>- Returns:
- the number of mappings
-
isEmpty
public abstract boolean isEmpty()Description copied from interface:TableMappingStorageReturns true if this storage contains no mappings.- Specified by:
isEmptyin interfaceTableMappingStorage<V>- Returns:
- true if this storage contains no mappings
-
keySet
Description copied from interface:TableMappingStorageReturns a set view of the table identifiers contained in this storage.- Specified by:
keySetin interfaceTableMappingStorage<V>- Returns:
- a set view of the table identifiers
-
forEach
Description copied from interface:TableMappingStoragePerforms the given action for each entry in this storage until all entries have been processed or the action throws an exception.- Specified by:
forEachin interfaceTableMappingStorage<V>- Parameters:
action- the action to be performed for each entry
-