diff options
author | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-03-07 14:16:35 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-03-07 14:16:35 +0000 |
commit | c75dff6987de2e3fae07dd1ca6802f6525d70b0d (patch) | |
tree | 88b5e2769d376a8b24c362616da26f1e76a9a26f /searchcore | |
parent | a0128c5cf975ba9362169699700969cdf0e6a6a9 (diff) |
Test that bucket checksum ignore document sizes.
Use document size when converting from bucket state to bucket info.
Test that bucket info contains document sizes.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/tests/proton/bucketdb/bucketdb/bucketdb_test.cpp | 14 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/bucketdb/bucketstate.cpp | 6 |
2 files changed, 18 insertions, 2 deletions
diff --git a/searchcore/src/tests/proton/bucketdb/bucketdb/bucketdb_test.cpp b/searchcore/src/tests/proton/bucketdb/bucketdb/bucketdb_test.cpp index 9a329f19a7f..b5fa3ae044e 100644 --- a/searchcore/src/tests/proton/bucketdb/bucketdb/bucketdb_test.cpp +++ b/searchcore/src/tests/proton/bucketdb/bucketdb/bucketdb_test.cpp @@ -24,6 +24,7 @@ const Timestamp TIME_1(1u); const Timestamp TIME_2(2u); const Timestamp TIME_3(3u); constexpr uint32_t DOCSIZE_1(4096u); +constexpr uint32_t DOCSIZE_2(10000u); typedef BucketInfo::ReadyState RS; typedef SubDbType SDT; @@ -51,6 +52,9 @@ assertDocSizes(size_t ready, EXPECT_EQUAL(ready, state.getReadyDocSizes()); EXPECT_EQUAL(notReady, state.getNotReadyDocSizes()); EXPECT_EQUAL(removed, state.getRemovedDocSizes()); + BucketInfo info = state; + EXPECT_EQUAL(ready + notReady, info.getDocumentSize()); + EXPECT_EQUAL(ready + notReady + removed, info.getUsedSize()); } void @@ -163,6 +167,16 @@ TEST_F("require that bucket can be cached", Fixture) f.remove(TIME_2, SDT::NOTREADY); } +TEST_F("require that bucket checksum ignores document sizes", Fixture) +{ + auto state1 = f.add(TIME_1, DOCSIZE_1, SDT::READY); + f.remove(TIME_1, DOCSIZE_1, SDT::READY); + auto state2 = f.add(TIME_1, DOCSIZE_2, SDT::READY); + f.remove(TIME_1, DOCSIZE_2, SDT::READY); + EXPECT_NOT_EQUAL(state1.getReadyDocSizes(), state2.getReadyDocSizes()); + EXPECT_EQUAL(state1.getChecksum(), state2.getChecksum()); +} + TEST("require that bucket db can be explored") { BucketDBOwner db; diff --git a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketstate.cpp b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketstate.cpp index 2030b448d52..e8fad2054da 100644 --- a/searchcore/src/vespa/searchcore/proton/bucketdb/bucketstate.cpp +++ b/searchcore/src/vespa/searchcore/proton/bucketdb/bucketstate.cpp @@ -167,14 +167,16 @@ BucketState::operator storage::spi::BucketInfo() const uint32_t notReady = getNotReadyCount(); uint32_t documentCount = getReadyCount() + notReady; uint32_t entryCount = documentCount + getRemovedCount(); + size_t docSizes = getReadyDocSizes() + getNotReadyDocSizes(); + size_t entrySizes = docSizes + getRemovedDocSizes(); using BucketInfo = storage::spi::BucketInfo; return BucketInfo(storage::spi::BucketChecksum(_checksum), documentCount, - 0, + docSizes, entryCount, - 0, + entrySizes, notReady > 0 ? BucketInfo::NOT_READY : BucketInfo::READY, _active ? BucketInfo::ACTIVE : BucketInfo::NOT_ACTIVE); } |