Skip to content

Commit

Permalink
[Cpp] Pass path as output argument when BuildFileSystem
Browse files Browse the repository at this point in the history
Signed-off-by: sunby <[email protected]>
  • Loading branch information
sunby committed Oct 18, 2023
1 parent 3b03ad8 commit 747433e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cpp/include/milvus-storage/common/fs_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "result.h"
namespace milvus_storage {

Result<std::shared_ptr<arrow::fs::FileSystem>> BuildFileSystem(const std::string& uri);
Result<std::shared_ptr<arrow::fs::FileSystem>> BuildFileSystem(const std::string& uri, std::string* out_path = nullptr);

std::string UriToPath(const std::string& uri);

Expand Down
9 changes: 5 additions & 4 deletions cpp/src/common/fs_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
#include "common/macro.h"
namespace milvus_storage {

Result<std::shared_ptr<arrow::fs::FileSystem>> BuildFileSystem(const std::string& uri) {
Result<std::shared_ptr<arrow::fs::FileSystem>> BuildFileSystem(const std::string& uri,
std::string* out_path) {
arrow::internal::Uri uri_parser;
RETURN_ARROW_NOT_OK(uri_parser.Parse(uri));
auto schema = uri_parser.scheme();
if (schema == "file") {
auto output_path = uri_parser.path();
ASSIGN_OR_RETURN_ARROW_NOT_OK(auto option, arrow::fs::LocalFileSystemOptions::FromUri(uri_parser, &output_path));
// auto output_path = uri_parser.path();
ASSIGN_OR_RETURN_ARROW_NOT_OK(auto option, arrow::fs::LocalFileSystemOptions::FromUri(uri_parser, out_path));
return std::shared_ptr<arrow::fs::FileSystem>(new arrow::fs::LocalFileSystem(option));
}

Expand All @@ -34,7 +35,7 @@ Result<std::shared_ptr<arrow::fs::FileSystem>> BuildFileSystem(const std::string
}
});
}
ASSIGN_OR_RETURN_ARROW_NOT_OK(auto option, arrow::fs::S3Options::FromUri(uri_parser));
ASSIGN_OR_RETURN_ARROW_NOT_OK(auto option, arrow::fs::S3Options::FromUri(uri_parser, out_path));
ASSIGN_OR_RETURN_ARROW_NOT_OK(auto fs, arrow::fs::S3FileSystem::Make(option));

return std::shared_ptr<arrow::fs::FileSystem>(fs);
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/storage/space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,9 @@ Result<std::unique_ptr<Space>> Space::Open(const std::string& uri, Options optio
std::string path;
std::atomic_int64_t next_manifest_version = 1;

ASSIGN_OR_RETURN_NOT_OK(fs, BuildFileSystem(uri));
arrow::internal::Uri uri_parser;
RETURN_ARROW_NOT_OK(uri_parser.Parse(uri));
path = uri_parser.path();
ASSIGN_OR_RETURN_NOT_OK(fs, BuildFileSystem(uri, &path));

LOG_STORAGE_INFO_ << "Open space: " << path;
RETURN_ARROW_NOT_OK(fs->CreateDir(GetManifestDir(path)));
RETURN_ARROW_NOT_OK(fs->CreateDir(GetScalarDataDir(path)));
RETURN_ARROW_NOT_OK(fs->CreateDir(GetVectorDataDir(path)));
Expand Down

0 comments on commit 747433e

Please sign in to comment.