public class Warehouse extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DATABASE_WAREHOUSE_SUFFIX |
static String |
DEFAULT_CATALOG_COMMENT |
static String |
DEFAULT_CATALOG_NAME |
static String |
DEFAULT_DATABASE_COMMENT |
static String |
DEFAULT_DATABASE_NAME |
static String |
DEFAULT_SERIALIZATION_FORMAT |
static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
Warehouse(org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
boolean |
deleteDir(org.apache.hadoop.fs.Path f,
boolean recursive,
boolean ifPurge,
boolean needCmRecycle) |
boolean |
deleteDir(org.apache.hadoop.fs.Path f,
boolean recursive,
boolean ifPurge,
Database db) |
boolean |
deleteDir(org.apache.hadoop.fs.Path f,
boolean recursive,
Database db) |
org.apache.hadoop.fs.Path |
determineDatabasePath(Catalog cat,
Database db)
Build the database path based on catalog name and database name.
|
static String |
getCatalogQualifiedDbName(String catName,
String dbName) |
static String |
getCatalogQualifiedTableName(String catName,
String dbName,
String tableName)
Get table name in cat.db.table format.
|
static String |
getCatalogQualifiedTableName(Table table)
Get table name in cat.db.table format.
|
org.apache.hadoop.fs.Path |
getDatabasePath(Database db)
Get the path specified by the database.
|
org.apache.hadoop.fs.Path |
getDefaultDatabasePath(String dbName) |
org.apache.hadoop.fs.Path |
getDefaultExternalDatabasePath(String dbName) |
org.apache.hadoop.fs.Path |
getDefaultPartitionPath(Database db,
Table table,
Map<String,String> pm)
Returns the default partition path of a table within a given database and partition key value
pairs.
|
org.apache.hadoop.fs.Path |
getDefaultTablePath(Database db,
String tableName)
Deprecated.
|
org.apache.hadoop.fs.Path |
getDefaultTablePath(Database db,
String tableName,
boolean isExternal) |
org.apache.hadoop.fs.Path |
getDefaultTablePath(Database db,
Table table) |
org.apache.hadoop.fs.Path |
getDefaultTablePath(String dbName,
String tableName,
boolean isExternal) |
org.apache.hadoop.fs.Path |
getDnsPath(org.apache.hadoop.fs.Path path) |
static org.apache.hadoop.fs.Path |
getDnsPath(org.apache.hadoop.fs.Path path,
org.apache.hadoop.conf.Configuration conf)
Hadoop File System reverse lookups paths with raw ip addresses The File
System URI always contains the canonical DNS name of the Namenode.
|
List<org.apache.hadoop.fs.FileStatus> |
getFileStatusesForLocation(String location) |
List<org.apache.hadoop.fs.FileStatus> |
getFileStatusesForSD(StorageDescriptor desc) |
List<org.apache.hadoop.fs.FileStatus> |
getFileStatusesForUnpartitionedTable(Database db,
Table table) |
org.apache.hadoop.fs.FileSystem |
getFs(org.apache.hadoop.fs.Path f) |
static org.apache.hadoop.fs.FileSystem |
getFs(org.apache.hadoop.fs.Path f,
org.apache.hadoop.conf.Configuration conf)
Helper functions to convert IOException to MetaException
|
org.apache.hadoop.fs.Path |
getPartitionPath(Database db,
Table table,
List<String> vals)
Given a database, a table and the partition key value pairs this method returns the Path object
corresponding to the partition key value pairs.
|
org.apache.hadoop.fs.Path |
getPartitionPath(org.apache.hadoop.fs.Path tblPath,
Map<String,String> pm)
Returns the path object for the given partition key-value pairs and the base location
|
static List<String> |
getPartValuesFromPartName(String partName) |
static String |
getQualifiedName(Partition partition) |
static String |
getQualifiedName(String dbName,
String tableName) |
static String |
getQualifiedName(Table table) |
org.apache.hadoop.fs.Path |
getWhRoot()
Resolve the configured warehouse root dir with respect to the configuration
This involves opening the FileSystem corresponding to the warehouse root
dir (but that should be ok given that this is only called during DDL
statements for non-external tables).
|
org.apache.hadoop.fs.Path |
getWhRootExternal() |
boolean |
isDir(org.apache.hadoop.fs.Path f) |
boolean |
isEmpty(org.apache.hadoop.fs.Path path) |
boolean |
isWritable(org.apache.hadoop.fs.Path path) |
static String |
makeDynamicPartName(Map<String,String> spec)
Given a dynamic partition specification, return the path corresponding to the
static part of partition specification.
|
static Map<String,String> |
makeEscSpecFromName(String name) |
static String |
makePartName(List<FieldSchema> partCols,
List<String> vals) |
static String |
makePartName(List<FieldSchema> partCols,
List<String> vals,
String defaultStr)
Makes a valid partition name.
|
static String |
makePartName(Map<String,String> spec,
boolean addTrailingSeperator)
Makes a partition name from a specification
|
static String |
makePartPath(Map<String,String> spec)
Given a partition specification, return the path corresponding to the
partition spec.
|
static boolean |
makeSpecFromName(Map<String,String> partSpec,
org.apache.hadoop.fs.Path currPath,
Set<String> requiredKeys) |
static LinkedHashMap<String,String> |
makeSpecFromName(String name) |
static Map<String,String> |
makeSpecFromValues(List<FieldSchema> partCols,
List<String> values) |
static AbstractList<String> |
makeValsFromName(String name,
AbstractList<String> result)
Extracts values from partition name without the column names.
|
boolean |
mkdirs(org.apache.hadoop.fs.Path f) |
void |
recycleDirToCmPath(org.apache.hadoop.fs.Path f,
boolean ifPurge) |
boolean |
renameDir(org.apache.hadoop.fs.Path sourcePath,
org.apache.hadoop.fs.Path destPath,
boolean needCmRecycle) |
public static final String DEFAULT_CATALOG_NAME
public static final String DEFAULT_CATALOG_COMMENT
public static final String DEFAULT_DATABASE_NAME
public static final String DEFAULT_DATABASE_COMMENT
public static final String DEFAULT_SERIALIZATION_FORMAT
public static final String DATABASE_WAREHOUSE_SUFFIX
public static final org.slf4j.Logger LOG
public Warehouse(org.apache.hadoop.conf.Configuration conf) throws MetaException
MetaException
public static org.apache.hadoop.fs.FileSystem getFs(org.apache.hadoop.fs.Path f, org.apache.hadoop.conf.Configuration conf) throws MetaException
MetaException
public org.apache.hadoop.fs.FileSystem getFs(org.apache.hadoop.fs.Path f) throws MetaException
MetaException
public static org.apache.hadoop.fs.Path getDnsPath(org.apache.hadoop.fs.Path path, org.apache.hadoop.conf.Configuration conf) throws MetaException
path
- Path to be canonicalizedMetaException
public org.apache.hadoop.fs.Path getDnsPath(org.apache.hadoop.fs.Path path) throws MetaException
MetaException
public org.apache.hadoop.fs.Path getWhRoot() throws MetaException
MetaException
public org.apache.hadoop.fs.Path getWhRootExternal() throws MetaException
MetaException
public org.apache.hadoop.fs.Path determineDatabasePath(Catalog cat, Database db) throws MetaException
getDatabasePath(Database)
. If the passed in
database already has a path set that will be used. If not the location will be built using
catalog's path and the database name.cat
- catalog the database is indb
- database objectMetaException
- when the file path cannot be properly determined from the configured
file system.public org.apache.hadoop.fs.Path getDatabasePath(Database db) throws MetaException
db
- database to get the path ofMetaException
- when the file path cannot be properly determined from the configured
file system.public org.apache.hadoop.fs.Path getDefaultDatabasePath(String dbName) throws MetaException
MetaException
public org.apache.hadoop.fs.Path getDefaultExternalDatabasePath(String dbName) throws MetaException
MetaException
@Deprecated public org.apache.hadoop.fs.Path getDefaultTablePath(Database db, String tableName) throws MetaException
db
- Database where the table is createdtableName
- table nameMetaException
public org.apache.hadoop.fs.Path getDefaultTablePath(Database db, String tableName, boolean isExternal) throws MetaException
MetaException
public org.apache.hadoop.fs.Path getDefaultTablePath(String dbName, String tableName, boolean isExternal) throws MetaException
MetaException
public org.apache.hadoop.fs.Path getDefaultTablePath(Database db, Table table) throws MetaException
MetaException
public static String getCatalogQualifiedTableName(Table table)
table
- table objectpublic static String getCatalogQualifiedTableName(String catName, String dbName, String tableName)
catName
- catalog namedbName
- database nametableName
- table namepublic static String getCatalogQualifiedDbName(String catName, String dbName)
public boolean mkdirs(org.apache.hadoop.fs.Path f) throws MetaException
MetaException
public boolean renameDir(org.apache.hadoop.fs.Path sourcePath, org.apache.hadoop.fs.Path destPath, boolean needCmRecycle) throws MetaException
MetaException
public boolean deleteDir(org.apache.hadoop.fs.Path f, boolean recursive, Database db) throws MetaException
MetaException
public boolean deleteDir(org.apache.hadoop.fs.Path f, boolean recursive, boolean ifPurge, Database db) throws MetaException
MetaException
public boolean deleteDir(org.apache.hadoop.fs.Path f, boolean recursive, boolean ifPurge, boolean needCmRecycle) throws MetaException
MetaException
public void recycleDirToCmPath(org.apache.hadoop.fs.Path f, boolean ifPurge) throws MetaException
MetaException
public boolean isEmpty(org.apache.hadoop.fs.Path path) throws IOException, MetaException
IOException
MetaException
public boolean isWritable(org.apache.hadoop.fs.Path path) throws IOException
IOException
public static String makePartPath(Map<String,String> spec) throws MetaException
spec
- MetaException
public static String makePartName(Map<String,String> spec, boolean addTrailingSeperator) throws MetaException
spec
- addTrailingSeperator
- if true, adds a trailing separator e.g. 'ds=1/'MetaException
public static String makeDynamicPartName(Map<String,String> spec)
spec
- public static AbstractList<String> makeValsFromName(String name, AbstractList<String> result) throws MetaException
name
- Partition name.result
- The result. Must be pre-sized to the expected number of columns.MetaException
public static LinkedHashMap<String,String> makeSpecFromName(String name) throws MetaException
MetaException
public static boolean makeSpecFromName(Map<String,String> partSpec, org.apache.hadoop.fs.Path currPath, Set<String> requiredKeys)
public static Map<String,String> makeEscSpecFromName(String name) throws MetaException
MetaException
public org.apache.hadoop.fs.Path getDefaultPartitionPath(Database db, Table table, Map<String,String> pm) throws MetaException
db
- - parent database which is used to get the base location of the partition directorytable
- - table for the partitionspm
- - Partition key value pairsMetaException
public org.apache.hadoop.fs.Path getPartitionPath(org.apache.hadoop.fs.Path tblPath, Map<String,String> pm) throws MetaException
tblPath
- - the base location for the partitions. Typically the table locationpm
- - Partition key value pairsMetaException
public org.apache.hadoop.fs.Path getPartitionPath(Database db, Table table, List<String> vals) throws MetaException
db
- - Parent database of the given tabletable
- - Table for which the partition key-values are givenvals
- - List of values for the partition keysMetaException
public boolean isDir(org.apache.hadoop.fs.Path f) throws MetaException
MetaException
public static String makePartName(List<FieldSchema> partCols, List<String> vals) throws MetaException
MetaException
public List<org.apache.hadoop.fs.FileStatus> getFileStatusesForSD(StorageDescriptor desc) throws MetaException
desc
- MetaException
public List<org.apache.hadoop.fs.FileStatus> getFileStatusesForLocation(String location) throws MetaException
location
- MetaException
public List<org.apache.hadoop.fs.FileStatus> getFileStatusesForUnpartitionedTable(Database db, Table table) throws MetaException
db
- databasetable
- tableMetaException
public static String makePartName(List<FieldSchema> partCols, List<String> vals, String defaultStr) throws MetaException
partCols
- The partition columnsvals
- The partition valuesdefaultStr
- The default name given to a partition value if the respective value is empty or null.MetaException
public static List<String> getPartValuesFromPartName(String partName) throws MetaException
MetaException
Copyright © 2022 The Apache Software Foundation. All rights reserved.