org.apache.hadoop.hive.ql.exec
Class ArchiveUtils

java.lang.Object
  extended by org.apache.hadoop.hive.ql.exec.ArchiveUtils

public final class ArchiveUtils
extends Object

ArchiveUtils.


Nested Class Summary
static class ArchiveUtils.HarPathHelper
          HarPathHelper helps to create har:/ URIs for locations inside of archive.
static class ArchiveUtils.PartSpecInfo
          PartSpecInfo keeps fields and values extracted from partial partition info which is prefix of the full info.
 
Field Summary
static String ARCHIVING_LEVEL
           
 
Constructor Summary
ArchiveUtils()
           
 
Method Summary
static String addSlash(String s)
           
static URI addSlash(URI u)
          Makes sure, that URI points to directory by adding slash to it.
static String conflictingArchiveNameOrNull(Hive db, Table tbl, LinkedHashMap<String,String> partSpec)
          Determines if one can insert into partition(s), or there's a conflict with archive.
static int getArchivingLevel(Partition p)
          Returns archiving level, which is how many fields were set in partial specification ARCHIVE was run for
static String getPartialName(Partition p, int level)
          Get a prefix of the given parition's string representation.
static boolean isArchived(Partition p)
          Determines whether a partition has been archived
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARCHIVING_LEVEL

public static String ARCHIVING_LEVEL
Constructor Detail

ArchiveUtils

public ArchiveUtils()
Method Detail

addSlash

public static String addSlash(String s)

addSlash

public static URI addSlash(URI u)
                    throws HiveException
Makes sure, that URI points to directory by adding slash to it. Useful in relativizing URIs.

Throws:
HiveException

isArchived

public static boolean isArchived(Partition p)
Determines whether a partition has been archived

Parameters:
p -
Returns:
is it archived?

getArchivingLevel

public static int getArchivingLevel(Partition p)
                             throws HiveException
Returns archiving level, which is how many fields were set in partial specification ARCHIVE was run for

Throws:
HiveException

getPartialName

public static String getPartialName(Partition p,
                                    int level)
                             throws HiveException
Get a prefix of the given parition's string representation. The sencond argument, level, is used for the prefix length. For example, partition (ds='2010-01-01', hr='00', min='00'), level 1 will reture 'ds=2010-01-01', and level 2 will return 'ds=2010-01-01/hr=00'.

Parameters:
p - partition object
level - level for prefix depth
Returns:
prefix of partition's string representation
Throws:
HiveException

conflictingArchiveNameOrNull

public static String conflictingArchiveNameOrNull(Hive db,
                                                  Table tbl,
                                                  LinkedHashMap<String,String> partSpec)
                                           throws HiveException
Determines if one can insert into partition(s), or there's a conflict with archive. It can be because partition is itself archived or it is to be created inside existing archive. The second case is when partition doesn't exist yet, but it would be inside of an archive if it existed. This one is quite tricky to check, we need to find at least one partition inside of the parent directory. If it is archived and archiving level tells that the archival was done of directory partition is in it means we cannot insert; otherwise we can. This method works both for full specifications and partial ones - in second case it checks if any partition that could possibly match such specification is inside archive.

Parameters:
db - - Hive object
tbl - - table where partition is
partSpec - - partition specification with possible nulls in case of dynamic partiton inserts
Returns:
null if partition can be inserted, string with colliding archive name when it can't
Throws:
HiveException


Copyright © 2014 The Apache Software Foundation. All rights reserved.