aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-02-04 10:53:45 +0100
committerGitHub <noreply@github.com>2023-02-04 10:53:45 +0100
commitaf3f18d04035756819ab5c39aaf0e45e41b63f9d (patch)
tree7de5f1689259382c020349853dd691d55e752f23
parentf064fca059cfbab773c61893a39d34602d3616e2 (diff)
parent70327112cb2679dcf0e4879d71fe745c33a42bb7 (diff)
Merge pull request #25871 from vespa-engine/balder/drop-boost-crc-random-tokenizer
Drop boost crc, random and tokenizer
-rw-r--r--document/src/tests/documenttestcase.cpp31
-rw-r--r--document/src/vespa/document/base/testdocman.cpp36
-rw-r--r--document/src/vespa/document/fieldvalue/document.cpp15
-rw-r--r--document/src/vespa/document/fieldvalue/document.h3
-rw-r--r--document/src/vespa/document/fieldvalue/stringfieldvalue.h8
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.cpp14
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.h4
-rw-r--r--messagebus/src/vespa/messagebus/testlib/custompolicy.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/ftlib.cpp64
-rw-r--r--searchlib/src/vespa/searchlib/fef/test/ftlib.h2
-rw-r--r--searchlib/src/vespa/searchlib/test/doc_builder.cpp18
-rw-r--r--searchlib/src/vespa/searchlib/test/doc_builder.h2
-rw-r--r--vespalib/src/tests/bits/bits_test.cpp34
-rw-r--r--vespalib/src/tests/crc/crc_test.cpp47
-rw-r--r--vespalib/src/vespa/vespalib/util/crc.h1
-rw-r--r--vespalib/src/vespa/vespalib/util/rand48.h11
16 files changed, 94 insertions, 210 deletions
diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp
index 4c97e99459e..bc4065438e6 100644
--- a/document/src/tests/documenttestcase.cpp
+++ b/document/src/tests/documenttestcase.cpp
@@ -900,37 +900,6 @@ TEST(DocumentTest, testBogusserialize)
}
}
-TEST(DocumentTest, testCRC32)
-{
- TestDocRepo test_repo;
- Document doc(*test_repo.getDocumentType("testdoctype1"), DocumentId("id:ns:testdoctype1::crawler:http://www.ntnu.no/"));
-
- doc.setValue(doc.getField("hstringval"), StringFieldValue("bla bla bla bla bla"));
-
- uint32_t crc = doc.calculateChecksum();
- EXPECT_EQ(3987392271u, crc);
-
- nbostream buf = doc.serialize();
-
- int pos = 30;
-
- // Corrupt serialization.
- const_cast<char *>(buf.peek())[pos] ^= 72;
- // Create document. Byte corrupted above is in data area and
- // shouldn't fail deserialization.
- try {
- Document doc2(test_repo.getTypeRepo(), buf);
- buf.rp(0);
- EXPECT_TRUE(crc != doc2.calculateChecksum());
- } catch (document::DeserializeException& e) {
- EXPECT_TRUE(false);
- }
- // Return original value and retry
- const_cast<char *>(buf.peek())[pos] ^= 72;
-
- /// \todo TODO (was warning): Cannot test for in memory representation altered, as there is no syntax for getting internal refs to data from document. Add test when this is added.
-}
-
TEST(DocumentTest, testSliceSerialize)
{
// Test that document doesn't need its own bytebuffer, such that we
diff --git a/document/src/vespa/document/base/testdocman.cpp b/document/src/vespa/document/base/testdocman.cpp
index 2994de9c9c1..59e4d4d8386 100644
--- a/document/src/vespa/document/base/testdocman.cpp
+++ b/document/src/vespa/document/base/testdocman.cpp
@@ -5,7 +5,7 @@
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/document/fieldvalue/stringfieldvalue.h>
-#include <boost/random.hpp>
+#include <vespa/vespalib/util/rand48.h>
#include <sstream>
namespace document {
@@ -62,13 +62,13 @@ TestDocMan::TestDocMan()
_typeCfg(&_test_repo.getTypeConfig())
{ }
-TestDocMan::~TestDocMan() { }
+TestDocMan::~TestDocMan() = default;
void
TestDocMan::setTypeRepo(const std::shared_ptr<const DocumentTypeRepo> &repo)
{
_repo = repo;
- _typeCfg = NULL;
+ _typeCfg = nullptr;
}
Document::UP
@@ -77,8 +77,7 @@ TestDocMan::createDocument(
const std::string& id,
const std::string& type) const
{
- const DocumentType *type_ptr = 0;
- type_ptr = _repo->getDocumentType(type);
+ const DocumentType *type_ptr = _repo->getDocumentType(type);
assert(type_ptr);
Document::UP doc(new Document(*type_ptr, DocumentId(id)));
doc->setValue(doc->getField("content"), StringFieldValue(content.c_str()));
@@ -96,11 +95,11 @@ Document::UP
TestDocMan::createRandomDocumentAtLocation(
int location, int seed, int maxContentSize) const
{
- boost::rand48 rnd(seed);
+ vespalib::Rand48 rnd(seed);
std::ostringstream id;
- id << "id:mail:testdoctype1:n=" << location << ":" << (rnd() % 0x10000)
+ id << "id:mail:testdoctype1:n=" << location << ":" << (rnd.lrand48() % 0x10000)
<< ".html";
- return createDocument(generateRandomContent(rnd() % maxContentSize),
+ return createDocument(generateRandomContent(rnd.lrand48() % maxContentSize),
id.str(), "testdoctype1");
}
@@ -108,27 +107,26 @@ Document::UP
TestDocMan::createRandomDocumentAtLocation(
int location, int seed, int minContentSize, int maxContentSize) const
{
- boost::rand48 rnd(seed);
+ vespalib::Rand48 rnd(seed);
std::ostringstream id;
- id << "id:mail:testdoctype1:n=" << location << ":" << (rnd() % 0x10000)
+ id << "id:mail:testdoctype1:n=" << location << ":" << (rnd.lrand48() % 0x10000)
<< ".html";
- int size = maxContentSize > minContentSize ?
- rnd() % (maxContentSize - minContentSize) + minContentSize :
- minContentSize;
+ int size = maxContentSize > minContentSize
+ ? rnd.lrand48() % (maxContentSize - minContentSize) + minContentSize
+ : minContentSize;
return
createDocument(generateRandomContent(size), id.str(), "testdoctype1");
}
Document::UP
-TestDocMan::createRandomDocument(
- const std::string& type, int seed, int maxContentSize) const
+TestDocMan::createRandomDocument(const std::string& type, int seed, int maxContentSize) const
{
- boost::rand48 rnd(seed);
+ vespalib::Rand48 rnd(seed);
std::ostringstream id;
- id << "id:mail:" << type << ":n=" << (rnd() % 0xFFFF);
- id << ":" << (rnd() % 256) << ".html";
- return createDocument(generateRandomContent(rnd() % maxContentSize), id.str(), type);
+ id << "id:mail:" << type << ":n=" << (rnd.lrand48() % 0xFFFF);
+ id << ":" << (rnd.lrand48() % 256) << ".html";
+ return createDocument(generateRandomContent(rnd.lrand48() % maxContentSize), id.str(), type);
}
std::string
diff --git a/document/src/vespa/document/fieldvalue/document.cpp b/document/src/vespa/document/fieldvalue/document.cpp
index 0cd1faa5d62..33b1bbe8d2c 100644
--- a/document/src/vespa/document/fieldvalue/document.cpp
+++ b/document/src/vespa/document/fieldvalue/document.cpp
@@ -3,7 +3,6 @@
#include "document.h"
#include "structuredcache.h"
#include <vespa/document/datatype/documenttype.h>
-#include <vespa/vespalib/util/crc.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/document/serialization/vespadocumentserializer.h>
@@ -238,20 +237,6 @@ Document::toXml(const std::string& indent) const
return ost.str();
}
-uint32_t
-Document::calculateChecksum() const
-{
- vespalib::string docId(_id.toString());
- const vespalib::string & typeName(getType().getName());
- uint16_t typeVersion(0); // Hardcode version 0 (version not supported)
-
- vespalib::crc_32_type calculator;
- calculator.process_bytes(docId.c_str(), docId.size());
- calculator.process_bytes(typeName.c_str(), typeName.size());
- calculator.process_bytes(&typeVersion, sizeof(typeVersion));
- return calculator.checksum() ^ _fields.calculateChecksum();
-}
-
void Document::serializeHeader(nbostream& stream) const {
VespaDocumentSerializer serializer(stream);
serializer.write(*this);
diff --git a/document/src/vespa/document/fieldvalue/document.h b/document/src/vespa/document/fieldvalue/document.h
index efdc61c93b0..c871e324f05 100644
--- a/document/src/vespa/document/fieldvalue/document.h
+++ b/document/src/vespa/document/fieldvalue/document.h
@@ -106,7 +106,6 @@ public:
bool empty() const override { return _fields.empty(); }
- uint32_t calculateChecksum() const;
void setFieldValue(const Field& field, FieldValue::UP data) override;
private:
friend TransactionGuard;
@@ -125,7 +124,7 @@ private:
class TransactionGuard {
public:
- TransactionGuard(Document & value)
+ explicit TransactionGuard(Document & value)
: _value(value)
{
_value.beginTransaction();
diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.h b/document/src/vespa/document/fieldvalue/stringfieldvalue.h
index a9d1267d21c..1f364acc760 100644
--- a/document/src/vespa/document/fieldvalue/stringfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.h
@@ -30,7 +30,7 @@ public:
StringFieldValue &operator=(const StringFieldValue &rhs);
StringFieldValue &operator=(vespalib::stringref value) override;
- ~StringFieldValue();
+ ~StringFieldValue() override;
FieldValue &assign(const FieldValue &) override;
@@ -69,9 +69,9 @@ private:
VESPA_DLL_LOCAL AnnotationData(vespalib::ConstBufferRef serialized, const FixedTypeRepo &repo,
uint8_t version, bool isSerializedDataLongLived);
- bool hasSpanTrees() const { return _serialized.size() > 0u; }
- vespalib::ConstBufferRef getSerializedAnnotations() const { return _serialized; }
- VESPA_DLL_LOCAL SpanTrees getSpanTrees() const;
+ [[nodiscard]] bool hasSpanTrees() const { return _serialized.size() > 0u; }
+ [[nodiscard]] vespalib::ConstBufferRef getSerializedAnnotations() const { return _serialized; }
+ [[nodiscard]] VESPA_DLL_LOCAL SpanTrees getSpanTrees() const;
private:
vespalib::ConstBufferRef _serialized;
BackingBlob _backingBlob;
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
index 7975dd3a327..444e763c52b 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
@@ -7,7 +7,6 @@
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <vespa/vespalib/util/crc.h>
#include <vespa/document/datatype/positiondatatype.h>
#include <vespa/document/util/serializableexceptions.h>
#include <vespa/document/base/exceptions.h>
@@ -148,7 +147,7 @@ StructFieldValue::getFieldValue(const Field& field) const
}
return value;
}
- return FieldValue::UP();
+ return {};
}
vespalib::ConstBufferRef
@@ -159,7 +158,7 @@ StructFieldValue::getRawField(uint32_t id) const
return buf;
}
- return vespalib::ConstBufferRef();
+ return {};
}
bool
@@ -265,15 +264,6 @@ StructFieldValue::compare(const FieldValue& otherOrg) const
return 0;
}
-uint32_t
-StructFieldValue::calculateChecksum() const
-{
- nbostream buffer(serialize());
- vespalib::crc_32_type calculator;
- calculator.process_bytes(buffer.peek(), buffer.size());
- return calculator.checksum();
-}
-
void
StructFieldValue::printXml(XmlOutputStream& xos) const
{
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.h b/document/src/vespa/document/fieldvalue/structfieldvalue.h
index 564c48273e6..360aa6dca63 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.h
@@ -35,7 +35,7 @@ private:
public:
using UP = std::unique_ptr<StructFieldValue>;
- StructFieldValue(const DataType &type);
+ explicit StructFieldValue(const DataType &type);
StructFieldValue(const StructFieldValue & rhs);
StructFieldValue & operator = (const StructFieldValue & rhs);
StructFieldValue(StructFieldValue && rhs) noexcept = default;
@@ -83,8 +83,6 @@ public:
*/
bool hasChanged() const { return _hasChanged; }
- uint32_t calculateChecksum() const;
-
/**
* Called by document to reset struct when deserializing where this struct
* has no content. This clears content and sets changed to false.
diff --git a/messagebus/src/vespa/messagebus/testlib/custompolicy.cpp b/messagebus/src/vespa/messagebus/testlib/custompolicy.cpp
index c7db802420d..a2d99d0c63a 100644
--- a/messagebus/src/vespa/messagebus/testlib/custompolicy.cpp
+++ b/messagebus/src/vespa/messagebus/testlib/custompolicy.cpp
@@ -4,7 +4,7 @@
#include <vespa/messagebus/emptyreply.h>
#include <vespa/messagebus/errorcode.h>
#include <vespa/messagebus/routing/routingcontext.h>
-#include <boost/tokenizer.hpp>
+#include <vespa/vespalib/text/stringtokenizer.h>
#include <vespa/log/log.h>
LOG_SETUP(".custompolicy");
@@ -114,15 +114,9 @@ std::vector<Route>
CustomPolicyFactory::parseRoutes(const string &str)
{
std::vector<Route> routes;
- using Separator = boost::char_separator<char>;
- using Tokenizer = boost::tokenizer<Separator>;
- Separator separator(",");
- std::string stdstr(str);
- Tokenizer tokenizer(stdstr, separator);
- for (Tokenizer::iterator it = tokenizer.begin();
- it != tokenizer.end(); ++it)
- {
- routes.push_back(Route::parse(*it));
+ vespalib::StringTokenizer tokenizer(str, ",", "");
+ for (const auto & token : tokenizer) {
+ routes.emplace_back(Route::parse(token));
}
return routes;
}
diff --git a/searchlib/src/vespa/searchlib/fef/test/ftlib.cpp b/searchlib/src/vespa/searchlib/fef/test/ftlib.cpp
index bd627258c66..a6b59ed38fc 100644
--- a/searchlib/src/vespa/searchlib/fef/test/ftlib.cpp
+++ b/searchlib/src/vespa/searchlib/fef/test/ftlib.cpp
@@ -4,7 +4,7 @@
#include "dummy_dependency_handler.h"
#include <vespa/searchlib/features/utils.h>
#include <vespa/vespalib/util/stringfmt.h>
-#include <boost/tokenizer.hpp>
+#include <vespa/vespalib/text/stringtokenizer.h>
#include <vespa/log/log.h>
LOG_SETUP(".ftlib");
@@ -26,12 +26,9 @@ FtQueryEnvironment::FtQueryEnvironment(search::fef::test::IndexEnvironment &env)
{
}
-FtQueryEnvironment::~FtQueryEnvironment() { }
+FtQueryEnvironment::~FtQueryEnvironment() = default;
-FtDumpFeatureVisitor::FtDumpFeatureVisitor() :
- _features()
-{
-}
+FtDumpFeatureVisitor::FtDumpFeatureVisitor() = default;
FtFeatureTest::FtFeatureTest(search::fef::BlueprintFactory &factory, const vespalib::string &feature) :
_indexEnv(),
@@ -49,7 +46,7 @@ FtFeatureTest::FtFeatureTest(search::fef::BlueprintFactory &factory, const std::
{
}
-FtFeatureTest::~FtFeatureTest() {}
+FtFeatureTest::~FtFeatureTest() = default;
//---------------------------------------------------------------------------------------------------------------------
// FtUtil
@@ -57,19 +54,16 @@ FtFeatureTest::~FtFeatureTest() {}
std::vector<vespalib::string>
FtUtil::tokenize(const vespalib::string & str, const vespalib::string & separator)
{
- using Tokenizer = boost::tokenizer<boost::char_separator<char> >;
- using Separator = boost::char_separator<char>;
-
std::vector<vespalib::string> retval;
if (separator != vespalib::string("")) {
- std::string stdstr(str);
- Tokenizer tnz(stdstr, Separator(separator.c_str()));
- for (Tokenizer::const_iterator itr = tnz.begin(); itr != tnz.end(); ++itr) {
- retval.push_back(*itr);
+ vespalib::StringTokenizer tnz(str, separator);
+ tnz.removeEmptyTokens();
+ for (auto token : tnz) {
+ retval.emplace_back(token);
}
} else {
for (uint32_t i = 0; i < str.size(); ++i) {
- retval.push_back(str.substr(i, 1));
+ retval.emplace_back(str.substr(i, 1));
}
}
return retval;
@@ -87,15 +81,15 @@ FtUtil::toQuery(const vespalib::string & query, const vespalib::string & separat
std::vector<vespalib::string> connexitySplit = FtUtil::tokenize(weightSplit[0], vespalib::string(":"));
if (connexitySplit.size() > 1) {
retval[i].term = connexitySplit[1];
- retval[i].connexity = search::features::util::strToNum<feature_t>(connexitySplit[0]);
+ retval[i].connexity = util::strToNum<feature_t>(connexitySplit[0]);
} else {
retval[i].term = connexitySplit[0];
}
if (significanceSplit.size() > 1) {
- retval[i].significance = search::features::util::strToNum<feature_t>(significanceSplit[1]);
+ retval[i].significance = util::strToNum<feature_t>(significanceSplit[1]);
}
if (weightSplit.size() > 1) {
- retval[i].termWeight.setPercent(search::features::util::strToNum<uint32_t>(weightSplit[1]));
+ retval[i].termWeight.setPercent(util::strToNum<uint32_t>(weightSplit[1]));
}
}
return retval;
@@ -106,8 +100,8 @@ FtUtil::toRankResult(const vespalib::string & baseName, const vespalib::string &
{
RankResult retval;
std::vector<vespalib::string> prepResult = FtUtil::tokenize(result, separator);
- for (uint32_t i = 0; i < prepResult.size(); ++i) {
- std::vector<vespalib::string> rs = FtUtil::tokenize(prepResult[i], ":");
+ for (const auto & str : prepResult) {
+ std::vector<vespalib::string> rs = FtUtil::tokenize(str, ":");
vespalib::string name = rs[0];
vespalib::string value = rs[1];
retval.addScore(baseName + "." + name, search::features::util::strToNum<feature_t>(value));
@@ -115,7 +109,7 @@ FtUtil::toRankResult(const vespalib::string & baseName, const vespalib::string &
return retval;
}
-FtIndex::~FtIndex() {}
+FtIndex::~FtIndex() = default;
//---------------------------------------------------------------------------------------------------------------------
// FtTestApp
@@ -187,9 +181,9 @@ FtTestApp::FT_DUMP(search::fef::BlueprintFactory &factory, const vespalib::strin
{
FtDumpFeatureVisitor dfv;
search::fef::Blueprint::SP bp = factory.createBlueprint(baseName);
- if (bp.get() == NULL) {
+ if ( ! bp) {
LOG(error, "Blueprint '%s' does not exist in factory, did you forget to add it?", baseName.c_str());
- ASSERT_TRUE(bp.get() != NULL);
+ ASSERT_TRUE(bp);
}
bp->visitDumpFeatures(env, dfv);
FT_EQUAL(expected, dfv.features(), "Dump");
@@ -197,7 +191,7 @@ FtTestApp::FT_DUMP(search::fef::BlueprintFactory &factory, const vespalib::strin
void
FtTestApp::FT_EQUAL(const std::vector<string> &expected, const std::vector<string> &actual,
- const vespalib::string prefix)
+ const vespalib::string &prefix)
{
FT_LOG(prefix + " expected", expected);
FT_LOG(prefix + " actual ", actual);
@@ -215,9 +209,8 @@ FtTestApp::FT_LOG(const search::fef::Blueprint &prototype, const search::fef::te
{
LOG(info, "Testing blueprint '%s'.", prototype.getBaseName().c_str());
std::vector<vespalib::string> arr;
- for (std::vector<search::fef::FieldInfo>::const_iterator it = env.getFields().begin();
- it != env.getFields().end(); ++it) {
- arr.push_back(it->name());
+ for (const auto & it : env.getFields()) {
+ arr.push_back(it.name());
}
FT_LOG("Environment ", arr);
FT_LOG("Parameters ", params);
@@ -252,8 +245,7 @@ FtTestApp::FT_SETUP(FtFeatureTest &test, const vespalib::string &query, const St
// Add all occurences.
search::fef::test::MatchDataBuilder::UP mdb = test.createMatchDataBuilder();
- for (StringMap::const_iterator it = index.begin();
- it != index.end(); ++it) {
+ for (auto it = index.begin();it != index.end(); ++it) {
ASSERT_TRUE(mdb->setFieldLength(it->first, it->second.size()));
for (uint32_t i = 0; i < it->second.size(); ++i) {
size_t pos = query.find_first_of(it->second[i]);
@@ -276,10 +268,10 @@ FtTestApp::FT_SETUP(FtFeatureTest & test, const std::vector<FtQueryTerm> & query
search::fef::test::MatchDataBuilder::UP mdb = test.createMatchDataBuilder();
// Add all occurences.
- for (StringVectorMap::const_iterator itr = index.begin(); itr != index.end(); ++itr) {
+ for (auto itr = index.begin(); itr != index.end(); ++itr) {
ASSERT_TRUE(mdb->setFieldLength(itr->first, itr->second.size()));
for (uint32_t i = 0; i < itr->second.size(); ++i) {
- FtQuery::const_iterator fitr = query.begin();
+ auto fitr = query.begin();
for (;;) {
fitr = std::find(fitr, query.end(), FtQueryTerm(itr->second[i]));
if (fitr != query.end()) {
@@ -304,7 +296,7 @@ FtTestApp::FT_SETUP(FtFeatureTest &test, const FtQuery &query, const FtIndex &in
search::fef::test::MatchDataBuilder::UP mdb = test.createMatchDataBuilder();
// Add all occurences.
- for (FtIndex::FieldMap::const_iterator itr = index.index.begin(); itr != index.index.end(); ++itr) {
+ for (auto itr = index.index.begin(); itr != index.index.end(); ++itr) {
const FtIndex::Field &field = itr->second;
for (size_t e = 0; e < field.size(); ++e) {
const FtIndex::Element &element = field[e];
@@ -353,7 +345,7 @@ FtTestApp::setupFieldMatch(FtFeatureTest & ft, const vespalib::string & indexNam
{
ft.getIndexEnv().getBuilder().addField(FieldType::INDEX, FieldInfo::CollectionType::SINGLE, indexName);
- if (params != NULL) {
+ if (params != nullptr) {
Properties & p = ft.getIndexEnv().getProperties();
p.add("fieldMatch(" + indexName + ").proximityLimit", vespalib::make_string("%u", params->getProximityLimit()));
p.add("fieldMatch(" + indexName + ").maxAlternativeSegmentations", vespalib::make_string("%u", params->getMaxAlternativeSegmentations()));
@@ -364,10 +356,8 @@ FtTestApp::setupFieldMatch(FtFeatureTest & ft, const vespalib::string & indexNam
p.add("fieldMatch(" + indexName + ").segmentProximityImportance", vespalib::make_string("%f", params->getSegmentProximityImportance()));
p.add("fieldMatch(" + indexName + ").occurrenceImportance", vespalib::make_string("%f", params->getOccurrenceImportance()));
p.add("fieldMatch(" + indexName + ").fieldCompletenessImportance", vespalib::make_string("%f", params->getFieldCompletenessImportance()));
- for (std::vector<feature_t>::const_iterator it = params->getProximityTable().begin();
- it != params->getProximityTable().end(); ++it)
- {
- p.add("fieldMatch(" + indexName + ").proximityTable", vespalib::make_string("%f", *it));
+ for (double it : params->getProximityTable()) {
+ p.add("fieldMatch(" + indexName + ").proximityTable", vespalib::make_string("%f", it));
}
}
diff --git a/searchlib/src/vespa/searchlib/fef/test/ftlib.h b/searchlib/src/vespa/searchlib/fef/test/ftlib.h
index 27e23fbbfdc..38c2c1b394c 100644
--- a/searchlib/src/vespa/searchlib/fef/test/ftlib.h
+++ b/searchlib/src/vespa/searchlib/fef/test/ftlib.h
@@ -207,7 +207,7 @@ struct FtTestApp : public vespalib::TestApp {
const StringList &expected);
static void FT_EQUAL(const std::vector<string> &expected, const std::vector<string> &actual,
- const vespalib::string prefix = "");
+ const vespalib::string & prefix = "");
static void FT_LOG(const search::fef::Blueprint &prototype, const search::fef::test::IndexEnvironment &env, const StringList &params);
static void FT_LOG(const vespalib::string &prefix, const std::vector<vespalib::string> &arr);
diff --git a/searchlib/src/vespa/searchlib/test/doc_builder.cpp b/searchlib/src/vespa/searchlib/test/doc_builder.cpp
index 4ed64b9bfe6..2097cd53b2c 100644
--- a/searchlib/src/vespa/searchlib/test/doc_builder.cpp
+++ b/searchlib/src/vespa/searchlib/test/doc_builder.cpp
@@ -80,15 +80,6 @@ DocBuilder::make_array(vespalib::stringref field_name)
assert(field_type.isArray());
return {field_type};
}
-MapFieldValue
-DocBuilder::make_map(vespalib::stringref field_name)
-{
- auto& field = _document_type->getField(field_name);
- auto& field_type = field.getDataType();
- assert(field_type.isMap());
- return {field_type};
-
-}
WeightedSetFieldValue
DocBuilder::make_wset(vespalib::stringref field_name)
@@ -99,13 +90,4 @@ DocBuilder::make_wset(vespalib::stringref field_name)
return {field_type};
}
-StructFieldValue
-DocBuilder::make_struct(vespalib::stringref field_name)
-{
- auto& field = _document_type->getField(field_name);
- auto& field_type = field.getDataType();
- assert(field_type.isStructured());
- return {field_type};
-}
-
}
diff --git a/searchlib/src/vespa/searchlib/test/doc_builder.h b/searchlib/src/vespa/searchlib/test/doc_builder.h
index 1f652694b0a..01aadb7b9c4 100644
--- a/searchlib/src/vespa/searchlib/test/doc_builder.h
+++ b/searchlib/src/vespa/searchlib/test/doc_builder.h
@@ -42,9 +42,7 @@ public:
const document::DataType &get_data_type(const vespalib::string &name) const;
const DocumenttypesConfig& get_documenttypes_config() const noexcept { return *_document_types_config; }
document::ArrayFieldValue make_array(vespalib::stringref field_name);
- document::MapFieldValue make_map(vespalib::stringref field_name);
document::WeightedSetFieldValue make_wset(vespalib::stringref field_name);
- document::StructFieldValue make_struct(vespalib::stringref field_name);
};
}
diff --git a/vespalib/src/tests/bits/bits_test.cpp b/vespalib/src/tests/bits/bits_test.cpp
index 47d691c739d..7d4de014860 100644
--- a/vespalib/src/tests/bits/bits_test.cpp
+++ b/vespalib/src/tests/bits/bits_test.cpp
@@ -2,14 +2,6 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/bits.h>
-#include <boost/crc.hpp>
-#include <boost/version.hpp>
-
-#if BOOST_VERSION < 106900
- #define REFLECT reflect
-#else
- #define REFLECT reflect_q
-#endif
using namespace vespalib;
@@ -18,7 +10,7 @@ class Test : public TestApp
public:
int Main() override;
template <typename T>
- void testFixed(const T * v, size_t sz);
+ void testFixed(const T * v, size_t sz, const T * exp);
void testBuffer();
};
@@ -26,26 +18,30 @@ int
Test::Main()
{
TEST_INIT("bits_test");
- uint8_t u8[5] = { 0, 1, 127, 135, 255 };
- testFixed(u8, sizeof(u8)/sizeof(u8[0]));
- uint16_t u16[5] = { 0, 1, 127, 135, 255 };
- testFixed(u16, sizeof(u16)/sizeof(u16[0]));
- uint32_t u32[5] = { 0, 1, 127, 135, 255 };
- testFixed(u32, sizeof(u32)/sizeof(u32[0]));
- uint64_t u64[5] = { 0, 1, 127, 135, 255 };
- testFixed(u64, sizeof(u64)/sizeof(u64[0]));
+ uint8_t u8[5] = { 0, 0x1, 0x7f, 0x87, 0xff };
+ uint8_t exp8[5] = { 0, 0x80, 0xfe, 0xe1, 0xff };
+ testFixed(u8, sizeof(u8)/sizeof(u8[0]), exp8);
+ uint16_t u16[5] = { 0, 0x1, 0x7f, 0x87, 0xff };
+ uint16_t exp16[5] = { 0, 0x8000, 0xfe00, 0xe100, 0xff00 };
+ testFixed(u16, sizeof(u16)/sizeof(u16[0]), exp16);
+ uint32_t u32[5] = { 0, 0x1, 0x7f, 0x87, 0xff };
+ uint32_t exp32[5] = { 0, 0x80000000, 0xfe000000, 0xe1000000, 0xff000000 };
+ testFixed(u32, sizeof(u32)/sizeof(u32[0]), exp32);
+ uint64_t u64[5] = { 0, 0x1, 0x7f, 0x87, 0xff };
+ uint64_t exp64[5] = { 0, 0x8000000000000000, 0xfe00000000000000, 0xe100000000000000, 0xff00000000000000 };
+ testFixed(u64, sizeof(u64)/sizeof(u64[0]), exp64);
testBuffer();
TEST_DONE();
}
template <typename T>
-void Test::testFixed(const T * v, size_t sz)
+void Test::testFixed(const T * v, size_t sz, const T * exp)
{
EXPECT_EQUAL(0u, Bits::reverse(static_cast<T>(0)));
EXPECT_EQUAL(1ul << (sizeof(T)*8 - 1), Bits::reverse(static_cast<T>(1)));
EXPECT_EQUAL(static_cast<T>(-1), Bits::reverse(static_cast<T>(-1)));
for (size_t i(0); i < sz; i++) {
- EXPECT_EQUAL(Bits::reverse(v[i]), boost::detail::reflector<sizeof(T)*8>::REFLECT(v[i]));
+ EXPECT_EQUAL(Bits::reverse(v[i]), exp[i]);
EXPECT_EQUAL(Bits::reverse(Bits::reverse(v[i])), v[i]);
}
}
diff --git a/vespalib/src/tests/crc/crc_test.cpp b/vespalib/src/tests/crc/crc_test.cpp
index 8afeed487ee..28e904b5056 100644
--- a/vespalib/src/tests/crc/crc_test.cpp
+++ b/vespalib/src/tests/crc/crc_test.cpp
@@ -2,7 +2,6 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/crc.h>
-#include <boost/crc.hpp>
#include <vector>
using namespace vespalib;
@@ -12,7 +11,7 @@ class Test : public TestApp
public:
int Main() override;
void testCorrectNess();
- void testBenchmark(bool our, size_t bufSz, size_t numRep);
+ void testBenchmark(size_t bufSz, size_t numRep);
};
int
@@ -20,57 +19,43 @@ Test::Main()
{
TEST_INIT("crc_test");
testCorrectNess();
- if (_argc >= 2) {
- testBenchmark(false, 1024, 1000*1000);
- } else {
- testBenchmark(true, 1024, 1000*1000);
- }
+ testBenchmark(1024, 1000*1000);
TEST_DONE();
}
-void Test::testCorrectNess()
+void
+Test::testCorrectNess()
{
const char *a[7] = { "", "a", "ab", "abc", "abcd", "abcde", "doc:crawler:http://www.ntnu.no/" };
+ uint32_t expected[7] = {0, 0xe8b7be43, 0x9e83486d, 0x352441c2, 0xed82cd11, 0x8587d865, 0x86287fc5};
for (size_t i(0); i < sizeof(a)/sizeof(a[0]); i++) {
uint32_t vespaCrc32 = crc_32_type::crc(a[i], strlen(a[i]));
- boost::crc_32_type calculator;
- calculator.process_bytes(a[i], strlen(a[i]));
- EXPECT_EQUAL(vespaCrc32, calculator.checksum());
+ EXPECT_EQUAL(vespaCrc32, expected[i]);
vespalib::crc_32_type calculator2;
calculator2.process_bytes(a[i], strlen(a[i]));
EXPECT_EQUAL(vespaCrc32, calculator2.checksum());
- EXPECT_EQUAL(calculator.checksum(), calculator2.checksum());
}
- vespalib::crc_32_type calculator2;
- boost::crc_32_type calculator;
+ vespalib::crc_32_type calculator;
+ uint32_t accum_expected[7] = {0, 0xe8b7be43, 0x690e2297, 0x8d7284f9, 0x7ed0c389, 0x61bc2a26, 0x1816e339};
for (size_t i(0); i < sizeof(a)/sizeof(a[0]); i++) {
calculator.process_bytes(a[i], strlen(a[i]));
- calculator2.process_bytes(a[i], strlen(a[i]));
- EXPECT_EQUAL(calculator.checksum(), calculator2.checksum());
+ EXPECT_EQUAL(calculator.checksum(), accum_expected[i]);
}
- EXPECT_EQUAL(calculator.checksum(), calculator2.checksum());
}
-void Test::testBenchmark(bool our, size_t bufSz, size_t numRep)
+void
+Test::testBenchmark(size_t bufSz, size_t numRep)
{
std::vector<char> a(numRep+bufSz);
for(size_t i(0), m(a.size()); i < m; i++) {
a[i] = i&0xff;
}
uint32_t sum(0);
- if (our) {
- for (size_t i(0); i < (numRep); i++) {
- //sum ^= crc_32_type::crc(&a[i], bufSz);
- vespalib::crc_32_type calculator;
- calculator.process_bytes(&a[i], bufSz);
- sum ^=calculator.checksum();
- }
- } else {
- for (size_t i(0); i < (numRep); i++) {
- boost::crc_32_type calculator;
- calculator.process_bytes(&a[i], bufSz);
- sum ^=calculator.checksum();
- }
+ for (size_t i(0); i < (numRep); i++) {
+ //sum ^= crc_32_type::crc(&a[i], bufSz);
+ vespalib::crc_32_type calculator;
+ calculator.process_bytes(&a[i], bufSz);
+ sum ^=calculator.checksum();
}
printf("sum = %x\n", sum);
}
diff --git a/vespalib/src/vespa/vespalib/util/crc.h b/vespalib/src/vespa/vespalib/util/crc.h
index f5acafeff36..3e65946bd8c 100644
--- a/vespalib/src/vespa/vespalib/util/crc.h
+++ b/vespalib/src/vespa/vespalib/util/crc.h
@@ -14,7 +14,6 @@ class crc_32_type
{
public:
crc_32_type() : _c(uint32_t(-1)) { }
- void process_block(const void *start, const void *end) { process_bytes(start, (const uint8_t *)end-(const uint8_t *)start); }
void process_bytes(const void *start, size_t sz);
uint32_t checksum() const { return _c ^ uint32_t(-1); }
static uint32_t crc(const void * v, size_t sz);
diff --git a/vespalib/src/vespa/vespalib/util/rand48.h b/vespalib/src/vespa/vespalib/util/rand48.h
index 05290585f6d..374096404d5 100644
--- a/vespalib/src/vespa/vespalib/util/rand48.h
+++ b/vespalib/src/vespa/vespalib/util/rand48.h
@@ -15,17 +15,18 @@ class Rand48
private:
uint64_t _state;
public:
- void
- srand48(long seed)
- {
+ void srand48(long seed) {
_state = ((static_cast<uint64_t>(seed & 0xffffffffu)) << 16) + 0x330e;
}
Rand48()
+ : Rand48(0x1234abcd)
+ { }
+ explicit Rand48(long seed)
: _state(0)
{
- srand48(0x1234abcd);
- };
+ srand48(seed);
+ }
void iterate() {
_state = (UINT64_C(0x5DEECE66D) * _state + 0xb) &
UINT64_C(0xFFFFFFFFFFFF);