rewrite cache code

Former-commit-id: 7dc429b553891f98baa0cef21bee58c545ab9748
pull/191/head
groot 2019-04-24 12:10:37 +08:00
parent 97d4738bc6
commit 01c5b43130
1 changed files with 6 additions and 10 deletions

View File

@ -6,10 +6,7 @@
#pragma once
#include "faiss/AutoTune.h"
#include "faiss/AuxIndexStructures.h"
#include "faiss/gpu/GpuAutoTune.h"
#include "faiss/index_io.h"
#include "wrapper/Index.h"
#include <memory>
@ -19,24 +16,23 @@ namespace cache {
class DataObj {
public:
DataObj(const std::shared_ptr<faiss::Index>& index)
DataObj(const engine::Index_ptr& index)
: index_(index)
{}
std::shared_ptr<faiss::Index> data() { return index_; }
const std::shared_ptr<faiss::Index>& data() const { return index_; }
engine::Index_ptr data() { return index_; }
const engine::Index_ptr& data() const { return index_; }
int64_t size() const {
if(index_ == nullptr) {
return 0;
}
return index_->ntotal*(index_->d*4 + sizeof(faiss::Index::idx_t));
return index_->ntotal*(index_->dim*4);
}
private:
std::shared_ptr<faiss::Index> index_ = nullptr;
int64_t size_ = 0;
engine::Index_ptr index_ = nullptr;
};
using DataObjPtr = std::shared_ptr<DataObj>;