summaryrefslogtreecommitdiffstats
path: root/searchlib/src
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2020-06-16 18:05:52 +0000
committerArne Juul <arnej@verizonmedia.com>2020-06-16 18:05:52 +0000
commit8d7162f6e803e3be272ea906778b9d185ac62854 (patch)
tree41545a016a408892e6ca0a518c569ee4110e4d9b /searchlib/src
parentfb2b67a51102aa4ae3bfa9e1432d00073fd68e89 (diff)
get rid of test-internal race condition in MyDocVectorStore
Diffstat (limited to 'searchlib/src')
-rw-r--r--searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp
index 7be105cbd72..ea443cfe252 100644
--- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp
+++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp
@@ -99,19 +99,18 @@ void read_vector_file(MallocPointVector *p) {
class MyDocVectorStore : public DocVectorAccess {
private:
- using Vector = std::vector<float>;
- std::vector<Vector> _vectors;
-
+ MallocPointVector *_vectors;
public:
- MyDocVectorStore() : _vectors() {}
+ MyDocVectorStore() {
+ _vectors = aligned_alloc_pv(NUM_POSSIBLE_DOCS);
+ }
MyDocVectorStore& set(uint32_t docid, ConstVectorRef vec) {
- if (docid >= _vectors.size()) {
- _vectors.resize(docid + 1);
- }
- _vectors[docid] = Vector(vec.begin(), vec.end());
+ assert(docid < NUM_POSSIBLE_DOCS);
+ memcpy(&_vectors[docid], vec.cbegin(), sizeof(MallocPointVector));
return *this;
}
vespalib::tensor::TypedCells get_vector(uint32_t docid) const override {
+ assert(docid < NUM_POSSIBLE_DOCS);
ConstVectorRef ref(_vectors[docid]);
return vespalib::tensor::TypedCells(ref);
}
@@ -283,7 +282,6 @@ public:
index = std::make_unique<HnswIndex>(vectors, std::make_unique<FloatSqEuclideanDistance>(),
std::make_unique<InvLogLevelGenerator>(m),
HnswIndex::Config(2*m, m, 200, true));
- vectors.set(NUM_POSSIBLE_DOCS, loaded_vectors[0]);
}
size_t get_rnd(size_t size) {
return rng.nextUniform() * size;