diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-08-28 13:53:07 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-08-28 13:55:47 +0200 |
commit | 2868058bbb1427bc16a941e453314ee856303c4e (patch) | |
tree | f23b807bf20443f721c436f27a435efd9009ad94 /searchlib | |
parent | ccf572d02b2552f033f2811666dc7a5cb9546fa6 (diff) |
Moved databuffer and compresssion to vespalib
Diffstat (limited to 'searchlib')
33 files changed, 105 insertions, 101 deletions
diff --git a/searchlib/src/apps/docstore/create-idx-from-dat.cpp b/searchlib/src/apps/docstore/create-idx-from-dat.cpp index ac3b34a3b41..6124b36de8d 100644 --- a/searchlib/src/apps/docstore/create-idx-from-dat.cpp +++ b/searchlib/src/apps/docstore/create-idx-from-dat.cpp @@ -39,7 +39,7 @@ bool tryDecode(size_t chunks, size_t offset, const char * p, size_t sz, size_t n } bool validUncompressed(const char * n, size_t offset) { - return (n[1] == document::CompressionConfig::NONE) && + return (n[1] == vespalib::compression::CompressionConfig::NONE) && (n[2] == 0) && (n[3] == 0) && (n[4] == 0) && diff --git a/searchlib/src/tests/common/packets/packets_test.cpp b/searchlib/src/tests/common/packets/packets_test.cpp index 7504e1c1570..cf0e858a014 100644 --- a/searchlib/src/tests/common/packets/packets_test.cpp +++ b/searchlib/src/tests/common/packets/packets_test.cpp @@ -8,6 +8,8 @@ #include <vespa/fnet/controlpacket.h> using namespace search::fs4transport; +using vespalib::compression::CompressionConfig; + // ---------------------------------------------------------------------------- // @@ -524,7 +526,7 @@ TEST("test pre serializing packets with compression") { EXPECT_EQUAL(src->GetLength(), decoded->GetLength()); FS4PersistentPacketStreamer::Instance.SetCompressionLimit(100); FS4Packet_PreSerialized serialized(*src); - EXPECT_EQUAL(218u | (document::CompressionConfig::LZ4 << 24), serialized.GetPCODE()); + EXPECT_EQUAL(218u | (CompressionConfig::LZ4 << 24), serialized.GetPCODE()); EXPECT_GREATER_EQUAL(321u, serialized.GetLength()); FNET_Packet::UP decoded2(testEncodeDecode(serialized)); EXPECT_EQUAL(500u, decoded2->GetLength()); diff --git a/searchlib/src/tests/docstore/chunk/chunk_test.cpp b/searchlib/src/tests/docstore/chunk/chunk_test.cpp index 4687f45acde..84ac877c54d 100644 --- a/searchlib/src/tests/docstore/chunk/chunk_test.cpp +++ b/searchlib/src/tests/docstore/chunk/chunk_test.cpp @@ -12,7 +12,7 @@ LOG_SETUP("chunk_test"); using namespace search; -using document::CompressionConfig; +using vespalib::compression::CompressionConfig; TEST("require that Chunk obey limits") { 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 e3e4a1432d1..e8c2173a87f 100644 --- a/searchlib/src/tests/docstore/document_store/document_store_test.cpp +++ b/searchlib/src/tests/docstore/document_store/document_store_test.cpp @@ -5,6 +5,7 @@ #include <vespa/document/repo/documenttyperepo.h> using namespace search; +using CompressionConfig = vespalib::compression::CompressionConfig; document::DocumentTypeRepo repo; @@ -43,7 +44,7 @@ struct NullDataStore : IDataStore { }; TEST_FFF("require that uncache docstore lookups are counted", - DocumentStore::Config(document::CompressionConfig::NONE, 0, 0), + DocumentStore::Config(CompressionConfig::NONE, 0, 0), NullDataStore(), DocumentStore(f1, f2)) { EXPECT_EQUAL(0u, f3.getCacheStats().misses); @@ -52,7 +53,7 @@ TEST_FFF("require that uncache docstore lookups are counted", } TEST_FFF("require that cached docstore lookups are counted", - DocumentStore::Config(document::CompressionConfig::NONE, 100000, 100), + DocumentStore::Config(CompressionConfig::NONE, 100000, 100), NullDataStore(), DocumentStore(f1, f2)) { EXPECT_EQUAL(0u, f3.getCacheStats().misses); diff --git a/searchlib/src/tests/docstore/document_store/visitcache_test.cpp b/searchlib/src/tests/docstore/document_store/visitcache_test.cpp index 70e0c7f01fb..d5d95097c66 100644 --- a/searchlib/src/tests/docstore/document_store/visitcache_test.cpp +++ b/searchlib/src/tests/docstore/document_store/visitcache_test.cpp @@ -56,11 +56,12 @@ void verifyAB(const BlobSet & a) { using B=vespalib::ConstBufferRef; TEST("require that BlobSet can be built") { + using CompressionConfig = vespalib::compression::CompressionConfig; BlobSet a; a.append(7, B("aaaaaa",6)); a.append(9, B("bbbbb",5)); verifyAB(a); - document::CompressionConfig cfg(document::CompressionConfig::LZ4); + CompressionConfig cfg(CompressionConfig::LZ4); CompressedBlobSet ca(cfg, a); BlobSet b = ca.getBlobSet(); verifyAB(b); diff --git a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp index 944d0a543f5..1c7053500c7 100644 --- a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp +++ b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp @@ -24,7 +24,7 @@ using document::Document; using document::DocumentId; using document::DocumentType; using document::DocumentTypeRepo; -using document::CompressionConfig; +using vespalib::compression::CompressionConfig; using vespalib::asciistream; using index::DummyFileHeaderContext; 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 6d75c6365f9..598913a3222 100644 --- a/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp +++ b/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp @@ -113,6 +113,7 @@ struct ReadFixture : public FixtureBase { struct WriteFixture : public FixtureBase { WriteableFileChunk chunk; + using CompressionConfig = vespalib::compression::CompressionConfig; WriteFixture(const vespalib::string &baseName, uint32_t docIdLimit, @@ -124,7 +125,7 @@ struct WriteFixture : public FixtureBase { baseName, serialNum, docIdLimit, - WriteableFileChunk::Config(document::CompressionConfig(), 0x1000), + WriteableFileChunk::Config(CompressionConfig(), 0x1000), tuneFile, fileHeaderCtx, &bucketizer, diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp index 82a158fd53e..ed6afb06681 100644 --- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp +++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp @@ -15,7 +15,6 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <iomanip> -#include <iostream> using document::BucketId; using namespace search::docstore; @@ -36,7 +35,7 @@ public: using namespace search; using namespace search::docstore; using search::index::DummyFileHeaderContext; -using document::CompressionConfig; +using vespalib::compression::CompressionConfig; namespace { diff --git a/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp b/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp index 3faf9395ec5..e9514c1d385 100644 --- a/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp +++ b/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp @@ -4,17 +4,17 @@ #include <vespa/document/bucket/bucketid.h> #include <vespa/document/base/documentid.h> -#include <vespa/log/log.h> #include <vespa/searchlib/docstore/storebybucket.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/stllike/hash_set.h> #include <vespa/vespalib/util/threadstackexecutor.h> +#include <vespa/log/log.h> LOG_SETUP("store_by_bucket_test"); using namespace search::docstore; using document::BucketId; -using document::CompressionConfig; +using vespalib::compression::CompressionConfig; vespalib::string createPayload(BucketId b) { diff --git a/searchlib/src/vespa/searchlib/attribute/attribute_header.cpp b/searchlib/src/vespa/searchlib/attribute/attribute_header.cpp index 0848d9996c3..4a69e0a827d 100644 --- a/searchlib/src/vespa/searchlib/attribute/attribute_header.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attribute_header.cpp @@ -2,9 +2,9 @@ #include "attribute_header.h" #include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/data/databuffer.h> -namespace search { -namespace attribute { +namespace search::attribute { namespace { @@ -168,5 +168,4 @@ AttributeHeader::hasWeightedSetType() const return _collectionType.isWeightedSet(); } -} // namespace search::attribute -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/attribute/readerbase.h b/searchlib/src/vespa/searchlib/attribute/readerbase.h index 88081906f71..358038f9ba2 100644 --- a/searchlib/src/vespa/searchlib/attribute/readerbase.h +++ b/searchlib/src/vespa/searchlib/attribute/readerbase.h @@ -3,6 +3,7 @@ #pragma once #include <vespa/searchlib/util/fileutil.h> +#include <cassert> namespace search { diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp index e50ebec105b..aa39b798b7a 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/compression.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/compression.cpp @@ -5,10 +5,9 @@ #include <vespa/searchlib/fef/termfieldmatchdata.h> #include <vespa/searchlib/fef/termfieldmatchdataarray.h> #include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/data/databuffer.h> -namespace search { - -namespace bitcompression { +namespace search::bitcompression { using vespalib::nbostream; @@ -157,17 +156,12 @@ DecodeContext64Base::checkPointRead(nbostream &in) (void) in; } -} // namespace bitcompression - - namespace { vespalib::string noFeatures = "NoFeatures"; } -namespace bitcompression { - template <bool bigEndian> void FeatureDecodeContext<bigEndian>:: @@ -486,6 +480,4 @@ template class FeatureEncodeContext<true>; template class FeatureEncodeContext<false>; -} // namespace bitcompression - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/common/packets.cpp b/searchlib/src/vespa/searchlib/common/packets.cpp index 667334bf64e..4ccda718698 100644 --- a/searchlib/src/vespa/searchlib/common/packets.cpp +++ b/searchlib/src/vespa/searchlib/common/packets.cpp @@ -4,7 +4,7 @@ #include "packets.h" #include "sortdata.h" #include <vespa/searchlib/util/rawbuf.h> -#include <vespa/document/util/compressor.h> +#include <vespa/vespalib/util/compressor.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/data/databuffer.h> @@ -12,7 +12,6 @@ #include <vespa/log/log.h> LOG_SETUP(".searchlib.common.fs4packets"); -using document::CompressionConfig; using vespalib::ConstBufferRef; using vespalib::make_string; using vespalib::stringref; @@ -151,7 +150,7 @@ FS4PersistentPacketStreamer::Decode(FNET_DataBuffer *src, uint32_t plen, uint32_ uint32_t uncompressed_size = src->ReadInt32(); ConstBufferRef org(src->GetData(), plen - sizeof(uint32_t)); vespalib::DataBuffer uncompressed(uncompressed_size); - document::compression::decompress(compressionType, uncompressed_size, org, uncompressed, false); + vespalib::compression::decompress(compressionType, uncompressed_size, org, uncompressed, false); FNET_DataBuffer buf(uncompressed.getData(), uncompressed.getDataLen()); decodePacket(packet, buf, uncompressed_size, pcode); src->DataToDead(plen - sizeof(uint32_t)); @@ -192,7 +191,7 @@ FS4PersistentPacketStreamer::Encode(FNET_Packet *packet, uint32_t chid, FNET_Dat CompressionConfig config(_compressionType, _compressionLevel, 90); ConstBufferRef org(dst->GetData() + packet_start + header_len, body_len); vespalib::DataBuffer compressed(org.size()); - CompressionConfig::Type r = document::compression::compress(config, org, compressed, false); + CompressionConfig::Type r = vespalib::compression::compress(config, org, compressed, false); if (r != CompressionConfig::NONE) { dst->DataToFree(body_len + header_len); // sizeof(data + header + uncompressed_size) - sizeof(uint32_t) @@ -455,7 +454,7 @@ FS4Packet_PreSerialized::FS4Packet_PreSerialized(FNET_Packet & packet) 90); ConstBufferRef org(tmp.GetData(), tmp.GetDataLen()); vespalib::DataBuffer compressed(org.size()); - _compressionType = document::compression::compress(config, org, compressed, false); + _compressionType = vespalib::compression::compress(config, org, compressed, false); if (_compressionType != CompressionConfig::NONE) { _data.WriteInt32Fast(body_len); _data.WriteBytes(compressed.getData(), compressed.getDataLen()); diff --git a/searchlib/src/vespa/searchlib/common/packets.h b/searchlib/src/vespa/searchlib/common/packets.h index d9bc4d50462..52130c57374 100644 --- a/searchlib/src/vespa/searchlib/common/packets.h +++ b/searchlib/src/vespa/searchlib/common/packets.h @@ -9,7 +9,7 @@ #include <vespa/fnet/packet.h> #include <vespa/fnet/databuffer.h> #include <vespa/document/base/globalid.h> -#include <vespa/document/util/compressionconfig.h> +#include <vespa/vespalib/util/compressionconfig.h> #include <vespa/vespalib/util/memory.h> #include <vespa/fastos/timestamp.h> #include <vector> @@ -110,10 +110,11 @@ public: class FS4PersistentPacketStreamer : public FNET_IPacketStreamer { FS4PersistentPacketStreamer(const FS4PersistentPacketStreamer &); FS4PersistentPacketStreamer& operator=(const FS4PersistentPacketStreamer &); + using CompressionConfig = vespalib::compression::CompressionConfig; unsigned int _compressionLimit; unsigned int _compressionLevel; - document::CompressionConfig::Type _compressionType; + CompressionConfig::Type _compressionType; protected: bool _conservative; // Set to true if out of sync should mark the // stream as broken. @@ -139,8 +140,8 @@ public: void SetConservativeMode(bool cons) { _conservative = cons; } void SetCompressionLimit(unsigned int limit) { _compressionLimit = limit; } void SetCompressionLevel(unsigned int level) { _compressionLevel = level; } - void SetCompressionType(document::CompressionConfig::Type compressionType) { _compressionType = compressionType; } - document::CompressionConfig::Type getCompressionType() const { return _compressionType; } + void SetCompressionType(CompressionConfig::Type compressionType) { _compressionType = compressionType; } + CompressionConfig::Type getCompressionType() const { return _compressionType; } uint32_t getCompressionLimit() const { return _compressionLimit; } uint32_t getCompressionLevel() const { return _compressionLevel; } }; @@ -243,9 +244,10 @@ public: bool Decode(FNET_DataBuffer *src, uint32_t len) override; vespalib::string toString(uint32_t indent) const override; private: - uint32_t _pcode; - document::CompressionConfig::Type _compressionType; - FNET_DataBuffer _data; + using CompressionConfig = vespalib::compression::CompressionConfig; + uint32_t _pcode; + CompressionConfig::Type _compressionType; + FNET_DataBuffer _data; }; class FS4Packet_Shared : public FS4Packet diff --git a/searchlib/src/vespa/searchlib/diskindex/checkpointfile.cpp b/searchlib/src/vespa/searchlib/diskindex/checkpointfile.cpp index a55ec9494dc..0324f00f63c 100644 --- a/searchlib/src/vespa/searchlib/diskindex/checkpointfile.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/checkpointfile.cpp @@ -1,18 +1,16 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - #include "checkpointfile.h" #include <vespa/vespalib/data/fileheader.h> #include <vespa/searchlib/common/fileheadercontext.h> +#include <cassert> #include <vespa/log/log.h> LOG_SETUP(".diskindex.checkpointfile"); using vespalib::getLastErrorString; -namespace search { - -namespace diskindex { +namespace search::diskindex { using common::FileHeaderContext; @@ -182,6 +180,4 @@ CheckPointFile::readHeader() } -} // namespace diskindex - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/docstore/chunk.cpp b/searchlib/src/vespa/searchlib/docstore/chunk.cpp index 179fda8689b..ba467501fba 100644 --- a/searchlib/src/vespa/searchlib/docstore/chunk.cpp +++ b/searchlib/src/vespa/searchlib/docstore/chunk.cpp @@ -43,12 +43,12 @@ Chunk::hasRoom(size_t len) const } size_t -Chunk::getMaxPackSize(const document::CompressionConfig & compression) const { +Chunk::getMaxPackSize(const CompressionConfig & compression) const { return _format->getMaxPackSize(compression); } void -Chunk::pack(uint64_t lastSerial, vespalib::DataBuffer & compressed, const document::CompressionConfig & compression) +Chunk::pack(uint64_t lastSerial, vespalib::DataBuffer & compressed, const CompressionConfig & compression) { _lastSerial = lastSerial; _format->pack(_lastSerial, compressed, compression); diff --git a/searchlib/src/vespa/searchlib/docstore/chunk.h b/searchlib/src/vespa/searchlib/docstore/chunk.h index bdf0d9793b2..cd551de1a9e 100644 --- a/searchlib/src/vespa/searchlib/docstore/chunk.h +++ b/searchlib/src/vespa/searchlib/docstore/chunk.h @@ -4,7 +4,7 @@ #include <vespa/searchlib/util/memoryusage.h> #include <vespa/vespalib/util/buffer.h> -#include <vespa/document/util/compressionconfig.h> +#include <vespa/vespalib/util/compressionconfig.h> #include <memory> #include <vector> @@ -60,7 +60,8 @@ private: class Chunk { public: - typedef std::unique_ptr<Chunk> UP; + using UP = std::unique_ptr<Chunk>; + using CompressionConfig = vespalib::compression::CompressionConfig; class Config { public: Config(size_t maxBytes) : _maxBytes(maxBytes) { } @@ -93,8 +94,8 @@ public: size_t size() const; const LidList & getLids() const { return _lids; } LidList getUniqueLids() const; - size_t getMaxPackSize(const document::CompressionConfig & compression) const; - void pack(uint64_t lastSerial, vespalib::DataBuffer & buffer, const document::CompressionConfig & compression); + size_t getMaxPackSize(const CompressionConfig & compression) const; + void pack(uint64_t lastSerial, vespalib::DataBuffer & buffer, const CompressionConfig & compression); uint64_t getLastSerial() const { return _lastSerial; } uint32_t getId() const { return _id; } bool validSerial() const { return getLastSerial() != static_cast<uint64_t>(-1l); } diff --git a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp index 204c7b07acb..37381cfa3f6 100644 --- a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp +++ b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp @@ -1,17 +1,17 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "chunkformats.h" -#include <vespa/document/util/compressor.h> +#include <vespa/vespalib/util/compressor.h> #include <vespa/vespalib/util/stringfmt.h> namespace search { using vespalib::make_string; using vespalib::Exception; -using document::compression::compress; -using document::compression::decompress; -using document::compression::computeMaxCompressedsize; -using document::CompressionConfig; +using vespalib::compression::compress; +using vespalib::compression::decompress; +using vespalib::compression::computeMaxCompressedsize; +using vespalib::compression::CompressionConfig; ChunkException::ChunkException(const vespalib::stringref & msg, const vespalib::stringref & location) : Exception(make_string("Illegal chunk: %s", msg.c_str()), location) diff --git a/searchlib/src/vespa/searchlib/docstore/chunkformat.h b/searchlib/src/vespa/searchlib/docstore/chunkformat.h index 5f1e3d852a9..9f9580f1f1d 100644 --- a/searchlib/src/vespa/searchlib/docstore/chunkformat.h +++ b/searchlib/src/vespa/searchlib/docstore/chunkformat.h @@ -2,7 +2,7 @@ #pragma once -#include <vespa/document/util/compressionconfig.h> +#include <vespa/vespalib/util/compressionconfig.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/util/exception.h> @@ -20,7 +20,8 @@ class ChunkFormat { public: virtual ~ChunkFormat(); - typedef std::unique_ptr<ChunkFormat> UP; + using UP = std::unique_ptr<ChunkFormat>; + using CompressionConfig = vespalib::compression::CompressionConfig; vespalib::nbostream & getBuffer() { return _dataBuf; } const vespalib::nbostream & getBuffer() const { return _dataBuf; } @@ -30,7 +31,7 @@ public: * @param compressed The buffer where the serialized data shall be placed. * @param compression What kind of compression shall be employed. */ - void pack(uint64_t lastSerial, vespalib::DataBuffer & compressed, const document::CompressionConfig & compression); + void pack(uint64_t lastSerial, vespalib::DataBuffer & compressed, const CompressionConfig & compression); /** * Will deserialize and create a representation of the uncompressed data. * param buffer Pointer to the serialized data @@ -44,7 +45,7 @@ public: * @param compression Compression config to be used. * @return maximum number of bytes a packet can take in serialized form. */ - size_t getMaxPackSize(const document::CompressionConfig & compression) const; + size_t getMaxPackSize(const CompressionConfig & compression) const; protected: /** * Constructor used when deserializing diff --git a/searchlib/src/vespa/searchlib/docstore/compacter.h b/searchlib/src/vespa/searchlib/docstore/compacter.h index 264cce8d3aa..362896487aa 100644 --- a/searchlib/src/vespa/searchlib/docstore/compacter.h +++ b/searchlib/src/vespa/searchlib/docstore/compacter.h @@ -33,7 +33,7 @@ private: **/ class BucketCompacter : public IWriteData, public StoreByBucket::IWrite { - using CompressionConfig = document::CompressionConfig; + using CompressionConfig = vespalib::compression::CompressionConfig; using ThreadExecutor = vespalib::ThreadExecutor; public: using FileId = FileChunk::FileId; diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp index a13fffdaa24..bf59614a297 100644 --- a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp @@ -6,12 +6,12 @@ #include "ibucketizer.h" #include <vespa/vespalib/stllike/cache.hpp> #include <vespa/vespalib/data/databuffer.h> -#include <vespa/document/util/compressor.h> +#include <vespa/vespalib/util/compressor.h> using document::DocumentTypeRepo; -using document::CompressionConfig; -using document::compression::compress; -using document::compression::decompress; +using vespalib::compression::CompressionConfig; +using vespalib::compression::compress; +using vespalib::compression::decompress; namespace search { diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.h b/searchlib/src/vespa/searchlib/docstore/documentstore.h index 45dfcb35e37..4ba5c27cd07 100644 --- a/searchlib/src/vespa/searchlib/docstore/documentstore.h +++ b/searchlib/src/vespa/searchlib/docstore/documentstore.h @@ -26,25 +26,26 @@ class DocumentStore : public IDocumentStore public: class Config { public: + using CompressionConfig = vespalib::compression::CompressionConfig; Config() : - _compression(document::CompressionConfig::LZ4, 9, 70), + _compression(CompressionConfig::LZ4, 9, 70), _maxCacheBytes(1000000000), _initialCacheEntries(0), _allowVisitCaching(false) { } - Config(const document::CompressionConfig & compression, size_t maxCacheBytes, size_t initialCacheEntries) : - _compression((maxCacheBytes != 0) ? compression : document::CompressionConfig::NONE), + Config(const CompressionConfig & compression, size_t maxCacheBytes, size_t initialCacheEntries) : + _compression((maxCacheBytes != 0) ? compression : CompressionConfig::NONE), _maxCacheBytes(maxCacheBytes), _initialCacheEntries(initialCacheEntries), _allowVisitCaching(false) { } - const document::CompressionConfig & getCompression() const { return _compression; } + const CompressionConfig & getCompression() const { return _compression; } size_t getMaxCacheBytes() const { return _maxCacheBytes; } size_t getInitialCacheEntries() const { return _initialCacheEntries; } bool allowVisitCaching() const { return _allowVisitCaching; } Config & allowVisitCaching(bool allow) { _allowVisitCaching = allow; return *this; } private: - document::CompressionConfig _compression; + CompressionConfig _compression; size_t _maxCacheBytes; size_t _initialCacheEntries; bool _allowVisitCaching; diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp index f271e6f320b..2a748a302c6 100644 --- a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp +++ b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp @@ -5,6 +5,7 @@ #include "summaryexceptions.h" #include "randreaders.h" #include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/array.hpp> #include <vespa/vespalib/stllike/hash_map.hpp> diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.h b/searchlib/src/vespa/searchlib/docstore/logdatastore.h index 0ca658ba803..080e6f80503 100644 --- a/searchlib/src/vespa/searchlib/docstore/logdatastore.h +++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.h @@ -5,7 +5,7 @@ #include "idatastore.h" #include "lid_info.h" #include "writeablefilechunk.h" -#include <vespa/document/util/compressionconfig.h> +#include <vespa/vespalib/util/compressionconfig.h> #include <vespa/searchlib/common/rcuvector.h> #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/searchlib/transactionlog/syncproxy.h> @@ -33,7 +33,7 @@ private: public: using NameIdSet = std::set<NameId>; using LockGuard = vespalib::LockGuard; - using CompressionConfig = document::CompressionConfig; + using CompressionConfig = vespalib::compression::CompressionConfig; class Config { public: Config() diff --git a/searchlib/src/vespa/searchlib/docstore/storebybucket.h b/searchlib/src/vespa/searchlib/docstore/storebybucket.h index f93826027f5..ac1f6fbe007 100644 --- a/searchlib/src/vespa/searchlib/docstore/storebybucket.h +++ b/searchlib/src/vespa/searchlib/docstore/storebybucket.h @@ -23,9 +23,9 @@ class StoreByBucket using MemoryDataStore = vespalib::MemoryDataStore; using ThreadExecutor = vespalib::ThreadExecutor; using ConstBufferRef = vespalib::ConstBufferRef; - using CompressionConfig = document::CompressionConfig; + using CompressionConfig = vespalib::compression::CompressionConfig; public: - StoreByBucket(vespalib::MemoryDataStore & backingMemory, const document::CompressionConfig & compression); + StoreByBucket(vespalib::MemoryDataStore & backingMemory, const CompressionConfig & compression); StoreByBucket(MemoryDataStore & backingMemory, ThreadExecutor & executor, const CompressionConfig & compression); StoreByBucket(StoreByBucket &&) = default; ~StoreByBucket(); diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp index 22a16947b67..b3fd236d73d 100644 --- a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp +++ b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp @@ -5,7 +5,7 @@ #include <vespa/vespalib/stllike/cache.hpp> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/data/databuffer.h> -#include <vespa/document/util/compressor.h> +#include <vespa/vespalib/util/compressor.h> #include <algorithm> namespace search::docstore { @@ -74,7 +74,7 @@ BlobSet::get(uint32_t lid) const } CompressedBlobSet::CompressedBlobSet() : - _compression(document::CompressionConfig::Type::LZ4), + _compression(CompressionConfig::Type::LZ4), _positions(), _buffer() { @@ -83,7 +83,7 @@ CompressedBlobSet::CompressedBlobSet() : CompressedBlobSet::~CompressedBlobSet() { } -CompressedBlobSet::CompressedBlobSet(const document::CompressionConfig &compression, const BlobSet & uncompressed) : +CompressedBlobSet::CompressedBlobSet(const CompressionConfig &compression, const BlobSet & uncompressed) : _compression(compression.type), _positions(uncompressed.getPositions()), _buffer() @@ -91,7 +91,7 @@ CompressedBlobSet::CompressedBlobSet(const document::CompressionConfig &compress if ( ! _positions.empty() ) { DataBuffer compressed; ConstBufferRef org = uncompressed.getBuffer(); - _compression = document::compression::compress(compression, org, compressed, false); + _compression = vespalib::compression::compress(compression, org, compressed, false); _buffer.resize(compressed.getDataLen()); memcpy(_buffer, compressed.getData(), compressed.getDataLen()); } @@ -100,7 +100,7 @@ CompressedBlobSet::CompressedBlobSet(const document::CompressionConfig &compress BlobSet CompressedBlobSet::getBlobSet() const { - using document::compression::decompress; + using vespalib::compression::decompress; // These are frequent lage allocations that are to expensive to mmap. DataBuffer uncompressed(0, 1, Alloc::alloc(0, 16 * MemoryAllocator::HUGEPAGE_SIZE)); if ( ! _positions.empty() ) { @@ -145,7 +145,7 @@ VisitCache::BackingStore::read(const KeySet &key, CompressedBlobSet &blobs) cons return ! blobs.empty(); } -VisitCache::VisitCache(IDataStore &store, size_t cacheSize, const document::CompressionConfig &compression) : +VisitCache::VisitCache(IDataStore &store, size_t cacheSize, const CompressionConfig &compression) : _store(store, compression), _cache(std::make_unique<Cache>(_store, cacheSize)) { diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.h b/searchlib/src/vespa/searchlib/docstore/visitcache.h index 44ee5542a72..a89620b7bde 100644 --- a/searchlib/src/vespa/searchlib/docstore/visitcache.h +++ b/searchlib/src/vespa/searchlib/docstore/visitcache.h @@ -72,8 +72,9 @@ private: **/ class CompressedBlobSet { public: + using CompressionConfig = vespalib::compression::CompressionConfig; CompressedBlobSet(); - CompressedBlobSet(const document::CompressionConfig &compression, const BlobSet & uncompressed); + CompressedBlobSet(const CompressionConfig &compression, const BlobSet & uncompressed); CompressedBlobSet(CompressedBlobSet && rhs) = default; CompressedBlobSet & operator=(CompressedBlobSet && rhs) = default; CompressedBlobSet(const CompressedBlobSet & rhs) = default; @@ -83,7 +84,7 @@ public: bool empty() const { return _positions.empty(); } BlobSet getBlobSet() const; private: - document::CompressionConfig::Type _compression; + CompressionConfig::Type _compression; BlobSet::Positions _positions; vespalib::MallocPtr _buffer; }; @@ -95,7 +96,8 @@ private: **/ class VisitCache { public: - VisitCache(IDataStore &store, size_t cacheSize, const document::CompressionConfig &compression); + using CompressionConfig = vespalib::compression::CompressionConfig; + VisitCache(IDataStore &store, size_t cacheSize, const CompressionConfig &compression); CompressedBlobSet read(const IDocumentStore::LidVector & keys) const; void remove(uint32_t key); @@ -111,17 +113,17 @@ private: */ class BackingStore { public: - BackingStore(IDataStore &store, const document::CompressionConfig &compression) : + BackingStore(IDataStore &store, const CompressionConfig &compression) : _backingStore(store), _compression(compression) { } bool read(const KeySet &key, CompressedBlobSet &blobs) const; void write(const KeySet &, const CompressedBlobSet &) { } void erase(const KeySet &) { } - const document::CompressionConfig &getCompression() const { return _compression; } + const CompressionConfig &getCompression() const { return _compression; } private: IDataStore &_backingStore; - const document::CompressionConfig _compression; + const CompressionConfig _compression; }; using CacheParams = vespalib::CacheParam< diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp index c6b93a59ae8..5cf5c646148 100644 --- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp +++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/util/closuretask.h> #include <vespa/vespalib/util/array.hpp> #include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/data/databuffer.h> #include <vespa/searchlib/common/fileheadercontext.h> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/objects/nbostream.h> diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h index 86415e0cb40..2b21f12a314 100644 --- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h +++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h @@ -22,20 +22,21 @@ public: class Config { public: + using CompressionConfig = vespalib::compression::CompressionConfig; Config() - : _compression(document::CompressionConfig::LZ4, 9, 60), + : _compression(CompressionConfig::LZ4, 9, 60), _maxChunkBytes(0x10000) { } - Config(const document::CompressionConfig &compression, size_t maxChunkBytes) + Config(const CompressionConfig &compression, size_t maxChunkBytes) : _compression(compression), _maxChunkBytes(maxChunkBytes) { } - const document::CompressionConfig & getCompression() const { return _compression; } + const CompressionConfig & getCompression() const { return _compression; } size_t getMaxChunkBytes() const { return _maxChunkBytes; } private: - document::CompressionConfig _compression; + CompressionConfig _compression; size_t _maxChunkBytes; }; diff --git a/searchlib/src/vespa/searchlib/grouping/hyperloglog.h b/searchlib/src/vespa/searchlib/grouping/hyperloglog.h index 753b81d92f2..931b832c76d 100644 --- a/searchlib/src/vespa/searchlib/grouping/hyperloglog.h +++ b/searchlib/src/vespa/searchlib/grouping/hyperloglog.h @@ -3,8 +3,8 @@ #pragma once #include "sketch.h" -#include <vespa/document/util/compressionconfig.h> -#include <vespa/document/util/compressor.h> +#include <vespa/vespalib/util/compressionconfig.h> +#include <vespa/vespalib/util/compressor.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/objects/deserializer.h> #include <vespa/vespalib/objects/serializer.h> diff --git a/searchlib/src/vespa/searchlib/grouping/sketch.h b/searchlib/src/vespa/searchlib/grouping/sketch.h index bb7db02d81c..317c1bfef9d 100644 --- a/searchlib/src/vespa/searchlib/grouping/sketch.h +++ b/searchlib/src/vespa/searchlib/grouping/sketch.h @@ -2,8 +2,8 @@ #pragma once -#include <vespa/document/util/compressionconfig.h> -#include <vespa/document/util/compressor.h> +#include <vespa/vespalib/util/compressionconfig.h> +#include <vespa/vespalib/util/compressor.h> #include <lz4.h> #include <vespa/searchlib/common/identifiable.h> #include <vespa/vespalib/data/databuffer.h> @@ -205,13 +205,13 @@ deserialize(vespalib::Deserializer &is) { template <int BucketBits, typename HashT> uint32_t NormalSketch<BucketBits, HashT>:: compress_buckets_into(char *buffer, uint32_t size) const { - document::CompressionConfig config(document::CompressionConfig::LZ4, 9, 9); + vespalib::compression::CompressionConfig config(vespalib::compression::CompressionConfig::LZ4, 9, 9); vespalib::ConstBufferRef org(&bucket[0], BUCKET_COUNT); vespalib::DataBuffer compress_buffer(buffer, size); - document::CompressionConfig::Type r = - document::compression::compress(config, org, compress_buffer, false); + vespalib::compression::CompressionConfig::Type r = + vespalib::compression::compress(config, org, compress_buffer, false); assert(compress_buffer.getDead() == buffer); - if (r == document::CompressionConfig::LZ4) { + if (r == vespalib::compression::CompressionConfig::LZ4) { assert(compress_buffer.getDataLen() < BUCKET_COUNT); return compress_buffer.getDataLen(); } else { @@ -228,7 +228,8 @@ decompress_buckets_from(char *buffer, uint32_t size) { } else { vespalib::ConstBufferRef compressed(buffer, size); vespalib::DataBuffer uncompressed(reinterpret_cast<char *>(&bucket[0]), BUCKET_COUNT); - document::compression::decompress(document::CompressionConfig::LZ4, BUCKET_COUNT, compressed, uncompressed, false); + vespalib::compression::decompress(vespalib::compression::CompressionConfig::LZ4, BUCKET_COUNT, + compressed, uncompressed, false); } } template <int BucketBits, typename HashT> diff --git a/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.cpp b/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.cpp index 6c4155b035e..e5e582b673b 100644 --- a/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.cpp +++ b/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.cpp @@ -4,6 +4,7 @@ #include <vespa/vespalib/data/fileheader.h> #include <vespa/searchlib/util/fileheadertk.h> #include <vespa/vespalib/util/host_name.h> +#include <cassert> #include <unistd.h> namespace search::index { diff --git a/searchlib/src/vespa/searchlib/util/fileutil.cpp b/searchlib/src/vespa/searchlib/util/fileutil.cpp index c1d34f66b0b..674608bdda1 100644 --- a/searchlib/src/vespa/searchlib/util/fileutil.cpp +++ b/searchlib/src/vespa/searchlib/util/fileutil.cpp @@ -4,6 +4,7 @@ #include "filesizecalculator.h" #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/guard.h> +#include <cassert> #include <fcntl.h> #include <sys/mman.h> #include <sys/stat.h> @@ -18,7 +19,6 @@ using vespalib::FileDescriptor; using vespalib::getLastErrorString; namespace search { - namespace fileutil { LoadedMmap::LoadedMmap(const vespalib::string &fileName) @@ -177,4 +177,5 @@ FileWriterBase::write(const void *buf, size_t sz) { } return numWritten; } + } |