org.apache.hadoop.hive.ql.metadata
Class Table

java.lang.Object
  extended by org.apache.hadoop.hive.ql.metadata.Table

public class Table
extends Object

A Hive Table: is a fundamental unit of data in Hive that shares a common schema/DDL


Constructor Summary
protected Table()
          Table (only used internally)
  Table(String name)
           
  Table(String name, Properties schema, Deserializer deserializer, Class<? extends org.apache.hadoop.mapred.InputFormat<?,?>> inputFormatClass, Class<?> outputFormatClass, URI dataLocation, Hive hive)
          Table Create a TableMetaInfo object presumably with the intent of saving it to the metastore
 
Method Summary
 void checkValidity()
           
 Table copy()
           
protected  void copyFiles(org.apache.hadoop.fs.Path srcf)
          Inserts files specified into the partition.
 LinkedHashMap<String,String> createSpec(Partition tp)
          Creates a partition name -> value spec map object
 List<FieldSchema> getAllCols()
          Returns a list of all the columns of the table (data columns + partition columns in that order.
 List<String> getBucketCols()
           
 String getBucketingDimensionId()
           
 List<FieldSchema> getCols()
           
 URI getDataLocation()
           
 String getDbName()
           
 Deserializer getDeserializer()
           
 StructField getField(String fld)
           
 Vector<StructField> getFields()
           
 Class<? extends org.apache.hadoop.mapred.InputFormat> getInputFormatClass()
           
 String getName()
           
 int getNumBuckets()
           
 Class<? extends HiveOutputFormat> getOutputFormatClass()
           
 String getOwner()
           
 Map<String,String> getParameters()
           
 List<FieldSchema> getPartCols()
           
 org.apache.hadoop.fs.Path getPath()
           
 String getProperty(String name)
          getProperty
 int getRetention()
           
 Properties getSchema()
           
 String getSerdeParam(String param)
           
 String getSerializationLib()
           
 List<Order> getSortCols()
           
 Table getTTable()
           
protected  void initSerDe()
           
 boolean isPartitioned()
           
 boolean isPartitionKey(String colName)
           
 boolean isValidSpec(Map<String,String> spec)
           
 void reinitSerDe()
           
protected  void replaceFiles(org.apache.hadoop.fs.Path srcf, org.apache.hadoop.fs.Path tmpd)
          Replaces files in the partition with new data set specified by srcf.
 void setBucketCols(List<String> bucketCols)
           
 void setDataLocation(URI uri2)
           
 void setDeserializer(Deserializer deserializer)
           
 void setFields(List<FieldSchema> fields)
           
 void setInputFormatClass(Class<? extends org.apache.hadoop.mapred.InputFormat> inputFormatClass)
           
 void setInputFormatClass(String name)
           
 void setNumBuckets(int nb)
           
 void setOutputFormatClass(Class<?> class1)
           
 void setOutputFormatClass(String name)
           
 void setOwner(String owner)
           
 void setPartCols(List<FieldSchema> partCols)
           
 void setProperty(String name, String value)
           
 void setRetention(int retention)
           
 void setSchema(Properties schema)
           
 String setSerdeParam(String param, String value)
           
 void setSerializationLib(String lib)
           
 void setSortCols(List<Order> sortOrder)
           
protected  void setTTable(Table table)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

protected Table()
         throws HiveException
Table (only used internally)

Throws:
HiveException

Table

public Table(String name,
             Properties schema,
             Deserializer deserializer,
             Class<? extends org.apache.hadoop.mapred.InputFormat<?,?>> inputFormatClass,
             Class<?> outputFormatClass,
             URI dataLocation,
             Hive hive)
      throws HiveException
Table Create a TableMetaInfo object presumably with the intent of saving it to the metastore

Parameters:
name - the name of this table in the metadb
schema - an object that represents the schema that this SerDe must know
deserializer - a Class to be used for deserializing the data
dataLocation - where is the table ? (e.g., dfs://hadoop001.sf2p.facebook.com:9000/user/facebook/warehouse/example) NOTE: should not be hardcoding this, but ok for now
Throws:
HiveException - on internal error. Note not possible now, but in the future reserve the right to throw an exception

Table

public Table(String name)
Method Detail

reinitSerDe

public void reinitSerDe()
                 throws HiveException
Throws:
HiveException

initSerDe

protected void initSerDe()
                  throws HiveException
Throws:
HiveException

checkValidity

public void checkValidity()
                   throws HiveException
Throws:
HiveException

setInputFormatClass

public void setInputFormatClass(Class<? extends org.apache.hadoop.mapred.InputFormat> inputFormatClass)
Parameters:
inputFormatClass -

setOutputFormatClass

public void setOutputFormatClass(Class<?> class1)
Parameters:
class1 -

getSchema

public final Properties getSchema()

getPath

public final org.apache.hadoop.fs.Path getPath()

getName

public final String getName()

getDataLocation

public final URI getDataLocation()

getDeserializer

public final Deserializer getDeserializer()

getInputFormatClass

public final Class<? extends org.apache.hadoop.mapred.InputFormat> getInputFormatClass()

getOutputFormatClass

public final Class<? extends HiveOutputFormat> getOutputFormatClass()

isValidSpec

public final boolean isValidSpec(Map<String,String> spec)
                          throws HiveException
Throws:
HiveException

setProperty

public void setProperty(String name,
                        String value)

getProperty

public String getProperty(String name)
getProperty


getFields

public Vector<StructField> getFields()

getField

public StructField getField(String fld)

setSchema

public void setSchema(Properties schema)
Parameters:
schema - the schema to set

setDeserializer

public void setDeserializer(Deserializer deserializer)
Parameters:
deserializer - the deserializer to set

toString

public String toString()
Overrides:
toString in class Object

getPartCols

public List<FieldSchema> getPartCols()

isPartitionKey

public boolean isPartitionKey(String colName)

getBucketingDimensionId

public String getBucketingDimensionId()

getTTable

public Table getTTable()
Returns:
the tTable

setTTable

protected void setTTable(Table table)
Parameters:
table - the tTable to set

setDataLocation

public void setDataLocation(URI uri2)

setBucketCols

public void setBucketCols(List<String> bucketCols)
                   throws HiveException
Throws:
HiveException

setSortCols

public void setSortCols(List<Order> sortOrder)
                 throws HiveException
Throws:
HiveException

getCols

public List<FieldSchema> getCols()

getAllCols

public List<FieldSchema> getAllCols()
Returns a list of all the columns of the table (data columns + partition columns in that order.

Returns:
List

setPartCols

public void setPartCols(List<FieldSchema> partCols)

getDbName

public String getDbName()

getNumBuckets

public int getNumBuckets()

replaceFiles

protected void replaceFiles(org.apache.hadoop.fs.Path srcf,
                            org.apache.hadoop.fs.Path tmpd)
                     throws HiveException
Replaces files in the partition with new data set specified by srcf. Works by moving files

Parameters:
srcf - Files to be replaced. Leaf directories or globbed file paths
tmpd - Temporary directory
Throws:
HiveException

copyFiles

protected void copyFiles(org.apache.hadoop.fs.Path srcf)
                  throws HiveException
Inserts files specified into the partition. Works by moving files

Parameters:
srcf - Files to be moved. Leaf directories or globbed file paths
Throws:
HiveException

setInputFormatClass

public void setInputFormatClass(String name)
                         throws HiveException
Throws:
HiveException

setOutputFormatClass

public void setOutputFormatClass(String name)
                          throws HiveException
Throws:
HiveException

isPartitioned

public boolean isPartitioned()

setFields

public void setFields(List<FieldSchema> fields)

setNumBuckets

public void setNumBuckets(int nb)

getOwner

public String getOwner()
Returns:
The owner of the table.
See Also:
Table.getOwner()

getParameters

public Map<String,String> getParameters()
Returns:
The table parameters.
See Also:
Table.getParameters()

getRetention

public int getRetention()
Returns:
The retention on the table.
See Also:
Table.getRetention()

setOwner

public void setOwner(String owner)
Parameters:
owner -
See Also:
Table.setOwner(java.lang.String)

setRetention

public void setRetention(int retention)
Parameters:
retention -
See Also:
Table.setRetention(int)

setSerializationLib

public void setSerializationLib(String lib)

getSerializationLib

public String getSerializationLib()

getSerdeParam

public String getSerdeParam(String param)

setSerdeParam

public String setSerdeParam(String param,
                            String value)

getBucketCols

public List<String> getBucketCols()

getSortCols

public List<Order> getSortCols()

createSpec

public LinkedHashMap<String,String> createSpec(Partition tp)
Creates a partition name -> value spec map object

Parameters:
tp - Use the information from this partition.
Returns:
Partition name to value mapping.

copy

public Table copy()
           throws HiveException
Throws:
HiveException


Copyright © 2009 The Apache Software Foundation