Class CachingHiveMetastore
java.lang.Object
io.trino.plugin.hive.metastore.cache.CachingHiveMetastore
- All Implemented Interfaces:
HiveMetastore
Hive Metastore Cache
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enum -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCachingHiveMetastore(HiveMetastore delegate, boolean metadataCacheEnabled, boolean statsCacheEnabled, OptionalLong expiresAfterWriteMillis, OptionalLong statsExpiresAfterWriteMillis, OptionalLong refreshMills, Optional<Executor> executor, long maximumSize, CachingHiveMetastore.StatsRecording statsRecording, boolean cacheMissing, boolean partitionCacheEnabled) -
Method Summary
Modifier and TypeMethodDescriptionvoidabortTransaction(long transactionId) voidacquireSharedReadLock(AcidTransactionOwner transactionOwner, String queryId, long transactionId, List<SchemaTableName> fullTables, List<HivePartition> partitions) voidacquireTableWriteLock(AcidTransactionOwner transactionOwner, String queryId, long transactionId, String dbName, String tableName, io.trino.hive.thrift.metastore.DataOperationType operation, boolean isDynamicPartitionWrite) voidaddColumn(String databaseName, String tableName, String columnName, HiveType columnType, String columnComment) voidaddDynamicPartitions(String dbName, String tableName, List<String> partitionNames, long transactionId, long writeId, AcidOperation operation) voidaddPartitions(String databaseName, String tableName, List<PartitionWithStatistics> partitions) longallocateWriteId(String dbName, String tableName, long transactionId) voidalterPartition(String databaseName, String tableName, PartitionWithStatistics partition) voidalterPartitions(String dbName, String tableName, List<Partition> partitions, long writeId) voidalterTransactionalTable(Table table, long transactionId, long writeId, PrincipalPrivileges principalPrivileges) builder()voidvoidvoidcommentTable(String databaseName, String tableName, Optional<String> comment) voidcommitTransaction(long transactionId) voidcreateDatabase(Database database) voidcreateRole(String role, String grantor) voidcreateTable(Table table, PrincipalPrivileges principalPrivileges) voiddropColumn(String databaseName, String tableName, String columnName) voiddropDatabase(String databaseName, boolean deleteData) voiddropPartition(String databaseName, String tableName, List<String> parts, boolean deleteData) voidvoidvoidvoidflushPartitionCache(String schemaName, String tableName, List<String> partitionColumns, List<String> partitionValues) io.airlift.jmx.CacheStatsMBeangetAllTables(String databaseName) io.airlift.jmx.CacheStatsMBeangetAllViews(String databaseName) Lists views and materialized views from given database.getConfigValue(String name) io.airlift.jmx.CacheStatsMBeangetDatabase(String databaseName) io.airlift.jmx.CacheStatsMBeanio.airlift.jmx.CacheStatsMBeanio.airlift.jmx.CacheStatsMBeangetPartition(Table table, List<String> partitionValues) io.airlift.jmx.CacheStatsMBeangetPartitionNamesByFilter(String databaseName, String tableName, List<String> columnNames, TupleDomain<String> partitionKeysFilter) Return a list of partition names, with optional filtering (hint to improve performance if possible).getPartitionsByNames(Table table, List<String> partitionNames) getPartitionStatistics(Table table, List<Partition> partitions) The method will cache and return columns specified in theTable.getDataColumns()but may return more if other columns are already cached for a given partition.io.airlift.jmx.CacheStatsMBeanio.airlift.jmx.CacheStatsMBeanio.airlift.jmx.CacheStatsMBeanio.airlift.jmx.CacheStatsMBeanio.airlift.jmx.CacheStatsMBeanio.airlift.jmx.CacheStatsMBeangetTableStatistics(Table table) The method will cache and return columns specified in theTable.getDataColumns()but may return more if other columns are already cached.io.airlift.jmx.CacheStatsMBeanio.airlift.jmx.CacheStatsMBeangetTablesWithParameter(String databaseName, String parameterKey, String parameterValue) io.airlift.jmx.CacheStatsMBeangetValidWriteIds(List<SchemaTableName> tables, long currentTransactionId) io.airlift.jmx.CacheStatsMBeanvoidgrantRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor) voidgrantTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, HivePrincipal grantor, Set<HivePrivilegeInfo.HivePrivilege> privileges, boolean grantOption) protected voidinvalidateDatabase(String databaseName) voidinvalidateTable(String databaseName, String tableName) listGrantedPrincipals(String role) listRoleGrants(HivePrincipal principal) listTablePrivileges(String databaseName, String tableName, Optional<String> tableOwner, Optional<HivePrincipal> principal) static CachingHiveMetastorememoizeMetastore(HiveMetastore delegate, long maximumSize) longopenTransaction(AcidTransactionOwner transactionOwner) voidrenameColumn(String databaseName, String tableName, String oldColumnName, String newColumnName) voidrenameDatabase(String databaseName, String newDatabaseName) voidrenameTable(String databaseName, String tableName, String newDatabaseName, String newTableName) voidreplaceTable(String databaseName, String tableName, Table newTable, PrincipalPrivileges principalPrivileges) This should only be used if the semantic here is drop and add.voidrevokeRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor) voidrevokeTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, HivePrincipal grantor, Set<HivePrivilegeInfo.HivePrivilege> privileges, boolean grantOption) voidsendTransactionHeartbeat(long transactionId) voidsetDatabaseOwner(String databaseName, HivePrincipal principal) voidsetTableOwner(String databaseName, String tableName, HivePrincipal principal) voidupdatePartitionStatistics(Table table, String partitionName, Function<PartitionStatistics, PartitionStatistics> update) voidupdatePartitionStatistics(Table table, Map<String, Function<PartitionStatistics, PartitionStatistics>> updates) voidupdateTableStatistics(String databaseName, String tableName, AcidTransaction transaction, Function<PartitionStatistics, PartitionStatistics> update) voidupdateTableWriteId(String dbName, String tableName, long transactionId, long writeId, OptionalLong rowCountChange)
-
Field Details
-
delegate
-
-
Constructor Details
-
CachingHiveMetastore
protected CachingHiveMetastore(HiveMetastore delegate, boolean metadataCacheEnabled, boolean statsCacheEnabled, OptionalLong expiresAfterWriteMillis, OptionalLong statsExpiresAfterWriteMillis, OptionalLong refreshMills, Optional<Executor> executor, long maximumSize, CachingHiveMetastore.StatsRecording statsRecording, boolean cacheMissing, boolean partitionCacheEnabled)
-
-
Method Details
-
builder
-
builder
public static CachingHiveMetastore.CachingHiveMetastoreBuilder builder(CachingHiveMetastore.CachingHiveMetastoreBuilder other) -
memoizeMetastore
-
flushCache
public void flushCache() -
flushPartitionCache
-
getDatabase
- Specified by:
getDatabasein interfaceHiveMetastore
-
getAllDatabases
- Specified by:
getAllDatabasesin interfaceHiveMetastore
-
getTable
- Specified by:
getTablein interfaceHiveMetastore
-
getSupportedColumnStatistics
- Specified by:
getSupportedColumnStatisticsin interfaceHiveMetastore
-
getTableStatistics
The method will cache and return columns specified in theTable.getDataColumns()but may return more if other columns are already cached.- Specified by:
getTableStatisticsin interfaceHiveMetastore
-
getPartitionStatistics
public Map<String,PartitionStatistics> getPartitionStatistics(Table table, List<Partition> partitions) The method will cache and return columns specified in theTable.getDataColumns()but may return more if other columns are already cached for a given partition.- Specified by:
getPartitionStatisticsin interfaceHiveMetastore
-
updateTableStatistics
public void updateTableStatistics(String databaseName, String tableName, AcidTransaction transaction, Function<PartitionStatistics, PartitionStatistics> update) - Specified by:
updateTableStatisticsin interfaceHiveMetastore
-
updatePartitionStatistics
public void updatePartitionStatistics(Table table, String partitionName, Function<PartitionStatistics, PartitionStatistics> update) - Specified by:
updatePartitionStatisticsin interfaceHiveMetastore
-
updatePartitionStatistics
public void updatePartitionStatistics(Table table, Map<String, Function<PartitionStatistics, PartitionStatistics>> updates) - Specified by:
updatePartitionStatisticsin interfaceHiveMetastore
-
getAllTables
- Specified by:
getAllTablesin interfaceHiveMetastore
-
getAllTables
- Specified by:
getAllTablesin interfaceHiveMetastore- Returns:
- List of tables, views and materialized views names from all schemas or Optional.empty if operation is not supported
-
getTablesWithParameter
public List<String> getTablesWithParameter(String databaseName, String parameterKey, String parameterValue) - Specified by:
getTablesWithParameterin interfaceHiveMetastore
-
getAllViews
Description copied from interface:HiveMetastoreLists views and materialized views from given database.- Specified by:
getAllViewsin interfaceHiveMetastore
-
getAllViews
- Specified by:
getAllViewsin interfaceHiveMetastore- Returns:
- List of views including materialized views names from all schemas or Optional.empty if operation is not supported
-
createDatabase
- Specified by:
createDatabasein interfaceHiveMetastore
-
dropDatabase
- Specified by:
dropDatabasein interfaceHiveMetastore
-
renameDatabase
- Specified by:
renameDatabasein interfaceHiveMetastore
-
setDatabaseOwner
- Specified by:
setDatabaseOwnerin interfaceHiveMetastore
-
invalidateDatabase
-
createTable
- Specified by:
createTablein interfaceHiveMetastore
-
dropTable
- Specified by:
dropTablein interfaceHiveMetastore
-
replaceTable
public void replaceTable(String databaseName, String tableName, Table newTable, PrincipalPrivileges principalPrivileges) Description copied from interface:HiveMetastoreThis should only be used if the semantic here is drop and add. Trying to alter one field of a table object previously acquired from getTable is probably not what you want.- Specified by:
replaceTablein interfaceHiveMetastore
-
renameTable
public void renameTable(String databaseName, String tableName, String newDatabaseName, String newTableName) - Specified by:
renameTablein interfaceHiveMetastore
-
commentTable
- Specified by:
commentTablein interfaceHiveMetastore
-
setTableOwner
- Specified by:
setTableOwnerin interfaceHiveMetastore
-
commentColumn
public void commentColumn(String databaseName, String tableName, String columnName, Optional<String> comment) - Specified by:
commentColumnin interfaceHiveMetastore
-
addColumn
public void addColumn(String databaseName, String tableName, String columnName, HiveType columnType, String columnComment) - Specified by:
addColumnin interfaceHiveMetastore
-
renameColumn
public void renameColumn(String databaseName, String tableName, String oldColumnName, String newColumnName) - Specified by:
renameColumnin interfaceHiveMetastore
-
dropColumn
- Specified by:
dropColumnin interfaceHiveMetastore
-
invalidateTable
-
getPartition
- Specified by:
getPartitionin interfaceHiveMetastore
-
getPartitionNamesByFilter
public Optional<List<String>> getPartitionNamesByFilter(String databaseName, String tableName, List<String> columnNames, TupleDomain<String> partitionKeysFilter) Description copied from interface:HiveMetastoreReturn a list of partition names, with optional filtering (hint to improve performance if possible).- Specified by:
getPartitionNamesByFilterin interfaceHiveMetastore- Parameters:
databaseName- the name of the databasetableName- the name of the tablecolumnNames- the list of partition column namespartitionKeysFilter- optional filter for the partition column values- Returns:
- a list of partition names as created by
MetastoreUtil.toPartitionName(java.util.List<java.lang.String>, java.util.List<java.lang.String>) - See Also:
-
getPartitionsByNames
public Map<String,Optional<Partition>> getPartitionsByNames(Table table, List<String> partitionNames) - Specified by:
getPartitionsByNamesin interfaceHiveMetastore
-
addPartitions
public void addPartitions(String databaseName, String tableName, List<PartitionWithStatistics> partitions) - Specified by:
addPartitionsin interfaceHiveMetastore
-
dropPartition
public void dropPartition(String databaseName, String tableName, List<String> parts, boolean deleteData) - Specified by:
dropPartitionin interfaceHiveMetastore
-
alterPartition
public void alterPartition(String databaseName, String tableName, PartitionWithStatistics partition) - Specified by:
alterPartitionin interfaceHiveMetastore
-
createRole
- Specified by:
createRolein interfaceHiveMetastore
-
dropRole
- Specified by:
dropRolein interfaceHiveMetastore
-
listRoles
- Specified by:
listRolesin interfaceHiveMetastore
-
grantRoles
public void grantRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor) - Specified by:
grantRolesin interfaceHiveMetastore
-
revokeRoles
public void revokeRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor) - Specified by:
revokeRolesin interfaceHiveMetastore
-
listGrantedPrincipals
- Specified by:
listGrantedPrincipalsin interfaceHiveMetastore
-
listRoleGrants
- Specified by:
listRoleGrantsin interfaceHiveMetastore
-
grantTablePrivileges
public void grantTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, HivePrincipal grantor, Set<HivePrivilegeInfo.HivePrivilege> privileges, boolean grantOption) - Specified by:
grantTablePrivilegesin interfaceHiveMetastore
-
revokeTablePrivileges
public void revokeTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, HivePrincipal grantor, Set<HivePrivilegeInfo.HivePrivilege> privileges, boolean grantOption) - Specified by:
revokeTablePrivilegesin interfaceHiveMetastore
-
listTablePrivileges
public Set<HivePrivilegeInfo> listTablePrivileges(String databaseName, String tableName, Optional<String> tableOwner, Optional<HivePrincipal> principal) - Specified by:
listTablePrivilegesin interfaceHiveMetastoreprincipal- when empty, all table privileges are returned
-
getConfigValue
- Specified by:
getConfigValuein interfaceHiveMetastore
-
checkSupportsTransactions
public void checkSupportsTransactions()- Specified by:
checkSupportsTransactionsin interfaceHiveMetastore
-
openTransaction
- Specified by:
openTransactionin interfaceHiveMetastore
-
commitTransaction
public void commitTransaction(long transactionId) - Specified by:
commitTransactionin interfaceHiveMetastore
-
abortTransaction
public void abortTransaction(long transactionId) - Specified by:
abortTransactionin interfaceHiveMetastore
-
sendTransactionHeartbeat
public void sendTransactionHeartbeat(long transactionId) - Specified by:
sendTransactionHeartbeatin interfaceHiveMetastore
-
getValidWriteIds
- Specified by:
getValidWriteIdsin interfaceHiveMetastore
-
allocateWriteId
- Specified by:
allocateWriteIdin interfaceHiveMetastore
-
acquireTableWriteLock
public void acquireTableWriteLock(AcidTransactionOwner transactionOwner, String queryId, long transactionId, String dbName, String tableName, io.trino.hive.thrift.metastore.DataOperationType operation, boolean isDynamicPartitionWrite) - Specified by:
acquireTableWriteLockin interfaceHiveMetastore
-
updateTableWriteId
public void updateTableWriteId(String dbName, String tableName, long transactionId, long writeId, OptionalLong rowCountChange) - Specified by:
updateTableWriteIdin interfaceHiveMetastore
-
alterPartitions
public void alterPartitions(String dbName, String tableName, List<Partition> partitions, long writeId) - Specified by:
alterPartitionsin interfaceHiveMetastore
-
addDynamicPartitions
public void addDynamicPartitions(String dbName, String tableName, List<String> partitionNames, long transactionId, long writeId, AcidOperation operation) - Specified by:
addDynamicPartitionsin interfaceHiveMetastore
-
alterTransactionalTable
public void alterTransactionalTable(Table table, long transactionId, long writeId, PrincipalPrivileges principalPrivileges) - Specified by:
alterTransactionalTablein interfaceHiveMetastore
-
getDatabaseStats
public io.airlift.jmx.CacheStatsMBean getDatabaseStats() -
getDatabaseNamesStats
public io.airlift.jmx.CacheStatsMBean getDatabaseNamesStats() -
getTableStats
public io.airlift.jmx.CacheStatsMBean getTableStats() -
getTableNamesStats
public io.airlift.jmx.CacheStatsMBean getTableNamesStats() -
getAllTableNamesStats
public io.airlift.jmx.CacheStatsMBean getAllTableNamesStats() -
getTableWithParameterStats
public io.airlift.jmx.CacheStatsMBean getTableWithParameterStats() -
getTableStatisticsStats
public io.airlift.jmx.CacheStatsMBean getTableStatisticsStats() -
getPartitionStatisticsStats
public io.airlift.jmx.CacheStatsMBean getPartitionStatisticsStats() -
getViewNamesStats
public io.airlift.jmx.CacheStatsMBean getViewNamesStats() -
getAllViewNamesStats
public io.airlift.jmx.CacheStatsMBean getAllViewNamesStats() -
getPartitionStats
public io.airlift.jmx.CacheStatsMBean getPartitionStats() -
getPartitionFilterStats
public io.airlift.jmx.CacheStatsMBean getPartitionFilterStats() -
getTablePrivilegesStats
public io.airlift.jmx.CacheStatsMBean getTablePrivilegesStats() -
getRolesStats
public io.airlift.jmx.CacheStatsMBean getRolesStats() -
getRoleGrantsStats
public io.airlift.jmx.CacheStatsMBean getRoleGrantsStats() -
getGrantedPrincipalsStats
public io.airlift.jmx.CacheStatsMBean getGrantedPrincipalsStats() -
getConfigValuesStats
public io.airlift.jmx.CacheStatsMBean getConfigValuesStats()
-