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:
AuthorizationPreEventListener.PartitionWrapper, 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, org.apache.hadoop.hive.metastore.api.Partition tp)
           
 
Method Summary
 boolean canDrop()
           
 boolean canWrite()
           
static org.apache.hadoop.hive.metastore.api.StorageDescriptor cloneSd(Table tbl)
          We already have methods that clone stuff using XML or Kryo.
static org.apache.hadoop.hive.metastore.api.Partition createMetaPartitionObject(Table tbl, Map<String,String> partSpec, org.apache.hadoop.fs.Path location)
           
 List<String> getBucketCols()
           
 int getBucketCount()
           
 org.apache.hadoop.fs.Path getBucketPath(int bucketNum)
          mapping from bucket number to bucket path
 List<org.apache.hadoop.hive.metastore.api.FieldSchema> getCols()
           
 String getCompleteName()
           
 org.apache.hadoop.fs.Path getDataLocation()
           
 Deserializer getDeserializer()
           
 Class<? extends org.apache.hadoop.mapred.InputFormat> getInputFormatClass()
           
 int getLastAccessTime()
           
 String getLocation()
           
 Properties getMetadataFromPartitionSchema()
           
 String getName()
           
 Class<? extends HiveOutputFormat> getOutputFormatClass()
           
 Map<String,String> getParameters()
           
 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<org.apache.hadoop.hive.metastore.api.Order> getSortCols()
           
 org.apache.hadoop.fs.FileStatus[] getSortedPaths()
          get all paths for this partition in a sorted manner
 LinkedHashMap<String,String> getSpec()
           
 Table getTable()
           
 org.apache.hadoop.hive.metastore.api.Partition getTPartition()
          Should be only used by serialization.
 List<String> getValues()
           
 boolean isOffline()
           
 boolean isStoredAsSubDirectories()
           
 void setBucketCount(int newBucketNum)
           
 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(org.apache.hadoop.hive.metastore.api.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
equals, 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,
                 org.apache.hadoop.hive.metastore.api.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()

createMetaPartitionObject

public static org.apache.hadoop.hive.metastore.api.Partition createMetaPartitionObject(Table tbl,
                                                                                       Map<String,String> partSpec,
                                                                                       org.apache.hadoop.fs.Path location)
                                                                                throws HiveException
Throws:
HiveException

cloneSd

public static org.apache.hadoop.hive.metastore.api.StorageDescriptor cloneSd(Table tbl)
                                                                      throws HiveException
We already have methods that clone stuff using XML or Kryo. And now for something completely different - let's clone SD using Thrift! Refactored into a method.

Throws:
HiveException

getName

public String getName()

getPath

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

getDataLocation

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

getDeserializer

public final Deserializer getDeserializer()

getSchema

public Properties getSchema()

getMetadataFromPartitionSchema

public Properties getMetadataFromPartitionSchema()

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()

setBucketCount

public void setBucketCount(int newBucketNum)

getBucketCols

public List<String> getBucketCols()

getSortCols

public List<org.apache.hadoop.hive.metastore.api.Order> getSortCols()

getSortColNames

public List<String> getSortColNames()

getSortedPaths

public org.apache.hadoop.fs.FileStatus[] getSortedPaths()
get all paths for this partition in a sorted manner


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 org.apache.hadoop.hive.metastore.api.Partition getTPartition()
Should be only used by serialization.


setTPartition

public void setTPartition(org.apache.hadoop.hive.metastore.api.Partition partition)
Should be only used by serialization.


getParameters

public Map<String,String> getParameters()

getCols

public List<org.apache.hadoop.hive.metastore.api.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)

isStoredAsSubDirectories

public boolean isStoredAsSubDirectories()

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 © 2014 The Apache Software Foundation. All rights reserved.