summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/docstore/file_chunk
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahoo-inc.com>2017-05-09 11:11:28 +0000
committerGeir Storli <geirst@yahoo-inc.com>2017-05-12 14:01:24 +0000
commit9b815d1bcc2665ae30b2bd1d7a304bbeb73a4b95 (patch)
tree200b81ca6270418cce9413d10453a5f3af810cf8 /searchlib/src/tests/docstore/file_chunk
parent5b3771f5173ba75036b32444ffd2afddad18e05e (diff)
Don't use bucketizer for entries with lid >= docIdLimit.
Diffstat (limited to 'searchlib/src/tests/docstore/file_chunk')
-rw-r--r--searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp25
1 files changed, 23 insertions, 2 deletions
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<uint32_t> 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<uint32_t> &expLids) {
EXPECT_EQUAL(expLids, lidObserver.lids);
}
+ void assertBucketizer(const std::vector<uint32_t> &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());
}
}