public class MetaStoreServerUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
MetaStoreServerUtils.ColStatsObjWithSourceInfo |
| Modifier and Type | Field and Description |
|---|---|
static String |
JUNIT_DATABASE_PREFIX |
| Constructor and Description |
|---|
MetaStoreServerUtils() |
| Modifier and Type | Method and Description |
|---|---|
static List<ColumnStatisticsObj> |
aggrPartitionStats(List<ColumnStatistics> partStats,
String catName,
String dbName,
String tableName,
List<String> partNames,
List<String> colNames,
boolean areAllPartsFound,
boolean useDensityFunctionForNDVEstimation,
double ndvTuner) |
static List<ColumnStatisticsObj> |
aggrPartitionStats(Map<ColumnStatsAggregator,List<MetaStoreServerUtils.ColStatsObjWithSourceInfo>> colStatsMap,
List<String> partNames,
boolean areAllPartsFound,
boolean useDensityFunctionForNDVEstimation,
double ndvTuner) |
static String |
anonymizeConnectionURL(String connectionURL)
Mask out all sensitive information from the jdbc connection url string.
|
static boolean |
arePrefixColumns(List<FieldSchema> p,
List<FieldSchema> s)
Returns true if p is a prefix of s.
|
static boolean |
areSameColumns(List<FieldSchema> oldCols,
List<FieldSchema> newCols)
Compare the names, types and comments of two lists of
FieldSchema. |
static boolean |
checkUserHasHostProxyPrivileges(String user,
org.apache.hadoop.conf.Configuration conf,
String ipAddress)
Verify if the user is allowed to make DB notification related calls.
|
static void |
clearQuickStats(Map<String,String> params) |
static boolean |
columnsIncludedByNameType(List<FieldSchema> oldCols,
List<FieldSchema> newCols) |
static Partition |
createMetaPartitionObject(Table tbl,
Map<String,String> partSpec,
org.apache.hadoop.fs.Path location) |
static double |
decimalToDouble(Decimal decimal) |
static int |
findFreePort()
Finds a free port on the machine.
|
static int |
findFreePortExcepting(int portToExclude)
Finds a free port on the machine, but allow the
ability to specify a port number to not use, no matter what.
|
static List<Partition> |
getAllPartitionsOf(IMetaStoreClient msc,
Table table) |
static boolean |
getBooleanEnvProp(EnvironmentContext envContext,
String key) |
static List<String> |
getColumnNames(List<FieldSchema> cols)
Generate list of lower case column names from the fieldSchema list
|
static org.apache.hadoop.fs.Path |
getDataLocation(Table table,
Partition partition) |
static String |
getIndexTableName(String dbName,
String baseTblName,
String indexName) |
static void |
getMergableCols(ColumnStatistics csNew,
Map<String,String> parameters) |
static <T> List<T> |
getMetaStoreListeners(Class<T> clazz,
org.apache.hadoop.conf.Configuration conf,
String listenerImplList)
create listener instances as per the configuration.
|
static String |
getNormalisedPartitionValue(String partitionValue,
String type) |
static List<String> |
getPartColNames(Table table) |
static List<FieldSchema> |
getPartCols(Table table) |
static Partition |
getPartition(IMetaStoreClient msc,
Table tbl,
Map<String,String> partSpec) |
static Map<String,String> |
getPartitionColtoTypeMap(List<FieldSchema> partitionCols) |
static void |
getPartitionListByFilterExp(IMetaStoreClient msc,
Table table,
byte[] filterExp,
String defaultPartName,
List<Partition> results) |
static String |
getPartitionName(org.apache.hadoop.fs.Path tablePath,
org.apache.hadoop.fs.Path partitionPath,
Set<String> partCols,
Map<String,String> partitionColToTypeMap)
Get the partition name from the path.
|
static String |
getPartitionName(Table table,
Partition partition) |
static List<Partition> |
getPartitionsByProjectSpec(IMetaStoreClient msc,
GetPartitionsRequest request) |
static Map<String,String> |
getPartitionSpec(Table table,
Partition partition) |
static List<PartitionSpec> |
getPartitionspecsGroupedByStorageDescriptor(Table table,
Collection<Partition> partitions)
Coalesce list of partitions belonging to a table into a more compact PartitionSpec
representation.
|
static org.apache.hadoop.fs.Path |
getPath(Table table) |
static String |
getTokenStoreClassName(org.apache.hadoop.conf.Configuration conf)
This method should be used to return the metastore specific tokenstore class name to main
backwards compatibility
|
static byte[] |
hashStorageDescriptor(StorageDescriptor sd,
MessageDigest md)
Produce a hash for the storage descriptor
|
static boolean |
isCompactionTxn(TxnType txnType) |
static boolean |
isFastStatsSame(Partition oldPart,
Partition newPart)
Determines whether the "fast stats" for the passed partitions are the same.
|
static boolean |
isPartitioned(Table table) |
static boolean |
isTransactionalTable(Map<String,String> params)
Duplicates AcidUtils; used in a couple places in metastore.
|
static void |
mergeColStats(ColumnStatistics csNew,
ColumnStatistics csOld) |
static boolean |
partitionNameHasValidCharacters(List<String> partVals,
Pattern partitionValidationPattern) |
static void |
populateQuickStats(List<org.apache.hadoop.fs.FileStatus> fileStatus,
Map<String,String> params)
This method is invalid for MM and ACID tables unless fileStatus comes from AcidUtils.
|
static boolean |
requireCalStats(Partition oldPart,
Partition newPart,
Table tbl,
EnvironmentContext environmentContext) |
static void |
setNestedProperty(Object bean,
String propertyName,
Object value,
boolean instantiateMissingFields)
This is a util method to set a nested property of a given object.
|
static int |
startMetaStore() |
static int |
startMetaStore(org.apache.hadoop.conf.Configuration conf) |
static int |
startMetaStore(HadoopThriftAuthBridge bridge,
org.apache.hadoop.conf.Configuration conf) |
static void |
startMetaStore(int port,
HadoopThriftAuthBridge bridge) |
static void |
startMetaStore(int port,
HadoopThriftAuthBridge bridge,
org.apache.hadoop.conf.Configuration hiveConf) |
static Map<String,String> |
trimMapNulls(Map<String,String> dnMap,
boolean retrieveMapNullsAsEmptyStrings)
We have a need to sanity-check the map before conversion from persisted objects to
metadata thrift objects because null values in maps will cause a NPE if we send
across thrift.
|
static void |
updateBasicState(EnvironmentContext environmentContext,
Map<String,String> params) |
static boolean |
updatePartitionStatsFast(PartitionSpecProxy.PartitionIterator part,
Table table,
Warehouse wh,
boolean madeDir,
boolean forceRecompute,
EnvironmentContext environmentContext,
boolean isCreate)
Updates the numFiles and totalSize parameters for the passed Partition by querying
the warehouse if the passed Partition does not already have values for these parameters.
|
static boolean |
updatePartitionStatsFast(Partition part,
Table tbl,
Warehouse wh,
boolean madeDir,
boolean forceRecompute,
EnvironmentContext environmentContext,
boolean isCreate)
Updates the numFiles and totalSize parameters for the passed Partition by querying
the warehouse if the passed Partition does not already have values for these parameters.
|
static void |
updateTableStatsForCreateTable(Warehouse wh,
Database db,
Table tbl,
EnvironmentContext envContext,
org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.Path tblPath,
boolean newDir) |
static void |
updateTableStatsSlow(Database db,
Table tbl,
Warehouse wh,
boolean newDir,
boolean forceRecompute,
EnvironmentContext environmentContext)
Updates the numFiles and totalSize parameters for the passed Table by querying
the warehouse if the passed Table does not already have values for these parameters.
|
static List<String> |
validateBucketColumns(StorageDescriptor sd)
Validate bucket columns should belong to table columns.
|
static boolean |
validateColumnName(String name) |
static void |
validatePartitionNameCharacters(List<String> partVals,
Pattern partitionValidationPattern) |
static String |
validateSkewedColNames(List<String> cols) |
static String |
validateSkewedColNamesSubsetCol(List<String> skewedColNames,
List<FieldSchema> cols) |
static String |
validateTblColumns(List<FieldSchema> cols) |
public static final String JUNIT_DATABASE_PREFIX
public static Map<String,String> trimMapNulls(Map<String,String> dnMap, boolean retrieveMapNullsAsEmptyStrings)
public static List<ColumnStatisticsObj> aggrPartitionStats(List<ColumnStatistics> partStats, String catName, String dbName, String tableName, List<String> partNames, List<String> colNames, boolean areAllPartsFound, boolean useDensityFunctionForNDVEstimation, double ndvTuner) throws MetaException
MetaExceptionpublic static List<ColumnStatisticsObj> aggrPartitionStats(Map<ColumnStatsAggregator,List<MetaStoreServerUtils.ColStatsObjWithSourceInfo>> colStatsMap, List<String> partNames, boolean areAllPartsFound, boolean useDensityFunctionForNDVEstimation, double ndvTuner) throws MetaException
MetaExceptionpublic static double decimalToDouble(Decimal decimal)
public static void validatePartitionNameCharacters(List<String> partVals, Pattern partitionValidationPattern) throws MetaException
MetaExceptionpublic static byte[] hashStorageDescriptor(StorageDescriptor sd, MessageDigest md)
sd - storage descriptor to hashmd - message descriptor to use to generate the hashpublic static boolean validateColumnName(String name)
public static boolean isFastStatsSame(Partition oldPart, Partition newPart)
oldPart - Old partition to compare.newPart - New partition to compare.public static void updateTableStatsSlow(Database db, Table tbl, Warehouse wh, boolean newDir, boolean forceRecompute, EnvironmentContext environmentContext) throws MetaException
newDir - if true, the directory was just created and can be assumed to be emptyforceRecompute - Recompute stats even if the passed Table already has
these parameters setMetaExceptionpublic static void populateQuickStats(List<org.apache.hadoop.fs.FileStatus> fileStatus, Map<String,String> params)
public static void updateTableStatsForCreateTable(Warehouse wh, Database db, Table tbl, EnvironmentContext envContext, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path tblPath, boolean newDir) throws MetaException
MetaExceptionpublic static boolean getBooleanEnvProp(EnvironmentContext envContext, String key)
public static boolean areSameColumns(List<FieldSchema> oldCols, List<FieldSchema> newCols)
FieldSchema.
The name of FieldSchema is compared in the case-insensitive mode
because all names in Hive are case-insensitive.
oldCols - old columnsnewCols - new columnspublic static boolean arePrefixColumns(List<FieldSchema> p, List<FieldSchema> s)
The compare of FieldSchema is the same as areSameColumns(List, List).
public static void updateBasicState(EnvironmentContext environmentContext, Map<String,String> params)
public static boolean updatePartitionStatsFast(Partition part, Table tbl, Warehouse wh, boolean madeDir, boolean forceRecompute, EnvironmentContext environmentContext, boolean isCreate) throws MetaException
part - wh - madeDir - if true, the directory was just created and can be assumed to be emptyforceRecompute - Recompute stats even if the passed Partition already has
these parameters setMetaExceptionpublic static boolean updatePartitionStatsFast(PartitionSpecProxy.PartitionIterator part, Table table, Warehouse wh, boolean madeDir, boolean forceRecompute, EnvironmentContext environmentContext, boolean isCreate) throws MetaException
part - wh - madeDir - if true, the directory was just created and can be assumed to be emptyforceRecompute - Recompute stats even if the passed Partition already has
these parameters setMetaExceptionpublic static boolean columnsIncludedByNameType(List<FieldSchema> oldCols, List<FieldSchema> newCols)
public static boolean isTransactionalTable(Map<String,String> params)
public static <T> List<T> getMetaStoreListeners(Class<T> clazz, org.apache.hadoop.conf.Configuration conf, String listenerImplList) throws MetaException
clazz - Class of the listenerconf - configuration objectlistenerImplList - Implementation class nameMetaException - if there is any failure instantiating the classpublic static String validateSkewedColNamesSubsetCol(List<String> skewedColNames, List<FieldSchema> cols)
public static boolean partitionNameHasValidCharacters(List<String> partVals, Pattern partitionValidationPattern)
public static void getMergableCols(ColumnStatistics csNew, Map<String,String> parameters)
public static void mergeColStats(ColumnStatistics csNew, ColumnStatistics csOld) throws InvalidObjectException
InvalidObjectExceptionpublic static boolean checkUserHasHostProxyPrivileges(String user, org.apache.hadoop.conf.Configuration conf, String ipAddress)
user - the short user nameconf - that contains the proxy user settingspublic static int startMetaStore(HadoopThriftAuthBridge bridge, org.apache.hadoop.conf.Configuration conf) throws Exception
Exceptionpublic static int startMetaStore(org.apache.hadoop.conf.Configuration conf)
throws Exception
Exceptionpublic static void startMetaStore(int port,
HadoopThriftAuthBridge bridge)
throws Exception
Exceptionpublic static void startMetaStore(int port,
HadoopThriftAuthBridge bridge,
org.apache.hadoop.conf.Configuration hiveConf)
throws Exception
Exceptionpublic static int findFreePort()
throws IOException
IOExceptionpublic static int findFreePortExcepting(int portToExclude)
throws IOException
IOExceptionpublic static String getIndexTableName(String dbName, String baseTblName, String indexName)
public static String validateTblColumns(List<FieldSchema> cols)
public static boolean requireCalStats(Partition oldPart, Partition newPart, Table tbl, EnvironmentContext environmentContext)
public static String getTokenStoreClassName(org.apache.hadoop.conf.Configuration conf)
conf - - HiveConf objectpublic static List<PartitionSpec> getPartitionspecsGroupedByStorageDescriptor(Table table, Collection<Partition> partitions)
table - Table thrift objectpartitions - List of partition objectspublic static void setNestedProperty(Object bean, String propertyName, Object value, boolean instantiateMissingFields) throws MetaException
bean - the object whose nested field needs to be set. This object must have setter methods
defined for each nested field name in the propertyNamepropertyName - the nested propertyName to be set. Each level of nesting is dot separatedvalue - the value to which the nested property is setinstantiateMissingFields - in case of some nestedFields being nulls, setting this argument
to true will attempt to instantiate the missing fields using the
default constructor. If there is no default constructor available this would throw a MetaExceptionMetaExceptionpublic static String anonymizeConnectionURL(String connectionURL)
connectionURL - the connection url, can be nullpublic static org.apache.hadoop.fs.Path getPath(Table table)
public static List<Partition> getAllPartitionsOf(IMetaStoreClient msc, Table table) throws MetastoreException
MetastoreExceptionpublic static List<Partition> getPartitionsByProjectSpec(IMetaStoreClient msc, GetPartitionsRequest request) throws MetastoreException
MetastoreExceptionpublic static void getPartitionListByFilterExp(IMetaStoreClient msc, Table table, byte[] filterExp, String defaultPartName, List<Partition> results) throws MetastoreException
MetastoreExceptionpublic static boolean isPartitioned(Table table)
public static List<FieldSchema> getPartCols(Table table)
public static org.apache.hadoop.fs.Path getDataLocation(Table table, Partition partition)
public static Map<String,String> getPartitionSpec(Table table, Partition partition)
public static Partition getPartition(IMetaStoreClient msc, Table tbl, Map<String,String> partSpec) throws MetastoreException
MetastoreExceptionpublic static String getPartitionName(org.apache.hadoop.fs.Path tablePath, org.apache.hadoop.fs.Path partitionPath, Set<String> partCols, Map<String,String> partitionColToTypeMap)
tablePath - Path of the table.partitionPath - Path of the partition.partCols - Set of partition columns from table definitionpublic static String getNormalisedPartitionValue(String partitionValue, String type)
public static Map<String,String> getPartitionColtoTypeMap(List<FieldSchema> partitionCols)
public static Partition createMetaPartitionObject(Table tbl, Map<String,String> partSpec, org.apache.hadoop.fs.Path location) throws MetastoreException
MetastoreExceptionpublic static List<String> validateBucketColumns(StorageDescriptor sd)
sd - StorageDescriptor of given tablepublic static List<String> getColumnNames(List<FieldSchema> cols)
cols - fieldSchema listpublic static boolean isCompactionTxn(TxnType txnType)
Copyright © 2024 The Apache Software Foundation. All rights reserved.