summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-01-19 01:02:10 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-01-19 01:02:10 +0100
commit8c02a1288b1cf36841ad46d6255c202ddeed8464 (patch)
treea11c90c3de0bad9bbc61834182184719fecfd8b2 /searchlib
parent02700f1dd97365690a6deece2b471b55434c3bea (diff)
Clearly differentiate when you promise a long lived buffer and not.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/transactionlog/translogclient_test.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/common.cpp14
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/common.h8
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/domain.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp13
5 files changed, 25 insertions, 29 deletions
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;