Skip to content

Commit

Permalink
feat: Add setting/getting properties on directories. (facebookincubat…
Browse files Browse the repository at this point in the history
…or#12247)

Summary:

We'd like to set/get properties on directories if the remote filesystem supports APIs like TTL. In POSIX, this would be similar to ioctl.

Simply expose a property bag for which users can use for setting key-value pairs for the set path, and on the get path, only support getting a single key for now. If the key is not present, nullopt is returned.

Differential Revision: D68650034
  • Loading branch information
yuandagits authored and facebook-github-bot committed Feb 3, 2025
1 parent a8ea2c9 commit 0d0efb0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions velox/common/file/FileSystems.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ struct FileOptions {
/// filesystem on Unix-like operating system, this corresponds to the direct
/// IO mode if set.
bool bufferIo{true};

/// Property bag to set onto files/directories. Think something similar to
/// ioctl(2). For other remote filesystems, this can be PutObjectTagging in
/// S3.
std::optional<std::unordered_map<std::string, std::string>> properties{
std::nullopt};
};

/// Defines directory options
Expand Down Expand Up @@ -144,6 +150,22 @@ class FileSystem {
/// recursively). Throws velox exception on failure.
virtual void rmdir(std::string_view path) = 0;

/// Sets the property for a directory. The user provides the key-value pairs
/// inside 'properties' field of options. Throws velox exception on failure.
virtual void setDirectoryProperty(
std::string_view /*path*/,
const DirectoryOptions& options = {}) {
VELOX_UNSUPPORTED("setDirectoryProperty not implemented");
}

/// Gets the property for a directory. If no property is found, std::nullopt
/// is returned. Throws velox exception on failure.
virtual std::optional<std::string> getDirectoryProperty(
std::string_view /*path*/,
std::string_view /*propertyKey*/) {
VELOX_UNSUPPORTED("getDirectoryProperty not implemented");
}

protected:
std::shared_ptr<const config::ConfigBase> config_;
};
Expand Down

0 comments on commit 0d0efb0

Please sign in to comment.