public class HCatClientHMSImpl extends HCatClient
HCatClient.DropDBMode
HCAT_CLIENT_IMPL_CLASS
Constructor and Description |
---|
HCatClientHMSImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addPartition(HCatAddPartitionDesc partInfo)
Adds the partition.
|
int |
addPartitions(List<HCatAddPartitionDesc> partInfoList)
Adds a list of partitions.
|
int |
addPartitionSpec(HCatPartitionSpec partitionSpec)
Adds partitions using HCatPartitionSpec.
|
void |
cancelDelegationToken(String tokenStrForm)
Cancel delegation token.
|
void |
close()
Close the hcatalog client.
|
void |
createDatabase(HCatCreateDBDesc dbInfo)
Creates the database.
|
void |
createTable(HCatCreateTableDesc createTableDesc)
Creates the table.
|
void |
createTableLike(String dbName,
String existingTblName,
String newTableName,
boolean ifNotExists,
boolean isExternal,
String location)
Creates the table like an existing table.
|
HCatPartition |
deserializePartition(String hcatPartitionStringRep)
Deserializer for an HCatPartition.
|
List<HCatPartition> |
deserializePartitions(List<String> hcatPartitionStringReps)
Deserializer for a list of HCatPartition strings.
|
HCatPartitionSpec |
deserializePartitionSpec(List<String> hcatPartitionSpecStrings)
Deserializer for HCatPartitionSpec.
|
HCatTable |
deserializeTable(String hcatTableStringRep)
Deserializer for HCatTable.
|
void |
dropDatabase(String dbName,
boolean ifExists,
HCatClient.DropDBMode mode)
Drops a database.
|
void |
dropPartitions(String dbName,
String tableName,
Map<String,String> partitionSpec,
boolean ifExists)
Drops partition(s) that match the specified (and possibly partial) partition specification.
|
void |
dropPartitions(String dbName,
String tableName,
Map<String,String> partitionSpec,
boolean ifExists,
boolean deleteData)
Drops partition(s) that match the specified (and possibly partial) partition specification.
|
void |
dropTable(String dbName,
String tableName,
boolean ifExists)
Drop table.
|
String |
getConfVal(String key,
String defaultVal)
Fetch configuration value on conf that the HCatClient is instantiated
against.
|
long |
getCurrentNotificationEventId()
Get the most recently used notification id.
|
HCatDatabase |
getDatabase(String dbName)
Gets the database.
|
String |
getDelegationToken(String owner,
String renewerKerberosPrincipalName)
Gets the delegation token.
|
String |
getMessageBusTopicName(String dbName,
String tableName)
Retrieve Message-bus topic for a table.
|
List<HCatNotificationEvent> |
getNextNotification(long lastEventId,
int maxEvents,
IMetaStoreClient.NotificationFilter filter)
Get a list of notifications
|
HCatPartition |
getPartition(String dbName,
String tableName,
Map<String,String> partitionSpec)
Gets the partition.
|
List<HCatPartition> |
getPartitions(String dbName,
String tblName)
Gets all the partitions.
|
List<HCatPartition> |
getPartitions(String dbName,
String tblName,
Map<String,String> partitionSpec)
Gets all the partitions that match the specified (and possibly partial) partition specification.
|
HCatPartitionSpec |
getPartitionSpecs(String dbName,
String tableName,
int maxPartitions)
Gets partitions in terms of generic HCatPartitionSpec instances.
|
HCatPartitionSpec |
getPartitionSpecs(String dbName,
String tableName,
Map<String,String> partitionSelector,
int maxPartitions)
Gets partitions in terms of generic HCatPartitionSpec instances.
|
Iterator<ReplicationTask> |
getReplicationTasks(long lastEventId,
int maxEvents,
String dbName,
String tableName)
Get an iterator that iterates over a list of replication tasks needed to replicate all the
events that have taken place for a given db/table.
|
HCatTable |
getTable(String dbName,
String tableName)
Gets the table.
|
boolean |
isPartitionMarkedForEvent(String dbName,
String tblName,
Map<String,String> partKVs,
PartitionEventType eventType)
Checks if a partition is marked for event.
|
List<String> |
listDatabaseNamesByPattern(String pattern)
Get all existing databases that match the given
pattern.
|
List<HCatPartition> |
listPartitionsByFilter(String dbName,
String tblName,
String filter)
List partitions by filter.
|
HCatPartitionSpec |
listPartitionSpecsByFilter(String dbName,
String tblName,
String filter,
int maxPartitions)
List partitions by filter, but as HCatPartitionSpecs.
|
List<String> |
listTableNamesByPattern(String dbName,
String tablePattern)
Returns all existing tables from the specified database which match the given
pattern.
|
void |
markPartitionForEvent(String dbName,
String tblName,
Map<String,String> partKVs,
PartitionEventType eventType)
Mark partition for event.
|
void |
renameTable(String dbName,
String oldName,
String newName)
Renames a table.
|
long |
renewDelegationToken(String tokenStrForm)
Renew delegation token.
|
String |
serializePartition(HCatPartition hcatPartition)
Serializer for HCatPartition.
|
List<String> |
serializePartitions(List<HCatPartition> hcatPartitions)
Serializer for a list of HCatPartition.
|
List<String> |
serializePartitionSpec(HCatPartitionSpec partitionSpec)
Serializer for HCatPartitionSpec.
|
String |
serializeTable(HCatTable hcatTable)
Serializer for HCatTable.
|
void |
updateTableSchema(String dbName,
String tableName,
HCatTable newTableDefinition)
Updates the Table's whole schema (including column schema, I/O Formats, SerDe definitions, etc.)
|
void |
updateTableSchema(String dbName,
String tableName,
List<HCatFieldSchema> columnSchema)
Updates the Table's column schema to the specified definition.
|
create
public List<String> listDatabaseNamesByPattern(String pattern) throws HCatException
HCatClient
listDatabaseNamesByPattern
in class HCatClient
pattern
- java re patternHCatException
public HCatDatabase getDatabase(String dbName) throws HCatException
HCatClient
getDatabase
in class HCatClient
dbName
- The name of the database.HCatException
public void createDatabase(HCatCreateDBDesc dbInfo) throws HCatException
HCatClient
createDatabase
in class HCatClient
dbInfo
- An instance of HCatCreateDBDesc.HCatException
public void dropDatabase(String dbName, boolean ifExists, HCatClient.DropDBMode mode) throws HCatException
HCatClient
dropDatabase
in class HCatClient
dbName
- The name of the database to delete.ifExists
- Hive returns an error if the database specified does not exist,
unless ifExists is set to true.mode
- This is set to either "restrict" or "cascade". Restrict will
remove the schema if all the tables are empty. Cascade removes
everything including data and definitions.HCatException
public List<String> listTableNamesByPattern(String dbName, String tablePattern) throws HCatException
HCatClient
listTableNamesByPattern
in class HCatClient
dbName
- The name of the DB (to be searched)tablePattern
- The regex for the table-nameHCatException
public HCatTable getTable(String dbName, String tableName) throws HCatException
HCatClient
getTable
in class HCatClient
dbName
- The name of the database.tableName
- The name of the table.HCatException
public void createTable(HCatCreateTableDesc createTableDesc) throws HCatException
HCatClient
createTable
in class HCatClient
createTableDesc
- An instance of HCatCreateTableDesc class.HCatException
public void updateTableSchema(String dbName, String tableName, List<HCatFieldSchema> columnSchema) throws HCatException
HCatClient
updateTableSchema
in class HCatClient
dbName
- The name of the database.tableName
- The name of the table.columnSchema
- The (new) definition of the column schema (i.e. list of fields).HCatException
public void updateTableSchema(String dbName, String tableName, HCatTable newTableDefinition) throws HCatException
HCatClient
updateTableSchema
in class HCatClient
dbName
- The name of the database.tableName
- The name of the table.newTableDefinition
- The (new) definition of the table.HCatException
public void createTableLike(String dbName, String existingTblName, String newTableName, boolean ifNotExists, boolean isExternal, String location) throws HCatException
HCatClient
createTableLike
in class HCatClient
dbName
- The name of the database.existingTblName
- The name of the existing table.newTableName
- The name of the new table.ifNotExists
- If true, then error related to already table existing is skipped.isExternal
- Set to "true", if table has be created at a different
location other than default.location
- The location for the table.HCatException
public void dropTable(String dbName, String tableName, boolean ifExists) throws HCatException
HCatClient
dropTable
in class HCatClient
dbName
- The name of the database.tableName
- The name of the table.ifExists
- Hive returns an error if the database specified does not exist,
unless ifExists is set to true.HCatException
public void renameTable(String dbName, String oldName, String newName) throws HCatException
HCatClient
renameTable
in class HCatClient
dbName
- The name of the database.oldName
- The name of the table to be renamed.newName
- The new name of the table.HCatException
public List<HCatPartition> getPartitions(String dbName, String tblName) throws HCatException
HCatClient
getPartitions
in class HCatClient
dbName
- The name of the database.tblName
- The name of the table.HCatException
public List<HCatPartition> getPartitions(String dbName, String tblName, Map<String,String> partitionSpec) throws HCatException
HCatClient
getPartitions
in class HCatClient
dbName
- The name of the database.tblName
- The name of the table.partitionSpec
- The partition specification. (Need not include all partition keys.)HCatException
@InterfaceAudience.LimitedPrivate(value="Hive") @InterfaceStability.Evolving public HCatPartitionSpec getPartitionSpecs(String dbName, String tableName, int maxPartitions) throws HCatException
HCatClient
getPartitionSpecs
in class HCatClient
HCatException
public HCatPartitionSpec getPartitionSpecs(String dbName, String tableName, Map<String,String> partitionSelector, int maxPartitions) throws HCatException
HCatClient
getPartitionSpecs
in class HCatClient
HCatException
public HCatPartition getPartition(String dbName, String tableName, Map<String,String> partitionSpec) throws HCatException
HCatClient
getPartition
in class HCatClient
dbName
- The database name.tableName
- The table name.partitionSpec
- The partition specification, {[col_name,value],[col_name2,value2]}. All partition-key-values
must be specified.HCatException
public void addPartition(HCatAddPartitionDesc partInfo) throws HCatException
HCatClient
addPartition
in class HCatClient
partInfo
- An instance of HCatAddPartitionDesc.HCatException
public void dropPartitions(String dbName, String tableName, Map<String,String> partitionSpec, boolean ifExists, boolean deleteData) throws HCatException
HCatClient
dropPartitions
in class HCatClient
dbName
- The database name.tableName
- The table name.partitionSpec
- The partition specification, {[col_name,value],[col_name2,value2]}.ifExists
- Hive returns an error if the partition specified does not exist, unless ifExists is set to true.deleteData
- Whether to delete the underlying data.HCatException
public void dropPartitions(String dbName, String tableName, Map<String,String> partitionSpec, boolean ifExists) throws HCatException
HCatClient
dropPartitions
in class HCatClient
dbName
- The database name.tableName
- The table name.partitionSpec
- The partition specification, {[col_name,value],[col_name2,value2]}.ifExists
- Hive returns an error if the partition specified does not exist, unless ifExists is set to true.HCatException
public List<HCatPartition> listPartitionsByFilter(String dbName, String tblName, String filter) throws HCatException
HCatClient
listPartitionsByFilter
in class HCatClient
dbName
- The database name.tblName
- The table name.filter
- The filter string,
for example "part1 = \"p1_abc\" and part2 <= "\p2_test\"". Filtering can
be done only on string partition keys.HCatException
@InterfaceAudience.LimitedPrivate(value="Hive") @InterfaceStability.Evolving public HCatPartitionSpec listPartitionSpecsByFilter(String dbName, String tblName, String filter, int maxPartitions) throws HCatException
HCatClient
listPartitionSpecsByFilter
in class HCatClient
HCatException
public void markPartitionForEvent(String dbName, String tblName, Map<String,String> partKVs, PartitionEventType eventType) throws HCatException
HCatClient
markPartitionForEvent
in class HCatClient
dbName
- The database name.tblName
- The table name.partKVs
- the key-values associated with the partition.eventType
- the event typeHCatException
public boolean isPartitionMarkedForEvent(String dbName, String tblName, Map<String,String> partKVs, PartitionEventType eventType) throws HCatException
HCatClient
isPartitionMarkedForEvent
in class HCatClient
dbName
- the db nametblName
- the table namepartKVs
- the key-values associated with the partition.eventType
- the event typeHCatException
public String getDelegationToken(String owner, String renewerKerberosPrincipalName) throws HCatException
HCatClient
getDelegationToken
in class HCatClient
owner
- the ownerrenewerKerberosPrincipalName
- the renewer kerberos principal nameHCatException
public long renewDelegationToken(String tokenStrForm) throws HCatException
HCatClient
renewDelegationToken
in class HCatClient
tokenStrForm
- the token stringHCatException
public void cancelDelegationToken(String tokenStrForm) throws HCatException
HCatClient
cancelDelegationToken
in class HCatClient
tokenStrForm
- the token stringHCatException
public String getConfVal(String key, String defaultVal)
HCatClient
getConfVal
in class HCatClient
key
- keyname to look updefaultVal
- default value to furnish in case the key does not existpublic void close() throws HCatException
HCatClient
close
in class HCatClient
HCatException
public int addPartitions(List<HCatAddPartitionDesc> partInfoList) throws HCatException
HCatClient
addPartitions
in class HCatClient
partInfoList
- A list of HCatAddPartitionDesc.HCatException
@InterfaceAudience.LimitedPrivate(value="Hive") @InterfaceStability.Evolving public int addPartitionSpec(HCatPartitionSpec partitionSpec) throws HCatException
HCatClient
addPartitionSpec
in class HCatClient
partitionSpec
- The HCatPartitionSpec representing the set of partitions added.HCatException
- On failure to add partitions.public String getMessageBusTopicName(String dbName, String tableName) throws HCatException
HCatClient
getMessageBusTopicName
in class HCatClient
dbName
- The name of the DB.tableName
- The name of the table.HCatException
public Iterator<ReplicationTask> getReplicationTasks(long lastEventId, int maxEvents, String dbName, String tableName) throws HCatException
HCatClient
getReplicationTasks
in class HCatClient
lastEventId
- : The last event id that was processed for this reader. The returned
replication tasks will start from this point forwardmaxEvents
- : Maximum number of events to consider for generating the
replication tasks. If < 1, then all available events will be considered.dbName
- : The database name for which we're interested in the events for.tableName
- : The table name for which we're interested in the events for - if null,
then this function will behave as if it were running at a db level.HCatException
public List<HCatNotificationEvent> getNextNotification(long lastEventId, int maxEvents, IMetaStoreClient.NotificationFilter filter) throws HCatException
HCatClient
getNextNotification
in class HCatClient
lastEventId
- The last event id that was consumed by this reader. The returned
notifications will start at the next eventId available this eventId that
matches the filter.maxEvents
- Maximum number of events to return. If < 1, then all available events will
be returned.filter
- Filter to determine if message should be accepted. If null, then all
available events up to maxEvents will be returned.HCatException
public long getCurrentNotificationEventId() throws HCatException
HCatClient
getCurrentNotificationEventId
in class HCatClient
HCatException
public String serializeTable(HCatTable hcatTable) throws HCatException
HCatClient
serializeTable
in class HCatClient
hcatTable
- The HCatTable to be serialized into string formHCatException
public HCatTable deserializeTable(String hcatTableStringRep) throws HCatException
HCatClient
deserializeTable
in class HCatClient
hcatTableStringRep
- The String representation of an HCatTable, presumably retrieved from HCatClient.serializeTable(HCatTable)
HCatException
public String serializePartition(HCatPartition hcatPartition) throws HCatException
HCatClient
serializePartition
in class HCatClient
hcatPartition
- The HCatPartition instance to be serialized.HCatException
public List<String> serializePartitions(List<HCatPartition> hcatPartitions) throws HCatException
HCatClient
serializePartitions
in class HCatClient
hcatPartitions
- The HCatPartitions to be serialized.HCatException
public HCatPartition deserializePartition(String hcatPartitionStringRep) throws HCatException
HCatClient
deserializePartition
in class HCatClient
hcatPartitionStringRep
- The String representation of the HCatPartition, presumably retrieved from HCatClient.serializePartition(HCatPartition)
HCatException
public List<HCatPartition> deserializePartitions(List<String> hcatPartitionStringReps) throws HCatException
HCatClient
deserializePartitions
in class HCatClient
hcatPartitionStringReps
- The list of HCatPartition strings to be deserialized.HCatException
public List<String> serializePartitionSpec(HCatPartitionSpec partitionSpec) throws HCatException
HCatClient
serializePartitionSpec
in class HCatClient
partitionSpec
- HCatPartitionSpec to be serialized.HCatException
- On failure to serialize.public HCatPartitionSpec deserializePartitionSpec(List<String> hcatPartitionSpecStrings) throws HCatException
HCatClient
deserializePartitionSpec
in class HCatClient
hcatPartitionSpecStrings
- List of strings, representing the HCatPartitionSpec as a whole.HCatException
- On failure to deserialize.Copyright © 2017 The Apache Software Foundation. All rights reserved.