Package org.apache.iceberg.hadoop
Class HadoopCatalog
- java.lang.Object
- 
- org.apache.iceberg.BaseMetastoreCatalog
- 
- org.apache.iceberg.hadoop.HadoopCatalog
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.lang.AutoCloseable,- org.apache.hadoop.conf.Configurable,- Catalog,- SupportsNamespaces
 
 public class HadoopCatalog extends BaseMetastoreCatalog implements java.io.Closeable, SupportsNamespaces, org.apache.hadoop.conf.Configurable HadoopCatalog provides a way to use table names like db.table to work with path-based tables under a common location. It uses a specified directory under a specified filesystem as the warehouse directory, and organizes multiple levels directories that mapped to the database, namespace and the table respectively. The HadoopCatalog takes a location as the warehouse directory. When creating a table such as $db.$tbl, it creates $db/$tbl directory under the warehouse directory, and put the table metadata into that directory. The HadoopCatalog now supportsCatalog.createTable(org.apache.iceberg.catalog.TableIdentifier, org.apache.iceberg.Schema, org.apache.iceberg.PartitionSpec, java.lang.String, java.util.Map<java.lang.String, java.lang.String>),Catalog.dropTable(org.apache.iceberg.catalog.TableIdentifier), theCatalog.renameTable(org.apache.iceberg.catalog.TableIdentifier, org.apache.iceberg.catalog.TableIdentifier)is not supported yet. Note: The HadoopCatalog requires that the underlying file system supports atomic rename.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class org.apache.iceberg.BaseMetastoreCatalogBaseMetastoreCatalog.BaseMetastoreCatalogTableBuilder
 - 
Nested classes/interfaces inherited from interface org.apache.iceberg.catalog.CatalogCatalog.TableBuilder
 
- 
 - 
Constructor SummaryConstructors Constructor Description HadoopCatalog()HadoopCatalog(org.apache.hadoop.conf.Configuration conf, java.lang.String warehouseLocation)The constructor of the HadoopCatalog.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description Catalog.TableBuilderbuildTable(TableIdentifier identifier, Schema schema)/** Instantiate a builder to either create a table or start a create/replace transaction.voidclose()voidcreateNamespace(Namespace namespace, java.util.Map<java.lang.String,java.lang.String> meta)Create a namespace in the catalog.protected java.lang.StringdefaultWarehouseLocation(TableIdentifier tableIdentifier)booleandropNamespace(Namespace namespace)Drop a namespace.booleandropTable(TableIdentifier identifier, boolean purge)Drop a table; optionally delete data and metadata files.org.apache.hadoop.conf.ConfigurationgetConf()voidinitialize(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> properties)Initialize a catalog given a custom name and a map of catalog properties.protected booleanisValidIdentifier(TableIdentifier identifier)java.util.List<Namespace>listNamespaces(Namespace namespace)List namespaces from the namespace.java.util.List<TableIdentifier>listTables(Namespace namespace)Return all the identifiers under this namespace.java.util.Map<java.lang.String,java.lang.String>loadNamespaceMetadata(Namespace namespace)Load metadata properties for a namespace.java.lang.Stringname()Return the name for this catalog.protected TableOperationsnewTableOps(TableIdentifier identifier)booleanremoveProperties(Namespace namespace, java.util.Set<java.lang.String> properties)Remove a set of property keys from a namespace in the catalog.voidrenameTable(TableIdentifier from, TableIdentifier to)Rename a table.voidsetConf(org.apache.hadoop.conf.Configuration conf)booleansetProperties(Namespace namespace, java.util.Map<java.lang.String,java.lang.String> properties)Set a collection of properties on a namespace in the catalog.java.lang.StringtoString()- 
Methods inherited from class org.apache.iceberg.BaseMetastoreCatalogfullTableName, loadTable
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.iceberg.catalog.CatalogcreateTable, createTable, createTable, createTable, dropTable, invalidateTable, newCreateTableTransaction, newCreateTableTransaction, newCreateTableTransaction, newCreateTableTransaction, newReplaceTableTransaction, newReplaceTableTransaction, newReplaceTableTransaction, newReplaceTableTransaction, registerTable, tableExists
 - 
Methods inherited from interface org.apache.iceberg.catalog.SupportsNamespacescreateNamespace, listNamespaces, namespaceExists
 
- 
 
- 
- 
- 
Constructor Detail- 
HadoopCatalogpublic HadoopCatalog() 
 - 
HadoopCatalogpublic HadoopCatalog(org.apache.hadoop.conf.Configuration conf, java.lang.String warehouseLocation)The constructor of the HadoopCatalog. It uses the passed location as its warehouse directory.- Parameters:
- conf- The Hadoop configuration
- warehouseLocation- The location used as warehouse directory
 
 
- 
 - 
Method Detail- 
initializepublic void initialize(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> properties)Description copied from interface:CatalogInitialize a catalog given a custom name and a map of catalog properties.A custom Catalog implementation must have a no-arg constructor. A compute engine like Spark or Flink will first initialize the catalog without any arguments, and then call this method to complete catalog initialization with properties passed into the engine. - Specified by:
- initializein interface- Catalog
- Parameters:
- name- a custom name for the catalog
- properties- catalog properties
 
 - 
namepublic java.lang.String name() Description copied from interface:CatalogReturn the name for this catalog.
 - 
listTablespublic java.util.List<TableIdentifier> listTables(Namespace namespace) Description copied from interface:CatalogReturn all the identifiers under this namespace.- Specified by:
- listTablesin interface- Catalog
- Parameters:
- namespace- a namespace
- Returns:
- a list of identifiers for tables
 
 - 
isValidIdentifierprotected boolean isValidIdentifier(TableIdentifier identifier) - Overrides:
- isValidIdentifierin class- BaseMetastoreCatalog
 
 - 
newTableOpsprotected TableOperations newTableOps(TableIdentifier identifier) - Specified by:
- newTableOpsin class- BaseMetastoreCatalog
 
 - 
defaultWarehouseLocationprotected java.lang.String defaultWarehouseLocation(TableIdentifier tableIdentifier) - Specified by:
- defaultWarehouseLocationin class- BaseMetastoreCatalog
 
 - 
dropTablepublic boolean dropTable(TableIdentifier identifier, boolean purge) Description copied from interface:CatalogDrop a table; optionally delete data and metadata files.If purge is set to true the implementation should delete all data and metadata files. 
 - 
renameTablepublic void renameTable(TableIdentifier from, TableIdentifier to) Description copied from interface:CatalogRename a table.- Specified by:
- renameTablein interface- Catalog
- Parameters:
- from- identifier of the table to rename
- to- new table name
 
 - 
createNamespacepublic void createNamespace(Namespace namespace, java.util.Map<java.lang.String,java.lang.String> meta) Description copied from interface:SupportsNamespacesCreate a namespace in the catalog.- Specified by:
- createNamespacein interface- SupportsNamespaces
- Parameters:
- namespace- a multi-part namespace
- meta- a string Map of properties for the given namespace
 
 - 
listNamespacespublic java.util.List<Namespace> listNamespaces(Namespace namespace) Description copied from interface:SupportsNamespacesList namespaces from the namespace.For example, if table a.b.t exists, use 'SELECT NAMESPACE IN a' this method must return Namepace.of("a","b") Namespace.- Specified by:
- listNamespacesin interface- SupportsNamespaces
- Returns:
- a List of namespace Namespacenames
 
 - 
dropNamespacepublic boolean dropNamespace(Namespace namespace) Description copied from interface:SupportsNamespacesDrop a namespace. If the namespace exists and was dropped, this will return true.- Specified by:
- dropNamespacein interface- SupportsNamespaces
- Parameters:
- namespace- a namespace.- Namespace
- Returns:
- true if the namespace was dropped, false otherwise.
 
 - 
setPropertiespublic boolean setProperties(Namespace namespace, java.util.Map<java.lang.String,java.lang.String> properties) Description copied from interface:SupportsNamespacesSet a collection of properties on a namespace in the catalog.Properties that are not in the given map are not modified or removed by this method. - Specified by:
- setPropertiesin interface- SupportsNamespaces
- Parameters:
- namespace- a namespace.- Namespace
- properties- a collection of metadata to apply to the namespace
 
 - 
removePropertiespublic boolean removeProperties(Namespace namespace, java.util.Set<java.lang.String> properties) Description copied from interface:SupportsNamespacesRemove a set of property keys from a namespace in the catalog.Properties that are not in the given set are not modified or removed by this method. - Specified by:
- removePropertiesin interface- SupportsNamespaces
- Parameters:
- namespace- a namespace.- Namespace
- properties- a collection of metadata to apply to the namespace
 
 - 
loadNamespaceMetadatapublic java.util.Map<java.lang.String,java.lang.String> loadNamespaceMetadata(Namespace namespace) Description copied from interface:SupportsNamespacesLoad metadata properties for a namespace.- Specified by:
- loadNamespaceMetadatain interface- SupportsNamespaces
- Parameters:
- namespace- a namespace.- Namespace
- Returns:
- a string map of properties for the given namespace
 
 - 
closepublic void close() throws java.io.IOException- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Throws:
- java.io.IOException
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- BaseMetastoreCatalog
 
 - 
buildTablepublic Catalog.TableBuilder buildTable(TableIdentifier identifier, Schema schema) Description copied from interface:Catalog/** Instantiate a builder to either create a table or start a create/replace transaction.- Specified by:
- buildTablein interface- Catalog
- Overrides:
- buildTablein class- BaseMetastoreCatalog
- Parameters:
- identifier- a table identifier
- schema- a schema
- Returns:
- the builder to create a table or start a create/replace transaction
 
 - 
setConfpublic void setConf(org.apache.hadoop.conf.Configuration conf) - Specified by:
- setConfin interface- org.apache.hadoop.conf.Configurable
 
 - 
getConfpublic org.apache.hadoop.conf.Configuration getConf() - Specified by:
- getConfin interface- org.apache.hadoop.conf.Configurable
 
 
- 
 
-