forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(custom options to spill directories): Add ability to make par…
…ent spill directory with custom options Summary: Add ability to create the parent spill direction with custom options. We also add the ability for mkdir to decide whether or not to fail if a directory was created Differential Revision: D65964247
- Loading branch information
1 parent
3eb2fa4
commit 386f2cb
Showing
7 changed files
with
284 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <gmock/gmock.h> | ||
|
||
#include "velox/common/file/FileSystems.h" | ||
|
||
namespace facebook::velox::exec::test { | ||
|
||
class MockFilesystem : public filesystems::FileSystem { | ||
public: | ||
explicit MockFilesystem() : filesystems::FileSystem(nullptr){}; | ||
|
||
~MockFilesystem() override = default; | ||
|
||
MOCK_METHOD(std::string, name, (), (const, override)); | ||
|
||
MOCK_METHOD(std::string_view, extractPath, (std::string_view), (override)); | ||
|
||
MOCK_METHOD( | ||
std::unique_ptr<ReadFile>, | ||
openFileForRead, | ||
(std::string_view, const filesystems::FileOptions&), | ||
(override)); | ||
|
||
MOCK_METHOD( | ||
std::unique_ptr<WriteFile>, | ||
openFileForWrite, | ||
(std::string_view, const filesystems::FileOptions&), | ||
(override)); | ||
|
||
MOCK_METHOD(void, remove, (std::string_view), (override)); | ||
|
||
MOCK_METHOD( | ||
void, | ||
rename, | ||
(std::string_view, std::string_view, bool), | ||
(override)); | ||
|
||
MOCK_METHOD(bool, exists, (std::string_view), (override)); | ||
|
||
MOCK_METHOD(std::vector<std::string>, list, (std::string_view), (override)); | ||
|
||
MOCK_METHOD( | ||
void, | ||
mkdir, | ||
(std::string_view, const filesystems::DirectoryOptions&), | ||
(override)); | ||
|
||
MOCK_METHOD(void, rmdir, (std::string_view), (override)); | ||
|
||
static void registerMockFileSystem() { | ||
static std::string_view kMockFileSystemPrefix = "mock://"; | ||
std::function<bool(std::string_view)> filenameMatcher = | ||
[](std::string_view filename) { | ||
return filename.find(kMockFileSystemPrefix) == 0; | ||
}; | ||
|
||
std::function<std::shared_ptr<filesystems::FileSystem>( | ||
std::shared_ptr<const config::ConfigBase>, std::string_view)> | ||
fileSystemGenerator = | ||
[](std::shared_ptr<const config::ConfigBase>, | ||
std::string_view) -> std::shared_ptr<filesystems::FileSystem> { | ||
static std::shared_ptr<filesystems::FileSystem> mockFilesystem; | ||
static folly::once_flag fsInstantiationFlag; | ||
folly::call_once(fsInstantiationFlag, [&]() { | ||
mockFilesystem = std::make_shared<MockFilesystem>(); | ||
}); | ||
return mockFilesystem; | ||
}; | ||
|
||
facebook::velox::filesystems::registerFileSystem( | ||
std::move(filenameMatcher), fileSystemGenerator); | ||
} | ||
}; | ||
|
||
} // namespace facebook::velox::exec::test |