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_MSfor 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 longexpirationIntervalMillisprotected com.github.benmanes.caffeine.cache.Cache<TableIdentifier,Table>tableCache 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedCachingCatalog(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.TableBuilderbuildTable(TableIdentifier identifier, Schema schema)/** Instantiate a builder to either create a table or start a create/replace transaction.booleandropTable(TableIdentifier ident, boolean purge)Drop a table; optionally delete data and metadata files.voidinvalidateTable(TableIdentifier ident)Invalidate cached table metadata from current catalog.java.util.List<TableIdentifier>listTables(Namespace namespace)Return all the identifiers under this namespace.TableloadTable(TableIdentifier ident)Load a table.java.lang.Stringname()Return the name for this catalog.TableregisterTable(TableIdentifier identifier, java.lang.String metadataFileLocation)Register a table with the catalog if it does not exist.voidrenameTable(TableIdentifier from, TableIdentifier to)Rename a table.static Catalogwrap(Catalog catalog)static Catalogwrap(Catalog catalog, boolean caseSensitive, long expirationIntervalMillis)static Catalogwrap(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, 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:CatalogReturn the name for this catalog. 
- 
listTables
public java.util.List<TableIdentifier> listTables(Namespace namespace)
Description copied from interface:CatalogReturn all the identifiers under this namespace.- Specified by:
 listTablesin interfaceCatalog- Parameters:
 namespace- a namespace- Returns:
 - a list of identifiers for tables
 
 
- 
loadTable
public Table loadTable(TableIdentifier ident)
Description copied from interface:CatalogLoad a table. 
- 
dropTable
public boolean dropTable(TableIdentifier ident, boolean purge)
Description copied from interface:CatalogDrop 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:CatalogRename a table.- Specified by:
 renameTablein interfaceCatalog- Parameters:
 from- identifier of the table to renameto- new table name
 
- 
invalidateTable
public void invalidateTable(TableIdentifier ident)
Description copied from interface:CatalogInvalidate 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:
 invalidateTablein interfaceCatalog- Parameters:
 ident- a table identifier
 
- 
registerTable
public Table registerTable(TableIdentifier identifier, java.lang.String metadataFileLocation)
Description copied from interface:CatalogRegister a table with the catalog if it does not exist.- Specified by:
 registerTablein interfaceCatalog- Parameters:
 identifier- a table identifiermetadataFileLocation- 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:
 buildTablein interfaceCatalog- Parameters:
 identifier- a table identifierschema- a schema- Returns:
 - the builder to create a table or start a create/replace transaction
 
 
 - 
 
 -