Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TTL in directories #11498

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion velox/common/file/FileSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class LocalFileSystem : public FileSystem {
return filePaths;
}

void mkdir(std::string_view path) override {
void mkdir(std::string_view path, const DirectoryOptions& /*options*/)
override {
std::error_code ec;
std::filesystem::create_directories(path, ec);
VELOX_CHECK_EQ(
Expand Down
11 changes: 10 additions & 1 deletion velox/common/file/FileSystems.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ struct FileOptions {
bool bufferWrite{true};
};

/// Defines directory options
struct DirectoryOptions : FileOptions {
/// This is similar to kFileCreateConfig
static constexpr folly::StringPiece kMakeDirectoryConfig{
"make-directory-config"};
};

/// An abstract FileSystem
class FileSystem {
public:
Expand Down Expand Up @@ -113,7 +120,9 @@ class FileSystem {
virtual std::vector<std::string> list(std::string_view path) = 0;

/// Create a directory (recursively). Throws velox exception on failure.
virtual void mkdir(std::string_view path) = 0;
virtual void mkdir(
std::string_view path,
const DirectoryOptions& options = {}) = 0;

/// Remove a directory (all the files and sub-directories underneath
/// recursively). Throws velox exception on failure.
Expand Down
6 changes: 4 additions & 2 deletions velox/common/file/tests/FaultyFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ std::vector<std::string> FaultyFileSystem::list(std::string_view path) {
return files;
}

void FaultyFileSystem::mkdir(std::string_view path) {
void FaultyFileSystem::mkdir(
std::string_view path,
const DirectoryOptions& options) {
const auto delegatedDirPath = extractPath(path);
getFileSystem(delegatedDirPath, config_)->mkdir(delegatedDirPath);
getFileSystem(delegatedDirPath, config_)->mkdir(delegatedDirPath, options);
}

void FaultyFileSystem::rmdir(std::string_view path) {
Expand Down
2 changes: 1 addition & 1 deletion velox/common/file/tests/FaultyFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class FaultyFileSystem : public FileSystem {

std::vector<std::string> list(std::string_view path) override;

void mkdir(std::string_view path) override;
void mkdir(std::string_view path, const DirectoryOptions& options) override;

void rmdir(std::string_view path) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class AbfsFileSystem : public FileSystem {
VELOX_UNSUPPORTED("list for abfs not implemented");
}

void mkdir(std::string_view path) override {
void mkdir(
std::string_view path,
const filesystems::DirectoryOptions& options = {}) override {
VELOX_UNSUPPORTED("mkdir for abfs not implemented");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ void GcsFileSystem::rename(std::string_view, std::string_view, bool) {
VELOX_UNSUPPORTED("rename for GCS not implemented");
}

void GcsFileSystem::mkdir(std::string_view path) {
void GcsFileSystem::mkdir(
std::string_view path,
const DirectoryOptions& options) {
VELOX_UNSUPPORTED("mkdir for GCS not implemented");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class GcsFileSystem : public FileSystem {
void rename(std::string_view, std::string_view, bool) override;

/// Unsupported
void mkdir(std::string_view path) override;
void mkdir(std::string_view path, const DirectoryOptions& options = {})
override;

/// Unsupported
void rmdir(std::string_view path) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class HdfsFileSystem : public FileSystem {
VELOX_UNSUPPORTED("list for HDFS not implemented");
}

void mkdir(std::string_view path) override {
void mkdir(std::string_view path, const DirectoryOptions& options = {})
override {
VELOX_UNSUPPORTED("mkdir for HDFS not implemented");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class S3FileSystem : public FileSystem {
VELOX_UNSUPPORTED("list for S3 not implemented");
}

void mkdir(std::string_view path) override {
void mkdir(std::string_view path, const DirectoryOptions& options = {})
override {
VELOX_UNSUPPORTED("mkdir for S3 not implemented");
}

Expand Down
Loading