public abstract class BaseMetastoreTableOperations extends java.lang.Object implements TableOperations
Modifier and Type | Class and Description |
---|---|
protected static class |
BaseMetastoreTableOperations.CommitStatus |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ICEBERG_TABLE_TYPE_VALUE |
static java.lang.String |
METADATA_LOCATION_PROP |
static java.lang.String |
PREVIOUS_METADATA_LOCATION_PROP |
static java.lang.String |
TABLE_TYPE_PROP |
Modifier | Constructor and Description |
---|---|
protected |
BaseMetastoreTableOperations() |
Modifier and Type | Method and Description |
---|---|
protected BaseMetastoreTableOperations.CommitStatus |
checkCommitStatus(java.lang.String newMetadataLocation,
TableMetadata config)
Attempt to load the table and see if any current or past metadata location matches the one we
were attempting to set.
|
void |
commit(TableMetadata base,
TableMetadata metadata)
Replace the base table metadata with a new version.
|
TableMetadata |
current()
Return the currently loaded table metadata, without checking for updates.
|
java.lang.String |
currentMetadataLocation() |
int |
currentVersion() |
protected void |
disableRefresh() |
protected void |
doCommit(TableMetadata base,
TableMetadata metadata) |
protected void |
doRefresh() |
LocationProvider |
locationProvider()
Returns a
LocationProvider that supplies locations for new new data files. |
java.lang.String |
metadataFileLocation(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.
|
TableMetadata |
refresh()
Return the current table metadata after checking for updates.
|
protected void |
refreshFromMetadataLocation(java.lang.String newLocation) |
protected void |
refreshFromMetadataLocation(java.lang.String newLocation,
int numRetries) |
protected void |
refreshFromMetadataLocation(java.lang.String newLocation,
java.util.function.Predicate<java.lang.Exception> shouldRetry,
int numRetries) |
protected void |
refreshFromMetadataLocation(java.lang.String newLocation,
java.util.function.Predicate<java.lang.Exception> shouldRetry,
int numRetries,
java.util.function.Function<java.lang.String,TableMetadata> metadataLoader) |
protected void |
requestRefresh() |
protected abstract java.lang.String |
tableName()
The full name of the table used for logging purposes only.
|
TableOperations |
temp(TableMetadata uncommittedMetadata)
Return a temporary
TableOperations instance that uses configuration from uncommitted
metadata. |
protected java.lang.String |
writeNewMetadata(TableMetadata metadata,
int newVersion) |
protected java.lang.String |
writeNewMetadataIfRequired(boolean newTable,
TableMetadata metadata) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
encryption, io, newSnapshotId
public static final java.lang.String TABLE_TYPE_PROP
public static final java.lang.String ICEBERG_TABLE_TYPE_VALUE
public static final java.lang.String METADATA_LOCATION_PROP
public static final java.lang.String PREVIOUS_METADATA_LOCATION_PROP
protected abstract java.lang.String tableName()
public TableMetadata current()
TableOperations
current
in interface TableOperations
public java.lang.String currentMetadataLocation()
public int currentVersion()
public TableMetadata refresh()
TableOperations
refresh
in interface TableOperations
protected void doRefresh()
public void commit(TableMetadata base, TableMetadata metadata)
TableOperations
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.
Implementations must throw a CommitStateUnknownException
in cases where it cannot be
determined if the commit succeeded or failed. For example if a network partition causes the
confirmation of the commit to be lost, the implementation should throw a
CommitStateUnknownException. This is important because downstream users of this API need to
know whether they can clean up the commit or not, if the state is unknown then it is not safe
to remove any files. All other exceptions will be treated as if the commit has failed.
commit
in interface TableOperations
base
- table metadata on which changes were basedmetadata
- new table metadata with updatesprotected void doCommit(TableMetadata base, TableMetadata metadata)
protected void requestRefresh()
protected void disableRefresh()
protected java.lang.String writeNewMetadataIfRequired(boolean newTable, TableMetadata metadata)
protected java.lang.String writeNewMetadata(TableMetadata metadata, int newVersion)
protected void refreshFromMetadataLocation(java.lang.String newLocation)
protected void refreshFromMetadataLocation(java.lang.String newLocation, int numRetries)
protected void refreshFromMetadataLocation(java.lang.String newLocation, java.util.function.Predicate<java.lang.Exception> shouldRetry, int numRetries)
protected void refreshFromMetadataLocation(java.lang.String newLocation, java.util.function.Predicate<java.lang.Exception> shouldRetry, int numRetries, java.util.function.Function<java.lang.String,TableMetadata> metadataLoader)
public java.lang.String metadataFileLocation(java.lang.String filename)
TableOperations
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)
.
metadataFileLocation
in interface TableOperations
public LocationProvider locationProvider()
TableOperations
LocationProvider
that supplies locations for new new data files.locationProvider
in interface TableOperations
public TableOperations temp(TableMetadata uncommittedMetadata)
TableOperations
TableOperations
instance 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()
or TableOperations.commit(TableMetadata,
TableMetadata)
.
temp
in interface TableOperations
uncommittedMetadata
- uncommitted table metadataprotected BaseMetastoreTableOperations.CommitStatus checkCommitStatus(java.lang.String newMetadataLocation, TableMetadata config)
newMetadataLocation
- the path of the new commit fileconfig
- metadata to use for configuration