mirror of https://github.com/milvus-io/milvus.git
modify bitset from deque to vector (#1696)
Signed-off-by: shengjun.li <shengjun.li@zilliz.com>pull/1707/head
parent
fdd51400d2
commit
72ad100a90
|
@ -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>;
|
||||
|
|
Loading…
Reference in New Issue