public class CachingCatalog extends DelegateCatalog
Catalog
to cache databases and tables and manifests.Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException, Catalog.DatabaseAlreadyExistException, Catalog.DatabaseNotEmptyException, Catalog.DatabaseNotExistException, Catalog.Loader, Catalog.PartitionNotExistException, Catalog.ProcessSystemDatabaseException, Catalog.TableAlreadyExistException, Catalog.TableNotExistException, Catalog.ViewAlreadyExistException, Catalog.ViewNotExistException
Modifier and Type | Field and Description |
---|---|
protected org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache<String,Database> |
databaseCache |
protected SegmentsCache<Path> |
manifestCache |
protected org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache<Identifier,List<PartitionEntry>> |
partitionCache |
protected org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache<Identifier,Table> |
tableCache |
wrapped
COMMENT_PROP, DB_LOCATION_PROP, DB_SUFFIX, DEFAULT_DATABASE, HIVE_LAST_UPDATE_TIME_PROP, LAST_UPDATE_TIME_PROP, NUM_FILES_PROP, NUM_ROWS_PROP, OWNER_PROP, SYSTEM_BRANCH_PREFIX, SYSTEM_DATABASE_NAME, SYSTEM_TABLE_SPLITTER, TABLE_DEFAULT_OPTION_PREFIX, TOTAL_SIZE_PROP
Constructor and Description |
---|
CachingCatalog(Catalog wrapped) |
CachingCatalog(Catalog wrapped,
java.time.Duration expirationInterval,
MemorySize manifestMaxMemory,
long manifestCacheThreshold,
long cachedPartitionMaxNum,
int snapshotMaxNumPerTable) |
CachingCatalog(Catalog wrapped,
java.time.Duration expirationInterval,
MemorySize manifestMaxMemory,
long manifestCacheThreshold,
long cachedPartitionMaxNum,
int snapshotMaxNumPerTable,
org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Ticker ticker) |
Modifier and Type | Method and Description |
---|---|
void |
alterTable(Identifier identifier,
List<SchemaChange> changes,
boolean ignoreIfNotExists)
Modify an existing table from
SchemaChange s. |
void |
dropDatabase(String name,
boolean ignoreIfNotExists,
boolean cascade)
Drop a database.
|
void |
dropPartition(Identifier identifier,
Map<String,String> partitions)
Drop the partition of the specify table.
|
void |
dropTable(Identifier identifier,
boolean ignoreIfNotExists)
Drop a table.
|
Database |
getDatabase(String databaseName)
Return a
Database identified by the given name. |
Table |
getTable(Identifier identifier)
Return a
Table identified by the given Identifier . |
void |
invalidateTable(Identifier identifier)
Invalidate cached table metadata for an
identifier . |
List<PartitionEntry> |
listPartitions(Identifier identifier)
Get PartitionEntry of all partitions of the table.
|
void |
refreshPartitions(Identifier identifier) |
void |
renameTable(Identifier fromTable,
Identifier toTable,
boolean ignoreIfNotExists)
Rename a table.
|
static Catalog |
tryToCreate(Catalog catalog,
Options options) |
allowUpperCase, close, createDatabase, createPartition, createTable, createView, dropView, fileIO, getTableLocation, getView, listDatabases, listTables, listViews, options, renameView, repairCatalog, repairDatabase, repairTable, warehouse, wrapped
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
alterTable, createDatabase, tableDefaultOptions, validateCaseInsensitive, validateCaseInsensitive
protected final org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache<String,Database> databaseCache
protected final org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache<Identifier,Table> tableCache
@Nullable protected final SegmentsCache<Path> manifestCache
@Nullable protected final org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Cache<Identifier,List<PartitionEntry>> partitionCache
public CachingCatalog(Catalog wrapped)
public CachingCatalog(Catalog wrapped, java.time.Duration expirationInterval, MemorySize manifestMaxMemory, long manifestCacheThreshold, long cachedPartitionMaxNum, int snapshotMaxNumPerTable)
public CachingCatalog(Catalog wrapped, java.time.Duration expirationInterval, MemorySize manifestMaxMemory, long manifestCacheThreshold, long cachedPartitionMaxNum, int snapshotMaxNumPerTable, org.apache.paimon.shade.caffeine2.com.github.benmanes.caffeine.cache.Ticker ticker)
public Database getDatabase(String databaseName) throws Catalog.DatabaseNotExistException
Catalog
Database
identified by the given name.getDatabase
in interface Catalog
getDatabase
in class DelegateCatalog
databaseName
- Database nameDatabase
Catalog.DatabaseNotExistException
- if the requested database does not existpublic void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade) throws Catalog.DatabaseNotExistException, Catalog.DatabaseNotEmptyException
Catalog
dropDatabase
in interface Catalog
dropDatabase
in class DelegateCatalog
name
- Name of the database to be dropped.ignoreIfNotExists
- Flag to specify behavior when the database does not exist: if set to
false, throw an exception, if set to true, do nothing.cascade
- Flag to specify behavior when the database contains table or function: if set
to true, delete all tables and functions in the database and then delete the database, if
set to false, throw an exception.Catalog.DatabaseNotEmptyException
- if the given database is not empty and isRestrict is trueCatalog.DatabaseNotExistException
public void dropTable(Identifier identifier, boolean ignoreIfNotExists) throws Catalog.TableNotExistException
Catalog
NOTE: System tables can not be dropped.
dropTable
in interface Catalog
dropTable
in class DelegateCatalog
identifier
- Path of the table to be droppedignoreIfNotExists
- Flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException
- if the table does not existpublic void renameTable(Identifier fromTable, Identifier toTable, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.TableAlreadyExistException
Catalog
NOTE: If you use object storage, such as S3 or OSS, please use this syntax carefully, because the renaming of object storage is not atomic, and only partial files may be moved in case of failure.
NOTE: System tables can not be renamed.
renameTable
in interface Catalog
renameTable
in class DelegateCatalog
fromTable
- the name of the table which need to renametoTable
- the new tableignoreIfNotExists
- Flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException
- if the fromTable does not existCatalog.TableAlreadyExistException
- if the toTable already existspublic void alterTable(Identifier identifier, List<SchemaChange> changes, boolean ignoreIfNotExists) throws Catalog.TableNotExistException, Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException
Catalog
SchemaChange
s.
NOTE: System tables can not be altered.
alterTable
in interface Catalog
alterTable
in class DelegateCatalog
identifier
- path of the table to be modifiedchanges
- the schema changesignoreIfNotExists
- flag to specify behavior when the table does not exist: if set to
false, throw an exception, if set to true, do nothing.Catalog.TableNotExistException
- if the table does not existCatalog.ColumnAlreadyExistException
Catalog.ColumnNotExistException
public Table getTable(Identifier identifier) throws Catalog.TableNotExistException
Catalog
getTable
in interface Catalog
getTable
in class DelegateCatalog
identifier
- Path of the tableCatalog.TableNotExistException
- if the target does not existpublic List<PartitionEntry> listPartitions(Identifier identifier) throws Catalog.TableNotExistException
Catalog
listPartitions
in interface Catalog
listPartitions
in class DelegateCatalog
identifier
- path of the table to list partitionsCatalog.TableNotExistException
- if the table does not existpublic void dropPartition(Identifier identifier, Map<String,String> partitions) throws Catalog.TableNotExistException, Catalog.PartitionNotExistException
Catalog
dropPartition
in interface Catalog
dropPartition
in class DelegateCatalog
identifier
- path of the table to drop partitionpartitions
- the partition to be deletedCatalog.TableNotExistException
- if the table does not existCatalog.PartitionNotExistException
- if the partition does not existpublic void invalidateTable(Identifier identifier)
Catalog
identifier
.
If the table is already loaded or cached, drop cached data. If the table does not exist or is not cached, do nothing. Calling this method should not query remote services.
identifier
- a table identifierpublic void refreshPartitions(Identifier identifier) throws Catalog.TableNotExistException
Catalog.TableNotExistException
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.