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
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • CACHE_SIZE_CONFIG

      protected static final String CACHE_SIZE_CONFIG
      See Also:
    • DEFAULT_CACHE_SIZE

      protected static final int DEFAULT_CACHE_SIZE
      See Also:
    • tableIdCaseInsensitive

      protected boolean tableIdCaseInsensitive
    • cache

      private io.debezium.util.BoundedConcurrentHashMap<TableId,V> cache
  • Constructor Details

    • AbstractCachedTableMappingStorage

      public AbstractCachedTableMappingStorage()
  • Method Details

    • configure

      public void configure(RelationalDatabaseConnectorConfig config, boolean tableIdCaseInsensitive, TableMappingStorage.Type type)
      Description copied from interface: TableMappingStorage
      Configures this storage instance with connector configuration. This method is called once after instantiation and before any other methods.
      Specified by:
      configure in interface TableMappingStorage<V>
      Parameters:
      config - the connector configuration
      tableIdCaseInsensitive - whether table identifiers should be treated case-insensitively
      type - the type of storage (schemas or tables)
    • get

      public V get(TableId tableId)
      Description copied from interface: TableMappingStorage
      Retrieves the value associated with the given table identifier.
      Specified by:
      get in interface TableMappingStorage<V>
      Parameters:
      tableId - the table identifier
      Returns:
      the associated value, or null if not present
    • put

      public V put(TableId tableId, V value)
      Description copied from interface: TableMappingStorage
      Associates the specified value with the specified table identifier.
      Specified by:
      put in interface TableMappingStorage<V>
      Parameters:
      tableId - the table identifier
      value - the value to be associated
      Returns:
      the previous value associated with the table identifier, or null if there was no mapping
    • remove

      public V remove(TableId tableId)
      Description copied from interface: TableMappingStorage
      Removes the mapping for the specified table identifier.
      Specified by:
      remove in interface TableMappingStorage<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: TableMappingStorage
      Removes all mappings from this storage.
      Specified by:
      clear in interface TableMappingStorage<V>
    • normalizeTableId

      protected TableId normalizeTableId(TableId tableId)
      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 during configure(RelationalDatabaseConnectorConfig, boolean, TableMappingStorage.Type).
      Parameters:
      config - the connector configuration
      type - the type of storage (schemas or tables)
    • getFromStorage

      protected abstract V getFromStorage(TableId tableId)
      Retrieves a value from the underlying storage.
      Parameters:
      tableId - the normalized table identifier
      Returns:
      the value, or null if not found
    • putToStorage

      protected abstract void putToStorage(TableId tableId, V value)
      Stores a value in the underlying storage.
      Parameters:
      tableId - the normalized table identifier
      value - the value to store
    • removeFromStorage

      protected abstract void removeFromStorage(TableId tableId)
      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: TableMappingStorage
      Returns the number of table identifier-value mappings in this storage.
      Specified by:
      size in interface TableMappingStorage<V>
      Returns:
      the number of mappings
    • isEmpty

      public abstract boolean isEmpty()
      Description copied from interface: TableMappingStorage
      Returns true if this storage contains no mappings.
      Specified by:
      isEmpty in interface TableMappingStorage<V>
      Returns:
      true if this storage contains no mappings
    • keySet

      public abstract Set<TableId> keySet()
      Description copied from interface: TableMappingStorage
      Returns a set view of the table identifiers contained in this storage.
      Specified by:
      keySet in interface TableMappingStorage<V>
      Returns:
      a set view of the table identifiers
    • forEach

      public abstract void forEach(BiConsumer<? super TableId,? super V> action)
      Description copied from interface: TableMappingStorage
      Performs the given action for each entry in this storage until all entries have been processed or the action throws an exception.
      Specified by:
      forEach in interface TableMappingStorage<V>
      Parameters:
      action - the action to be performed for each entry