public class FSUtils extends Object
| Constructor and Description |
|---|
FSUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.hadoop.fs.Path |
addSchemeIfLocalPath(String path) |
static int |
computeNextLogVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path partitionPath,
String fileId,
String logFileExtension,
String baseCommitTime)
computes the next log version for the specified fileId in the partition path.
|
static String |
createNewFileIdPfx()
Returns a new unique prefix for creating a file group.
|
static void |
createPathIfNotExists(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path partitionPath) |
static void |
deleteInstantFile(org.apache.hadoop.fs.FileSystem fs,
String metaPath,
HoodieInstant instant) |
static org.apache.hadoop.fs.FileStatus[] |
getAllDataFilesInPartition(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path partitionPath)
Get the names of all the base and log files in the given partition path.
|
static List<String> |
getAllFoldersWithPartitionMetaFile(org.apache.hadoop.fs.FileSystem fs,
String basePathStr)
Obtain all the partition paths, that are present in this table, denoted by presence of
HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE. |
static Stream<HoodieLogFile> |
getAllLogFiles(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path partitionPath,
String fileId,
String logFileExtension,
String baseCommitTime)
Get all the log files for the passed in FileId in the partition path.
|
static List<String> |
getAllPartitionFoldersThreeLevelsDown(org.apache.hadoop.fs.FileSystem fs,
String basePath)
Gets all partition paths assuming date partitioning (year, month, day) three levels down.
|
static List<String> |
getAllPartitionPaths(HoodieEngineContext engineContext,
HoodieMetadataConfig metadataConfig,
String basePathStr) |
static List<String> |
getAllPartitionPaths(HoodieEngineContext engineContext,
String basePathStr,
boolean useFileListingFromMetadata,
boolean verifyListings,
boolean assumeDatePartitioning) |
static String |
getBaseCommitTimeFromLogPath(org.apache.hadoop.fs.Path path)
Get the first part of the file name in the log file.
|
static String |
getCommitFromCommitFile(String commitFileName) |
static String |
getCommitTime(String fullFileName) |
static int |
getDefaultBufferSize(org.apache.hadoop.fs.FileSystem fs) |
static Short |
getDefaultReplication(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path) |
static String |
getDFSFullPartitionPath(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path fullPartitionPath)
Get DFS full partition path (e.g.
|
static String |
getFileExtension(String fullName) |
static String |
getFileExtensionFromLog(org.apache.hadoop.fs.Path logPath)
Get the file extension from the log file.
|
static String |
getFileId(String fullFileName) |
static String |
getFileIdFromFilePath(org.apache.hadoop.fs.Path filePath)
Check if the file is a parquet file of a log file.
|
static String |
getFileIdFromLogPath(org.apache.hadoop.fs.Path path)
Get the first part of the file name in the log file.
|
static long |
getFileSize(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path) |
static int |
getFileVersionFromLog(org.apache.hadoop.fs.Path logPath)
Get the last part of the file name in the log file and convert to int.
|
static org.apache.hadoop.fs.FileSystem |
getFs(String path,
org.apache.hadoop.conf.Configuration conf) |
static org.apache.hadoop.fs.FileSystem |
getFs(String path,
org.apache.hadoop.conf.Configuration conf,
boolean localByDefault) |
static HoodieWrapperFileSystem |
getFs(String path,
SerializableConfiguration hadoopConf,
ConsistencyGuardConfig consistencyGuardConfig)
Get the FS implementation for this table.
|
static List<org.apache.hadoop.fs.FileStatus> |
getGlobStatusExcludingMetaFolder(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path globPath)
Helper to filter out paths under metadata folder when running fs.globStatus.
|
static Option<HoodieLogFile> |
getLatestLogFile(Stream<HoodieLogFile> logFiles)
Get the latest log file written from the list of log files passed in.
|
static Option<Pair<Integer,String>> |
getLatestLogVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path partitionPath,
String fileId,
String logFileExtension,
String baseCommitTime)
Get the latest log version for the fileId in the partition path.
|
static org.apache.hadoop.fs.Path |
getPartitionPath(org.apache.hadoop.fs.Path basePath,
String partitionPath) |
static org.apache.hadoop.fs.Path |
getPartitionPath(String basePath,
String partitionPath) |
static String |
getRelativePartitionPath(org.apache.hadoop.fs.Path basePath,
org.apache.hadoop.fs.Path fullPartitionPath)
Given a base partition and a partition path, return relative path of partition path to the base path.
|
static Long |
getSizeInMB(long sizeInBytes) |
static Integer |
getStageIdFromLogPath(org.apache.hadoop.fs.Path path)
Get StageId used in log-path.
|
static Integer |
getTaskAttemptIdFromLogPath(org.apache.hadoop.fs.Path path)
Get Task Attempt Id used in log-path.
|
static Integer |
getTaskPartitionIdFromLogPath(org.apache.hadoop.fs.Path path)
Get TaskPartitionId used in log-path.
|
static String |
getWriteTokenFromLogPath(org.apache.hadoop.fs.Path path)
Get Write-Token used in log-path.
|
static boolean |
isGCSFileSystem(org.apache.hadoop.fs.FileSystem fs)
This is due to HUDI-140 GCS has a different behavior for detecting EOF during seek().
|
static boolean |
isLogFile(org.apache.hadoop.fs.Path logPath) |
static String |
makeBootstrapIndexFileName(String instantTime,
String fileId,
String ext) |
static String |
makeDataFileName(String instantTime,
String writeToken,
String fileId) |
static String |
makeDataFileName(String instantTime,
String writeToken,
String fileId,
String fileExtension) |
static String |
makeLogFileName(String fileId,
String logFileExtension,
String baseCommitTime,
int version,
String writeToken) |
static String |
makeWriteToken(int taskPartitionId,
int stageId,
long taskAttemptId)
A write token uniquely identifies an attempt at one of the IOHandle operations (Merge/Create/Append).
|
static String |
maskWithoutFileId(String instantTime,
int taskPartitionId) |
static org.apache.hadoop.conf.Configuration |
prepareHadoopConf(org.apache.hadoop.conf.Configuration conf) |
static void |
processFiles(org.apache.hadoop.fs.FileSystem fs,
String basePathStr,
Function<org.apache.hadoop.fs.FileStatus,Boolean> consumer,
boolean excludeMetaFolder)
Recursively processes all files in the base-path.
|
static boolean |
recoverDFSFileLease(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path p)
When a file was opened and the task died without closing the stream, another task executor cannot open because the
existing lease will be active.
|
static org.apache.hadoop.conf.Configuration |
registerFileSystem(org.apache.hadoop.fs.Path file,
org.apache.hadoop.conf.Configuration conf) |
public static org.apache.hadoop.conf.Configuration prepareHadoopConf(org.apache.hadoop.conf.Configuration conf)
public static org.apache.hadoop.fs.FileSystem getFs(String path, org.apache.hadoop.conf.Configuration conf)
public static org.apache.hadoop.fs.FileSystem getFs(String path, org.apache.hadoop.conf.Configuration conf, boolean localByDefault)
public static org.apache.hadoop.fs.Path addSchemeIfLocalPath(String path)
public static String makeWriteToken(int taskPartitionId, int stageId, long taskAttemptId)
public static String makeDataFileName(String instantTime, String writeToken, String fileId)
public static String makeDataFileName(String instantTime, String writeToken, String fileId, String fileExtension)
public static String makeBootstrapIndexFileName(String instantTime, String fileId, String ext)
public static long getFileSize(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path path)
throws IOException
IOExceptionpublic static List<String> getAllPartitionFoldersThreeLevelsDown(org.apache.hadoop.fs.FileSystem fs, String basePath) throws IOException
IOExceptionpublic static String getRelativePartitionPath(org.apache.hadoop.fs.Path basePath, org.apache.hadoop.fs.Path fullPartitionPath)
public static List<String> getAllFoldersWithPartitionMetaFile(org.apache.hadoop.fs.FileSystem fs, String basePathStr) throws IOException
HoodiePartitionMetadata.HOODIE_PARTITION_METAFILE.
If the basePathStr is a subdirectory of .hoodie folder then we assume that the partitions of an internal
table (a hoodie table within the .hoodie directory) are to be obtained.fs - FileSystem instancebasePathStr - base directoryIOExceptionpublic static void processFiles(org.apache.hadoop.fs.FileSystem fs,
String basePathStr,
Function<org.apache.hadoop.fs.FileStatus,Boolean> consumer,
boolean excludeMetaFolder)
throws IOException
fs - File SystembasePathStr - Base-Pathconsumer - Callback for processingexcludeMetaFolder - Exclude .hoodie folderIOException - -public static List<String> getAllPartitionPaths(HoodieEngineContext engineContext, String basePathStr, boolean useFileListingFromMetadata, boolean verifyListings, boolean assumeDatePartitioning)
public static List<String> getAllPartitionPaths(HoodieEngineContext engineContext, HoodieMetadataConfig metadataConfig, String basePathStr)
public static String createNewFileIdPfx()
public static String getFileExtensionFromLog(org.apache.hadoop.fs.Path logPath)
public static String getFileIdFromLogPath(org.apache.hadoop.fs.Path path)
public static String getFileIdFromFilePath(org.apache.hadoop.fs.Path filePath)
public static String getBaseCommitTimeFromLogPath(org.apache.hadoop.fs.Path path)
public static Integer getTaskPartitionIdFromLogPath(org.apache.hadoop.fs.Path path)
public static String getWriteTokenFromLogPath(org.apache.hadoop.fs.Path path)
public static Integer getStageIdFromLogPath(org.apache.hadoop.fs.Path path)
public static Integer getTaskAttemptIdFromLogPath(org.apache.hadoop.fs.Path path)
public static int getFileVersionFromLog(org.apache.hadoop.fs.Path logPath)
public static String makeLogFileName(String fileId, String logFileExtension, String baseCommitTime, int version, String writeToken)
public static boolean isLogFile(org.apache.hadoop.fs.Path logPath)
public static org.apache.hadoop.fs.FileStatus[] getAllDataFilesInPartition(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path partitionPath)
throws IOException
IOExceptionpublic static Option<HoodieLogFile> getLatestLogFile(Stream<HoodieLogFile> logFiles)
public static Stream<HoodieLogFile> getAllLogFiles(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path partitionPath, String fileId, String logFileExtension, String baseCommitTime) throws IOException
IOExceptionpublic static Option<Pair<Integer,String>> getLatestLogVersion(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path partitionPath, String fileId, String logFileExtension, String baseCommitTime) throws IOException
IOExceptionpublic static int computeNextLogVersion(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path partitionPath,
String fileId,
String logFileExtension,
String baseCommitTime)
throws IOException
IOExceptionpublic static int getDefaultBufferSize(org.apache.hadoop.fs.FileSystem fs)
public static Short getDefaultReplication(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path)
public static boolean recoverDFSFileLease(org.apache.hadoop.hdfs.DistributedFileSystem dfs,
org.apache.hadoop.fs.Path p)
throws IOException,
InterruptedException
IOExceptionInterruptedExceptionpublic static void deleteInstantFile(org.apache.hadoop.fs.FileSystem fs,
String metaPath,
HoodieInstant instant)
public static void createPathIfNotExists(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path partitionPath)
throws IOException
IOExceptionpublic static Long getSizeInMB(long sizeInBytes)
public static org.apache.hadoop.fs.Path getPartitionPath(String basePath, String partitionPath)
public static org.apache.hadoop.fs.Path getPartitionPath(org.apache.hadoop.fs.Path basePath,
String partitionPath)
public static String getDFSFullPartitionPath(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path fullPartitionPath)
public static boolean isGCSFileSystem(org.apache.hadoop.fs.FileSystem fs)
fs - fileSystem instance.public static org.apache.hadoop.conf.Configuration registerFileSystem(org.apache.hadoop.fs.Path file,
org.apache.hadoop.conf.Configuration conf)
public static HoodieWrapperFileSystem getFs(String path, SerializableConfiguration hadoopConf, ConsistencyGuardConfig consistencyGuardConfig)
path - Path StringhadoopConf - Serializable Hadoop ConfigurationconsistencyGuardConfig - Consistency Guard Configpublic static List<org.apache.hadoop.fs.FileStatus> getGlobStatusExcludingMetaFolder(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path globPath) throws IOException
fs - File SystemglobPath - Glob PathIOException - when having trouble listing the pathCopyright © 2021 The Apache Software Foundation. All rights reserved.