aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2020-04-25 22:51:49 +0200
committerTor Egge <Tor.Egge@broadpark.no>2020-04-25 22:58:30 +0200
commitd4bf2e41fab0adce629308de75b3e1763dfadccb (patch)
tree2d4ac70964ab3a16fc46c38d3c7510aec64d8c34 /searchlib/src
parent35decca41db6b9a44b24b6f7501c84d159ebd6a7 (diff)
Reduce code duplication. Rand48 class is in vespalib.
Diffstat (limited to 'searchlib/src')
-rw-r--r--searchlib/src/apps/tests/btreestress_test.cpp8
-rw-r--r--searchlib/src/apps/tests/memoryindexstress_test.cpp8
-rw-r--r--searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp4
-rw-r--r--searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp4
-rw-r--r--searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp4
-rw-r--r--searchlib/src/tests/attribute/postinglist/postinglist.cpp4
-rw-r--r--searchlib/src/tests/common/bitvector/bitvector_test.cpp6
-rw-r--r--searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp4
-rw-r--r--searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp12
-rw-r--r--searchlib/src/tests/features/beta/beta_features.cpp2
-rw-r--r--searchlib/src/tests/features/prod_features.cpp6
-rw-r--r--searchlib/src/tests/postinglistbm/posting_list_test.cpp4
-rw-r--r--searchlib/src/tests/postinglistbm/postinglistbm.cpp4
-rw-r--r--searchlib/src/tests/postinglistbm/stress_runner.cpp8
-rw-r--r--searchlib/src/tests/postinglistbm/stress_runner.h9
-rw-r--r--searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp2
-rw-r--r--searchlib/src/tests/transactionlogstress/translogstress.cpp8
-rw-r--r--searchlib/src/tests/util/bufferwriter/bufferwriter_test.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/features/randomfeature.h6
-rw-r--r--searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp16
-rw-r--r--searchlib/src/vespa/searchlib/test/fakedata/fakeword.h12
-rw-r--r--searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h6
-rw-r--r--searchlib/src/vespa/searchlib/util/rand48.h43
-rw-r--r--searchlib/src/vespa/searchlib/util/random_normal.h4
-rw-r--r--searchlib/src/vespa/searchlib/util/randomgenerator.h4
26 files changed, 75 insertions, 121 deletions
diff --git a/searchlib/src/apps/tests/btreestress_test.cpp b/searchlib/src/apps/tests/btreestress_test.cpp
index e6ef0740fc3..a39416c2227 100644
--- a/searchlib/src/apps/tests/btreestress_test.cpp
+++ b/searchlib/src/apps/tests/btreestress_test.cpp
@@ -6,7 +6,7 @@
#include <vespa/vespalib/btree/btreenodeallocator.h>
#include <vespa/vespalib/btree/btree.h>
#include <vespa/vespalib/btree/btreestore.h>
-#include <vespa/searchlib/util/rand48.h>
+#include <vespa/vespalib/util/rand48.h>
#include <vespa/vespalib/btree/btreenodeallocator.hpp>
#include <vespa/vespalib/btree/btreenode.hpp>
@@ -37,7 +37,7 @@ struct Fixture
MyTreeIterator _writeItr;
vespalib::ThreadStackExecutor _writer; // 1 write thread
vespalib::ThreadStackExecutor _readers; // multiple reader threads
- search::Rand48 _rnd;
+ vespalib::Rand48 _rnd;
uint32_t _keyLimit;
std::atomic<long> _readSeed;
std::atomic<long> _doneWriteWork;
@@ -135,7 +135,7 @@ Fixture::remove(uint32_t key)
void
Fixture::readWork(uint32_t cnt)
{
- search::Rand48 rnd;
+ vespalib::Rand48 rnd;
rnd.srand48(++_readSeed);
uint32_t i;
for (i = 0; i < cnt && _stopRead.load() == 0; ++i) {
@@ -159,7 +159,7 @@ Fixture::readWork()
void
Fixture::writeWork(uint32_t cnt)
{
- search::Rand48 &rnd(_rnd);
+ vespalib::Rand48 &rnd(_rnd);
for (uint32_t i = 0; i < cnt; ++i) {
uint32_t key = rnd.lrand48() % _keyLimit;
if ((rnd.lrand48() & 1) == 0) {
diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp
index 6bbd93bda84..041335b7ed1 100644
--- a/searchlib/src/apps/tests/memoryindexstress_test.cpp
+++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp
@@ -20,7 +20,7 @@
#include <vespa/searchlib/queryeval/fake_searchable.h>
#include <vespa/searchlib/queryeval/searchiterator.h>
#include <vespa/searchlib/test/index/mock_field_length_inspector.h>
-#include <vespa/searchlib/util/rand48.h>
+#include <vespa/vespalib/util/rand48.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/vespalib/util/sequencedtaskexecutor.h>
@@ -201,7 +201,7 @@ struct Fixture {
uint32_t _readThreads;
vespalib::ThreadStackExecutor _writer; // 1 write thread
vespalib::ThreadStackExecutor _readers; // multiple reader threads
- search::Rand48 _rnd;
+ vespalib::Rand48 _rnd;
uint32_t _keyLimit;
std::atomic<long> _readSeed;
std::atomic<long> _doneWriteWork;
@@ -285,7 +285,7 @@ Fixture::~Fixture()
void
Fixture::readWork(uint32_t cnt)
{
- search::Rand48 rnd;
+ vespalib::Rand48 rnd;
rnd.srand48(++_readSeed);
uint32_t i;
uint32_t emptyCount = 0;
@@ -345,7 +345,7 @@ Fixture::readWork()
void
Fixture::writeWork(uint32_t cnt)
{
- search::Rand48 &rnd(_rnd);
+ vespalib::Rand48 &rnd(_rnd);
for (uint32_t i = 0; i < cnt; ++i) {
uint32_t key = rnd.lrand48() % _keyLimit;
if ((rnd.lrand48() & 1) == 0) {
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());
}
diff --git a/searchlib/src/vespa/searchlib/features/randomfeature.h b/searchlib/src/vespa/searchlib/features/randomfeature.h
index 8c94b71071f..3a93e77d4d0 100644
--- a/searchlib/src/vespa/searchlib/features/randomfeature.h
+++ b/searchlib/src/vespa/searchlib/features/randomfeature.h
@@ -3,7 +3,7 @@
#pragma once
#include <vespa/searchlib/fef/blueprint.h>
-#include <vespa/searchlib/util/rand48.h>
+#include <vespa/vespalib/util/rand48.h>
namespace search::features {
@@ -12,8 +12,8 @@ namespace search::features {
**/
class RandomExecutor : public search::fef::FeatureExecutor {
private:
- Rand48 _rnd; // seeded once per query
- Rand48 _matchRnd; // seeded once per match
+ vespalib::Rand48 _rnd; // seeded once per query
+ vespalib::Rand48 _matchRnd; // seeded once per match
uint64_t _matchSeed;
public:
diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp
index 19080acaad3..4681861dd73 100644
--- a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp
+++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.cpp
@@ -31,7 +31,7 @@ namespace fakedata
static void
fillbitset(search::BitVector *bitvector,
unsigned int size,
- search::Rand48 &rnd)
+ vespalib::Rand48 &rnd)
{
unsigned int range;
unsigned int idx;
@@ -70,7 +70,7 @@ static void
fillcorrelatedbitset(search::BitVector &bitvector,
unsigned int size,
const FakeWord &otherword,
- search::Rand48 &rnd)
+ vespalib::Rand48 &rnd)
{
const FakeWord::DocWordFeatureList &opostings = otherword._postings;
@@ -145,7 +145,7 @@ FakeWord::FakeWord(uint32_t docIdLimit,
for (uint32_t docId : docIds) {
bitmap->setBit(docId);
}
- search::Rand48 rnd;
+ vespalib::Rand48 rnd;
fakeup(*bitmap, rnd, _postings, _wordPosFeatures);
}
@@ -153,7 +153,7 @@ FakeWord::FakeWord(uint32_t docIdLimit,
uint32_t wordDocs,
uint32_t tempWordDocs,
const std::string &name,
- search::Rand48 &rnd,
+ vespalib::Rand48 &rnd,
const PosOccFieldsParams &fieldsParams,
uint32_t packedIndex)
: _postings(),
@@ -181,7 +181,7 @@ FakeWord::FakeWord(uint32_t docIdLimit,
const std::string &name,
const FakeWord &otherWord,
size_t overlapDocs,
- search::Rand48 &rnd,
+ vespalib::Rand48 &rnd,
const PosOccFieldsParams &fieldsParams,
uint32_t packedIndex)
: _postings(),
@@ -211,7 +211,7 @@ FakeWord::~FakeWord()
void
FakeWord::fakeup(search::BitVector &bitmap,
- search::Rand48 &rnd,
+ vespalib::Rand48 &rnd,
DocWordFeatureList &postings,
DocWordPosFeatureList &wordPosFeatures)
{
@@ -301,7 +301,7 @@ FakeWord::fakeup(search::BitVector &bitmap,
void
-FakeWord::fakeupTemps(search::Rand48 &rnd,
+FakeWord::fakeupTemps(vespalib::Rand48 &rnd,
uint32_t docIdLimit,
uint32_t tempWordDocs)
{
@@ -315,7 +315,7 @@ FakeWord::fakeupTemps(search::Rand48 &rnd,
}
void
-FakeWord::setupRandomizer(search::Rand48 &rnd)
+FakeWord::setupRandomizer(vespalib::Rand48 &rnd)
{
typedef DocWordFeatureList DWFL;
Randomizer randomAdd;
diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.h b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.h
index 30f960c2d4c..ffe9e2e54d0 100644
--- a/searchlib/src/vespa/searchlib/test/fakedata/fakeword.h
+++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeword.h
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/searchlib/util/rand48.h>
+#include <vespa/vespalib/util/rand48.h>
#include <vector>
#include <vespa/searchlib/queryeval/searchiterator.h>
#include <vespa/searchlib/bitcompression/compression.h>
@@ -156,16 +156,16 @@ public:
void
fakeup(search::BitVector &bitmap,
- search::Rand48 &rnd,
+ vespalib::Rand48 &rnd,
DocWordFeatureList &postings,
DocWordPosFeatureList &wordPosFeatures);
void
- fakeupTemps(search::Rand48 &rnd,
+ fakeupTemps(vespalib::Rand48 &rnd,
uint32_t docIdLimit,
uint32_t tempWordDocs);
- void setupRandomizer(search::Rand48 &rnd);
+ void setupRandomizer(vespalib::Rand48 &rnd);
const DocWordFeature &
getDocWordFeature(const Randomizer &r) const
@@ -220,7 +220,7 @@ public:
uint32_t wordDocs,
uint32_t tempWordDocs,
const std::string &name,
- search::Rand48 &rnd,
+ vespalib::Rand48 &rnd,
const PosOccFieldsParams &fieldsParams,
uint32_t packedIndex);
@@ -230,7 +230,7 @@ public:
const std::string &name,
const FakeWord &otherWord,
size_t overlapDocs,
- search::Rand48 &rnd,
+ vespalib::Rand48 &rnd,
const PosOccFieldsParams &fieldsParams,
uint32_t packedIndex);
diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp
index ba691e507fa..6bb39598fab 100644
--- a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp
+++ b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.cpp
@@ -77,7 +77,7 @@ FakeWordSet::setupParams(bool hasElements,
}
void
-FakeWordSet::setupWords(search::Rand48 &rnd,
+FakeWordSet::setupWords(vespalib::Rand48 &rnd,
uint32_t numDocs,
uint32_t commonDocFreq,
uint32_t numWordsPerWordClass)
@@ -86,7 +86,7 @@ FakeWordSet::setupWords(search::Rand48 &rnd,
}
void
-FakeWordSet::setupWords(search::Rand48 &rnd,
+FakeWordSet::setupWords(vespalib::Rand48 &rnd,
uint32_t numDocs,
uint32_t commonDocFreq,
uint32_t mediumDocFreq,
diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h
index 3dcf47cf8c8..de7efef1517 100644
--- a/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h
+++ b/searchlib/src/vespa/searchlib/test/fakedata/fakewordset.h
@@ -6,7 +6,7 @@
#include <vespa/searchlib/bitcompression/posocccompression.h>
#include <vespa/searchlib/bitcompression/posocc_fields_params.h>
-namespace search { class Rand48; }
+namespace vespalib { class Rand48; }
namespace search::fakedata {
@@ -46,12 +46,12 @@ public:
void setupParams(bool hasElements,
bool hasElementWeights);
- void setupWords(search::Rand48 &rnd,
+ void setupWords(vespalib::Rand48 &rnd,
uint32_t numDocs,
uint32_t commonDocFreq,
uint32_t numWordsPerWordClass);
- void setupWords(search::Rand48 &rnd,
+ void setupWords(vespalib::Rand48 &rnd,
uint32_t numDocs,
uint32_t commonDocFreq,
uint32_t mediumDocFreq,
diff --git a/searchlib/src/vespa/searchlib/util/rand48.h b/searchlib/src/vespa/searchlib/util/rand48.h
deleted file mode 100644
index 8ef529493c1..00000000000
--- a/searchlib/src/vespa/searchlib/util/rand48.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include <cstdlib>
-#include <cstdint>
-
-namespace search {
-
-/*
- * Simple random generator based on lrand48() spec.
- */
-class Rand48
-{
-private:
- uint64_t _state;
-public:
- void
- srand48(long seed)
- {
- _state = ((static_cast<uint64_t>(seed & 0xffffffffu)) << 16) + 0x330e;
- }
-
- Rand48()
- : _state(0)
- {
- srand48(0x1234abcd);
- };
- void iterate() {
- _state = (UINT64_C(0x5DEECE66D) * _state + 0xb) &
- UINT64_C(0xFFFFFFFFFFFF);
- }
- /*
- * Return value from 0 to 2^31 - 1
- */
- long lrand48() {
- iterate();
- return static_cast<long>(_state >> 17);
- }
-};
-
-} // namespace search
-
diff --git a/searchlib/src/vespa/searchlib/util/random_normal.h b/searchlib/src/vespa/searchlib/util/random_normal.h
index 74596066312..c74935de02f 100644
--- a/searchlib/src/vespa/searchlib/util/random_normal.h
+++ b/searchlib/src/vespa/searchlib/util/random_normal.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/searchlib/util/rand48.h>
+#include <vespa/vespalib/util/rand48.h>
#include <cmath>
namespace search {
@@ -14,7 +14,7 @@ namespace search {
class RandomNormal
{
private:
- Rand48 _rnd;
+ vespalib::Rand48 _rnd;
double _mean;
double _stddev;
diff --git a/searchlib/src/vespa/searchlib/util/randomgenerator.h b/searchlib/src/vespa/searchlib/util/randomgenerator.h
index 40305a1d02d..ac23b387740 100644
--- a/searchlib/src/vespa/searchlib/util/randomgenerator.h
+++ b/searchlib/src/vespa/searchlib/util/randomgenerator.h
@@ -2,7 +2,7 @@
#pragma once
-#include <vespa/searchlib/util/rand48.h>
+#include <vespa/vespalib/util/rand48.h>
#include <vespa/vespalib/stllike/string.h>
#include <vector>
#include <cassert>
@@ -11,7 +11,7 @@ namespace search {
class RandomGenerator
{
private:
- Rand48 _rnd;
+ vespalib::Rand48 _rnd;
public:
RandomGenerator() : _rnd() {}