diff options
author | Geir Storli <geirst@yahoo-inc.com> | 2017-05-08 12:44:25 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahoo-inc.com> | 2017-05-12 14:01:23 +0000 |
commit | 9211b09e161580f5c9b12631a85d13f6b0e47357 (patch) | |
tree | b2941c97e9c1009bf04536cb07c5af8e059e8b76 /searchlib/src/tests/docstore/file_chunk | |
parent | 01a1839b9209f2ce4e2f707a75e2e73ede20c671 (diff) |
Write docIdLimit to header in idx file of WriteableFileChunk.
Diffstat (limited to 'searchlib/src/tests/docstore/file_chunk')
-rw-r--r-- | searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp | 65 | ||||
-rw-r--r-- | searchlib/src/tests/docstore/file_chunk/without_doc_id_limit/0000000000000001234.dat | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | searchlib/src/tests/docstore/file_chunk/without_doc_id_limit/0000000000000001234.idx | bin | 0 -> 56 bytes |
3 files changed, 64 insertions, 1 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 0c21217648c..cb2eb0a0044 100644 --- a/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp +++ b/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp @@ -1,12 +1,75 @@ // Copyright 2017 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - #include <vespa/vespalib/testkit/test_kit.h> + +#include <vespa/searchlib/common/fileheadercontext.h> #include <vespa/searchlib/docstore/filechunk.h> +#include <vespa/searchlib/docstore/writeablefilechunk.h> +#include <vespa/searchlib/test/directory_handler.h> +#include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/log/log.h> LOG_SETUP("file_chunk_test"); using namespace search; +using common::FileHeaderContext; +using vespalib::ThreadStackExecutor; + +constexpr uint64_t initSerialNum = 10; + +struct MyFileHeaderContext : public FileHeaderContext { + virtual void addTags(vespalib::GenericHeader &header, const vespalib::string &name) const override { + (void) header; + (void) name; + } +}; + +struct Fixture { + test::DirectoryHandler dir; + ThreadStackExecutor executor; + TuneFileSummary tuneFile; + MyFileHeaderContext fileHeaderCtx; + WriteableFileChunk chunk; + + Fixture(const vespalib::string &baseName, + uint32_t docIdLimit, + bool dirCleanup = true) + : dir(baseName), + executor(1, 0x10000), + tuneFile(), + fileHeaderCtx(), + chunk(executor, + FileChunk::FileId(0), + FileChunk::NameId(1234), + baseName, + initSerialNum, + docIdLimit, + WriteableFileChunk::Config(), + tuneFile, + fileHeaderCtx, + nullptr, + false) + { + dir.cleanup(dirCleanup); + } + ~Fixture() {} +}; + +TEST_F("require that idx file without docIdLimit in header can be read", Fixture("without_doc_id_limit", 1000, false)) +{ + EXPECT_EQUAL(std::numeric_limits<uint32_t>::max(), f.chunk.getDocIdLimit()); +} + +TEST("require that docIdLimit is written to and read from idx file header") +{ + { + Fixture f("tmp", 1000, false); + } + { + Fixture f("tmp", 0); + EXPECT_EQUAL(1000u, f.chunk.getDocIdLimit()); + } +} + TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchlib/src/tests/docstore/file_chunk/without_doc_id_limit/0000000000000001234.dat b/searchlib/src/tests/docstore/file_chunk/without_doc_id_limit/0000000000000001234.dat Binary files differnew file mode 100644 index 00000000000..1b8edd69fe8 --- /dev/null +++ b/searchlib/src/tests/docstore/file_chunk/without_doc_id_limit/0000000000000001234.dat diff --git a/searchlib/src/tests/docstore/file_chunk/without_doc_id_limit/0000000000000001234.idx b/searchlib/src/tests/docstore/file_chunk/without_doc_id_limit/0000000000000001234.idx Binary files differnew file mode 100644 index 00000000000..f2fda58f94e --- /dev/null +++ b/searchlib/src/tests/docstore/file_chunk/without_doc_id_limit/0000000000000001234.idx |