diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-03-23 11:44:07 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-03-27 07:54:52 +0000 |
commit | 490d18680b82b74a35750843b4f308c51cb089e1 (patch) | |
tree | 2c46c477243432059b68c1df8cd3b17a46ba8ff5 /searchcore/src/tests/proton/documentmetastore | |
parent | 5e33bb54604989bb2cef605572f7750d45eb630a (diff) |
- Wire in control of checksum type.
- Implement both legacy and xxhash64
- Add a small conformance test.
Diffstat (limited to 'searchcore/src/tests/proton/documentmetastore')
-rw-r--r-- | searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp index d436c63ae2e..d7d6159af61 100644 --- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp @@ -4,6 +4,7 @@ #include <vespa/searchcore/proton/documentmetastore/documentmetastore.h> #include <vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> +#include <vespa/searchcore/proton/bucketdb/checksumaggregators.h> #include <vespa/searchcore/proton/bucketdb/i_bucket_create_listener.h> #include <vespa/searchlib/attribute/attributefilesavetarget.h> #include <vespa/searchlib/fef/matchdatalayout.h> @@ -22,6 +23,8 @@ LOG_SETUP("documentmetastore_test"); using namespace document; using proton::bucketdb::BucketState; +using proton::bucketdb::LegacyChecksumAggregator; +using proton::bucketdb::XXHChecksumAggregator; using proton::bucketdb::IBucketCreateListener; using search::AttributeFileSaveTarget; using search::AttributeGuard; @@ -771,7 +774,9 @@ TEST("requireThatWeCanSortGids") } } -TEST("requireThatBasicBucketInfoWorks") +template <typename T> +void +requireThatBasicBucketInfoWorks() { DocumentMetaStore dms(createBucketDB()); typedef std::pair<BucketId, GlobalId> Elem; @@ -808,24 +813,22 @@ TEST("requireThatBasicBucketInfoWorks") m.erase(std::make_pair(bucketId, gid)); } assert(!m.empty()); - BucketChecksum cksum; + T cksum(BucketChecksum(0)); BucketId prevBucket = m.begin()->first.first; uint32_t cnt = 0u; uint32_t maxcnt = 0u; BucketDBOwner::Guard bucketDB = dms.getBucketDB().takeGuard(); for (Map::const_iterator i = m.begin(), ie = m.end(); i != ie; ++i) { if (i->first.first == prevBucket) { - cksum = BucketChecksum(cksum + - BucketState::calcChecksum(i->first.second, - i->second)); + cksum.addDoc(i->first.second, i->second); ++cnt; } else { BucketInfo bi = bucketDB->get(prevBucket); EXPECT_EQUAL(cnt, bi.getDocumentCount()); - EXPECT_EQUAL(cksum, bi.getChecksum()); + EXPECT_EQUAL(cksum.getChecksum(), bi.getChecksum()); prevBucket = i->first.first; - cksum = BucketState::calcChecksum(i->first.second, - i->second); + cksum = T(BucketChecksum(0)); + cksum.addDoc(i->first.second, i->second); maxcnt = std::max(maxcnt, cnt); cnt = 1u; } @@ -833,10 +836,18 @@ TEST("requireThatBasicBucketInfoWorks") maxcnt = std::max(maxcnt, cnt); BucketInfo bi = bucketDB->get(prevBucket); EXPECT_EQUAL(cnt, bi.getDocumentCount()); - EXPECT_EQUAL(cksum, bi.getChecksum()); + EXPECT_EQUAL(cksum.getChecksum(), bi.getChecksum()); LOG(info, "Largest bucket: %u elements", maxcnt); } +TEST("requireThatBasicBucketInfoWorks") +{ + BucketState::setChecksumType(BucketState::ChecksumType::LEGACY); + requireThatBasicBucketInfoWorks<LegacyChecksumAggregator>(); + BucketState::setChecksumType(BucketState::ChecksumType::XXHASH64); + requireThatBasicBucketInfoWorks<XXHChecksumAggregator>(); +} + TEST("requireThatWeCanRetrieveListOfLidsFromBucketId") { typedef std::vector<uint32_t> LidVector; |