Package org.apache.iceberg
Class RewriteTablePathUtil
java.lang.Object
org.apache.iceberg.RewriteTablePathUtil
Utilities for Rewrite table path action.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Class providing engine-specific methods to read and write position delete files.static class
Rewrite result. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic String
combinePaths
(String absolutePath, String relativePath) Combine a base and relative path.static String
Returns the file name of a path.static String
static String
Replace path referencestatic String
relativize
(String path, String prefix) Relativize a path.static TableMetadata
replacePaths
(TableMetadata metadata, String sourcePrefix, String targetPrefix) Create a new table metadata object, replacing path referencesrewriteDataManifest
(ManifestFile manifestFile, OutputFile outputFile, FileIO io, int format, Map<Integer, PartitionSpec> specsById, String sourcePrefix, String targetPrefix) Rewrite a data manifest, replacing path references.rewriteDeleteManifest
(ManifestFile manifestFile, OutputFile outputFile, FileIO io, int format, Map<Integer, PartitionSpec> specsById, String sourcePrefix, String targetPrefix, String stagingLocation) Rewrite a delete manifest, replacing path references.rewriteManifestList
(Snapshot snapshot, FileIO io, TableMetadata tableMetadata, Set<String> manifestsToRewrite, String sourcePrefix, String targetPrefix, String stagingDir, String outputPath) Rewrite a manifest list representing a snapshot, replacing path references.static void
rewritePositionDeleteFile
(DeleteFile deleteFile, OutputFile outputFile, FileIO io, PartitionSpec spec, String sourcePrefix, String targetPrefix, RewriteTablePathUtil.PositionDeleteReaderWriter posDeleteReaderWriter) Rewrite a position delete file, replacing path references.static String
stagingPath
(String originalPath, String stagingDir) Construct a staging path under a given staging directory
-
Field Details
-
FILE_SEPARATOR
- See Also:
-
-
Method Details
-
replacePaths
public static TableMetadata replacePaths(TableMetadata metadata, String sourcePrefix, String targetPrefix) Create a new table metadata object, replacing path references- Parameters:
metadata
- source table metadatasourcePrefix
- source prefix that will be replacedtargetPrefix
- target prefix that will replace it- Returns:
- copy of table metadata with paths replaced
-
rewriteManifestList
public static RewriteTablePathUtil.RewriteResult<ManifestFile> rewriteManifestList(Snapshot snapshot, FileIO io, TableMetadata tableMetadata, Set<String> manifestsToRewrite, String sourcePrefix, String targetPrefix, String stagingDir, String outputPath) Rewrite a manifest list representing a snapshot, replacing path references.- Parameters:
snapshot
- snapshot represented by the manifest listio
- file iotableMetadata
- metadata of tablemanifestsToRewrite
- a list of manifest files to filter for rewritesourcePrefix
- source prefix that will be replacedtargetPrefix
- target prefix that will replace itstagingDir
- staging directoryoutputPath
- location to write the manifest list- Returns:
- a copy plan for manifest files whose metadata were contained in the rewritten manifest list
-
rewriteDataManifest
public static RewriteTablePathUtil.RewriteResult<DataFile> rewriteDataManifest(ManifestFile manifestFile, OutputFile outputFile, FileIO io, int format, Map<Integer, PartitionSpec> specsById, String sourcePrefix, String targetPrefix) throws IOExceptionRewrite a data manifest, replacing path references.- Parameters:
manifestFile
- source manifest file to rewriteoutputFile
- output file to rewrite manifest file toio
- file ioformat
- format of the manifest filespecsById
- map of partition specs by idsourcePrefix
- source prefix that will be replacedtargetPrefix
- target prefix that will replace it- Returns:
- a copy plan of content files in the manifest that was rewritten
- Throws:
IOException
-
rewriteDeleteManifest
public static RewriteTablePathUtil.RewriteResult<DeleteFile> rewriteDeleteManifest(ManifestFile manifestFile, OutputFile outputFile, FileIO io, int format, Map<Integer, PartitionSpec> specsById, String sourcePrefix, String targetPrefix, String stagingLocation) throws IOExceptionRewrite a delete manifest, replacing path references.- Parameters:
manifestFile
- source delete manifest to rewriteoutputFile
- output file to rewrite manifest file toio
- file ioformat
- format of the manifest filespecsById
- map of partition specs by idsourcePrefix
- source prefix that will be replacedtargetPrefix
- target prefix that will replace itstagingLocation
- staging location for rewritten files (referred delete file will be rewritten here)- Returns:
- a copy plan of content files in the manifest that was rewritten
- Throws:
IOException
-
rewritePositionDeleteFile
public static void rewritePositionDeleteFile(DeleteFile deleteFile, OutputFile outputFile, FileIO io, PartitionSpec spec, String sourcePrefix, String targetPrefix, RewriteTablePathUtil.PositionDeleteReaderWriter posDeleteReaderWriter) throws IOException Rewrite a position delete file, replacing path references.- Parameters:
deleteFile
- source delete file to be rewrittenoutputFile
- output file to rewrite delete file toio
- file iospec
- spec of delete filesourcePrefix
- source prefix that will be replacedtargetPrefix
- target prefix to replace itposDeleteReaderWriter
- class to read and write position delete files- Throws:
IOException
-
newPath
Replace path reference- Parameters:
path
- path referencesourcePrefix
- source prefix that will be replacedtargetPrefix
- target prefix that will replace it- Returns:
- new path reference
-
combinePaths
Combine a base and relative path. -
fileName
Returns the file name of a path. -
relativize
Relativize a path. -
maybeAppendFileSeparator
-
stagingPath
Construct a staging path under a given staging directory- Parameters:
originalPath
- source pathstagingDir
- staging directory- Returns:
- a staging path under the staging directory, based on the original path
-