Skip to content

Commit

Permalink
feat: Introduce extraFileInfo and readRangeHint (facebookincubator#12501
Browse files Browse the repository at this point in the history
)

Summary:

Introduce extraFileInfo and readRangeHint as options in fileOptions. This allows the underlying backend filesystem to use these for opening files with customizable options.

Differential Revision: D70365576
  • Loading branch information
yuandagits authored and facebook-github-bot committed Mar 1, 2025
1 parent ffc6237 commit 8e5c5ee
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions velox/common/file/FileSystems.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ struct FileOptions {
std::nullopt};

File::IoStats* stats{nullptr};

/// A raw string that client can encode as anything they want to describe the
/// file.
std::optional<std::string> extraFileInfo{std::nullopt};

/// A hint to the file system for which region of the file should be read.
std::optional<int64_t> readRangeHint{std::nullopt};
};

/// Defines directory options
Expand Down
12 changes: 12 additions & 0 deletions velox/common/file/tests/FaultyFileSystemOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct FaultFileOperation : public BaseFaultOperation {
struct FaultFileSystemOperation : public BaseFaultOperation {
enum class Type {
kMkdir = 0,
kOpenFileForRead = 1,
/// TODO: Add support for fileSystem operations.
};
FaultFileSystemOperation(Type _type, const std::string& _path)
Expand Down Expand Up @@ -166,6 +167,17 @@ struct FaultFileWriteOperation : FaultFileOperation {
length(_length) {}
};

/// Fault injection parameters for file system openFileForRead API.
struct FaultFileSystemOpenFileForReadOperation : FaultFileSystemOperation {
FileOptions options;

FaultFileSystemOpenFileForReadOperation(
const std::string& _path,
const FileOptions& _options)
: FaultFileSystemOperation(Type::kOpenFileForRead, _path),
options(_options) {}
};

/// Fault injection parameters for file system mkdir API.
struct FaultFileSystemMkdirOperation : FaultFileSystemOperation {
DirectoryOptions options;
Expand Down
2 changes: 2 additions & 0 deletions velox/connectors/hive/FileHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ std::unique_ptr<FileHandle> FileHandleGenerator::operator()(
options.stats = stats;
if (properties) {
options.fileSize = properties->fileSize;
options.readRangeHint = properties->readRangeHint;
options.extraFileInfo = properties->extraFileInfo;
}
fileHandle->file = filesystems::getFileSystem(filename, properties_)
->openFileForRead(filename, options);
Expand Down
2 changes: 2 additions & 0 deletions velox/connectors/hive/FileProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace facebook::velox {
struct FileProperties {
std::optional<int64_t> fileSize;
std::optional<int64_t> modificationTime;
std::optional<int64_t> readRangeHint;
std::optional<std::string> extraFileInfo;
};

} // namespace facebook::velox

0 comments on commit 8e5c5ee

Please sign in to comment.