feat(db): add drop_all

Former-commit-id: 70720144d39f5ca18d349e475e66fb6ccca7bacf
pull/191/head
Xu Peng 2019-04-23 20:03:55 +08:00
parent d7a87d14b1
commit d6344006e5
8 changed files with 26 additions and 0 deletions

View File

@ -30,6 +30,8 @@ public:
virtual Status search(const std::string& group_id, size_t k, size_t nq,
const float* vectors, QueryResults& results) = 0;
virtual Status drop_all() = 0;
DB() = default;
DB(const DB&) = delete;
DB& operator=(const DB&) = delete;

View File

@ -344,6 +344,10 @@ void DBImpl::background_compaction() {
}
}
Status DBImpl::drop_all() {
return _pMeta->drop_all();
}
DBImpl::~DBImpl() {
{
std::unique_lock<std::mutex> lock(_mutex);

View File

@ -36,6 +36,8 @@ public:
virtual Status search(const std::string& group_id, size_t k, size_t nq,
const float* vectors, QueryResults& results) override;
virtual Status drop_all() override;
virtual ~DBImpl();
private:

View File

@ -427,6 +427,13 @@ Status DBMetaImpl::cleanup() {
return Status::OK();
}
Status DBMetaImpl::drop_all() {
if (boost::filesystem::is_directory(_options.path)) {
boost::filesystem::remove_all(_options.path);
}
return Status::OK();
}
DBMetaImpl::~DBMetaImpl() {
cleanup();
}

View File

@ -48,6 +48,8 @@ public:
virtual Status cleanup_ttl_files(uint16_t seconds) override;
virtual Status drop_all() override;
virtual ~DBMetaImpl();
private:

View File

@ -246,6 +246,11 @@ Status LocalMetaImpl::cleanup_ttl_files(uint16_t seconds) {
return Status::OK();
}
Status LocalMetaImpl::drop_all() {
// PXU TODO
return Status::OK();
}
} // namespace meta
} // namespace engine
} // namespace vecwise

View File

@ -43,6 +43,8 @@ public:
virtual Status cleanup_ttl_files(uint16_t seconds) override;
virtual Status drop_all() override;
private:
Status GetGroupMetaInfoByPath(const std::string& path, GroupSchema& group_info);

View File

@ -83,6 +83,8 @@ public:
virtual Status cleanup() = 0;
virtual Status cleanup_ttl_files(uint16_t) = 0;
virtual Status drop_all() = 0;
static DateT GetDate(const std::time_t& t);
static DateT GetDate();