Class BaseMetastoreTableOperations
- java.lang.Object
-
- org.apache.iceberg.BaseMetastoreTableOperations
-
- All Implemented Interfaces:
TableOperations
- Direct Known Subclasses:
HiveTableOperations
public abstract class BaseMetastoreTableOperations extends java.lang.Object implements TableOperations
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringICEBERG_TABLE_TYPE_VALUEstatic java.lang.StringMETADATA_LOCATION_PROPstatic java.lang.StringPREVIOUS_METADATA_LOCATION_PROPstatic java.lang.StringTABLE_TYPE_PROP
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseMetastoreTableOperations()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit(TableMetadata base, TableMetadata metadata)Replace the base table metadata with a new version.TableMetadatacurrent()Return the currently loaded table metadata, without checking for updates.java.lang.StringcurrentMetadataLocation()intcurrentVersion()protected voiddoCommit(TableMetadata base, TableMetadata metadata)protected voiddoRefresh()LocationProviderlocationProvider()Returns aLocationProviderthat supplies locations for new new data files.java.lang.StringmetadataFileLocation(java.lang.String filename)Given the name of a metadata file, obtain the full path of that file using an appropriate base location of the implementation's choosing.TableMetadatarefresh()Return the current table metadata after checking for updates.protected voidrefreshFromMetadataLocation(java.lang.String newLocation)protected voidrefreshFromMetadataLocation(java.lang.String newLocation, int numRetries)protected voidrefreshFromMetadataLocation(java.lang.String newLocation, java.util.function.Predicate<java.lang.Exception> shouldRetry, int numRetries)protected voidrequestRefresh()TableOperationstemp(TableMetadata uncommittedMetadata)Return a temporaryTableOperationsinstance that uses configuration from uncommitted metadata.protected java.lang.StringwriteNewMetadata(TableMetadata metadata, int newVersion)-
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.TableOperations
encryption, io, newSnapshotId
-
-
-
-
Field Detail
-
TABLE_TYPE_PROP
public static final java.lang.String TABLE_TYPE_PROP
- See Also:
- Constant Field Values
-
ICEBERG_TABLE_TYPE_VALUE
public static final java.lang.String ICEBERG_TABLE_TYPE_VALUE
- See Also:
- Constant Field Values
-
METADATA_LOCATION_PROP
public static final java.lang.String METADATA_LOCATION_PROP
- See Also:
- Constant Field Values
-
PREVIOUS_METADATA_LOCATION_PROP
public static final java.lang.String PREVIOUS_METADATA_LOCATION_PROP
- See Also:
- Constant Field Values
-
-
Method Detail
-
current
public TableMetadata current()
Description copied from interface:TableOperationsReturn the currently loaded table metadata, without checking for updates.- Specified by:
currentin interfaceTableOperations- Returns:
- table metadata
-
currentMetadataLocation
public java.lang.String currentMetadataLocation()
-
currentVersion
public int currentVersion()
-
refresh
public TableMetadata refresh()
Description copied from interface:TableOperationsReturn the current table metadata after checking for updates.- Specified by:
refreshin interfaceTableOperations- Returns:
- table metadata
-
doRefresh
protected void doRefresh()
-
commit
public void commit(TableMetadata base, TableMetadata metadata)
Description copied from interface:TableOperationsReplace the base table metadata with a new version.This method should implement and document atomicity guarantees.
Implementations must check that the base metadata is current to avoid overwriting updates. Once the atomic commit operation succeeds, implementations must not perform any operations that may fail because failure in this method cannot be distinguished from commit failure.
- Specified by:
commitin interfaceTableOperations- Parameters:
base- table metadata on which changes were basedmetadata- new table metadata with updates
-
doCommit
protected void doCommit(TableMetadata base, TableMetadata metadata)
-
requestRefresh
protected void requestRefresh()
-
writeNewMetadata
protected java.lang.String writeNewMetadata(TableMetadata metadata, int newVersion)
-
refreshFromMetadataLocation
protected void refreshFromMetadataLocation(java.lang.String newLocation)
-
refreshFromMetadataLocation
protected void refreshFromMetadataLocation(java.lang.String newLocation, int numRetries)
-
refreshFromMetadataLocation
protected void refreshFromMetadataLocation(java.lang.String newLocation, java.util.function.Predicate<java.lang.Exception> shouldRetry, int numRetries)
-
metadataFileLocation
public java.lang.String metadataFileLocation(java.lang.String filename)
Description copied from interface:TableOperationsGiven the name of a metadata file, obtain the full path of that file using an appropriate base location of the implementation's choosing.The file may not exist yet, in which case the path should be returned as if it were to be created by e.g.
FileIO.newOutputFile(String).- Specified by:
metadataFileLocationin interfaceTableOperations
-
locationProvider
public LocationProvider locationProvider()
Description copied from interface:TableOperationsReturns aLocationProviderthat supplies locations for new new data files.- Specified by:
locationProviderin interfaceTableOperations- Returns:
- a location provider configured for the current table state
-
temp
public TableOperations temp(TableMetadata uncommittedMetadata)
Description copied from interface:TableOperationsReturn a temporaryTableOperationsinstance that uses configuration from uncommitted metadata.This is called by transactions when uncommitted table metadata should be used; for example, to create a metadata file location based on metadata in the transaction that has not been committed.
Transactions will not call
TableOperations.refresh()orTableOperations.commit(TableMetadata, TableMetadata).- Specified by:
tempin interfaceTableOperations- Parameters:
uncommittedMetadata- uncommitted table metadata- Returns:
- a temporary table operations that behaves like the uncommitted metadata is current
-
-