Skip to content

Commit f87ce23

Browse files
committed
revert bindings + flow tests changes (move to another PR)
1 parent f67be31 commit f87ce23

File tree

11 files changed

+237
-871
lines changed

11 files changed

+237
-871
lines changed

src/VecSim/algorithms/brute_force/brute_force_multi.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class BruteForceIndex_Multi : public BruteForceIndex<DataType, DistType> {
3333
new (this->allocator) vecsim_stl::unique_results_container(cap, this->allocator));
3434
}
3535
#ifdef BUILD_TESTS
36-
void getDataByLabel(labelType label, std::vector<const char *> &vectors_output) const {
36+
void GetDataByLabel(labelType label, std::vector<std::vector<DataType>> &vectors_output) {
3737

3838
auto ids = labelToIdsLookup.find(label);
3939

4040
for (idType id : ids->second) {
41-
auto *vec_copy = new DataType[this->dim];
42-
memcpy(vec_copy, this->getDataByInternalId(id), this->dim * sizeof(DataType));
43-
vectors_output.push_back((const char *)vec_copy);
41+
auto vec = std::vector<DataType>(this->dim);
42+
memcpy(vec.data(), this->getDataByInternalId(id), this->dim * sizeof(DataType));
43+
vectors_output.push_back(vec);
4444
}
4545
}
4646
#endif

src/VecSim/algorithms/brute_force/brute_force_single.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ class BruteForceIndex_Single : public BruteForceIndex<DataType, DistType> {
3232

3333
inline size_t indexLabelCount() const override { return this->count; }
3434
#ifdef BUILD_TESTS
35-
void getDataByLabel(labelType label, std::vector<const char *> &vectors_output) const {
35+
void GetDataByLabel(labelType label, std::vector<std::vector<DataType>> &vectors_output) {
3636

3737
auto id = labelToIdLookup.at(label);
3838

39-
auto *vec_copy = new DataType[this->dim];
40-
memcpy(vec_copy, this->getDataByInternalId(id), this->dim * sizeof(DataType));
41-
vectors_output.push_back((const char *)vec_copy);
39+
auto vec = std::vector<DataType>(this->dim);
40+
memcpy(vec.data(), this->getDataByInternalId(id), this->dim * sizeof(DataType));
41+
vectors_output.push_back(vec);
4242
}
4343
#endif
4444
protected:

src/VecSim/algorithms/hnsw/hnsw_multi.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class HNSWIndex_Multi : public HNSWIndex<DataType, DistType> {
4242
: HNSWIndex<DataType, DistType>(input, params, allocator, version),
4343
label_lookup_(this->max_elements_, allocator) {}
4444

45-
void getDataByLabel(labelType label, std::vector<const char *> &vectors_output) const {
45+
void GetDataByLabel(labelType label, std::vector<std::vector<DataType>> &vectors_output) {
4646

4747
auto ids = label_lookup_.find(label);
4848

4949
for (idType id : ids->second) {
50-
auto *vec_copy = new DataType[this->dim];
51-
memcpy(vec_copy, this->getDataByInternalId(id), this->data_size_);
52-
vectors_output.push_back((const char *)vec_copy);
50+
auto vec = std::vector<DataType>(this->dim);
51+
memcpy(vec.data(), this->getDataByInternalId(id), this->data_size_);
52+
vectors_output.push_back(vec);
5353
}
5454
}
5555
#endif

src/VecSim/algorithms/hnsw/hnsw_single.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ class HNSWIndex_Single : public HNSWIndex<DataType, DistType> {
3535
: HNSWIndex<DataType, DistType>(input, params, allocator, version),
3636
label_lookup_(this->max_elements_, allocator) {}
3737

38-
void getDataByLabel(labelType label, std::vector<const char *> &vectors_output) const {
38+
void GetDataByLabel(labelType label, std::vector<std::vector<DataType>> &vectors_output) {
3939

4040
auto id = label_lookup_.at(label);
4141

42-
auto *vec_copy = new DataType[this->dim];
43-
memcpy(vec_copy, this->getDataByInternalId(id), this->data_size_);
44-
vectors_output.push_back((const char *)vec_copy);
42+
auto vec = std::vector<DataType>(this->dim);
43+
memcpy(vec.data(), this->getDataByInternalId(id), this->data_size_);
44+
vectors_output.push_back(vec);
4545
}
4646
#endif
4747
~HNSWIndex_Single() {}

src/VecSim/algorithms/hnsw/hnsw_single_tests_friends.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ INDEX_TEST_FRIEND_CLASS(HNSWTest_preferAdHocOptimization_Test)
1010
INDEX_TEST_FRIEND_CLASS(HNSWTest_testSizeEstimation_Test)
1111
INDEX_TEST_FRIEND_CLASS(IndexAllocatorTest_testIncomingEdgesSet_Test)
1212
INDEX_TEST_FRIEND_CLASS(IndexAllocatorTest_test_hnsw_reclaim_memory_Test)
13-
INDEX_TEST_FRIEND_CLASS(HNSWTestParallel_parallelInsertSearch_Test)
13+
INDEX_TEST_FRIEND_CLASS(HNSWTestParallel_parallelInsertSearch_Test)

src/VecSim/algorithms/hnsw/hnsw_tiered.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,4 @@ class TieredHNSWIndex : public VecSimTieredIndex<DataType, DistType> {
7272
inline void setLastSearchMode(VecSearchMode mode) override {
7373
return this->index->setLastSearchMode(mode);
7474
}
75-
void getDataByLabel(labelType label, std::vector<const char *> &vectors_output) const override {
76-
77-
}
7875
};

src/VecSim/vec_sim_interface.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include <stddef.h>
1414
#include <stdexcept>
15-
#include <vector>
1615
/**
1716
* @brief Abstract C++ class for vector index, delete and lookup
1817
*
@@ -177,16 +176,4 @@ struct VecSimIndexInterface : public VecsimBaseObject {
177176
inline static void setTimeoutCallbackFunction(timeoutCallbackFunction callback) {
178177
VecSimIndexInterface::timeoutCallback = callback;
179178
}
180-
#ifdef BUILD_TESTS
181-
/**
182-
* @brief Used for testing - store vector(s) data associated with a given label. This function
183-
* copies the vector(s)' data buffer(s) and place its pointer(s) in the output vector
184-
*
185-
* @param label
186-
* @param vectors_output empty vector to be modified, should store the blob(s) associated with
187-
* the label.
188-
*/
189-
virtual void getDataByLabel(labelType label,
190-
std::vector<const char *> &vectors_output) const = 0;
191-
#endif
192179
};

src/python_bindings/Mybytearray.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
def create_bytearray(np_arr):
3+
return bytearray(np_arr)

0 commit comments

Comments
 (0)