From 9b815d1bcc2665ae30b2bd1d7a304bbeb73a4b95 Mon Sep 17 00:00:00 2001 From: Geir Storli Date: Tue, 9 May 2017 11:11:28 +0000 Subject: Don't use bucketizer for entries with lid >= docIdLimit. --- .../tests/docstore/file_chunk/file_chunk_test.cpp | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'searchlib/src/tests/docstore/file_chunk') diff --git a/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp b/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp index ec7759a6cbc..9af5eeabab0 100644 --- a/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp +++ b/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp @@ -34,6 +34,18 @@ struct SetLidObserver : public ISetLid { } }; +struct BucketizerObserver : public IBucketizer { + mutable std::vector lids; + virtual document::BucketId getBucketOf(const vespalib::GenerationHandler::Guard &guard, uint32_t lid) const override { + (void) guard; + lids.push_back(lid); + return document::BucketId(); + } + virtual vespalib::GenerationHandler::Guard getGuard() const override { + return vespalib::GenerationHandler::Guard(); + } +}; + vespalib::string getData(uint32_t lid) { @@ -50,6 +62,7 @@ struct Fixture { MyFileHeaderContext fileHeaderCtx; vespalib::Lock updateLock; SetLidObserver lidObserver; + BucketizerObserver bucketizer; WriteableFileChunk chunk; uint64_t nextSerialNum() { @@ -65,6 +78,8 @@ struct Fixture { tuneFile(), fileHeaderCtx(), updateLock(), + lidObserver(), + bucketizer(), chunk(executor, FileChunk::FileId(0), FileChunk::NameId(1234), @@ -74,7 +89,7 @@ struct Fixture { WriteableFileChunk::Config(document::CompressionConfig(), 0x1000), tuneFile, fileHeaderCtx, - nullptr, + &bucketizer, false) { dir.cleanup(dirCleanup); @@ -96,6 +111,9 @@ struct Fixture { void assertLidMap(const std::vector &expLids) { EXPECT_EQUAL(expLids, lidObserver.lids); } + void assertBucketizer(const std::vector &expLids) { + EXPECT_EQUAL(expLids, bucketizer.lids); + } }; TEST_F("require that idx file without docIdLimit in header can be read", Fixture("without_doc_id_limit", 1000, false)) @@ -125,8 +143,11 @@ TEST("require that entries with lid >= docIdLimit are skipped in updateLidMap()" Fixture f("tmp", 0); f.updateLidMap(1000); f.assertLidMap({1,10,100,999,998,999}); + f.assertBucketizer({1,10,100,999,998,999}); + size_t entrySize = 10 + 8; + EXPECT_EQUAL(9 * entrySize, f.chunk.getAddedBytes()); EXPECT_EQUAL(3u, f.chunk.getBloatCount()); - EXPECT_EQUAL(3u * (10 + 8), f.chunk.getErasedBytes()); + EXPECT_EQUAL(3 * entrySize, f.chunk.getErasedBytes()); } } -- cgit v1.2.3