Skip to content

Commit

Permalink
Add blobs in manifest and fix bugs (#36)
Browse files Browse the repository at this point in the history
Signed-off-by: sunby <[email protected]>
  • Loading branch information
sunby committed Aug 3, 2023
1 parent d6da825 commit b281238
Show file tree
Hide file tree
Showing 10 changed files with 804 additions and 8 deletions.
3 changes: 2 additions & 1 deletion cpp/src/common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ Result<std::shared_ptr<arrow::Schema>> FromProtobufSchema(const schema_proto::Ar

std::string GetNewParquetFilePath(const std::string& path) {
auto scalar_file_id = boost::uuids::random_generator()();
return path + boost::uuids::to_string(scalar_file_id) + kParquetDataFileSuffix;
return arrow::fs::internal::JoinAbstractPath(
std::vector<std::string_view>{path, boost::uuids::to_string(scalar_file_id) + kParquetDataFileSuffix});
}

std::string GetScalarDataDir(const std::string& path) {
Expand Down
23 changes: 23 additions & 0 deletions cpp/src/file/blob.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "blob.h"
#include <memory>
#include "proto/manifest.pb.h"

namespace milvus_storage {

std::unique_ptr<manifest_proto::Blob> Blob::ToProtobuf() const {
auto blob = std::make_unique<manifest_proto::Blob>();
blob->set_name(name);
blob->set_size(size);
blob->set_file(file);
return blob;
}

Blob Blob::FromProtobuf(const manifest_proto::Blob blob) {
Blob ret;
ret.name = blob.name();
ret.size = blob.size();
ret.file = blob.file();
return ret;
}

} // namespace milvus_storage
19 changes: 19 additions & 0 deletions cpp/src/file/blob.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <string>
#include <vector>
#include "proto/manifest.pb.h"
#include "common/result.h"

namespace milvus_storage {
struct Blob {
std::string name;
int64_t size;
std::string file;

[[nodiscard]] std::unique_ptr<manifest_proto::Blob> ToProtobuf() const;
static Blob FromProtobuf(const manifest_proto::Blob blob);
};

using BlobVector = std::vector<Blob>;
} // namespace milvus_storage
Loading

0 comments on commit b281238

Please sign in to comment.