Class CachingHiveMetastore
- java.lang.Object
-
- io.trino.plugin.hive.metastore.cache.CachingHiveMetastore
-
- All Implemented Interfaces:
HiveMetastore
@ThreadSafe public class CachingHiveMetastore extends Object implements HiveMetastore
Hive Metastore Cache
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCachingHiveMetastore.StatsRecording
-
Field Summary
Fields Modifier and Type Field Description protected HiveMetastoredelegate
-
Constructor Summary
Constructors Modifier Constructor Description protectedCachingHiveMetastore(HiveMetastore delegate, Executor executor, OptionalLong expiresAfterWriteMillis, OptionalLong refreshMills, long maximumSize, CachingHiveMetastore.StatsRecording statsRecording)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireSharedReadLock(HiveIdentity identity, String queryId, long transactionId, List<SchemaTableName> fullTables, List<HivePartition> partitions)voidacquireTableWriteLock(HiveIdentity identity, String queryId, long transactionId, String dbName, String tableName, org.apache.hadoop.hive.metastore.api.DataOperationType operation, boolean isDynamicPartitionWrite)voidaddColumn(HiveIdentity identity, String databaseName, String tableName, String columnName, HiveType columnType, String columnComment)voidaddDynamicPartitions(HiveIdentity identity, String dbName, String tableName, List<String> partitionNames, long transactionId, long writeId, AcidOperation operation)voidaddPartitions(HiveIdentity identity, String databaseName, String tableName, List<PartitionWithStatistics> partitions)longallocateWriteId(HiveIdentity identity, String dbName, String tableName, long transactionId)voidalterPartition(HiveIdentity identity, String databaseName, String tableName, PartitionWithStatistics partition)voidalterPartitions(HiveIdentity identity, String dbName, String tableName, List<Partition> partitions, long writeId)voidalterTransactionalTable(HiveIdentity identity, Table table, long transactionId, long writeId, PrincipalPrivileges principalPrivileges)static HiveMetastorecachingHiveMetastore(HiveMetastore delegate, Executor executor, io.airlift.units.Duration cacheTtl, Optional<io.airlift.units.Duration> refreshInterval, long maximumSize)static HiveMetastorecachingHiveMetastore(HiveMetastore delegate, Executor executor, CachingHiveMetastoreConfig config)voidcommentColumn(HiveIdentity identity, String databaseName, String tableName, String columnName, Optional<String> comment)voidcommentTable(HiveIdentity identity, String databaseName, String tableName, Optional<String> comment)voidcommitTransaction(HiveIdentity identity, long transactionId)voidcreateDatabase(HiveIdentity identity, Database database)voidcreateRole(String role, String grantor)voidcreateTable(HiveIdentity identity, Table table, PrincipalPrivileges principalPrivileges)voiddropColumn(HiveIdentity identity, String databaseName, String tableName, String columnName)voiddropDatabase(HiveIdentity identity, String databaseName)voiddropPartition(HiveIdentity identity, String databaseName, String tableName, List<String> parts, boolean deleteData)voiddropRole(String role)voiddropTable(HiveIdentity identity, String databaseName, String tableName, boolean deleteData)voidflushCache()List<String>getAllDatabases()List<String>getAllTables(String databaseName)List<String>getAllViews(String databaseName)Optional<String>getConfigValue(String name)io.airlift.jmx.CacheStatsMBeangetConfigValuesStats()Optional<Database>getDatabase(String databaseName)io.airlift.jmx.CacheStatsMBeangetDatabaseNamesStats()io.airlift.jmx.CacheStatsMBeangetDatabaseStats()io.airlift.jmx.CacheStatsMBeangetGrantedPrincipalsStats()Optional<Partition>getPartition(HiveIdentity identity, Table table, List<String> partitionValues)io.airlift.jmx.CacheStatsMBeangetPartitionFilterStats()Optional<List<String>>getPartitionNamesByFilter(HiveIdentity identity, 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).Map<String,Optional<Partition>>getPartitionsByNames(HiveIdentity identity, Table table, List<String> partitionNames)Map<String,PartitionStatistics>getPartitionStatistics(HiveIdentity identity, Table table, List<Partition> partitions)io.airlift.jmx.CacheStatsMBeangetPartitionStatisticsStats()io.airlift.jmx.CacheStatsMBeangetPartitionStats()io.airlift.jmx.CacheStatsMBeangetRoleGrantsStats()io.airlift.jmx.CacheStatsMBeangetRolesStats()Set<ColumnStatisticType>getSupportedColumnStatistics(Type type)Optional<Table>getTable(HiveIdentity identity, String databaseName, String tableName)io.airlift.jmx.CacheStatsMBeangetTableNamesStats()io.airlift.jmx.CacheStatsMBeangetTablePrivilegesStats()PartitionStatisticsgetTableStatistics(HiveIdentity identity, Table table)io.airlift.jmx.CacheStatsMBeangetTableStatisticsStats()io.airlift.jmx.CacheStatsMBeangetTableStats()List<String>getTablesWithParameter(String databaseName, String parameterKey, String parameterValue)io.airlift.jmx.CacheStatsMBeangetTableWithParameterStats()StringgetValidWriteIds(HiveIdentity identity, List<SchemaTableName> tables, long currentTransactionId)io.airlift.jmx.CacheStatsMBeangetViewNamesStats()voidgrantRoles(Set<String> roles, Set<HivePrincipal> grantees, boolean adminOption, HivePrincipal grantor)voidgrantTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, Set<HivePrivilegeInfo> privileges)protected voidinvalidateDatabase(String databaseName)protected voidinvalidateTable(String databaseName, String tableName)booleanisImpersonationEnabled()Set<RoleGrant>listGrantedPrincipals(String role)Set<RoleGrant>listRoleGrants(HivePrincipal principal)Set<String>listRoles()Set<HivePrivilegeInfo>listTablePrivileges(String databaseName, String tableName, String tableOwner, Optional<HivePrincipal> principal)static CachingHiveMetastorememoizeMetastore(HiveMetastore delegate, long maximumSize)longopenTransaction(HiveIdentity identity)voidrenameColumn(HiveIdentity identity, String databaseName, String tableName, String oldColumnName, String newColumnName)voidrenameDatabase(HiveIdentity identity, String databaseName, String newDatabaseName)voidrenameTable(HiveIdentity identity, String databaseName, String tableName, String newDatabaseName, String newTableName)voidreplaceTable(HiveIdentity identity, 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, Set<HivePrivilegeInfo> privileges)voidsendTransactionHeartbeat(HiveIdentity identity, long transactionId)voidsetDatabaseOwner(HiveIdentity identity, String databaseName, HivePrincipal principal)voidsetTableOwner(HiveIdentity identity, String databaseName, String tableName, HivePrincipal principal)voidupdatePartitionStatistics(HiveIdentity identity, Table table, String partitionName, Function<PartitionStatistics,PartitionStatistics> update)voidupdateTableStatistics(HiveIdentity identity, String databaseName, String tableName, AcidTransaction transaction, Function<PartitionStatistics,PartitionStatistics> update)voidupdateTableWriteId(HiveIdentity identity, String dbName, String tableName, long transactionId, long writeId, OptionalLong rowCountChange)
-
-
-
Field Detail
-
delegate
protected final HiveMetastore delegate
-
-
Constructor Detail
-
CachingHiveMetastore
protected CachingHiveMetastore(HiveMetastore delegate, Executor executor, OptionalLong expiresAfterWriteMillis, OptionalLong refreshMills, long maximumSize, CachingHiveMetastore.StatsRecording statsRecording)
-
-
Method Detail
-
cachingHiveMetastore
public static HiveMetastore cachingHiveMetastore(HiveMetastore delegate, Executor executor, CachingHiveMetastoreConfig config)
-
cachingHiveMetastore
public static HiveMetastore cachingHiveMetastore(HiveMetastore delegate, Executor executor, io.airlift.units.Duration cacheTtl, Optional<io.airlift.units.Duration> refreshInterval, long maximumSize)
-
memoizeMetastore
public static CachingHiveMetastore memoizeMetastore(HiveMetastore delegate, long maximumSize)
-
flushCache
public void flushCache()
-
getDatabase
public Optional<Database> getDatabase(String databaseName)
- Specified by:
getDatabasein interfaceHiveMetastore
-
getAllDatabases
public List<String> getAllDatabases()
- Specified by:
getAllDatabasesin interfaceHiveMetastore
-
getTable
public Optional<Table> getTable(HiveIdentity identity, String databaseName, String tableName)
- Specified by:
getTablein interfaceHiveMetastore
-
getSupportedColumnStatistics
public Set<ColumnStatisticType> getSupportedColumnStatistics(Type type)
- Specified by:
getSupportedColumnStatisticsin interfaceHiveMetastore
-
getTableStatistics
public PartitionStatistics getTableStatistics(HiveIdentity identity, Table table)
- Specified by:
getTableStatisticsin interfaceHiveMetastore
-
getPartitionStatistics
public Map<String,PartitionStatistics> getPartitionStatistics(HiveIdentity identity, Table table, List<Partition> partitions)
- Specified by:
getPartitionStatisticsin interfaceHiveMetastore
-
updateTableStatistics
public void updateTableStatistics(HiveIdentity identity, String databaseName, String tableName, AcidTransaction transaction, Function<PartitionStatistics,PartitionStatistics> update)
- Specified by:
updateTableStatisticsin interfaceHiveMetastore
-
updatePartitionStatistics
public void updatePartitionStatistics(HiveIdentity identity, Table table, String partitionName, Function<PartitionStatistics,PartitionStatistics> update)
- Specified by:
updatePartitionStatisticsin interfaceHiveMetastore
-
getAllTables
public List<String> getAllTables(String databaseName)
- Specified by:
getAllTablesin interfaceHiveMetastore
-
getTablesWithParameter
public List<String> getTablesWithParameter(String databaseName, String parameterKey, String parameterValue)
- Specified by:
getTablesWithParameterin interfaceHiveMetastore
-
getAllViews
public List<String> getAllViews(String databaseName)
- Specified by:
getAllViewsin interfaceHiveMetastore
-
createDatabase
public void createDatabase(HiveIdentity identity, Database database)
- Specified by:
createDatabasein interfaceHiveMetastore
-
dropDatabase
public void dropDatabase(HiveIdentity identity, String databaseName)
- Specified by:
dropDatabasein interfaceHiveMetastore
-
renameDatabase
public void renameDatabase(HiveIdentity identity, String databaseName, String newDatabaseName)
- Specified by:
renameDatabasein interfaceHiveMetastore
-
setDatabaseOwner
public void setDatabaseOwner(HiveIdentity identity, String databaseName, HivePrincipal principal)
- Specified by:
setDatabaseOwnerin interfaceHiveMetastore
-
invalidateDatabase
protected void invalidateDatabase(String databaseName)
-
createTable
public void createTable(HiveIdentity identity, Table table, PrincipalPrivileges principalPrivileges)
- Specified by:
createTablein interfaceHiveMetastore
-
dropTable
public void dropTable(HiveIdentity identity, String databaseName, String tableName, boolean deleteData)
- Specified by:
dropTablein interfaceHiveMetastore
-
replaceTable
public void replaceTable(HiveIdentity identity, 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(HiveIdentity identity, String databaseName, String tableName, String newDatabaseName, String newTableName)
- Specified by:
renameTablein interfaceHiveMetastore
-
commentTable
public void commentTable(HiveIdentity identity, String databaseName, String tableName, Optional<String> comment)
- Specified by:
commentTablein interfaceHiveMetastore
-
setTableOwner
public void setTableOwner(HiveIdentity identity, String databaseName, String tableName, HivePrincipal principal)
- Specified by:
setTableOwnerin interfaceHiveMetastore
-
commentColumn
public void commentColumn(HiveIdentity identity, String databaseName, String tableName, String columnName, Optional<String> comment)
- Specified by:
commentColumnin interfaceHiveMetastore
-
addColumn
public void addColumn(HiveIdentity identity, String databaseName, String tableName, String columnName, HiveType columnType, String columnComment)
- Specified by:
addColumnin interfaceHiveMetastore
-
renameColumn
public void renameColumn(HiveIdentity identity, String databaseName, String tableName, String oldColumnName, String newColumnName)
- Specified by:
renameColumnin interfaceHiveMetastore
-
dropColumn
public void dropColumn(HiveIdentity identity, String databaseName, String tableName, String columnName)
- Specified by:
dropColumnin interfaceHiveMetastore
-
getPartition
public Optional<Partition> getPartition(HiveIdentity identity, Table table, List<String> partitionValues)
- Specified by:
getPartitionin interfaceHiveMetastore
-
getPartitionNamesByFilter
public Optional<List<String>> getPartitionNamesByFilter(HiveIdentity identity, 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 interfaceHiveMetastoredatabaseName- 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:
TupleDomain
-
getPartitionsByNames
public Map<String,Optional<Partition>> getPartitionsByNames(HiveIdentity identity, Table table, List<String> partitionNames)
- Specified by:
getPartitionsByNamesin interfaceHiveMetastore
-
addPartitions
public void addPartitions(HiveIdentity identity, String databaseName, String tableName, List<PartitionWithStatistics> partitions)
- Specified by:
addPartitionsin interfaceHiveMetastore
-
dropPartition
public void dropPartition(HiveIdentity identity, String databaseName, String tableName, List<String> parts, boolean deleteData)
- Specified by:
dropPartitionin interfaceHiveMetastore
-
alterPartition
public void alterPartition(HiveIdentity identity, String databaseName, String tableName, PartitionWithStatistics partition)
- Specified by:
alterPartitionin interfaceHiveMetastore
-
createRole
public void createRole(String role, String grantor)
- Specified by:
createRolein interfaceHiveMetastore
-
dropRole
public void dropRole(String role)
- Specified by:
dropRolein interfaceHiveMetastore
-
listRoles
public Set<String> 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
public Set<RoleGrant> listGrantedPrincipals(String role)
- Specified by:
listGrantedPrincipalsin interfaceHiveMetastore
-
listRoleGrants
public Set<RoleGrant> listRoleGrants(HivePrincipal principal)
- Specified by:
listRoleGrantsin interfaceHiveMetastore
-
grantTablePrivileges
public void grantTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, Set<HivePrivilegeInfo> privileges)
- Specified by:
grantTablePrivilegesin interfaceHiveMetastore
-
revokeTablePrivileges
public void revokeTablePrivileges(String databaseName, String tableName, String tableOwner, HivePrincipal grantee, Set<HivePrivilegeInfo> privileges)
- Specified by:
revokeTablePrivilegesin interfaceHiveMetastore
-
listTablePrivileges
public Set<HivePrivilegeInfo> listTablePrivileges(String databaseName, String tableName, String tableOwner, Optional<HivePrincipal> principal)
- Specified by:
listTablePrivilegesin interfaceHiveMetastoreprincipal- when empty, all table privileges are returned
-
getConfigValue
public Optional<String> getConfigValue(String name)
- Specified by:
getConfigValuein interfaceHiveMetastore
-
openTransaction
public long openTransaction(HiveIdentity identity)
- Specified by:
openTransactionin interfaceHiveMetastore
-
commitTransaction
public void commitTransaction(HiveIdentity identity, long transactionId)
- Specified by:
commitTransactionin interfaceHiveMetastore
-
sendTransactionHeartbeat
public void sendTransactionHeartbeat(HiveIdentity identity, long transactionId)
- Specified by:
sendTransactionHeartbeatin interfaceHiveMetastore
-
acquireSharedReadLock
public void acquireSharedReadLock(HiveIdentity identity, String queryId, long transactionId, List<SchemaTableName> fullTables, List<HivePartition> partitions)
- Specified by:
acquireSharedReadLockin interfaceHiveMetastore
-
getValidWriteIds
public String getValidWriteIds(HiveIdentity identity, List<SchemaTableName> tables, long currentTransactionId)
- Specified by:
getValidWriteIdsin interfaceHiveMetastore
-
isImpersonationEnabled
public boolean isImpersonationEnabled()
- Specified by:
isImpersonationEnabledin interfaceHiveMetastore
-
allocateWriteId
public long allocateWriteId(HiveIdentity identity, String dbName, String tableName, long transactionId)
- Specified by:
allocateWriteIdin interfaceHiveMetastore
-
acquireTableWriteLock
public void acquireTableWriteLock(HiveIdentity identity, String queryId, long transactionId, String dbName, String tableName, org.apache.hadoop.hive.metastore.api.DataOperationType operation, boolean isDynamicPartitionWrite)
- Specified by:
acquireTableWriteLockin interfaceHiveMetastore
-
updateTableWriteId
public void updateTableWriteId(HiveIdentity identity, String dbName, String tableName, long transactionId, long writeId, OptionalLong rowCountChange)
- Specified by:
updateTableWriteIdin interfaceHiveMetastore
-
alterPartitions
public void alterPartitions(HiveIdentity identity, String dbName, String tableName, List<Partition> partitions, long writeId)
- Specified by:
alterPartitionsin interfaceHiveMetastore
-
addDynamicPartitions
public void addDynamicPartitions(HiveIdentity identity, String dbName, String tableName, List<String> partitionNames, long transactionId, long writeId, AcidOperation operation)
- Specified by:
addDynamicPartitionsin interfaceHiveMetastore
-
alterTransactionalTable
public void alterTransactionalTable(HiveIdentity identity, 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()
-
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()
-
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()
-
-