Skip to content

Commit 427ac31

Browse files
yuandagitsfacebook-github-bot
authored andcommitted
Add support for TTL in directories (facebookincubator#11498)
Summary: Pull Request resolved: facebookincubator#11498 Support TTL for directories Reviewed By: xiaoxmeng Differential Revision: D65734798 fbshipit-source-id: 5082797b1fe82da495e2161514b2bdda118c724c
1 parent 99979c4 commit 427ac31

File tree

9 files changed

+29
-10
lines changed

9 files changed

+29
-10
lines changed

velox/common/file/FileSystems.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ class LocalFileSystem : public FileSystem {
163163
return filePaths;
164164
}
165165

166-
void mkdir(std::string_view path) override {
166+
void mkdir(std::string_view path, const DirectoryOptions& /*options*/)
167+
override {
167168
std::error_code ec;
168169
std::filesystem::create_directories(path, ec);
169170
VELOX_CHECK_EQ(

velox/common/file/FileSystems.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ struct FileOptions {
6666
bool bufferWrite{true};
6767
};
6868

69+
/// Defines directory options
70+
struct DirectoryOptions : FileOptions {
71+
/// This is similar to kFileCreateConfig
72+
static constexpr folly::StringPiece kMakeDirectoryConfig{
73+
"make-directory-config"};
74+
};
75+
6976
/// An abstract FileSystem
7077
class FileSystem {
7178
public:
@@ -113,7 +120,9 @@ class FileSystem {
113120
virtual std::vector<std::string> list(std::string_view path) = 0;
114121

115122
/// Create a directory (recursively). Throws velox exception on failure.
116-
virtual void mkdir(std::string_view path) = 0;
123+
virtual void mkdir(
124+
std::string_view path,
125+
const DirectoryOptions& options = {}) = 0;
117126

118127
/// Remove a directory (all the files and sub-directories underneath
119128
/// recursively). Throws velox exception on failure.

velox/common/file/tests/FaultyFileSystem.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ std::vector<std::string> FaultyFileSystem::list(std::string_view path) {
112112
return files;
113113
}
114114

115-
void FaultyFileSystem::mkdir(std::string_view path) {
115+
void FaultyFileSystem::mkdir(
116+
std::string_view path,
117+
const DirectoryOptions& options) {
116118
const auto delegatedDirPath = extractPath(path);
117-
getFileSystem(delegatedDirPath, config_)->mkdir(delegatedDirPath);
119+
getFileSystem(delegatedDirPath, config_)->mkdir(delegatedDirPath, options);
118120
}
119121

120122
void FaultyFileSystem::rmdir(std::string_view path) {

velox/common/file/tests/FaultyFileSystem.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class FaultyFileSystem : public FileSystem {
7171

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

74-
void mkdir(std::string_view path) override;
74+
void mkdir(std::string_view path, const DirectoryOptions& options) override;
7575

7676
void rmdir(std::string_view path) override;
7777

velox/connectors/hive/storage_adapters/abfs/AbfsFileSystem.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ class AbfsFileSystem : public FileSystem {
6666
VELOX_UNSUPPORTED("list for abfs not implemented");
6767
}
6868

69-
void mkdir(std::string_view path) override {
69+
void mkdir(
70+
std::string_view path,
71+
const filesystems::DirectoryOptions& options = {}) override {
7072
VELOX_UNSUPPORTED("mkdir for abfs not implemented");
7173
}
7274

velox/connectors/hive/storage_adapters/gcs/GcsFileSystem.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ void GcsFileSystem::rename(std::string_view, std::string_view, bool) {
433433
VELOX_UNSUPPORTED("rename for GCS not implemented");
434434
}
435435

436-
void GcsFileSystem::mkdir(std::string_view path) {
436+
void GcsFileSystem::mkdir(
437+
std::string_view path,
438+
const DirectoryOptions& options) {
437439
VELOX_UNSUPPORTED("mkdir for GCS not implemented");
438440
}
439441

velox/connectors/hive/storage_adapters/gcs/GcsFileSystem.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class GcsFileSystem : public FileSystem {
8181
void rename(std::string_view, std::string_view, bool) override;
8282

8383
/// Unsupported
84-
void mkdir(std::string_view path) override;
84+
void mkdir(std::string_view path, const DirectoryOptions& options = {})
85+
override;
8586

8687
/// Unsupported
8788
void rmdir(std::string_view path) override;

velox/connectors/hive/storage_adapters/hdfs/HdfsFileSystem.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class HdfsFileSystem : public FileSystem {
7878
VELOX_UNSUPPORTED("list for HDFS not implemented");
7979
}
8080

81-
void mkdir(std::string_view path) override {
81+
void mkdir(std::string_view path, const DirectoryOptions& options = {})
82+
override {
8283
VELOX_UNSUPPORTED("mkdir for HDFS not implemented");
8384
}
8485

velox/connectors/hive/storage_adapters/s3fs/S3FileSystem.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class S3FileSystem : public FileSystem {
6262
VELOX_UNSUPPORTED("list for S3 not implemented");
6363
}
6464

65-
void mkdir(std::string_view path) override {
65+
void mkdir(std::string_view path, const DirectoryOptions& options = {})
66+
override {
6667
VELOX_UNSUPPORTED("mkdir for S3 not implemented");
6768
}
6869

0 commit comments

Comments
 (0)