diff options
4 files changed, 29 insertions, 4 deletions
diff --git a/searchlib/src/tests/document_store/.gitignore b/searchlib/src/tests/document_store/.gitignore index bc9b97decab..b251626b435 100644 --- a/searchlib/src/tests/document_store/.gitignore +++ b/searchlib/src/tests/document_store/.gitignore @@ -1 +1,2 @@ searchlib_document_store_test_app +searchlib_visitcache_test_app diff --git a/searchlib/src/tests/document_store/visitcache_test.cpp b/searchlib/src/tests/document_store/visitcache_test.cpp index 64b3d75ac4b..1ecf83606c9 100644 --- a/searchlib/src/tests/document_store/visitcache_test.cpp +++ b/searchlib/src/tests/document_store/visitcache_test.cpp @@ -5,8 +5,7 @@ using namespace search; using namespace search::docstore; -TEST("require that KeySet compares well") -{ +TEST("require that KeySet compares well") { KeySet a({2,1,4,3,9,6}); EXPECT_TRUE(a.contains(1)); EXPECT_TRUE(a.contains(2)); @@ -40,4 +39,30 @@ TEST("require that KeySet compares well") EXPECT_EQUAL(9, a.getKeys()[5]); } +namespace { + +void verifyAB(const BlobSet & a) { + EXPECT_EQUAL(0, a.get(8).size()); + EXPECT_EQUAL(6, a.get(7).size()); + EXPECT_EQUAL(5, a.get(9).size()); + EXPECT_EQUAL(0, strncmp(a.get(7).c_str(), "aaaaaa", 6)); + EXPECT_EQUAL(0, strncmp(a.get(9).c_str(), "bbbbb", 5)); + EXPECT_EQUAL(11, a.getBuffer().size()); + EXPECT_EQUAL(0, strncmp(a.getBuffer().c_str(), "aaaaaabbbbb", 11)); +} + +} + +using B=vespalib::ConstBufferRef; +TEST("require that BlobSet can be built") { + BlobSet a; + a.append(7, B("aaaaaa",6)); + a.append(9, B("bbbbbb",5)); + verifyAB(a); + document::CompressionConfig cfg(document::CompressionConfig::LZ4); + CompressedBlobSet ca(cfg, a); + BlobSet b = ca.getBlobSet(); + verifyAB(b); +} + TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp index dad1560bb7b..ba8b1f52459 100644 --- a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp +++ b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp @@ -102,7 +102,7 @@ CompressedBlobSet::CompressedBlobSet(const document::CompressionConfig &compress if ( ! _positions.empty() ) { vespalib::DataBuffer compressed; vespalib::ConstBufferRef org = uncompressed.getBuffer(); - document::compress(_compression, org, compressed, false); + _compression = document::compress(compression, org, compressed, false); _buffer.resize(compressed.getDataLen()); memcpy(_buffer, compressed.getData(), compressed.getDataLen()); } diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.h b/searchlib/src/vespa/searchlib/docstore/visitcache.h index e215642235b..67a38e83beb 100644 --- a/searchlib/src/vespa/searchlib/docstore/visitcache.h +++ b/searchlib/src/vespa/searchlib/docstore/visitcache.h @@ -44,7 +44,6 @@ public: void remove(uint32_t lid); const Positions & getPositions() const { return _positions; } vespalib::ConstBufferRef get(uint32_t lid) const; - vespalib::ConstBufferRef getBuffer(uint32_t lid) const; vespalib::ConstBufferRef getBuffer() const { return vespalib::ConstBufferRef(_buffer.c_str(), _buffer.size()); } private: Positions _positions; |