提交 3393090d 编写于 作者: W wxyu

MS-640 Cache object size calculate incorrect


Former-commit-id: 63dfa23d1aef9cec5597a2aeecb2a0c73800882d
上级 75de7e19
...@@ -13,6 +13,7 @@ Please mark all change in change log and use the ticket from JIRA. ...@@ -13,6 +13,7 @@ Please mark all change in change log and use the ticket from JIRA.
- MS-601 - Docker logs error caused by get CPUTemperature error - MS-601 - Docker logs error caused by get CPUTemperature error
- MS-622 - Delete vectors should be failed if date range is invalid - MS-622 - Delete vectors should be failed if date range is invalid
- MS-620 - Get table row counts display wrong error code - MS-620 - Get table row counts display wrong error code
- MS-640 - Cache object size calculate incorrect
## Improvement ## Improvement
- MS-552 - Add and change the easylogging library - MS-552 - Add and change the easylogging library
......
...@@ -37,9 +37,17 @@ namespace engine { ...@@ -37,9 +37,17 @@ namespace engine {
int64_t int64_t
VecIndex::Size() { VecIndex::Size() {
if (size_ != 0) {
return size_;
}
return Count() * Dimension() * sizeof(float); return Count() * Dimension() * sizeof(float);
} }
void
VecIndex::set_size(int64_t size) {
size_ = size;
}
struct FileIOReader { struct FileIOReader {
std::fstream fs; std::fstream fs;
std::string name; std::string name;
...@@ -157,9 +165,10 @@ GetVecIndexFactory(const IndexType& type, const Config& cfg) { ...@@ -157,9 +165,10 @@ GetVecIndexFactory(const IndexType& type, const Config& cfg) {
} }
VecIndexPtr VecIndexPtr
LoadVecIndex(const IndexType& index_type, const knowhere::BinarySet& index_binary) { LoadVecIndex(const IndexType& index_type, const knowhere::BinarySet& index_binary, int64_t size) {
auto index = GetVecIndexFactory(index_type); auto index = GetVecIndexFactory(index_type);
index->Load(index_binary); index->Load(index_binary);
index->set_size(size);
return index; return index;
} }
...@@ -205,7 +214,7 @@ read_index(const std::string& location) { ...@@ -205,7 +214,7 @@ read_index(const std::string& location) {
delete[] meta; delete[] meta;
} }
return LoadVecIndex(current_type, load_data_list); return LoadVecIndex(current_type, load_data_list, length);
} }
Status Status
......
...@@ -87,6 +87,9 @@ class VecIndex : public cache::DataObj { ...@@ -87,6 +87,9 @@ class VecIndex : public cache::DataObj {
int64_t int64_t
Size() override; Size() override;
void
set_size(int64_t size);
virtual knowhere::BinarySet virtual knowhere::BinarySet
Serialize() = 0; Serialize() = 0;
...@@ -115,6 +118,8 @@ class VecIndex : public cache::DataObj { ...@@ -115,6 +118,8 @@ class VecIndex : public cache::DataObj {
return Status::OK(); return Status::OK();
} }
//////////////// ////////////////
private:
int64_t size_ = 0;
}; };
extern Status extern Status
...@@ -127,7 +132,7 @@ extern VecIndexPtr ...@@ -127,7 +132,7 @@ extern VecIndexPtr
GetVecIndexFactory(const IndexType& type, const Config& cfg = Config()); GetVecIndexFactory(const IndexType& type, const Config& cfg = Config());
extern VecIndexPtr extern VecIndexPtr
LoadVecIndex(const IndexType& index_type, const knowhere::BinarySet& index_binary); LoadVecIndex(const IndexType& index_type, const knowhere::BinarySet& index_binary, int64_t size);
extern IndexType extern IndexType
ConvertToCpuIndexType(const IndexType& type); ConvertToCpuIndexType(const IndexType& type);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册