Class CachingCatalog

java.lang.Object
org.apache.iceberg.CachingCatalog
All Implemented Interfaces:
Catalog

public class CachingCatalog extends Object implements Catalog
Class that wraps an Iceberg Catalog to cache tables.

See CatalogProperties.CACHE_EXPIRATION_INTERVAL_MS for more details regarding special values for expirationIntervalMillis.

  • Field Details

    • expirationIntervalMillis

      protected final long expirationIntervalMillis
    • tableCache

      protected final com.github.benmanes.caffeine.cache.Cache<TableIdentifier,Table> tableCache
  • Constructor Details

    • CachingCatalog

      protected CachingCatalog(Catalog catalog, boolean caseSensitive, long expirationIntervalMillis, com.github.benmanes.caffeine.cache.Ticker ticker)
  • Method Details

    • wrap

      public static Catalog wrap(Catalog catalog)
    • wrap

      public static Catalog wrap(Catalog catalog, long expirationIntervalMillis)
    • wrap

      public static Catalog wrap(Catalog catalog, boolean caseSensitive, long expirationIntervalMillis)
    • name

      public String name()
      Description copied from interface: Catalog
      Return the name for this catalog.
      Specified by:
      name in interface Catalog
      Returns:
      this catalog's name
    • listTables

      public List<TableIdentifier> listTables(Namespace namespace)
      Description copied from interface: Catalog
      Return all the identifiers under this namespace.
      Specified by:
      listTables in interface Catalog
      Parameters:
      namespace - a namespace
      Returns:
      a list of identifiers for tables
    • loadTable

      public Table loadTable(TableIdentifier ident)
      Description copied from interface: Catalog
      Load a table.
      Specified by:
      loadTable in interface Catalog
      Parameters:
      ident - a table identifier
      Returns:
      instance of Table implementation referred by tableIdentifier
    • dropTable

      public boolean dropTable(TableIdentifier ident, boolean purge)
      Description copied from interface: Catalog
      Drop a table; optionally delete data and metadata files.

      If purge is set to true the implementation should delete all data and metadata files.

      Specified by:
      dropTable in interface Catalog
      Parameters:
      ident - a table identifier
      purge - if true, delete all data and metadata files in the table
      Returns:
      true if the table was dropped, false if the table did not exist
    • renameTable

      public void renameTable(TableIdentifier from, TableIdentifier to)
      Description copied from interface: Catalog
      Rename a table.
      Specified by:
      renameTable in interface Catalog
      Parameters:
      from - identifier of the table to rename
      to - new table name
    • invalidateTable

      public void invalidateTable(TableIdentifier ident)
      Description copied from interface: Catalog
      Invalidate cached table metadata from current catalog.

      If the table is already loaded or cached, drop cached data. If the table does not exist or is not cached, do nothing.

      Specified by:
      invalidateTable in interface Catalog
      Parameters:
      ident - a table identifier
    • registerTable

      public Table registerTable(TableIdentifier identifier, String metadataFileLocation)
      Description copied from interface: Catalog
      Register a table with the catalog if it does not exist.
      Specified by:
      registerTable in interface Catalog
      Parameters:
      identifier - a table identifier
      metadataFileLocation - the location of a metadata file
      Returns:
      a Table instance
    • buildTable

      public Catalog.TableBuilder buildTable(TableIdentifier identifier, Schema schema)
      Description copied from interface: Catalog
      /** Instantiate a builder to either create a table or start a create/replace transaction.
      Specified by:
      buildTable in interface Catalog
      Parameters:
      identifier - a table identifier
      schema - a schema
      Returns:
      the builder to create a table or start a create/replace transaction