diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-11 12:14:36 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-11 12:14:36 +0000 |
commit | 1a9cab29819cfe54d2020f26917d8c76e16c27b6 (patch) | |
tree | 75ab928f450d81591e73cb3cf411c531c1fcf166 /searchlib | |
parent | 83b9fd60639415f651315c533d15321078a0eede (diff) |
Add test for correctly reported capacity.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/tests/docstore/document_store/document_store_test.cpp | 9 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/docstore/value.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/searchlib/src/tests/docstore/document_store/document_store_test.cpp b/searchlib/src/tests/docstore/document_store/document_store_test.cpp index f950377be4b..04ec18aacc4 100644 --- a/searchlib/src/tests/docstore/document_store/document_store_test.cpp +++ b/searchlib/src/tests/docstore/document_store/document_store_test.cpp @@ -142,6 +142,15 @@ TEST("require that Value can store zstd compressed data") { verifyValue(S1, v); } +TEST("require that Value is shrunk to fit compressed data") { + Value v = createValue(S1, CompressionConfig::ZSTD); + EXPECT_EQUAL(CompressionConfig::ZSTD, v.getCompression()); + EXPECT_EQUAL(128u, v.size()); + EXPECT_EQUAL(128u, v.capacity()); + EXPECT_EQUAL(297u, v.getUncompressedSize()); + verifyValue(S1, v); +} + TEST("require that Value can detect if output not equal to input") { Value v = createValue(S1, CompressionConfig::NONE); const_cast<uint8_t *>(static_cast<const uint8_t *>(v.get()))[8] ^= 0xff; diff --git a/searchlib/src/vespa/searchlib/docstore/value.h b/searchlib/src/vespa/searchlib/docstore/value.h index f58d96e3e77..fb377abb2fb 100644 --- a/searchlib/src/vespa/searchlib/docstore/value.h +++ b/searchlib/src/vespa/searchlib/docstore/value.h @@ -42,6 +42,7 @@ public: Result decompressed() const; size_t size() const { return _compressedSize; } + size_t capacity() const { return _buf ? _buf->size() : 0; } bool empty() const { return size() == 0; } operator const void *() const { return get(); } const void *get() const; |