-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: Allow custom S3 filesystem factory #17400
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
base: main
Are you sure you want to change the base?
Changes from all commits
31ed794
1e41a96
3c2c9b1
bab0b8a
8f25b5b
17d1401
956a515
19ebbe3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,11 +26,25 @@ | |
| return config->get<std::string>("hive.s3.endpoint").value(); | ||
| } | ||
|
|
||
| class CustomS3FileSystem : public S3FileSystem { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the customization, do we intend to override
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The factory hook is intended to customize the FileSystem/S3FileSystem instance, not override Impl. |
||
| public: | ||
| CustomS3FileSystem( | ||
| std::string_view bucketName, | ||
| std::shared_ptr<const config::ConfigBase> config) | ||
| : S3FileSystem(bucketName, config) {} | ||
|
Check warning on line 34 in velox/connectors/hive/storage_adapters/s3fs/tests/S3FileSystemRegistrationTest.cpp
|
||
| }; | ||
|
|
||
| std::shared_ptr<FileSystem> s3FileSystemFactory( | ||
| std::string bucketName, | ||
|
Check warning on line 38 in velox/connectors/hive/storage_adapters/s3fs/tests/S3FileSystemRegistrationTest.cpp
|
||
| std::shared_ptr<const config::ConfigBase> config) { | ||
|
Check warning on line 39 in velox/connectors/hive/storage_adapters/s3fs/tests/S3FileSystemRegistrationTest.cpp
|
||
| return std::make_shared<CustomS3FileSystem>(bucketName, config); | ||
| } | ||
|
|
||
| class S3FileSystemRegistrationTest : public S3Test { | ||
| protected: | ||
| static void SetUpTestCase() { | ||
| memory::MemoryManager::testingSetInstance(memory::MemoryManager::Options{}); | ||
| filesystems::registerS3FileSystem(cacheKeyFunc); | ||
| filesystems::registerS3FileSystem(cacheKeyFunc, s3FileSystemFactory); | ||
| } | ||
|
|
||
| static void TearDownTestCase() { | ||
|
|
@@ -85,6 +99,13 @@ | |
| ASSERT_EQ(s3fs, s3fs_new); | ||
| } | ||
|
|
||
| TEST_F(S3FileSystemRegistrationTest, customFileSystemFactory) { | ||
| auto hiveConfig = minioServer_->hiveConfig(); | ||
| auto s3fs = filesystems::getFileSystem(kDummyPath, hiveConfig); | ||
| auto customS3fs = std::dynamic_pointer_cast<CustomS3FileSystem>(s3fs); | ||
| VELOX_CHECK_NOT_NULL(customS3fs); | ||
| } | ||
|
|
||
| TEST_F(S3FileSystemRegistrationTest, finalize) { | ||
| auto hiveConfig = minioServer_->hiveConfig(); | ||
| auto s3fs = filesystems::getFileSystem(kDummyPath, hiveConfig); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check
fileSystemFactoryis not null before calling it.