|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hive.ql.metadata.Hive
public class Hive
The Hive class contains information about this instance of Hive. An instance of Hive represents a set of data in a file system (usually HDFS) organized for easy query processing
Method Summary | |
---|---|
void |
alterTable(String tblName,
Table newTbl)
Updates the existing table metadata with the new metadata. |
static void |
closeCurrent()
|
protected void |
copyFiles(org.apache.hadoop.fs.Path srcf,
org.apache.hadoop.fs.Path destf,
org.apache.hadoop.fs.FileSystem fs)
|
protected boolean |
createDatabase(String name,
String locationUri)
|
Partition |
createPartition(Table tbl,
Map<String,String> partSpec)
Creates a partition. |
Partition |
createPartition(Table tbl,
Map<String,String> partSpec,
org.apache.hadoop.fs.Path location)
Creates a partition |
void |
createTable(String tableName,
List<String> columns,
List<String> partCols,
Class<? extends org.apache.hadoop.mapred.InputFormat> fileInputFormat,
Class<? extends org.apache.hadoop.mapred.OutputFormat> fileOutputFormat)
Creates a table metdata and the directory for the table data |
void |
createTable(String tableName,
List<String> columns,
List<String> partCols,
Class<? extends org.apache.hadoop.mapred.InputFormat> fileInputFormat,
Class<? extends org.apache.hadoop.mapred.OutputFormat> fileOutputFormat,
int bucketCount,
List<String> bucketCols)
Creates a table metdata and the directory for the table data |
void |
createTable(Table tbl)
Creates the table with the give objects |
void |
createTable(Table tbl,
boolean ifNotExists)
Creates the table with the give objects |
protected boolean |
dropDatabase(String name)
|
boolean |
dropPartition(String db_name,
String tbl_name,
List<String> part_vals,
boolean deleteData)
|
void |
dropTable(String tableName)
Deprecated. Use dropTable(String, String) instead |
void |
dropTable(String tableName,
boolean deleteData,
boolean ignoreUnknownTab)
Deprecated. Use dropTable(String, String, boolean, boolean) instead |
void |
dropTable(String dbName,
String tableName)
Drops table along with the data in it. |
void |
dropTable(String dbName,
String tableName,
boolean deleteData,
boolean ignoreUnknownTab)
Drops the table. |
static Hive |
get()
|
static Hive |
get(HiveConf c)
Gets hive object for the current thread. |
static Hive |
get(HiveConf c,
boolean needsRefresh)
get a connection to metastore. |
List<String> |
getAllTables()
|
HiveConf |
getConf()
|
static List<FieldSchema> |
getFieldsFromDeserializer(String name,
Deserializer serde)
|
Partition |
getPartition(Table tbl,
Map<String,String> partSpec,
boolean forceCreate)
Returns partition metadata |
List<String> |
getPartitionNames(String dbName,
String tblName,
short max)
|
List<Partition> |
getPartitions(Table tbl)
get all the partitions that the table has |
Table |
getTable(String tableName)
Deprecated. Use getTable(String, String) instead |
Table |
getTable(String tableName,
boolean throwException)
Deprecated. Use getTable(String, String, boolean) instead |
Table |
getTable(String dbName,
String tableName)
Returns metadata of the table. |
Table |
getTable(String dbName,
String tableName,
boolean throwException)
Returns metadata of the table |
List<String> |
getTablesByPattern(String tablePattern)
returns all existing tables that match the given pattern. |
protected List<String> |
getTablesForDb(String database,
String tablePattern)
|
void |
loadPartition(org.apache.hadoop.fs.Path loadPath,
String tableName,
AbstractMap<String,String> partSpec,
boolean replace,
org.apache.hadoop.fs.Path tmpDirPath)
Load a directory into a Hive Table Partition - Alters existing content of the partition with the contents of loadPath. |
void |
loadTable(org.apache.hadoop.fs.Path loadPath,
String tableName,
boolean replace,
org.apache.hadoop.fs.Path tmpDirPath)
Load a directory into a Hive Table. |
protected void |
replaceFiles(org.apache.hadoop.fs.Path srcf,
org.apache.hadoop.fs.Path destf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tmppath)
Replaces files in the partition with new data set specifed by srcf. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Hive get(HiveConf c) throws HiveException
c
- new Hive Configuration
HiveException
public static Hive get(HiveConf c, boolean needsRefresh) throws HiveException
c
- new confneedsRefresh
- if true then creates a new one
HiveException
public static Hive get() throws HiveException
HiveException
public static void closeCurrent()
public void createTable(String tableName, List<String> columns, List<String> partCols, Class<? extends org.apache.hadoop.mapred.InputFormat> fileInputFormat, Class<? extends org.apache.hadoop.mapred.OutputFormat> fileOutputFormat) throws HiveException
tableName
- name of the tablecolumns
- list of fields of the tablepartCols
- partition keys of the tablefileInputFormat
- Class of the input format of the table data filefileOutputFormat
- Class of the output format of the table data file
HiveException
- thrown if the args are invalid or if the metadata or the data directory couldn't be createdpublic void createTable(String tableName, List<String> columns, List<String> partCols, Class<? extends org.apache.hadoop.mapred.InputFormat> fileInputFormat, Class<? extends org.apache.hadoop.mapred.OutputFormat> fileOutputFormat, int bucketCount, List<String> bucketCols) throws HiveException
tableName
- name of the tablecolumns
- list of fields of the tablepartCols
- partition keys of the tablefileInputFormat
- Class of the input format of the table data filefileOutputFormat
- Class of the output format of the table data filebucketCount
- number of buckets that each partition (or the table itself) should be divided into
HiveException
- thrown if the args are invalid or if the metadata or the data directory couldn't be createdpublic void alterTable(String tblName, Table newTbl) throws InvalidOperationException, HiveException
tblName
- name of the existing tablenewTbl
- new name of the table. could be the old name
InvalidOperationException
- if the changes in metadata is not acceptable
com.facebook.thrift.TException
HiveException
public void createTable(Table tbl) throws HiveException
tbl
- a table object
HiveException
public void createTable(Table tbl, boolean ifNotExists) throws HiveException
tbl
- a table objectifNotExists
- if true, ignore AlreadyExistsException
HiveException
public void dropTable(String tableName) throws HiveException
dropTable(String, String)
instead
tableName
-
HiveException
public void dropTable(String dbName, String tableName) throws HiveException
dbName
- database where the table livestableName
- table to drop
HiveException
- thrown if the drop failspublic void dropTable(String tableName, boolean deleteData, boolean ignoreUnknownTab) throws HiveException
dropTable(String, String, boolean, boolean)
instead
tableName
- deleteData
- deletes the underlying data along with metadataignoreUnknownTab
- an exception if thrown if this is falser
and table doesn't exist
HiveException
public void dropTable(String dbName, String tableName, boolean deleteData, boolean ignoreUnknownTab) throws HiveException
tableName
- deleteData
- deletes the underlying data along with metadataignoreUnknownTab
- an exception if thrown if this is falser and
table doesn't exist
HiveException
public HiveConf getConf()
public Table getTable(String tableName) throws HiveException
getTable(String, String)
instead
tableName
- the name of the table
HiveException
- if there's an internal error or if the
table doesn't existpublic Table getTable(String dbName, String tableName) throws HiveException
dbName
- the name of the databasetableName
- the name of the table
HiveException
- if there's an internal error or if the
table doesn't existpublic Table getTable(String tableName, boolean throwException) throws HiveException
getTable(String, String, boolean)
instead
tableName
- the name of the tablethrowException
- controls whether an exception is
thrown or a null returned
HiveException
public Table getTable(String dbName, String tableName, boolean throwException) throws HiveException
dbName
- the name of the databasetableName
- the name of the tablethrowException
- controls whether an exception is thrown
or a returns a null
HiveException
public List<String> getAllTables() throws HiveException
HiveException
public List<String> getTablesByPattern(String tablePattern) throws HiveException
tablePattern
- java re pattern
HiveException
protected List<String> getTablesForDb(String database, String tablePattern) throws HiveException
HiveException
protected boolean createDatabase(String name, String locationUri) throws AlreadyExistsException, MetaException, com.facebook.thrift.TException
name
- locationUri
-
AlreadyExistsException
MetaException
com.facebook.thrift.TException
HiveMetaStoreClient.createDatabase(java.lang.String, java.lang.String)
protected boolean dropDatabase(String name) throws MetaException, com.facebook.thrift.TException
name
-
MetaException
com.facebook.thrift.TException
HiveMetaStoreClient.dropDatabase(java.lang.String)
public void loadPartition(org.apache.hadoop.fs.Path loadPath, String tableName, AbstractMap<String,String> partSpec, boolean replace, org.apache.hadoop.fs.Path tmpDirPath) throws HiveException
loadPath
- Directory containing files to load into TabletableName
- name of table to be loaded.partSpec
- defines which partition needs to be loadedreplace
- if true - replace files in the partition, otherwise add files to the partitiontmpDirPath
- The temporary directory.
HiveException
public void loadTable(org.apache.hadoop.fs.Path loadPath, String tableName, boolean replace, org.apache.hadoop.fs.Path tmpDirPath) throws HiveException
loadPath
- Directory containing files to load into TabletableName
- name of table to be loaded.replace
- if true - replace files in the table, otherwise add files to tabletmpDirPath
- The temporary directory.
HiveException
public Partition createPartition(Table tbl, Map<String,String> partSpec) throws HiveException
tbl
- table for which partition needs to be createdpartSpec
- partition keys and their values
HiveException
- if table doesn't exist or partition already existspublic Partition createPartition(Table tbl, Map<String,String> partSpec, org.apache.hadoop.fs.Path location) throws HiveException
tbl
- table for which partition needs to be createdpartSpec
- partition keys and their valueslocation
- location of this partition
HiveException
- if table doesn't exist or partition already existspublic Partition getPartition(Table tbl, Map<String,String> partSpec, boolean forceCreate) throws HiveException
tbl
- the partition's tablepartSpec
- partition keys and valuesforceCreate
- if this is true and partition doesn't exist then a partition is created
HiveException
public boolean dropPartition(String db_name, String tbl_name, List<String> part_vals, boolean deleteData) throws HiveException
HiveException
public List<String> getPartitionNames(String dbName, String tblName, short max) throws HiveException
HiveException
public List<Partition> getPartitions(Table tbl) throws HiveException
tbl
- object for which partition is needed
HiveException
protected void copyFiles(org.apache.hadoop.fs.Path srcf, org.apache.hadoop.fs.Path destf, org.apache.hadoop.fs.FileSystem fs) throws HiveException
HiveException
protected void replaceFiles(org.apache.hadoop.fs.Path srcf, org.apache.hadoop.fs.Path destf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tmppath) throws HiveException
srcf
- Files to be moved. Leaf Directories or Globbed File Pathsdestf
- The directory where the final data needs to gofs
- The filesystem handletmppath
- Temporary directory
HiveException
public static List<FieldSchema> getFieldsFromDeserializer(String name, Deserializer serde) throws HiveException
HiveException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |