summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'searchlib/src/tests')
-rw-r--r--searchlib/src/tests/aggregator/perdocexpr_test.cpp1
-rw-r--r--searchlib/src/tests/attribute/extendattributes/extendattribute_test.cpp2
-rw-r--r--searchlib/src/tests/diskindex/pagedict4/pagedict4_test.cpp52
-rw-r--r--searchlib/src/tests/tensor/distance_calculator/distance_calculator_test.cpp8
-rw-r--r--searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp11
-rw-r--r--searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp22
6 files changed, 61 insertions, 35 deletions
diff --git a/searchlib/src/tests/aggregator/perdocexpr_test.cpp b/searchlib/src/tests/aggregator/perdocexpr_test.cpp
index 908e50ad4d2..e9f0981739c 100644
--- a/searchlib/src/tests/aggregator/perdocexpr_test.cpp
+++ b/searchlib/src/tests/aggregator/perdocexpr_test.cpp
@@ -604,6 +604,7 @@ getVespaChecksumV2(const std::string& ymumid, int fid, const std::string& flags_
sizeof(networkFid)+
new_flags_str.length();
+ // GNU extension: Variable-length automatic array
unsigned char buffer[length];
memset(buffer, 0x00, length);
memcpy(buffer, ymumid.c_str(), ymumid.length());
diff --git a/searchlib/src/tests/attribute/extendattributes/extendattribute_test.cpp b/searchlib/src/tests/attribute/extendattributes/extendattribute_test.cpp
index 48270694394..d67757a3811 100644
--- a/searchlib/src/tests/attribute/extendattributes/extendattribute_test.cpp
+++ b/searchlib/src/tests/attribute/extendattributes/extendattribute_test.cpp
@@ -224,7 +224,7 @@ void ExtendAttributeTest::testExtendRaw(AttributeVector& attr)
void ExtendAttributeTest::testExtendTensor(AttributeVector& attr)
{
- std::vector<double> empty_cells{0.0, 0.0};
+ std::vector<double> empty_cells{};
std::vector<double> spec0_dense_cells{1.0, 2.0};
std::vector<double> spec0_mixed_cells0{3.0, 4.0};
std::vector<double> spec0_mixed_cells1{5.0, 6.0};
diff --git a/searchlib/src/tests/diskindex/pagedict4/pagedict4_test.cpp b/searchlib/src/tests/diskindex/pagedict4/pagedict4_test.cpp
index 951d6f61980..3b7ec00211d 100644
--- a/searchlib/src/tests/diskindex/pagedict4/pagedict4_test.cpp
+++ b/searchlib/src/tests/diskindex/pagedict4/pagedict4_test.cpp
@@ -15,8 +15,9 @@
#include <vespa/searchlib/diskindex/pagedict4randread.h>
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/vespalib/util/signalhandler.h>
-#include <sstream>
#include <cinttypes>
+#include <optional>
+#include <sstream>
#include <vespa/log/log.h>
LOG_SETUP("pagedict4test");
@@ -357,6 +358,7 @@ checkCounts(const std::string &word,
void
testWords(const std::string &logname,
vespalib::Rand48 &rnd,
+ std::optional<uint32_t> mmap_file_size_threshold,
uint64_t numWordIds,
uint32_t tupleCount,
uint32_t chunkSize,
@@ -495,7 +497,14 @@ testWords(const std::string &logname,
LOG(info, "%s: pagedict4 written", logname.c_str());
}
{
- std::unique_ptr<DictionaryFileSeqRead> dr(new PageDict4FileSeqRead);
+ std::unique_ptr<DictionaryFileSeqRead> dr;
+ {
+ auto my_dr = std::make_unique<PageDict4FileSeqRead>();
+ if (mmap_file_size_threshold.has_value()) {
+ my_dr->set_mmap_file_size_threshold(mmap_file_size_threshold.value());
+ }
+ dr = std::move(my_dr);
+ }
search::TuneFileSeqRead tuneFileRead;
bool openres = dr->open("fakedict",
@@ -535,7 +544,14 @@ testWords(const std::string &logname,
LOG(info, "%s: pagedict4 seqverify OK", logname.c_str());
}
{
- std::unique_ptr<DictionaryFileRandRead> drr(new PageDict4RandRead);
+ std::unique_ptr<DictionaryFileRandRead> drr;
+ {
+ auto my_drr = std::make_unique<PageDict4RandRead>();
+ if (mmap_file_size_threshold.has_value()) {
+ my_drr->set_mmap_file_size_threshold(mmap_file_size_threshold.value());
+ }
+ drr = std::move(my_drr);
+ }
search::TuneFileRandRead tuneFileRead;
bool openres = drr->open("fakedict",
tuneFileRead);
@@ -649,46 +665,50 @@ testWords(const std::string &logname,
void
PageDict4TestApp::testWords()
{
- ::testWords("smallchunkwordsempty", _rnd,
+ ::testWords("smallchunkwordsempty", _rnd, std::nullopt,
1000000, 0,
64, 80, 72, 64,
false, false, false);
- ::testWords("smallchunkwordsempty2", _rnd,
+ ::testWords("smallchunkwordsempty2", _rnd, std::nullopt,
0, 0,
64, 80, 72, 64,
false, false, false);
- ::testWords("smallchunkwords", _rnd,
+ ::testWords("smallchunkwords", _rnd, std::nullopt,
1000000, 100,
64, 80, 72, 64,
false, false, false);
- ::testWords("smallchunkwordswithemptyword", _rnd,
+ ::testWords("smallchunkwordswithemptyword", _rnd, std::nullopt,
1000000, 100,
64, 80, 72, 64,
true, false, false);
- ::testWords("smallchunkwordswithcommonfirstword", _rnd,
+ ::testWords("smallchunkwordswithcommonfirstword", _rnd, std::nullopt,
1000000, 100,
64, 80, 72, 64,
false, true, false);
- ::testWords("smallchunkwordswithcommonemptyfirstword", _rnd,
+ ::testWords("smallchunkwordswithcommonemptyfirstword", _rnd, std::nullopt,
1000000, 100,
64, 80, 72, 64,
true, true, false);
- ::testWords("smallchunkwordswithcommonlastword", _rnd,
+ ::testWords("smallchunkwordswithcommonlastword", _rnd, std::nullopt,
1000000, 100,
64, 80, 72, 64,
false, false, true);
-#if 1
- ::testWords("smallchunkwords2", _rnd,
+ ::testWords("smallchunkwords2", _rnd, std::nullopt,
1000000, _stress ? 10000 : 100,
64, 80, 72, 64,
_emptyWord, _firstWordForcedCommon, _lastWordForcedCommon);
-#endif
-#if 1
- ::testWords("stdwords", _rnd,
+ ::testWords("stdwords", _rnd, std::nullopt,
1000000, _stress ? 10000 : 100,
262144, 80, 72, 64,
_emptyWord, _firstWordForcedCommon, _lastWordForcedCommon);
-#endif
+ ::testWords("stdwordsnommapssdat", _rnd, 500_Mi,
+ 1000000, 100,
+ 262144, 80, 72, 64,
+ _emptyWord, _firstWordForcedCommon, _lastWordForcedCommon);
+ ::testWords("stdwordsmmapssdat", _rnd, 1,
+ 1000000, 100,
+ 262144, 80, 72, 64,
+ _emptyWord, _firstWordForcedCommon, _lastWordForcedCommon);
}
int main(int argc, char **argv) {
diff --git a/searchlib/src/tests/tensor/distance_calculator/distance_calculator_test.cpp b/searchlib/src/tests/tensor/distance_calculator/distance_calculator_test.cpp
index b7702398857..4ffc1fe366e 100644
--- a/searchlib/src/tests/tensor/distance_calculator/distance_calculator_test.cpp
+++ b/searchlib/src/tests/tensor/distance_calculator/distance_calculator_test.cpp
@@ -44,12 +44,16 @@ public:
double calc_distance(uint32_t docid, const vespalib::string& query_tensor) {
auto qt = make_tensor(query_tensor);
auto calc = DistanceCalculator::make_with_validation(*attr, *qt);
- return calc->calc_with_limit(docid, std::numeric_limits<double>::max());
+ return calc->has_single_subspace()
+ ? calc->calc_with_limit<true>(docid, std::numeric_limits<double>::max())
+ : calc->calc_with_limit<false>(docid, std::numeric_limits<double>::max());
}
double calc_rawscore(uint32_t docid, const vespalib::string& query_tensor) {
auto qt = make_tensor(query_tensor);
auto calc = DistanceCalculator::make_with_validation(*attr, *qt);
- return calc->calc_raw_score(docid);
+ return calc->has_single_subspace()
+ ? calc->calc_raw_score<true>(docid)
+ : calc->calc_raw_score<false>(docid);
}
OptSubspace calc_closest_subspace(uint32_t docid, const vespalib::string& query_tensor) {
auto qt = make_tensor(query_tensor);
diff --git a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
index c01fc33767a..b697effeab4 100644
--- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
+++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp
@@ -62,14 +62,14 @@ public:
_vectors[docid] = vec;
return *this;
}
- vespalib::eval::TypedCells get_vector(uint32_t docid, uint32_t subspace) const override {
+ vespalib::eval::TypedCells get_vector(uint32_t docid, uint32_t subspace) const noexcept override {
return get_vectors(docid).cells(subspace);
}
- VectorBundle get_vectors(uint32_t docid) const override {
+ VectorBundle get_vectors(uint32_t docid) const noexcept override {
ArrayRef ref(_vectors[docid]);
assert((ref.size() % _subspace_type.size()) == 0);
uint32_t subspaces = ref.size() / _subspace_type.size();
- return VectorBundle(ref.data(), subspaces, _subspace_type);
+ return {ref.data(), subspaces, _subspace_type};
}
void clear() { _vectors.clear(); }
@@ -106,7 +106,7 @@ public:
.set(7, {3, 5}).set(8, {0, 3}).set(9, {4, 5});
}
- ~HnswIndexTest() override {}
+ ~HnswIndexTest() override;
auto dff() {
return search::tensor::make_distance_function_factory(
@@ -280,6 +280,9 @@ public:
static constexpr bool is_single = std::is_same_v<IndexType, HnswIndex<HnswIndexType::SINGLE>>;
};
+template <typename IndexType>
+HnswIndexTest<IndexType>::~HnswIndexTest() = default;
+
using HnswIndexTestTypes = ::testing::Types<HnswIndex<HnswIndexType::SINGLE>, HnswIndex<HnswIndexType::MULTI>>;
TYPED_TEST_SUITE(HnswIndexTest, HnswIndexTestTypes);
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 1feb968fbb4..dce09a87fb8 100644
--- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp
+++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp
@@ -1,13 +1,5 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <fcntl.h>
-#include <cstdio>
-#include <unistd.h>
-#include <chrono>
-#include <cstdlib>
-#include <future>
-#include <vector>
-
#include <vespa/eval/eval/typed_cells.h>
#include <vespa/eval/eval/value_type.h>
#include <vespa/searchlib/common/bitvector.h>
@@ -25,6 +17,9 @@
#include <vespa/vespalib/util/lambdatask.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/data/simple_buffer.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <future>
#include <vespa/log/log.h>
LOG_SETUP("stress_hnsw_mt");
@@ -119,17 +114,17 @@ public:
memcpy(&_vectors[docid], vec.cbegin(), sizeof(MallocPointVector));
return *this;
}
- vespalib::eval::TypedCells get_vector(uint32_t docid, uint32_t subspace) const override {
+ vespalib::eval::TypedCells get_vector(uint32_t docid, uint32_t subspace) const noexcept override {
assert(docid < NUM_POSSIBLE_DOCS);
(void) subspace;
ConstVectorRef ref(_vectors[docid]);
return vespalib::eval::TypedCells(ref);
}
- VectorBundle get_vectors(uint32_t docid) const override {
+ VectorBundle get_vectors(uint32_t docid) const noexcept override {
assert(docid < NUM_POSSIBLE_DOCS);
ConstVectorRef ref(_vectors[docid]);
assert(subspace_type.size() == ref.size());
- return VectorBundle(ref.data(), 1, subspace_type);
+ return {ref.data(), 1, subspace_type};
}
};
@@ -257,7 +252,7 @@ public:
loaded_vectors.load();
}
- ~Stressor() {}
+ ~Stressor() override;
auto dff() {
return search::tensor::make_distance_function_factory(
@@ -352,6 +347,9 @@ public:
}
};
+template <typename IndexType>
+Stressor<IndexType>::~Stressor() = default;
+
using StressorTypes = ::testing::Types<HnswIndex<HnswIndexType::SINGLE>>;
TYPED_TEST_SUITE(Stressor, StressorTypes);