未验证 提交 72ad100a 编写于 作者: S shengjun.li 提交者: GitHub

modify bitset from deque to vector (#1696)

Signed-off-by: Nshengjun.li <shengjun.li@zilliz.com>
上级 fdd51400
......@@ -19,12 +19,7 @@
namespace faiss {
ConcurrentBitset::ConcurrentBitset(id_type_t size) : size_(size) {
id_type_t bytes_count = (size >> 3) + 1;
// bitset_.resize(bytes_count, 0);
for (auto i = 0; i < bytes_count; ++i) {
bitset_.emplace_back(0);
}
ConcurrentBitset::ConcurrentBitset(id_type_t size) : size_(size), bitset_((size + 7) >> 3) {
}
bool
......@@ -42,4 +37,14 @@ ConcurrentBitset::clear(id_type_t id) {
bitset_[id >> 3].fetch_and(~(0x1 << (id & 0x7)));
}
ConcurrentBitset::id_type_t
ConcurrentBitset::size() {
return size_;
}
const unsigned char*
ConcurrentBitset::bitset() {
return reinterpret_cast<const unsigned char*>(bitset_.data());
}
} // namespace faiss
......@@ -19,7 +19,7 @@
#include <atomic>
#include <memory>
#include <deque>
#include <vector>
namespace faiss {
......@@ -42,9 +42,16 @@ class ConcurrentBitset {
void
clear(id_type_t id);
id_type_t
size();
const unsigned char*
bitset();
private:
std::deque<std::atomic<unsigned char>> bitset_;
id_type_t size_;
std::vector<std::atomic<unsigned char>> bitset_;
};
using ConcurrentBitsetPtr = std::shared_ptr<ConcurrentBitset>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册