-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: record memory size (uncompressed) item for index
Signed-off-by: chyezh <[email protected]>
- Loading branch information
Showing
64 changed files
with
1,499 additions
and
1,323 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "common/protobuf_utils.h" | ||
#include "common/protobuf_utils_c.h" | ||
|
||
static_assert( | ||
sizeof(milvus::ProtoLayout) == sizeof(ProtoLayout), | ||
"Size of milvus::ProtoLayout is not equal to size of ProtoLayoutInterface"); | ||
|
||
static_assert(alignof(milvus::ProtoLayout) == alignof(ProtoLayout), | ||
"Alignment of milvus::ProtoLayout is not equal to alignment of " | ||
"ProtoLayoutInterface"); | ||
|
||
ProtoLayoutInterface | ||
CreateProtoLayout() { | ||
auto ptr = new milvus::ProtoLayout(); | ||
return reinterpret_cast<ProtoLayoutInterface>(ptr); | ||
} | ||
|
||
void | ||
ReleaseProtoLayout(ProtoLayoutInterface proto) { | ||
delete reinterpret_cast<milvus::ProtoLayout*>(proto); | ||
} |
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,22 @@ | ||
#pragma once | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct ProtoLayout { | ||
void* blob; | ||
size_t size; | ||
} ProtoLayout; | ||
|
||
typedef ProtoLayout* ProtoLayoutInterface; | ||
|
||
ProtoLayoutInterface | ||
CreateProtoLayout(); | ||
|
||
void | ||
ReleaseProtoLayout(ProtoLayoutInterface proto); | ||
|
||
#ifdef __cplusplus | ||
} | ||
|
||
#endif |
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,53 @@ | ||
#include "index/CreateIndexResult.h" | ||
|
||
namespace milvus::index { | ||
CreateIndexResult::CreateIndexResult( | ||
int64_t mem_size, | ||
std::vector<SerializedIndexFileInfo>&& serialized_index_infos) | ||
: mem_size_(mem_size), serialized_index_infos_(serialized_index_infos) { | ||
} | ||
|
||
void | ||
CreateIndexResult::AppendSerializedIndexFileInfo( | ||
SerializedIndexFileInfo&& info) { | ||
serialized_index_infos_.push_back(std::move(info)); | ||
} | ||
|
||
void | ||
CreateIndexResult::SerializeAt(milvus::ProtoLayout* layout) { | ||
milvus::proto::cgo::CreateIndexResult result; | ||
result.set_mem_size(mem_size_); | ||
for (auto& info : serialized_index_infos_) { | ||
auto serialized_info = result.add_serialized_index_infos(); | ||
serialized_info->set_file_name(info.file_name); | ||
serialized_info->set_file_size(info.file_size); | ||
} | ||
layout->Initialize(result.ByteSizeLong()); | ||
AssertInfo(result.SerializeToArray(layout->blob, layout->size), | ||
"unmarshal CreateIndexResult failed"); | ||
} | ||
|
||
std::vector<std::string> | ||
CreateIndexResult::GetIndexFiles() const { | ||
std::vector<std::string> files; | ||
for (auto& info : serialized_index_infos_) { | ||
files.push_back(info.file_name); | ||
} | ||
return files; | ||
} | ||
|
||
int64_t | ||
CreateIndexResult::GetMemSize() const { | ||
return mem_size_; | ||
} | ||
|
||
int64_t | ||
CreateIndexResult::GetSerializedSize() const { | ||
int64_t size = 0; | ||
for (auto& info : serialized_index_infos_) { | ||
size += info.file_size; | ||
} | ||
return size; | ||
} | ||
|
||
} // namespace milvus::index |
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,48 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
#include "common/protobuf_utils.h" | ||
#include "pb/cgo_msg.pb.h" | ||
|
||
namespace milvus::index { | ||
|
||
class SerializedIndexFileInfo { | ||
public: | ||
SerializedIndexFileInfo(const std::string& file_name, int64_t file_size) | ||
: file_name(file_name), file_size(file_size) { | ||
} | ||
|
||
std::string file_name; | ||
int64_t file_size; | ||
}; | ||
|
||
class CreateIndexResult { | ||
public: | ||
CreateIndexResult( | ||
int64_t mem_size, | ||
std::vector<SerializedIndexFileInfo>&& serialized_index_infos); | ||
|
||
void | ||
AppendSerializedIndexFileInfo(SerializedIndexFileInfo&& info); | ||
|
||
void | ||
SerializeAt(milvus::ProtoLayout* layout); | ||
|
||
std::vector<std::string> | ||
GetIndexFiles() const; | ||
|
||
int64_t | ||
GetMemSize() const; | ||
|
||
int64_t | ||
GetSerializedSize() const; | ||
|
||
private: | ||
int64_t mem_size_; | ||
std::vector<SerializedIndexFileInfo> serialized_index_infos_; | ||
}; | ||
|
||
using CreateIndexResultPtr = std::unique_ptr<CreateIndexResult>; | ||
|
||
} // namespace milvus::index |
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
Oops, something went wrong.