提交 01c5b431 编写于 作者: G groot

rewrite cache code


Former-commit-id: 7dc429b553891f98baa0cef21bee58c545ab9748
上级 97d4738b
...@@ -6,10 +6,7 @@ ...@@ -6,10 +6,7 @@
#pragma once #pragma once
#include "faiss/AutoTune.h" #include "wrapper/Index.h"
#include "faiss/AuxIndexStructures.h"
#include "faiss/gpu/GpuAutoTune.h"
#include "faiss/index_io.h"
#include <memory> #include <memory>
...@@ -19,24 +16,23 @@ namespace cache { ...@@ -19,24 +16,23 @@ namespace cache {
class DataObj { class DataObj {
public: public:
DataObj(const std::shared_ptr<faiss::Index>& index) DataObj(const engine::Index_ptr& index)
: index_(index) : index_(index)
{} {}
std::shared_ptr<faiss::Index> data() { return index_; } engine::Index_ptr data() { return index_; }
const std::shared_ptr<faiss::Index>& data() const { return index_; } const engine::Index_ptr& data() const { return index_; }
int64_t size() const { int64_t size() const {
if(index_ == nullptr) { if(index_ == nullptr) {
return 0; return 0;
} }
return index_->ntotal*(index_->d*4 + sizeof(faiss::Index::idx_t)); return index_->ntotal*(index_->dim*4);
} }
private: private:
std::shared_ptr<faiss::Index> index_ = nullptr; engine::Index_ptr index_ = nullptr;
int64_t size_ = 0;
}; };
using DataObjPtr = std::shared_ptr<DataObj>; using DataObjPtr = std::shared_ptr<DataObj>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册