public class HCatUtil extends Object
Constructor and Description |
---|
HCatUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
assertNotNull(Object t,
String msg,
org.slf4j.Logger logger) |
static boolean |
checkJobContextIfRunningFromBackend(org.apache.hadoop.mapreduce.JobContext j) |
static void |
closeHiveClientQuietly(IMetaStoreClient client) |
static void |
configureOutputStorageHandler(HiveStorageHandler storageHandler,
org.apache.hadoop.conf.Configuration conf,
OutputJobInfo outputJobInfo) |
static void |
copyConf(org.apache.hadoop.conf.Configuration src,
org.apache.hadoop.conf.Configuration dest)
Replace the contents of dest with the contents of src
|
static void |
copyJobPropertiesToJobConf(Map<String,String> jobProperties,
org.apache.hadoop.mapred.JobConf jobConf) |
static byte[] |
decodeBytes(String str) |
static Object |
deserialize(String str) |
static String |
encodeBytes(byte[] bytes) |
static HCatSchema |
extractSchema(Partition partition) |
static HCatSchema |
extractSchema(Table table) |
static org.apache.hadoop.security.token.Token<? extends org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdentifier> |
extractThriftToken(String tokenStrForm,
String tokenSignature) |
static Pair<String,String> |
getDbAndTableName(String tableName) |
static List<FieldSchema> |
getFieldSchemaList(List<HCatFieldSchema> hcatFields) |
static List<HCatFieldSchema> |
getHCatFieldSchemaList(FieldSchema... fields) |
static List<HCatFieldSchema> |
getHCatFieldSchemaList(List<FieldSchema> fields) |
static HiveMetaStoreClient |
getHiveClient(HiveConf hiveConf)
Deprecated.
|
static HiveConf |
getHiveConf(org.apache.hadoop.conf.Configuration conf) |
static IMetaStoreClient |
getHiveMetastoreClient(HiveConf hiveConf)
Get or create a hive client depending on whether it exits in cache or not
|
static Map<String,String> |
getInputJobProperties(HiveStorageHandler storageHandler,
InputJobInfo inputJobInfo) |
static org.apache.hadoop.mapred.JobConf |
getJobConfFromContext(org.apache.hadoop.mapreduce.JobContext jobContext) |
static org.apache.hadoop.security.token.Token<org.apache.hadoop.mapreduce.security.token.delegation.DelegationTokenIdentifier> |
getJobTrackerDelegationToken(org.apache.hadoop.conf.Configuration conf,
String userName) |
static HCatSchema |
getPartitionColumns(Table table)
return the partition columns from a table instance
|
static HiveStorageHandler |
getStorageHandler(org.apache.hadoop.conf.Configuration conf,
PartInfo partitionInfo) |
static HiveStorageHandler |
getStorageHandler(org.apache.hadoop.conf.Configuration conf,
StorerInfo storerInfo)
Create an instance of a storage handler defined in storerInfo.
|
static HiveStorageHandler |
getStorageHandler(org.apache.hadoop.conf.Configuration conf,
String storageHandler,
String serDe,
String inputFormat,
String outputFormat)
Create an instance of a storage handler.
|
static Table |
getTable(IMetaStoreClient client,
String dbName,
String tableName) |
static HCatSchema |
getTableSchemaWithPtnCols(Table table) |
static boolean |
isHadoop23() |
static String |
makePathASafeFileName(String filePath)
Used by various tests to make sure the path is safe for Windows
|
static String |
serialize(Serializable obj) |
static boolean |
validateExecuteBitPresentIfReadOrWrite(org.apache.hadoop.fs.permission.FsAction perms)
Ensure that read or write permissions are not granted without also
granting execute permissions.
|
static boolean |
validateMorePermissive(org.apache.hadoop.fs.permission.FsAction first,
org.apache.hadoop.fs.permission.FsAction second)
Test if the first FsAction is more permissive than the second.
|
static List<FieldSchema> |
validatePartitionSchema(Table table,
HCatSchema partitionSchema)
Validate partition schema, checks if the column types match between the
partition and the existing table schema.
|
public static boolean checkJobContextIfRunningFromBackend(org.apache.hadoop.mapreduce.JobContext j)
public static String serialize(Serializable obj) throws IOException
IOException
public static Object deserialize(String str) throws IOException
IOException
public static String encodeBytes(byte[] bytes)
public static byte[] decodeBytes(String str)
public static List<HCatFieldSchema> getHCatFieldSchemaList(FieldSchema... fields) throws HCatException
HCatException
public static List<HCatFieldSchema> getHCatFieldSchemaList(List<FieldSchema> fields) throws HCatException
HCatException
public static HCatSchema extractSchema(Table table) throws HCatException
HCatException
public static HCatSchema extractSchema(Partition partition) throws HCatException
HCatException
public static List<FieldSchema> getFieldSchemaList(List<HCatFieldSchema> hcatFields)
public static Table getTable(IMetaStoreClient client, String dbName, String tableName) throws NoSuchObjectException, org.apache.thrift.TException, MetaException
NoSuchObjectException
org.apache.thrift.TException
MetaException
public static HCatSchema getTableSchemaWithPtnCols(Table table) throws IOException
IOException
public static HCatSchema getPartitionColumns(Table table) throws IOException
table
- the instance to extract partition columns fromIOException
public static List<FieldSchema> validatePartitionSchema(Table table, HCatSchema partitionSchema) throws IOException
table
- the tablepartitionSchema
- the partition schemaIOException
- Signals that an I/O exception has occurred.public static boolean validateMorePermissive(org.apache.hadoop.fs.permission.FsAction first, org.apache.hadoop.fs.permission.FsAction second)
public static boolean validateExecuteBitPresentIfReadOrWrite(org.apache.hadoop.fs.permission.FsAction perms)
perms
- The FsAction to verifypublic static org.apache.hadoop.security.token.Token<org.apache.hadoop.mapreduce.security.token.delegation.DelegationTokenIdentifier> getJobTrackerDelegationToken(org.apache.hadoop.conf.Configuration conf, String userName) throws Exception
Exception
public static org.apache.hadoop.security.token.Token<? extends org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdentifier> extractThriftToken(String tokenStrForm, String tokenSignature) throws MetaException, org.apache.thrift.TException, IOException
MetaException
org.apache.thrift.TException
IOException
public static HiveStorageHandler getStorageHandler(org.apache.hadoop.conf.Configuration conf, StorerInfo storerInfo) throws IOException
conf
- job's configuration will be used to configure the Configurable StorageHandlerstorerInfo
- StorerInfo to definining the StorageHandler and InputFormat, OutputFormat and SerDeIOException
public static HiveStorageHandler getStorageHandler(org.apache.hadoop.conf.Configuration conf, PartInfo partitionInfo) throws IOException
IOException
public static HiveStorageHandler getStorageHandler(org.apache.hadoop.conf.Configuration conf, String storageHandler, String serDe, String inputFormat, String outputFormat) throws IOException
conf
- job's configuration will be used to configure the Configurable StorageHandlerstorageHandler
- fully qualified class name of the desired StorageHandle instanceserDe
- fully qualified class name of the desired SerDe instanceinputFormat
- fully qualified class name of the desired InputFormat instanceoutputFormat
- fully qualified class name of the desired outputFormat instanceIOException
public static Pair<String,String> getDbAndTableName(String tableName) throws IOException
IOException
public static Map<String,String> getInputJobProperties(HiveStorageHandler storageHandler, InputJobInfo inputJobInfo)
@InterfaceAudience.Private @InterfaceStability.Evolving public static void configureOutputStorageHandler(HiveStorageHandler storageHandler, org.apache.hadoop.conf.Configuration conf, OutputJobInfo outputJobInfo)
public static void copyConf(org.apache.hadoop.conf.Configuration src, org.apache.hadoop.conf.Configuration dest)
src
- dest
- public static IMetaStoreClient getHiveMetastoreClient(HiveConf hiveConf) throws MetaException, IOException
hiveConf
- The hive configurationMetaException
- When HiveMetaStoreClient couldn't be createdIOException
@Deprecated public static HiveMetaStoreClient getHiveClient(HiveConf hiveConf) throws MetaException, IOException
hiveConf
- The hive configurationMetaException
- When HiveMetaStoreClient couldn't be createdIOException
public static void closeHiveClientQuietly(IMetaStoreClient client)
public static HiveConf getHiveConf(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public static org.apache.hadoop.mapred.JobConf getJobConfFromContext(org.apache.hadoop.mapreduce.JobContext jobContext)
public static void copyJobPropertiesToJobConf(Map<String,String> jobProperties, org.apache.hadoop.mapred.JobConf jobConf)
public static boolean isHadoop23()
public static String makePathASafeFileName(String filePath)
Copyright © 2017 The Apache Software Foundation. All rights reserved.