diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-01-19 01:02:10 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-01-19 01:02:10 +0100 |
commit | 8c02a1288b1cf36841ad46d6255c202ddeed8464 (patch) | |
tree | a11c90c3de0bad9bbc61834182184719fecfd8b2 | |
parent | 02700f1dd97365690a6deece2b471b55434c3bea (diff) |
Clearly differentiate when you promise a long lived buffer and not.
22 files changed, 82 insertions, 94 deletions
diff --git a/document/src/tests/serialization/vespadocumentserializer_test.cpp b/document/src/tests/serialization/vespadocumentserializer_test.cpp index 27f725bf38f..8bfe7b7d919 100644 --- a/document/src/tests/serialization/vespadocumentserializer_test.cpp +++ b/document/src/tests/serialization/vespadocumentserializer_test.cpp @@ -49,6 +49,7 @@ using document::DocumenttypesConfig; using vespalib::File; using vespalib::Slime; using vespalib::nbostream; +using vespalib::nbostream_longlivedbuf; using vespalib::slime::Cursor; using vespalib::tensor::Tensor; using vespalib::tensor::TensorBuilder; @@ -119,7 +120,7 @@ void testDeserializeAndClone(const T& value, const nbostream &stream, bool check T read_value = newFieldValue(value); vespalib::MallocPtr buf(stream.size()); memcpy(buf.str(), stream.peek(), stream.size()); - nbostream is(buf.c_str(), buf.size(), true); + nbostream_longlivedbuf is(buf.c_str(), buf.size()); VespaDocumentDeserializer deserializer(repo, is, 8); deserializer.read(read_value); @@ -666,7 +667,7 @@ void deserializeAndCheck(const string &file_name, FieldValueT &value, size_t r = file.read(&content[0], content.size(), 0); ASSERT_EQUAL(content.size(), r); - nbostream stream(&content[0], content.size(), true); + nbostream_longlivedbuf stream(&content[0], content.size()); Document doc; VespaDocumentDeserializer deserializer(myrepo, stream, 8); deserializer.read(doc); diff --git a/document/src/vespa/document/fieldvalue/document.cpp b/document/src/vespa/document/fieldvalue/document.cpp index 67134303586..cef9b885dd0 100644 --- a/document/src/vespa/document/fieldvalue/document.cpp +++ b/document/src/vespa/document/fieldvalue/document.cpp @@ -1,13 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "document.h" - -#include <memory> #include <vespa/vespalib/util/crc.h> -#include <vespa/document/base/documentid.h> -#include <vespa/document/base/field.h> -#include <vespa/document/fieldvalue/fieldvalue.h> - #include <vespa/document/repo/fixedtyperepo.h> #include <vespa/document/serialization/vespadocumentdeserializer.h> #include <vespa/document/serialization/vespadocumentserializer.h> @@ -357,7 +351,7 @@ Document::deserializeDocHeader(ByteBuffer& buffer, DocumentId& id) { if (len > (long)buffer.getRemaining()) { notEnoughDocumentError(len, buffer.getRemaining()); } else { - nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining(), false); + nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining()); id = DocumentId(stream); buffer.incPos(stream.rp()); unsigned char contentByte; @@ -396,30 +390,27 @@ void Document::deserialize(const DocumentTypeRepo& repo, vespalib::nbostream & o } } -void Document::deserialize(const DocumentTypeRepo& repo, ByteBuffer& data, - bool longLivedBuffer) { - nbostream stream(data.getBufferAtPos(), data.getRemaining(), longLivedBuffer); +void Document::deserialize(const DocumentTypeRepo& repo, ByteBuffer& data) { + nbostream stream(data.getBufferAtPos(), data.getRemaining()); deserialize(repo, stream); data.incPos(data.getRemaining() - stream.size()); } -void Document::deserialize(const DocumentTypeRepo& repo, ByteBuffer& header, - ByteBuffer& body, bool longLivedBuffer) { - deserializeHeader(repo, header, longLivedBuffer); - deserializeBody(repo, body, longLivedBuffer); +void Document::deserialize(const DocumentTypeRepo& repo, ByteBuffer& header, ByteBuffer& body) { + deserializeHeader(repo, header); + deserializeBody(repo, body); } void Document::deserializeHeader(const DocumentTypeRepo& repo, - ByteBuffer& header, bool longLivedBuffer) { - nbostream stream(header.getBufferAtPos(), header.getRemaining(), longLivedBuffer); + ByteBuffer& header) { + nbostream stream(header.getBufferAtPos(), header.getRemaining()); VespaDocumentDeserializer deserializer(repo, stream, 0); deserializer.read(*this); header.incPos(header.getRemaining() - stream.size()); } -void Document::deserializeBody(const DocumentTypeRepo& repo, - ByteBuffer& body, bool longLivedBuffer) { - nbostream body_stream(body.getBufferAtPos(), body.getRemaining(), longLivedBuffer); +void Document::deserializeBody(const DocumentTypeRepo& repo, ByteBuffer& body) { + nbostream body_stream(body.getBufferAtPos(), body.getRemaining()); VespaDocumentDeserializer body_deserializer(repo, body_stream, getFields().getVersion()); body_deserializer.readStructNoReset(getFields()); diff --git a/document/src/vespa/document/fieldvalue/document.h b/document/src/vespa/document/fieldvalue/document.h index 893d1b3fc9c..9942b9a0997 100644 --- a/document/src/vespa/document/fieldvalue/document.h +++ b/document/src/vespa/document/fieldvalue/document.h @@ -129,12 +129,12 @@ public: void serializeBody(vespalib::nbostream& stream) const; /** Deserialize document contained in given bytebuffer. */ - void deserialize(const DocumentTypeRepo& repo, ByteBuffer& data, bool longLivedBuffer=false); + void deserialize(const DocumentTypeRepo& repo, ByteBuffer& data); void deserialize(const DocumentTypeRepo& repo, vespalib::nbostream & os); /** Deserialize document contained in given bytebuffers. */ - void deserialize(const DocumentTypeRepo& repo, ByteBuffer& body, ByteBuffer& header, bool longLivedBuffer=false); - void deserializeHeader(const DocumentTypeRepo& repo, ByteBuffer& header, bool longLivedBuffer=false); - void deserializeBody(const DocumentTypeRepo& repo, ByteBuffer& body, bool longLivedBuffer=false); + void deserialize(const DocumentTypeRepo& repo, ByteBuffer& body, ByteBuffer& header); + void deserializeHeader(const DocumentTypeRepo& repo, ByteBuffer& header); + void deserializeBody(const DocumentTypeRepo& repo, ByteBuffer& body); size_t getSerializedSize() const; diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp index 3dac3123bd0..6c0903d44ee 100644 --- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp @@ -18,6 +18,7 @@ LOG_SETUP(".document.structfieldvalue"); using std::vector; using vespalib::nbostream; +using vespalib::nbostream_longlivedbuf; namespace document { @@ -200,7 +201,7 @@ StructFieldValue::getFieldValue(const Field& field, FieldValue& value) const vespalib::ConstBufferRef buf = getRawField(fieldId); if (buf.size() > 0) { - nbostream stream(buf.c_str(), buf.size(), true); + nbostream_longlivedbuf stream(buf.c_str(), buf.size()); if ((_repo == NULL) && (_doc_type != NULL)) { DocumentTypeRepo::UP tmpRepo(new DocumentTypeRepo(*_doc_type)); createFV(value, *tmpRepo, stream, *_doc_type, _version); diff --git a/document/src/vespa/document/update/documentupdate.cpp b/document/src/vespa/document/update/documentupdate.cpp index 584616f49dd..866a215505c 100644 --- a/document/src/vespa/document/update/documentupdate.cpp +++ b/document/src/vespa/document/update/documentupdate.cpp @@ -1,14 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/document/update/documentupdate.h> -#include <vespa/document/datatype/arraydatatype.h> -#include <vespa/document/datatype/datatype.h> -#include <vespa/document/datatype/weightedsetdatatype.h> +#include "documentupdate.h" +#include "documentupdateflags.h" #include <vespa/document/fieldvalue/fieldvalues.h> -#include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/serialization/vespadocumentserializer.h> -#include <vespa/document/update/documentupdateflags.h> -#include <vespa/document/update/fieldupdate.h> -#include <vespa/document/update/valueupdate.h> #include <vespa/document/util/serializableexceptions.h> #include <vespa/vespalib/objects/nbostream.h> #include <vespa/document/util/bufferexceptions.h> @@ -186,8 +180,7 @@ DocumentUpdate::serializeFlags(int size_) const namespace { std::pair<const DocumentType *, DocumentId> deserializeTypeAndId(const DocumentTypeRepo& repo, ByteBuffer& buffer) { - nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining(), - false); + nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining()); DocumentId docId(stream); buffer.incPos(stream.rp()); @@ -265,7 +258,7 @@ DocumentUpdate::deserializeHEAD(const DocumentTypeRepo &repo, ByteBuffer &buffer { int pos = buffer.getPos(); try { - nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining(), false); + nbostream stream(buffer.getBufferAtPos(), buffer.getRemaining()); _documentId = DocumentId(stream); buffer.incPos(stream.rp()); diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/documentstate.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/documentstate.cpp index b177475f82a..bca95de38a8 100644 --- a/documentapi/src/vespa/documentapi/messagebus/messages/documentstate.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/messages/documentstate.cpp @@ -38,8 +38,7 @@ DocumentState::DocumentState(document::ByteBuffer& buf) uint8_t hasDocId; buf.getByte(hasDocId); if (hasDocId) { - vespalib::nbostream stream( - buf.getBufferAtPos(), buf.getRemaining(), false); + vespalib::nbostream stream(buf.getBufferAtPos(), buf.getRemaining()); _docId.reset(new document::DocumentId(stream)); buf.incPos(stream.rp()); } diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories41.cpp b/documentapi/src/vespa/documentapi/messagebus/routablefactories41.cpp index baa400e5100..76caac68e46 100644 --- a/documentapi/src/vespa/documentapi/messagebus/routablefactories41.cpp +++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories41.cpp @@ -45,7 +45,7 @@ RoutableFactories41::decodeLong(document::ByteBuffer &in) document::DocumentId RoutableFactories41::decodeDocumentId(document::ByteBuffer &in) { - nbostream stream(in.getBufferAtPos(), in.getRemaining(), false); + nbostream stream(in.getBufferAtPos(), in.getRemaining()); document::DocumentId ret(stream); in.incPos(stream.rp()); return ret; diff --git a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp index cd4b150f41c..7622f421331 100644 --- a/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp +++ b/memfilepersistence/src/vespa/memfilepersistence/mapper/simplememfileiobuffer.cpp @@ -74,7 +74,7 @@ SimpleMemFileIOBuffer::getDocumentHeader( document::ByteBuffer buf(data.buf->getBuffer() + data.pos, data.buf->getSize() - data.pos); - doc->deserializeHeader(repo, buf, false); + doc->deserializeHeader(repo, buf); return doc; } @@ -103,7 +103,7 @@ SimpleMemFileIOBuffer::readBody( document::ByteBuffer buf(data.buf->getBuffer() + data.pos, data.buf->getSize() - data.pos); - doc.deserializeBody(repo, buf, false); + doc.deserializeBody(repo, buf); } DataLocation diff --git a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp index e0102c8e059..b6c8ba24de4 100644 --- a/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp +++ b/searchcore/src/apps/vespa-transactionlog-inspect/vespa-transactionlog-inspect.cpp @@ -296,9 +296,7 @@ public: { } virtual RPC::Result receive(const Packet &packet) { - vespalib::nbostream handle(packet.getHandle().c_str(), - packet.getHandle().size(), - true); + vespalib::nbostream_longlivedbuf handle(packet.getHandle().c_str(), packet.getHandle().size()); try { while (handle.size() > 0) { Packet::Entry entry; diff --git a/searchcore/src/vespa/searchcore/proton/server/feedstates.cpp b/searchcore/src/vespa/searchcore/proton/server/feedstates.cpp index 1da46a63995..6c008f6870b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/feedstates.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/feedstates.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "feedstates.h" #include "feedconfigstore.h" -#include "ireplaypackethandler.h" #include "replaypacketdispatcher.h" #include <vespa/searchcore/proton/common/eventlogger.h> #include <vespa/vespalib/util/closuretask.h> @@ -45,9 +44,7 @@ handleProgress(TlsReplayProgress &progress, SerialNum currentSerial) void handlePacket(PacketWrapper::SP wrap, EntryHandler entryHandler) { - vespalib::nbostream handle(wrap->packet.getHandle().c_str(), - wrap->packet.getHandle().size(), - true); + vespalib::nbostream_longlivedbuf handle(wrap->packet.getHandle().c_str(), wrap->packet.getHandle().size()); while (handle.size() > 0) { Packet::Entry entry; entry.deserialize(handle); diff --git a/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.cpp b/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.cpp index e4db294eb3c..7d44c504b50 100644 --- a/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "replaypacketdispatcher.h" -#include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/exceptions.h> #include <vespa/document/util/serializableexceptions.h> @@ -30,9 +29,7 @@ ReplayPacketDispatcher::ReplayPacketDispatcher(IReplayPacketHandler &handler) void ReplayPacketDispatcher::replayEntry(const Packet::Entry &entry) { - vespalib::nbostream is(entry.data().c_str(), - entry.data().size(), - false); + vespalib::nbostream is(entry.data().c_str(), entry.data().size()); switch (entry.type()) { case FeedOperation::PUT: { PutOperation op; diff --git a/searchlib/src/tests/transactionlog/translogclient_test.cpp b/searchlib/src/tests/transactionlog/translogclient_test.cpp index 2e756e9d4b8..249544984ab 100644 --- a/searchlib/src/tests/transactionlog/translogclient_test.cpp +++ b/searchlib/src/tests/transactionlog/translogclient_test.cpp @@ -79,7 +79,7 @@ public: RPC::Result CallBackTest::receive(const Packet & p) { - vespalib::nbostream h(p.getHandle().c_str(), p.getHandle().size(), true); + nbostream_longlivedbuf h(p.getHandle().c_str(), p.getHandle().size()); LOG(info,"CallBackTest::receive (%zu, %zu, %zu)(%s)", h.rp(), h.size(), h.capacity(), myhex(h.peek(), h.size()).c_str()); while(h.size() > 0) { Packet::Entry e; @@ -107,7 +107,7 @@ public: RPC::Result CallBackManyTest::receive(const Packet & p) { - nbostream h(p.getHandle().c_str(), p.getHandle().size(), true); + nbostream_longlivedbuf h(p.getHandle().c_str(), p.getHandle().size()); for(;h.size() > 0; _count++, _value++) { Packet::Entry e; e.deserialize(h); @@ -141,7 +141,7 @@ public: RPC::Result CallBackUpdate::receive(const Packet & packet) { - nbostream h(packet.getHandle().c_str(), packet.getHandle().size(), true); + nbostream_longlivedbuf h(packet.getHandle().c_str(), packet.getHandle().size()); while (h.size() > 0) { Packet::Entry e; e.deserialize(h); @@ -195,7 +195,7 @@ public: RPC::Result CallBackStatsTest::receive(const Packet & p) { - nbostream h(p.getHandle().c_str(), p.getHandle().size(), true); + nbostream_longlivedbuf h(p.getHandle().c_str(), p.getHandle().size()); for(;h.size() > 0; ++_count) { Packet::Entry e; e.deserialize(h); diff --git a/searchlib/src/vespa/searchlib/transactionlog/common.cpp b/searchlib/src/vespa/searchlib/transactionlog/common.cpp index 6ff2aee8ee7..4301208c980 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/common.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/common.cpp @@ -1,14 +1,14 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> + #include "common.h" +#include <vespa/fastos/file.h> -namespace search -{ +namespace search { -namespace transactionlog -{ +namespace transactionlog { using vespalib::nbostream; +using vespalib::nbostream_longlivedbuf; int makeDirectory(const char * dir) { @@ -37,9 +37,9 @@ Packet::Packet(const void * buf, size_t sz) : _count(0), _range(), _limit(sz), - _buf(static_cast<const char *>(buf), sz, true) + _buf(static_cast<const char *>(buf), sz) { - nbostream os(_buf.c_str(), sz, true); + nbostream_longlivedbuf os(_buf.c_str(), sz); while ( os.size() > 0 ) { Entry e; e.deserialize(os); diff --git a/searchlib/src/vespa/searchlib/transactionlog/common.h b/searchlib/src/vespa/searchlib/transactionlog/common.h index ae6f27f39a1..44914a14e29 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/common.h +++ b/searchlib/src/vespa/searchlib/transactionlog/common.h @@ -81,10 +81,10 @@ public: size_t sizeBytes() const { return _buf.size(); } bool merge(const Packet & packet); private: - size_t _count; - SerialNumRange _range; - size_t _limit; - vespalib::nbostream _buf; + size_t _count; + SerialNumRange _range; + size_t _limit; + vespalib::nbostream_longlivedbuf _buf; }; int makeDirectory(const char * dir); diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp index d7d28b937ba..9dad2216fcb 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp @@ -1,15 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/searchlib/transactionlog/domain.h> + +#include "domain.h" #include <limits> #include <vespa/vespalib/util/vstringfmt.h> #include <vespa/vespalib/util/stringfmt.h> -#include <vespa/vespalib/objects/nbostream.h> -#include <vespa/fastlib/io/bufferedfile.h> -#include <stdexcept> -#include <vespa/log/log.h> #include <vespa/vespalib/util/closuretask.h> +#include <vespa/log/log.h> LOG_SETUP(".transactionlog.domain"); using vespalib::string; @@ -278,7 +275,7 @@ void Domain::cleanSessions() void Domain::commit(const Packet & packet) { DomainPart::SP dp(_parts.rbegin()->second); - vespalib::nbostream is(packet.getHandle().c_str(), packet.getHandle().size(), true); + vespalib::nbostream_longlivedbuf is(packet.getHandle().c_str(), packet.getHandle().size()); Packet::Entry entry; entry.deserialize(is); if (dp->byteSize() > _domainPartSize) { diff --git a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp index baf1752a01e..9cf156a2737 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp @@ -1,15 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/searchlib/transactionlog/domainpart.h> + +#include "domainpart.h" #include <vespa/vespalib/util/crc.h> #include <vespa/vespalib/xxhash/xxhash.h> #include <vespa/vespalib/util/vstringfmt.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/data/fileheader.h> #include <vespa/searchlib/common/fileheadercontext.h> -#include <vespa/vespalib/objects/nbostream.h> #include <vespa/fastlib/io/bufferedfile.h> -#include <stdexcept> #include <vespa/log/log.h> LOG_SETUP(".transactionlog.domainpart"); @@ -21,6 +19,7 @@ using vespalib::getLastErrorString; using vespalib::IllegalHeaderException; using vespalib::LockGuard; using vespalib::nbostream; +using vespalib::nbostream_longlivedbuf; using vespalib::alloc::Alloc; using search::common::FileHeaderContext; using std::runtime_error; @@ -409,7 +408,7 @@ void DomainPart::commit(SerialNum firstSerial, const Packet &packet) { int64_t firstPos(_transLog.GetPosition()); - nbostream h(packet.getHandle().c_str(), packet.getHandle().size(), true); + nbostream h(packet.getHandle().c_str(), packet.getHandle().size()); if (_range.from() == 0) { _range.from(firstSerial); } @@ -504,7 +503,7 @@ DomainPart::visit(SerialNumRange &r, Packet &packet) } } else { const nbostream & tmp = start->second.getHandle(); - nbostream h(tmp.c_str(), tmp.size(), true); + nbostream_longlivedbuf h(tmp.c_str(), tmp.size()); LOG(debug, "Visit partial[%" PRIu64 ", %" PRIu64 "] (%zd, %zd, %zd)", start->second.range().from(), start->second.range().to(), h.rp(), h.size(), h.capacity()); Packet newPacket(h.size()); @@ -641,7 +640,7 @@ DomainPart::read(FastOS_FileInterface &file, if (!retval) { retval = handleReadError("packet blob", file, len, rlen, lastKnownGoodPos, allowTruncate); } else { - nbostream is(buf.get(), len, true); + nbostream_longlivedbuf is(buf.get(), len); entry.deserialize(is); int32_t crc(0); is >> crc; diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.cpp b/vespalib/src/vespa/vespalib/objects/nbostream.cpp index 7fe75326245..ec04ffb8b3b 100644 --- a/vespalib/src/vespa/vespalib/objects/nbostream.cpp +++ b/vespalib/src/vespa/vespalib/objects/nbostream.cpp @@ -26,6 +26,18 @@ nbostream::nbostream(const void * buf, size_t sz, bool longLivedBuffer) : _longLivedBuffer(longLivedBuffer) { } +nbostream_longlivedbuf::nbostream_longlivedbuf(const void * buf, size_t sz) : + nbostream(buf, sz, true) +{ } + +nbostream_longlivedbuf::nbostream_longlivedbuf(size_t initialSize) : + nbostream(initialSize) +{ } + +nbostream::nbostream(const void * buf, size_t sz) : + nbostream(buf, sz, false) +{ } + nbostream::nbostream(Alloc && buf, size_t sz) : _wbuf(std::move(buf), sz), _rbuf(&_wbuf[0], sz), diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.h b/vespalib/src/vespa/vespalib/objects/nbostream.h index 6914b533b63..cc5b1099f5d 100644 --- a/vespalib/src/vespa/vespalib/objects/nbostream.h +++ b/vespalib/src/vespa/vespalib/objects/nbostream.h @@ -22,7 +22,10 @@ class nbostream using Alloc = alloc::Alloc; enum State { ok=0, eof=0x01}; nbostream(size_t initialSize=1024); - nbostream(const void * buf, size_t sz, bool longLivedBuffer=false); +protected: + nbostream(const void * buf, size_t sz, bool longLivedBuffer); +public: + nbostream(const void * buf, size_t sz); nbostream(Alloc && buf, size_t sz); nbostream(const nbostream & rhs); ~nbostream(); @@ -235,5 +238,11 @@ class nbostream const bool _longLivedBuffer; }; +class nbostream_longlivedbuf : public nbostream { +public: + nbostream_longlivedbuf(size_t initialSize=1024); + nbostream_longlivedbuf(const void * buf, size_t sz); +}; + } diff --git a/vsm/src/tests/searcher/searcher.cpp b/vsm/src/tests/searcher/searcher.cpp index a9ae9f11705..28e97f5e726 100644 --- a/vsm/src/tests/searcher/searcher.cpp +++ b/vsm/src/tests/searcher/searcher.cpp @@ -2,19 +2,18 @@ #include <vespa/vespalib/testkit/testapp.h> -#include <vespa/document/fieldvalue/stringfieldvalue.h> #include <vespa/searchlib/query/queryterm.h> #include <vespa/vsm/searcher/fieldsearcher.h> #include <vespa/vsm/searcher/floatfieldsearcher.h> #include <vespa/vsm/searcher/futf8strchrfieldsearcher.h> #include <vespa/vsm/searcher/intfieldsearcher.h> -#include <vespa/vsm/searcher/strchrfieldsearcher.h> #include <vespa/vsm/searcher/utf8flexiblestringfieldsearcher.h> #include <vespa/vsm/searcher/utf8exactstringfieldsearcher.h> #include <vespa/vsm/searcher/utf8substringsearcher.h> #include <vespa/vsm/searcher/utf8substringsnippetmodifier.h> #include <vespa/vsm/searcher/utf8suffixstringfieldsearcher.h> #include <vespa/vsm/vsm/snippetmodifier.h> +#include <vespa/document/fieldvalue/fieldvalues.h> using namespace document; using search::EmptyQueryNodeResult; diff --git a/vsm/src/vespa/vsm/common/documenttypemapping.cpp b/vsm/src/vespa/vsm/common/documenttypemapping.cpp index 389c6608d70..96a7effae57 100644 --- a/vsm/src/vespa/vsm/common/documenttypemapping.cpp +++ b/vsm/src/vespa/vsm/common/documenttypemapping.cpp @@ -1,13 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "documenttypemapping.h" +#include <vespa/document/repo/documenttyperepo.h> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/log/log.h> LOG_SETUP(".vsm.common.documenttypemapping"); -#define DEBUGMASK 0x00 - namespace vsm { DocumentTypeMapping::DocumentTypeMapping() : diff --git a/vsm/src/vespa/vsm/common/storagedocument.h b/vsm/src/vespa/vsm/common/storagedocument.h index d748423dab4..cf0638cb3c3 100644 --- a/vsm/src/vespa/vsm/common/storagedocument.h +++ b/vsm/src/vespa/vsm/common/storagedocument.h @@ -1,14 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/document/util/bytebuffer.h> #include <vespa/document/fieldvalue/document.h> -#include <vespa/document/base/field.h> -#include <vespa/document/fieldvalue/fieldvalues.h> #include <vespa/vsm/common/document.h> -namespace vsm -{ +namespace vsm { typedef vespalib::CloneablePtr<document::FieldValue> FieldValueContainer; typedef document::FieldPath FieldPath; // field path to navigate a field value @@ -23,8 +19,7 @@ class StorageDocument : public Document public: SubDocument() : _fieldValue(NULL) - { - } + { } SubDocument(document::FieldValue * fv, FieldPath::const_iterator it, FieldPath::const_iterator mt) : _fieldValue(fv), _it(it), diff --git a/vsm/src/vespa/vsm/vsm/snippetmodifier.cpp b/vsm/src/vespa/vsm/vsm/snippetmodifier.cpp index ea3e1dc8e91..910b087f4b9 100644 --- a/vsm/src/vespa/vsm/vsm/snippetmodifier.cpp +++ b/vsm/src/vespa/vsm/vsm/snippetmodifier.cpp @@ -1,6 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "snippetmodifier.h" +#include <vespa/document/fieldvalue/stringfieldvalue.h> #include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/log/log.h> |