Skip to content

Commit b87f623

Browse files
committed
Explicitly check for filter functor being default.
1 parent aaee13a commit b87f623

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

hnswlib/hnswalg.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ namespace hnswlib {
247247
std::priority_queue<std::pair<dist_t, tableint>, std::vector<std::pair<dist_t, tableint>>, CompareByFirst> candidate_set;
248248

249249
dist_t lowerBound;
250-
if ((!has_deletions || !isMarkedDeleted(ep_id)) && isIdAllowed(getExternalLabel(ep_id))) {
250+
bool is_filter_disabled = std::is_same<filter_func_t, decltype(allowAllIds)>::value;
251+
if ((!has_deletions || !isMarkedDeleted(ep_id)) && (is_filter_disabled || isIdAllowed(getExternalLabel(ep_id)))) {
251252
dist_t dist = fstdistfunc_(data_point, getDataByInternalId(ep_id), dist_func_param_);
252253
lowerBound = dist;
253254
top_candidates.emplace(dist, ep_id);
@@ -307,7 +308,8 @@ namespace hnswlib {
307308
_MM_HINT_T0);////////////////////////
308309
#endif
309310

310-
if ((!has_deletions || !isMarkedDeleted(candidate_id)) && isIdAllowed(getExternalLabel(candidate_id)))
311+
is_filter_disabled = std::is_same<filter_func_t, decltype(allowAllIds)>::value;
312+
if ((!has_deletions || !isMarkedDeleted(candidate_id)) && (is_filter_disabled || isIdAllowed(getExternalLabel(candidate_id))))
311313
top_candidates.emplace(dist, candidate_id);
312314

313315
if (top_candidates.size() > ef)

hnswlib/hnswlib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ namespace hnswlib {
122122
bool operator()(Args&&...) { return true; }
123123
};
124124

125-
FilterFunctor allowAllIds;
125+
static FilterFunctor allowAllIds;
126126

127127
template <typename T>
128128
class pairGreater {

0 commit comments

Comments
 (0)