Class CatalogUtil
- java.lang.Object
-
- org.apache.iceberg.CatalogUtil
-
public class CatalogUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringICEBERG_CATALOG_GLUEstatic java.lang.StringICEBERG_CATALOG_HADOOPstatic java.lang.StringICEBERG_CATALOG_HIVEstatic java.lang.StringICEBERG_CATALOG_JDBCstatic java.lang.StringICEBERG_CATALOG_NESSIEstatic java.lang.StringICEBERG_CATALOG_RESTstatic java.lang.StringICEBERG_CATALOG_TYPEShortcut catalog property to load a catalog implementation through a short type name, instead of specifying a full java class throughCatalogProperties.CATALOG_IMPL.static java.lang.StringICEBERG_CATALOG_TYPE_GLUEstatic java.lang.StringICEBERG_CATALOG_TYPE_HADOOPstatic java.lang.StringICEBERG_CATALOG_TYPE_HIVEstatic java.lang.StringICEBERG_CATALOG_TYPE_JDBCstatic java.lang.StringICEBERG_CATALOG_TYPE_NESSIEstatic java.lang.StringICEBERG_CATALOG_TYPE_REST
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CatalogbuildIcebergCatalog(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> options, java.lang.Object conf)Build an IcebergCatalogbased on a map of catalog properties and optional Hadoop configuration.static voidconfigureHadoopConf(java.lang.Object maybeConfigurable, java.lang.Object conf)Dynamically detects whether an object is a Hadoop Configurable and calls setConf.static voiddeleteFiles(FileIO io, java.lang.Iterable<java.lang.String> files, java.lang.String type, boolean concurrent)Helper to delete files.static voiddeleteRemovedMetadataFiles(FileIO io, TableMetadata base, TableMetadata metadata)Deletes the oldest metadata files ifTableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLEDis true.static voiddropTableData(FileIO io, TableMetadata metadata)Drops all data and metadata files referenced by TableMetadata.static voiddropViewMetadata(FileIO io, ViewMetadata metadata)Drops view metadata files referenced by ViewMetadata.static java.lang.StringfullTableName(java.lang.String catalogName, TableIdentifier identifier)static CatalogloadCatalog(java.lang.String impl, java.lang.String catalogName, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.Object hadoopConf)Load a custom catalog implementation.static FileIOloadFileIO(java.lang.String impl, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.Object hadoopConf)Load a customFileIOimplementation.static MetricsReporterloadMetricsReporter(java.util.Map<java.lang.String,java.lang.String> properties)Load a customMetricsReporterimplementation.
-
-
-
Field Detail
-
ICEBERG_CATALOG_TYPE
public static final java.lang.String ICEBERG_CATALOG_TYPE
Shortcut catalog property to load a catalog implementation through a short type name, instead of specifying a full java class throughCatalogProperties.CATALOG_IMPL. Currently the following type to implementation mappings are supported:- hive: org.apache.iceberg.hive.HiveCatalog
- hadoop: org.apache.iceberg.hadoop.HadoopCatalog
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_TYPE_HADOOP
public static final java.lang.String ICEBERG_CATALOG_TYPE_HADOOP
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_TYPE_HIVE
public static final java.lang.String ICEBERG_CATALOG_TYPE_HIVE
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_TYPE_REST
public static final java.lang.String ICEBERG_CATALOG_TYPE_REST
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_TYPE_GLUE
public static final java.lang.String ICEBERG_CATALOG_TYPE_GLUE
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_TYPE_NESSIE
public static final java.lang.String ICEBERG_CATALOG_TYPE_NESSIE
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_TYPE_JDBC
public static final java.lang.String ICEBERG_CATALOG_TYPE_JDBC
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_HADOOP
public static final java.lang.String ICEBERG_CATALOG_HADOOP
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_HIVE
public static final java.lang.String ICEBERG_CATALOG_HIVE
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_REST
public static final java.lang.String ICEBERG_CATALOG_REST
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_GLUE
public static final java.lang.String ICEBERG_CATALOG_GLUE
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_NESSIE
public static final java.lang.String ICEBERG_CATALOG_NESSIE
- See Also:
- Constant Field Values
-
ICEBERG_CATALOG_JDBC
public static final java.lang.String ICEBERG_CATALOG_JDBC
- See Also:
- Constant Field Values
-
-
Method Detail
-
dropTableData
public static void dropTableData(FileIO io, TableMetadata metadata)
Drops all data and metadata files referenced by TableMetadata.This should be called by dropTable implementations to clean up table files once the table has been dropped in the metastore.
- Parameters:
io- a FileIO to use for deletesmetadata- the last valid TableMetadata instance for a dropped table.
-
dropViewMetadata
public static void dropViewMetadata(FileIO io, ViewMetadata metadata)
Drops view metadata files referenced by ViewMetadata.This should be called by dropView implementations
- Parameters:
io- a FileIO to use for deletesmetadata- the last valid ViewMetadata instance for a dropped view.
-
deleteFiles
public static void deleteFiles(FileIO io, java.lang.Iterable<java.lang.String> files, java.lang.String type, boolean concurrent)
Helper to delete files. Bulk deletion is used if possible.- Parameters:
io- FileIO for deletesfiles- files to deletetype- type of files being deletedconcurrent- controls concurrent deletion. Only applicable for non-bulk FileIO
-
loadCatalog
public static Catalog loadCatalog(java.lang.String impl, java.lang.String catalogName, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.Object hadoopConf)
Load a custom catalog implementation.The catalog must have a no-arg constructor. If the class implements Configurable, a Hadoop config will be passed using Configurable.setConf.
Catalog.initialize(String catalogName, Map options)is called to complete the initialization.- Parameters:
impl- catalog implementation full class namecatalogName- catalog nameproperties- catalog propertieshadoopConf- hadoop configuration if needed- Returns:
- initialized catalog object
- Throws:
java.lang.IllegalArgumentException- if no-arg constructor not found or error during initialization
-
buildIcebergCatalog
public static Catalog buildIcebergCatalog(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> options, java.lang.Object conf)
Build an IcebergCatalogbased on a map of catalog properties and optional Hadoop configuration.This method examines both the
ICEBERG_CATALOG_TYPEandCatalogProperties.CATALOG_IMPLproperties to determine the catalog implementation to load. If nothing is specified for both properties, Hive catalog will be loaded by default.- Parameters:
name- catalog nameoptions- catalog propertiesconf- a Hadoop Configuration- Returns:
- initialized catalog
-
loadFileIO
public static FileIO loadFileIO(java.lang.String impl, java.util.Map<java.lang.String,java.lang.String> properties, java.lang.Object hadoopConf)
Load a customFileIOimplementation.The implementation must have a no-arg constructor. If the class implements Configurable, a Hadoop config will be passed using Configurable.setConf.
FileIO.initialize(Map properties)is called to complete the initialization.- Parameters:
impl- full class name of a custom FileIO implementationproperties- used to initialize the FileIO implementationhadoopConf- a hadoop Configuration- Returns:
- FileIO class
- Throws:
java.lang.IllegalArgumentException- if class path not found or right constructor not found or the loaded class cannot be cast to the given interface type
-
configureHadoopConf
public static void configureHadoopConf(java.lang.Object maybeConfigurable, java.lang.Object conf)Dynamically detects whether an object is a Hadoop Configurable and calls setConf.- Parameters:
maybeConfigurable- an object that may be Configurableconf- a Configuration
-
loadMetricsReporter
public static MetricsReporter loadMetricsReporter(java.util.Map<java.lang.String,java.lang.String> properties)
Load a customMetricsReporterimplementation.The implementation must have a no-arg constructor.
- Parameters:
properties- catalog properties which contains class name of a customMetricsReporterimplementation- Returns:
- An initialized
MetricsReporter. - Throws:
java.lang.IllegalArgumentException- if class path not found or right constructor not found or the loaded class cannot be cast to the given interface type
-
fullTableName
public static java.lang.String fullTableName(java.lang.String catalogName, TableIdentifier identifier)
-
deleteRemovedMetadataFiles
public static void deleteRemovedMetadataFiles(FileIO io, TableMetadata base, TableMetadata metadata)
Deletes the oldest metadata files ifTableProperties.METADATA_DELETE_AFTER_COMMIT_ENABLEDis true.- Parameters:
io- FileIO instance to use for deletesbase- table metadata on which previous versions were basedmetadata- new table metadata with updated previous versions
-
-