Skip to content

Commit 6d741eb

Browse files
committed
chore: add empty constructor for Ruby GC
1 parent 07b803c commit 6d741eb

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

ext/hnswlib/src/bruteforce.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class BruteforceSearch : public AlgorithmInterface<dist_t> {
2121

2222
std::unordered_map<labeltype, size_t > dict_external_to_internal;
2323

24+
BruteforceSearch() : data_(nullptr) { }
2425

2526
BruteforceSearch(SpaceInterface <dist_t> *s)
2627
: data_(nullptr),

ext/hnswlib/src/hnswalg.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
7070
std::mutex deleted_elements_lock; // lock for deleted_elements
7171
std::unordered_set<tableint> deleted_elements; // contains internal ids of deleted elements
7272

73+
HierarchicalNSW() { }
7374

7475
HierarchicalNSW(SpaceInterface<dist_t> *s) {
7576
}
@@ -322,7 +323,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
322323
std::priority_queue<std::pair<dist_t, tableint>, std::vector<std::pair<dist_t, tableint>>, CompareByFirst> candidate_set;
323324

324325
dist_t lowerBound;
325-
if (bare_bone_search ||
326+
if (bare_bone_search ||
326327
(!isMarkedDeleted(ep_id) && ((!isIdAllowed) || (*isIdAllowed)(getExternalLabel(ep_id))))) {
327328
char* ep_data = getDataByInternalId(ep_id);
328329
dist_t dist = fstdistfunc_(data_point, ep_data, dist_func_param_);
@@ -403,7 +404,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
403404
_MM_HINT_T0); ////////////////////////
404405
#endif
405406

406-
if (bare_bone_search ||
407+
if (bare_bone_search ||
407408
(!isMarkedDeleted(candidate_id) && ((!isIdAllowed) || (*isIdAllowed)(getExternalLabel(candidate_id))))) {
408409
top_candidates.emplace(dist, candidate_id);
409410
if (!bare_bone_search && stop_condition) {
@@ -826,7 +827,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
826827
std::vector<data_t> getDataByLabel(labeltype label) const {
827828
// lock all operations with element by label
828829
std::unique_lock <std::mutex> lock_label(getLabelOpMutex(label));
829-
830+
830831
std::unique_lock <std::mutex> lock_table(label_lookup_lock);
831832
auto search = label_lookup_.find(label);
832833
if (search == label_lookup_.end() || isMarkedDeleted(search->second)) {
@@ -888,7 +889,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
888889

889890
/*
890891
* Removes the deleted mark of the node, does NOT really change the current graph.
891-
*
892+
*
892893
* Note: the method is not safe to use when replacement of deleted elements is enabled,
893894
* because elements marked as deleted can be completely removed by addPoint
894895
*/

ext/hnswlib/src/space_ip.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ InnerProductSIMD16ExtAVX512(const void *pVect1v, const void *pVect2v, const void
158158
__m512 sum512 = _mm512_set1_ps(0);
159159

160160
size_t loop = qty16 / 4;
161-
161+
162162
while (loop--) {
163163
__m512 v1 = _mm512_loadu_ps(pVect1);
164164
__m512 v2 = _mm512_loadu_ps(pVect2);
@@ -345,6 +345,8 @@ class InnerProductSpace : public SpaceInterface<float> {
345345
size_t dim_;
346346

347347
public:
348+
InnerProductSpace() : data_size_(0), dim_(0) { }
349+
348350
InnerProductSpace(size_t dim) {
349351
fstdistfunc_ = InnerProductDistance;
350352
#if defined(USE_AVX) || defined(USE_SSE) || defined(USE_AVX512)

ext/hnswlib/src/space_l2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ class L2Space : public SpaceInterface<float> {
211211
size_t dim_;
212212

213213
public:
214+
L2Space() : data_size_(0), dim_(0) { }
215+
214216
L2Space(size_t dim) {
215217
fstdistfunc_ = L2Sqr;
216218
#if defined(USE_SSE) || defined(USE_AVX) || defined(USE_AVX512)

0 commit comments

Comments
 (0)