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

java.lang.Object
  extended by org.apache.hadoop.hive.ql.metadata.Partition
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DummyPartition

public class Partition
extends Object
implements Serializable

A Hive Table Partition: is a fundamental storage unit within a Table. Please note that the ql code should always go through methods of this class to access the metadata, instead of directly accessing org.apache.hadoop.hive.metastore.api.Partition. This helps to isolate the metastore code and the ql code.

See Also:
Serialized Form

Constructor Summary
Partition()
          Used only for serialization.
Partition(Table tbl)
          create an empty partition.
Partition(Table tbl, Map<String,String> partSpec, org.apache.hadoop.fs.Path location)
          Create partition object with the given info.
Partition(Table tbl, Partition tp)
           
 
Method Summary
 boolean canDrop()
           
 boolean canWrite()
           
 List<String> getBucketCols()
           
 int getBucketCount()
           
 org.apache.hadoop.fs.Path getBucketPath(int bucketNum)
          mapping from bucket number to bucket path
 List<FieldSchema> getCols()
           
 String getCompleteName()
           
 URI getDataLocation()
           
 Deserializer getDeserializer()
           
 Deserializer getDeserializer(Properties props)
           
 Class<? extends org.apache.hadoop.mapred.InputFormat> getInputFormatClass()
           
 int getLastAccessTime()
           
 String getLocation()
           
 String getName()
           
 Class<? extends HiveOutputFormat> getOutputFormatClass()
           
 Map<String,String> getParameters()
           
 org.apache.hadoop.fs.Path getPartitionPath()
           
 org.apache.hadoop.fs.Path[] getPath()
           
 org.apache.hadoop.fs.Path[] getPath(Sample s)
           
 ProtectMode getProtectMode()
           
 Properties getSchema()
           
 Properties getSchemaFromTableSchema(Properties tblSchema)
           
 List<String> getSkewedColNames()
           
 Map<List<String>,String> getSkewedColValueLocationMaps()
           
 List<List<String>> getSkewedColValues()
           
 List<String> getSortColNames()
           
 List<Order> getSortCols()
           
 LinkedHashMap<String,String> getSpec()
           
 Table getTable()
           
 Partition getTPartition()
          Should be only used by serialization.
 List<String> getValues()
           
 boolean isOffline()
           
 void setInputFormatClass(Class<? extends org.apache.hadoop.mapred.InputFormat> inputFormatClass)
           
 void setLastAccessTime(int lastAccessTime)
           
 void setLocation(String location)
           
 void setOutputFormatClass(Class<? extends HiveOutputFormat> outputFormatClass)
           
 void setProtectMode(ProtectMode protectMode)
           
 void setSkewedValueLocationMap(List<String> valList, String dirName)
           
 void setTable(Table table)
          Should be only used by serialization.
 void setTPartition(Partition partition)
          Should be only used by serialization.
 void setValues(Map<String,String> partSpec)
          Set Partition's values
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Partition

public Partition()
Used only for serialization.


Partition

public Partition(Table tbl)
          throws HiveException
create an empty partition. SemanticAnalyzer code requires that an empty partition when the table is not partitioned.

Throws:
HiveException

Partition

public Partition(Table tbl,
                 Partition tp)
          throws HiveException
Throws:
HiveException

Partition

public Partition(Table tbl,
                 Map<String,String> partSpec,
                 org.apache.hadoop.fs.Path location)
          throws HiveException
Create partition object with the given info.

Parameters:
tbl - Table the partition will be in.
partSpec - Partition specifications.
location - Location of the partition, relative to the table.
Throws:
HiveException - Thrown if we could not create the partition.
Method Detail

getValues

public List<String> getValues()
Returns:
The values of the partition
See Also:
Partition.getValues()

getName

public String getName()

getPath

public org.apache.hadoop.fs.Path[] getPath()

getPartitionPath

public org.apache.hadoop.fs.Path getPartitionPath()

getDataLocation

public final URI getDataLocation()

getDeserializer

public final Deserializer getDeserializer()

getDeserializer

public final Deserializer getDeserializer(Properties props)

getSchema

public Properties getSchema()

getSchemaFromTableSchema

public Properties getSchemaFromTableSchema(Properties tblSchema)

setInputFormatClass

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

setOutputFormatClass

public void setOutputFormatClass(Class<? extends HiveOutputFormat> outputFormatClass)
Parameters:
outputFormatClass -

getInputFormatClass

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

getOutputFormatClass

public final Class<? extends HiveOutputFormat> getOutputFormatClass()
                                                             throws HiveException
Throws:
HiveException

getBucketCount

public int getBucketCount()

getBucketCols

public List<String> getBucketCols()

getSortCols

public List<Order> getSortCols()

getSortColNames

public List<String> getSortColNames()

getBucketPath

public org.apache.hadoop.fs.Path getBucketPath(int bucketNum)
mapping from bucket number to bucket path


getPath

public org.apache.hadoop.fs.Path[] getPath(Sample s)
                                    throws HiveException
Throws:
HiveException

getSpec

public LinkedHashMap<String,String> getSpec()

toString

public String toString()
Overrides:
toString in class Object

getTable

public Table getTable()

setTable

public void setTable(Table table)
Should be only used by serialization.


getTPartition

public Partition getTPartition()
Should be only used by serialization.


setTPartition

public void setTPartition(Partition partition)
Should be only used by serialization.


getParameters

public Map<String,String> getParameters()

getCols

public List<FieldSchema> getCols()

getLocation

public String getLocation()

setLocation

public void setLocation(String location)

setValues

public void setValues(Map<String,String> partSpec)
               throws HiveException
Set Partition's values

Parameters:
partSpec - Partition specifications.
Throws:
HiveException - Thrown if we could not create the partition.

setProtectMode

public void setProtectMode(ProtectMode protectMode)
Parameters:
protectMode -

getProtectMode

public ProtectMode getProtectMode()
Returns:
protect mode

isOffline

public boolean isOffline()
Returns:
True protect mode indicates the partition if offline.

canDrop

public boolean canDrop()
Returns:
True if protect mode attribute of the partition indicate that it is OK to drop the table

canWrite

public boolean canWrite()
Returns:
True if protect mode attribute of the partition indicate that it is OK to write to the table

getCompleteName

public String getCompleteName()
Returns:
include the db name

getLastAccessTime

public int getLastAccessTime()

setLastAccessTime

public void setLastAccessTime(int lastAccessTime)

getSkewedColValues

public List<List<String>> getSkewedColValues()

getSkewedColNames

public List<String> getSkewedColNames()

setSkewedValueLocationMap

public void setSkewedValueLocationMap(List<String> valList,
                                      String dirName)
                               throws HiveException
Throws:
HiveException

getSkewedColValueLocationMaps

public Map<List<String>,String> getSkewedColValueLocationMaps()


Copyright © 2013 The Apache Software Foundation