Package org.apache.iceberg.rest
Class RESTSessionCatalog
- java.lang.Object
-
- org.apache.iceberg.catalog.BaseSessionCatalog
-
- org.apache.iceberg.rest.RESTSessionCatalog
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,SessionCatalog,Configurable<java.lang.Object>
public class RESTSessionCatalog extends BaseSessionCatalog implements Configurable<java.lang.Object>, java.io.Closeable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.iceberg.catalog.BaseSessionCatalog
BaseSessionCatalog.AsCatalog
-
Nested classes/interfaces inherited from interface org.apache.iceberg.catalog.SessionCatalog
SessionCatalog.SessionContext
-
-
Constructor Summary
Constructors Constructor Description RESTSessionCatalog()RESTSessionCatalog(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,RESTClient> clientBuilder, java.util.function.BiFunction<SessionCatalog.SessionContext,java.util.Map<java.lang.String,java.lang.String>,FileIO> ioBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Catalog.TableBuilderbuildTable(SessionCatalog.SessionContext context, TableIdentifier identifier, Schema schema)Create a builder to create a table or start a create/replace transaction.voidclose()voidcommitTransaction(SessionCatalog.SessionContext context, java.util.List<TableCommit> commits)voidcreateNamespace(SessionCatalog.SessionContext context, Namespace namespace, java.util.Map<java.lang.String,java.lang.String> metadata)Create a namespace in the catalog.booleandropNamespace(SessionCatalog.SessionContext context, Namespace ns)Drop a namespace.booleandropTable(SessionCatalog.SessionContext context, TableIdentifier identifier)Drop a table, without requesting that files are immediately deleted.voidinitialize(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> unresolved)Initialize given a custom name and a map of catalog properties.voidinvalidateTable(SessionCatalog.SessionContext context, TableIdentifier ident)Invalidate cached table metadata from current catalog.java.util.List<Namespace>listNamespaces(SessionCatalog.SessionContext context, Namespace namespace)List child namespaces from the namespace.java.util.List<TableIdentifier>listTables(SessionCatalog.SessionContext context, Namespace ns)Return all the identifiers under this namespace.java.util.Map<java.lang.String,java.lang.String>loadNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns)Load metadata properties for a namespace.TableloadTable(SessionCatalog.SessionContext context, TableIdentifier identifier)Load a table.booleanpurgeTable(SessionCatalog.SessionContext context, TableIdentifier identifier)Drop a table and request that files are immediately deleted.TableregisterTable(SessionCatalog.SessionContext context, TableIdentifier ident, java.lang.String metadataFileLocation)Register a table if it does not exist.voidrenameTable(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to)Rename a table.voidsetConf(java.lang.Object newConf)booleanupdateNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns, java.util.Map<java.lang.String,java.lang.String> updates, java.util.Set<java.lang.String> removals)Set a collection of properties on a namespace in the catalog.-
Methods inherited from class org.apache.iceberg.catalog.BaseSessionCatalog
asCatalog, name, properties, withContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.iceberg.catalog.SessionCatalog
createNamespace, listNamespaces, namespaceExists, tableExists
-
-
-
-
Constructor Detail
-
RESTSessionCatalog
public RESTSessionCatalog()
-
RESTSessionCatalog
public RESTSessionCatalog(java.util.function.Function<java.util.Map<java.lang.String,java.lang.String>,RESTClient> clientBuilder, java.util.function.BiFunction<SessionCatalog.SessionContext,java.util.Map<java.lang.String,java.lang.String>,FileIO> ioBuilder)
-
-
Method Detail
-
initialize
public void initialize(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> unresolved)Description copied from interface:SessionCatalogInitialize given a custom name and a map of catalog properties.- Specified by:
initializein interfaceSessionCatalog- Overrides:
initializein classBaseSessionCatalog- Parameters:
name- a custom name for the catalogunresolved- catalog properties
-
setConf
public void setConf(java.lang.Object newConf)
- Specified by:
setConfin interfaceConfigurable<java.lang.Object>
-
listTables
public java.util.List<TableIdentifier> listTables(SessionCatalog.SessionContext context, Namespace ns)
Description copied from interface:SessionCatalogReturn all the identifiers under this namespace.- Specified by:
listTablesin interfaceSessionCatalog- Parameters:
context- session contextns- a namespace- Returns:
- a list of identifiers for tables
-
dropTable
public boolean dropTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:SessionCatalogDrop a table, without requesting that files are immediately deleted.Data and metadata files should be deleted according to the catalog's policy.
- Specified by:
dropTablein interfaceSessionCatalog- Parameters:
context- session contextidentifier- a table identifier- Returns:
- true if the table was dropped, false if the table did not exist
-
purgeTable
public boolean purgeTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:SessionCatalogDrop a table and request that files are immediately deleted.- Specified by:
purgeTablein interfaceSessionCatalog- Parameters:
context- session contextidentifier- a table identifier- Returns:
- true if the table was dropped and purged, false if the table did not exist
-
renameTable
public void renameTable(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to)
Description copied from interface:SessionCatalogRename a table.- Specified by:
renameTablein interfaceSessionCatalog- Parameters:
context- session contextfrom- identifier of the table to renameto- new table name
-
loadTable
public Table loadTable(SessionCatalog.SessionContext context, TableIdentifier identifier)
Description copied from interface:SessionCatalogLoad a table.- Specified by:
loadTablein interfaceSessionCatalog- Parameters:
context- session contextidentifier- a table identifier- Returns:
- instance of
Tableimplementation referred bytableIdentifier
-
buildTable
public Catalog.TableBuilder buildTable(SessionCatalog.SessionContext context, TableIdentifier identifier, Schema schema)
Description copied from interface:SessionCatalogCreate a builder to create a table or start a create/replace transaction.- Specified by:
buildTablein interfaceSessionCatalog- Parameters:
context- session contextidentifier- a table identifierschema- a schema- Returns:
- the builder to create a table or start a create/replace transaction
-
invalidateTable
public void invalidateTable(SessionCatalog.SessionContext context, TableIdentifier ident)
Description copied from interface:SessionCatalogInvalidate cached table metadata from current catalog.If the table is already loaded or cached, drop cached data. If the table does not exist or is not cached, do nothing.
- Specified by:
invalidateTablein interfaceSessionCatalog- Parameters:
context- session contextident- a table identifier
-
registerTable
public Table registerTable(SessionCatalog.SessionContext context, TableIdentifier ident, java.lang.String metadataFileLocation)
Description copied from interface:SessionCatalogRegister a table if it does not exist.- Specified by:
registerTablein interfaceSessionCatalog- Parameters:
context- session contextident- a table identifiermetadataFileLocation- the location of a metadata file- Returns:
- a Table instance
-
createNamespace
public void createNamespace(SessionCatalog.SessionContext context, Namespace namespace, java.util.Map<java.lang.String,java.lang.String> metadata)
Description copied from interface:SessionCatalogCreate a namespace in the catalog.- Specified by:
createNamespacein interfaceSessionCatalog- Parameters:
context- session contextnamespace- anamespacemetadata- a string Map of properties for the given namespace
-
listNamespaces
public java.util.List<Namespace> listNamespaces(SessionCatalog.SessionContext context, Namespace namespace)
Description copied from interface:SessionCatalogList child namespaces from the namespace.For two existing tables named 'a.b.c.table' and 'a.b.d.table', this method returns:
- Given:
Namespace.empty() - Returns:
Namespace.of("a")
- Given:
Namespace.of("a") - Returns:
Namespace.of("a", "b")
- Given:
Namespace.of("a", "b") - Returns:
Namespace.of("a", "b", "c")andNamespace.of("a", "b", "d")
- Given:
Namespace.of("a", "b", "c") - Returns: empty list, because there are no child namespaces
- Specified by:
listNamespacesin interfaceSessionCatalog- Parameters:
context- session contextnamespace- anamespace- Returns:
- a List of child
Namespacenames from the given namespace
- Given:
-
loadNamespaceMetadata
public java.util.Map<java.lang.String,java.lang.String> loadNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns)
Description copied from interface:SessionCatalogLoad metadata properties for a namespace.- Specified by:
loadNamespaceMetadatain interfaceSessionCatalog- Parameters:
context- session contextns- anamespace- Returns:
- a string map of properties for the given namespace
-
dropNamespace
public boolean dropNamespace(SessionCatalog.SessionContext context, Namespace ns)
Description copied from interface:SessionCatalogDrop a namespace. If the namespace exists and was dropped, this will return true.- Specified by:
dropNamespacein interfaceSessionCatalog- Parameters:
context- session contextns- anamespace- Returns:
- true if the namespace was dropped, false otherwise.
-
updateNamespaceMetadata
public boolean updateNamespaceMetadata(SessionCatalog.SessionContext context, Namespace ns, java.util.Map<java.lang.String,java.lang.String> updates, java.util.Set<java.lang.String> removals)
Description copied from interface:SessionCatalogSet 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:
updateNamespaceMetadatain interfaceSessionCatalog- Parameters:
context- session contextns- anamespaceupdates- properties to set for the namespaceremovals- properties to remove from the namespace
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
commitTransaction
public void commitTransaction(SessionCatalog.SessionContext context, java.util.List<TableCommit> commits)
-
-