diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2020-04-25 22:51:49 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2020-04-25 22:58:30 +0200 |
commit | d4bf2e41fab0adce629308de75b3e1763dfadccb (patch) | |
tree | 2d4ac70964ab3a16fc46c38d3c7510aec64d8c34 /searchlib/src/tests | |
parent | 35decca41db6b9a44b24b6f7501c84d159ebd6a7 (diff) |
Reduce code duplication. Rand48 class is in vespalib.
Diffstat (limited to 'searchlib/src/tests')
16 files changed, 41 insertions, 44 deletions
diff --git a/searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp b/searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp index 8d13987bb4f..eeabbf23c27 100644 --- a/searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp +++ b/searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp @@ -6,7 +6,7 @@ #include <vespa/searchlib/attribute/attributefilebufferwriter.h> #include <vespa/searchlib/attribute/attribute_header.h> #include <vespa/searchlib/util/fileutil.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/searchlib/common/fileheadercontext.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> @@ -77,7 +77,7 @@ TEST_F("Test that buffer writer passes on written data", Fixture) const size_t writerBufferSize = AttributeFileBufferWriter::BUFFER_SIZE; EXPECT_GREATER(mysize * sizeof(int), writerBufferSize); a.reserve(mysize); - search::Rand48 rnd; + vespalib::Rand48 rnd; for (uint32_t i = 0; i < mysize; ++i) { a.emplace_back(rnd.lrand48()); } diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp index 41313fc7c53..eeaf85472c3 100644 --- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp +++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp @@ -227,7 +227,7 @@ void EnumeratedSaveTest::populate(IntegerAttribute &v, unsigned seed, BasicType bt) { - search::Rand48 rnd; + vespalib::Rand48 rnd; IntegerAttribute::largeint_t mask(std::numeric_limits <IntegerAttribute::largeint_t>::max()); switch (bt.type()) { @@ -284,7 +284,7 @@ EnumeratedSaveTest::populate(FloatingPointAttribute &v, unsigned seed, BasicType bt) { (void) bt; - search::Rand48 rnd; + vespalib::Rand48 rnd; rnd.srand48(seed); int weight = 1; for(size_t i(0), m(v.getNumDocs()); i < m; i++) { diff --git a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp index 2f74e9d31f6..a936ba124ee 100644 --- a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp +++ b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp @@ -3,7 +3,7 @@ #include <vespa/searchlib/attribute/multi_value_mapping.h> #include <vespa/searchlib/attribute/multi_value_mapping.hpp> #include <vespa/searchlib/attribute/not_implemented_attribute.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/stllike/hash_set.h> #include <vespa/vespalib/test/insertion_operators.h> @@ -151,7 +151,7 @@ using IntMappingTest = MappingTestBase<int>; class CompactionIntMappingTest : public MappingTestBase<int> { - search::Rand48 _rnd; + vespalib::Rand48 _rnd; std::map<uint32_t, std::vector<int>> _refMapping; public: CompactionIntMappingTest() diff --git a/searchlib/src/tests/attribute/postinglist/postinglist.cpp b/searchlib/src/tests/attribute/postinglist/postinglist.cpp index 78b93e2b78b..37d76e4a9e8 100644 --- a/searchlib/src/tests/attribute/postinglist/postinglist.cpp +++ b/searchlib/src/tests/attribute/postinglist/postinglist.cpp @@ -7,7 +7,7 @@ #include <vespa/vespalib/btree/btreeroot.hpp> #include <vespa/vespalib/btree/btreestore.hpp> #include <vespa/vespalib/datastore/datastore.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/vespalib/testkit/testapp.h> #include <set> #include <map> @@ -143,7 +143,7 @@ private: PostingList *_intPostings; STLValueTree *_stlTree; - Rand48 _randomGenerator; + vespalib::Rand48 _randomGenerator; uint32_t _generation; void diff --git a/searchlib/src/tests/common/bitvector/bitvector_test.cpp b/searchlib/src/tests/common/bitvector/bitvector_test.cpp index 409cc9f2725..db29ab9881f 100644 --- a/searchlib/src/tests/common/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/common/bitvector/bitvector_test.cpp @@ -8,7 +8,7 @@ #include <vespa/searchlib/common/bitvectoriterator.h> #include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/searchlib/fef/termfieldmatchdataarray.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <algorithm> using namespace search; @@ -81,7 +81,7 @@ myCountInterval(const BitVector &bv, uint32_t low, uint32_t high) } void -scan(uint32_t count, uint32_t offset, uint32_t size, Rand48 &rnd) +scan(uint32_t count, uint32_t offset, uint32_t size, vespalib::Rand48 &rnd) { std::vector<uint32_t> lids; lids.reserve(count); @@ -110,7 +110,7 @@ scan(uint32_t count, uint32_t offset, uint32_t size, Rand48 &rnd) void scanWithOffset(uint32_t offset) { - Rand48 rnd; + vespalib::Rand48 rnd; rnd.srand48(32); scan(10, offset, 1000000, rnd); diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp index ef55ea60c2b..15a53497db9 100644 --- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp +++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/common/bitvector.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/searchlib/test/fakedata/fakeword.h> #include <vespa/searchlib/test/fakedata/fakewordset.h> #include <vespa/searchlib/index/docidandfeatures.h> @@ -99,7 +99,7 @@ private: FakeWordSet _wordSet; FakeWordSet _wordSet2; public: - search::Rand48 _rnd; + vespalib::Rand48 _rnd; private: void Usage(); diff --git a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp index e914fe7c559..6cc2f318f4b 100644 --- a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp +++ b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/searchlib/bitcompression/compression.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/searchlib/index/schemautil.h> #include <vespa/searchlib/bitcompression/countcompression.h> #include <vespa/searchlib/bitcompression/pagedict4.h> @@ -54,7 +54,7 @@ using RandReader = search::diskindex::test::PageDict4MemRandReader; class PageDict4TestApp : public FastOS_Application { public: - search::Rand48 _rnd; + vespalib::Rand48 _rnd; bool _stress; bool _emptyWord; bool _firstWordForcedCommon; @@ -206,7 +206,7 @@ deDup(std::vector<uint32_t> &v) static WordIndexCounts -makeIndex(search::Rand48 &rnd, bool forceCommon) +makeIndex(vespalib::Rand48 &rnd, bool forceCommon) { uint64_t bitLength = 10; uint32_t numDocs = 1; @@ -219,7 +219,7 @@ makeIndex(search::Rand48 &rnd, bool forceCommon) void -makeIndexes(search::Rand48 &rnd, +makeIndexes(vespalib::Rand48 &rnd, WordIndexCounts &counts, bool forceCommon) { @@ -229,7 +229,7 @@ makeIndexes(search::Rand48 &rnd, static void makeWords(std::vector<WordCounts> &v, - search::Rand48 &rnd, + vespalib::Rand48 &rnd, uint32_t numWordIds, uint32_t tupleCount, bool emptyWord, @@ -355,7 +355,7 @@ checkCounts(const std::string &word, void testWords(const std::string &logname, - search::Rand48 &rnd, + vespalib::Rand48 &rnd, uint64_t numWordIds, uint32_t tupleCount, uint32_t chunkSize, diff --git a/searchlib/src/tests/features/beta/beta_features.cpp b/searchlib/src/tests/features/beta/beta_features.cpp index 617bf2fb073..89a72fab6fc 100644 --- a/searchlib/src/tests/features/beta/beta_features.cpp +++ b/searchlib/src/tests/features/beta/beta_features.cpp @@ -31,7 +31,7 @@ #include <vespa/searchlib/fef/featurenamebuilder.h> #include <vespa/searchlib/fef/indexproperties.h> #include <vespa/searchlib/fef/test/plugin/setup.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/searchlib/fef/test/ftlib.h> #include <vespa/vespalib/util/stringfmt.h> diff --git a/searchlib/src/tests/features/prod_features.cpp b/searchlib/src/tests/features/prod_features.cpp index 1c07c81bc2f..3f71c9f85ea 100644 --- a/searchlib/src/tests/features/prod_features.cpp +++ b/searchlib/src/tests/features/prod_features.cpp @@ -40,7 +40,7 @@ #include <vespa/searchlib/fef/queryproperties.h> #include <vespa/searchlib/fef/test/plugin/setup.h> #include <vespa/searchlib/fef/test/dummy_dependency_handler.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/geo/zcurve.h> #include <vespa/vespalib/util/string_hash.h> @@ -1747,7 +1747,7 @@ Test::testRandom() FtFeatureTest ft(_factory, "random"); ft.getIndexEnv().getProperties().add("random.seed", "100"); ASSERT_TRUE(ft.setup()); - search::Rand48 rnd; + vespalib::Rand48 rnd; rnd.srand48(100); for (uint32_t i = 0; i < 5; ++i) { feature_t exp = static_cast<feature_t>(rnd.lrand48()) / static_cast<feature_t>(0x80000000u); @@ -1770,7 +1770,7 @@ Test::testRandom() FtFeatureTest ft(_factory, "random.match"); ft.getQueryEnv().getProperties().add("random.match.seed", "100"); ASSERT_TRUE(ft.setup()); - search::Rand48 rnd; + vespalib::Rand48 rnd; for (uint32_t i = 1; i <= 5; ++i) { rnd.srand48(100 + i); // seed + lid feature_t exp = static_cast<feature_t>(rnd.lrand48()) / static_cast<feature_t>(0x80000000u); diff --git a/searchlib/src/tests/postinglistbm/posting_list_test.cpp b/searchlib/src/tests/postinglistbm/posting_list_test.cpp index a7d810cb1a1..845201772f8 100644 --- a/searchlib/src/tests/postinglistbm/posting_list_test.cpp +++ b/searchlib/src/tests/postinglistbm/posting_list_test.cpp @@ -5,7 +5,7 @@ #include <vespa/searchlib/test/fakedata/fakeword.h> #include <vespa/searchlib/test/fakedata/fakewordset.h> #include <vespa/searchlib/test/fakedata/fpfactory.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/vespalib/gtest/gtest.h> #include <cinttypes> @@ -66,7 +66,7 @@ struct PostingListTest : public ::testing::Test { FakeWordUP word3; FakeWordUP word4; FakeWordUP word5; - search::Rand48 rnd; + vespalib::Rand48 rnd; PostingListTest() : num_docs(36000), diff --git a/searchlib/src/tests/postinglistbm/postinglistbm.cpp b/searchlib/src/tests/postinglistbm/postinglistbm.cpp index 16b8e9cd7f5..0ac3f15e015 100644 --- a/searchlib/src/tests/postinglistbm/postinglistbm.cpp +++ b/searchlib/src/tests/postinglistbm/postinglistbm.cpp @@ -10,7 +10,7 @@ #include <vespa/searchlib/test/fakedata/fakeword.h> #include <vespa/searchlib/test/fakedata/fakewordset.h> #include <vespa/searchlib/test/fakedata/fpfactory.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/log/log.h> @@ -42,7 +42,7 @@ private: bool _unpack; public: - search::Rand48 _rnd; + vespalib::Rand48 _rnd; public: PostingListBM(); diff --git a/searchlib/src/tests/postinglistbm/stress_runner.cpp b/searchlib/src/tests/postinglistbm/stress_runner.cpp index 9c78515a03f..fd12e9b5aa9 100644 --- a/searchlib/src/tests/postinglistbm/stress_runner.cpp +++ b/searchlib/src/tests/postinglistbm/stress_runner.cpp @@ -33,7 +33,7 @@ private: StressMaster &operator=(const StressMaster &); - search::Rand48 &_rnd; + vespalib::Rand48 &_rnd; uint32_t _numDocs; std::vector<std::string> _postingTypes; StressRunner::OperatorType _operatorType; @@ -62,7 +62,7 @@ private: std::vector<Task> _tasks; public: - StressMaster(search::Rand48 &rnd, + StressMaster(vespalib::Rand48 &rnd, FakeWordSet &wordSet, const std::vector<std::string> &postingType, StressRunner::OperatorType operatorType, @@ -129,7 +129,7 @@ public: }; -StressMaster::StressMaster(search::Rand48 &rnd, +StressMaster::StressMaster(vespalib::Rand48 &rnd, FakeWordSet &wordSet, const std::vector<std::string> &postingTypes, StressRunner::OperatorType operatorType, @@ -420,7 +420,7 @@ OrStressWorker::run_task(const FakePosting& f1, const FakePosting& f2, uint32_t } void -StressRunner::run(search::Rand48 &rnd, +StressRunner::run(vespalib::Rand48 &rnd, FakeWordSet &wordSet, const std::vector<std::string> &postingTypes, OperatorType operatorType, diff --git a/searchlib/src/tests/postinglistbm/stress_runner.h b/searchlib/src/tests/postinglistbm/stress_runner.h index d4974bc969e..249645f70aa 100644 --- a/searchlib/src/tests/postinglistbm/stress_runner.h +++ b/searchlib/src/tests/postinglistbm/stress_runner.h @@ -4,12 +4,9 @@ #include <string> #include <vector> -namespace search { -class Rand48; +namespace vespalib { class Rand48; } -namespace fakedata { class FakeWordSet; } - -} +namespace search::fakedata { class FakeWordSet; } namespace postinglistbm { @@ -21,7 +18,7 @@ public: Or }; - static void run(search::Rand48 &rnd, + static void run(vespalib::Rand48 &rnd, search::fakedata::FakeWordSet &wordSet, const std::vector<std::string> &postingTypes, OperatorType operatorType, diff --git a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp index a8aab279a98..1cf39183206 100644 --- a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp +++ b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp @@ -9,7 +9,7 @@ #include <vespa/searchlib/queryeval/andnotsearch.h> #include <vespa/searchlib/queryeval/andsearch.h> #include <vespa/searchlib/queryeval/dot_product_search.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/searchlib/queryeval/orsearch.h> #include <vespa/searchlib/queryeval/simpleresult.h> #include <vespa/searchlib/queryeval/wand/weak_and_search.h> diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp index 74e48081e17..81a3006dbff 100644 --- a/searchlib/src/tests/transactionlogstress/translogstress.cpp +++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp @@ -3,7 +3,7 @@ #include <vespa/vespalib/util/stringfmt.h> #include <vespa/searchlib/transactionlog/translogserver.h> #include <vespa/searchlib/transactionlog/translogclient.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> #include <vespa/searchlib/util/runnable.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/fastos/app.h> @@ -37,7 +37,7 @@ using Visitor = TransLogClient::Visitor; class BufferGenerator { private: - Rand48 _rnd; + vespalib::Rand48 _rnd; uint32_t _minStrLen; uint32_t _maxStrLen; @@ -71,7 +71,7 @@ BufferGenerator::getRandomBuffer() class EntryGenerator { private: - Rand48 _rnd; + vespalib::Rand48 _rnd; long _baseSeed; BufferGenerator _bufferGenerator; const std::vector<nbostream> * _buffers; @@ -93,7 +93,7 @@ public: }; SerialNum getRandomSerialNum(SerialNum begin, SerialNum end); Packet::Entry getRandomEntry(SerialNum num); - Rand48 & getRnd() { return _rnd; } + vespalib::Rand48 & getRnd() { return _rnd; } void setBuffers(const std::vector<nbostream> & buffers) { _buffers = &buffers; } diff --git a/searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp b/searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp index 33afa67e660..8787712663d 100644 --- a/searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp +++ b/searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp @@ -4,7 +4,7 @@ #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/bufferwriter.h> #include <vespa/searchlib/util/drainingbufferwriter.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/rand48.h> namespace search { @@ -130,7 +130,7 @@ TEST("Test that bufferwriter passes on written data") const size_t drainerBufferSize = DrainingBufferWriter::BUFFER_SIZE; EXPECT_GREATER(mysize * sizeof(int), drainerBufferSize); a.reserve(mysize); - search::Rand48 rnd; + vespalib::Rand48 rnd; for (uint32_t i = 0; i < mysize; ++i) { a.emplace_back(rnd.lrand48()); } |