Skip to content

Commit

Permalink
modify the data structure of VisitList for stack operations (#206)
Browse files Browse the repository at this point in the history
Signed-off-by: jinjiabao.jjb <jinjiabao.jjb@antgroup.com>
  • Loading branch information
inabao authored and jinjiabao.jjb committed Dec 11, 2024
1 parent 2f67c39 commit 62312c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/algorithm/hnswlib/visited_list_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class VisitedListPool {
std::unique_lock<std::mutex> lock(poolguard_);
if (not pool_.empty()) {
rez = pool_.front();
pool_.pop_back();
pool_.pop_front();
} else {
rez = std::make_shared<VisitedList>(max_element_count_, allocator_);
}
Expand All @@ -104,7 +104,7 @@ class VisitedListPool {
}

private:
vsag::Vector<std::shared_ptr<VisitedList>> pool_;
vsag::Deque<std::shared_ptr<VisitedList>> pool_;
std::mutex poolguard_;
uint64_t max_element_count_;
vsag::Allocator* allocator_;
Expand Down
4 changes: 4 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <chrono>
#include <cstdint>
#include <deque>
#include <string>
#include <vector>

Expand All @@ -34,6 +35,9 @@ using UnorderedSet =
template <typename T>
using Vector = std::vector<T, vsag::AllocatorWrapper<T>>;

template <typename T>
using Deque = std::deque<T, vsag::AllocatorWrapper<T>>;

template <typename KeyType, typename ValType>
using UnorderedMap = std::unordered_map<KeyType,
ValType,
Expand Down

0 comments on commit 62312c0

Please sign in to comment.