Package org.apache.iceberg
Class CachingCatalog
- java.lang.Object
-
- org.apache.iceberg.CachingCatalog
-
- All Implemented Interfaces:
Catalog
public class CachingCatalog extends java.lang.Object implements Catalog
Class that wraps an Iceberg Catalog to cache tables.See
CatalogProperties.CACHE_EXPIRATION_INTERVAL_MS
for more details regarding special values forexpirationIntervalMillis
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.iceberg.catalog.Catalog
Catalog.TableBuilder
-
-
Field Summary
Fields Modifier and Type Field Description protected long
expirationIntervalMillis
protected com.github.benmanes.caffeine.cache.Cache<TableIdentifier,Table>
tableCache
-
Constructor Summary
Constructors Modifier Constructor Description protected
CachingCatalog(Catalog catalog, boolean caseSensitive, long expirationIntervalMillis, com.github.benmanes.caffeine.cache.Ticker ticker)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Catalog.TableBuilder
buildTable(TableIdentifier identifier, Schema schema)
/** Instantiate a builder to either create a table or start a create/replace transaction.boolean
dropTable(TableIdentifier ident, boolean purge)
Drop a table; optionally delete data and metadata files.void
invalidateTable(TableIdentifier ident)
Invalidate cached table metadata from current catalog.java.util.List<TableIdentifier>
listTables(Namespace namespace)
Return all the identifiers under this namespace.Table
loadTable(TableIdentifier ident)
Load a table.java.lang.String
name()
Return the name for this catalog.void
renameTable(TableIdentifier from, TableIdentifier to)
Rename a table.static Catalog
wrap(Catalog catalog)
static Catalog
wrap(Catalog catalog, boolean caseSensitive, long expirationIntervalMillis)
static Catalog
wrap(Catalog catalog, long expirationIntervalMillis)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.iceberg.catalog.Catalog
createTable, createTable, createTable, createTable, dropTable, initialize, newCreateTableTransaction, newCreateTableTransaction, newCreateTableTransaction, newCreateTableTransaction, newReplaceTableTransaction, newReplaceTableTransaction, newReplaceTableTransaction, newReplaceTableTransaction, registerTable, tableExists
-
-
-
-
Field Detail
-
expirationIntervalMillis
protected final long expirationIntervalMillis
-
tableCache
protected final com.github.benmanes.caffeine.cache.Cache<TableIdentifier,Table> tableCache
-
-
Constructor Detail
-
CachingCatalog
protected CachingCatalog(Catalog catalog, boolean caseSensitive, long expirationIntervalMillis, com.github.benmanes.caffeine.cache.Ticker ticker)
-
-
Method Detail
-
wrap
public static Catalog wrap(Catalog catalog, boolean caseSensitive, long expirationIntervalMillis)
-
name
public java.lang.String name()
Description copied from interface:Catalog
Return the name for this catalog.
-
listTables
public java.util.List<TableIdentifier> listTables(Namespace namespace)
Description copied from interface:Catalog
Return all the identifiers under this namespace.- Specified by:
listTables
in interfaceCatalog
- 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.
-
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.
-
renameTable
public void renameTable(TableIdentifier from, TableIdentifier to)
Description copied from interface:Catalog
Rename a table.- Specified by:
renameTable
in interfaceCatalog
- Parameters:
from
- identifier of the table to renameto
- 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 interfaceCatalog
- Parameters:
ident
- a table identifier
-
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 interfaceCatalog
- Parameters:
identifier
- a table identifierschema
- a schema- Returns:
- the builder to create a table or start a create/replace transaction
-
-