summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-09-26 19:19:24 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-09-26 19:19:24 +0000
commit80b2585f2c5bed035d5fb9215533109ad00a3fc5 (patch)
tree6a3158f65d3c336b5ca05804b22171e100ed6bd4
parent72b6f0a82a7f1f7caec8cc58815b3802d94fb92d (diff)
Use && qualified member functions.
-rw-r--r--fnet/src/vespa/fnet/frt/values.cpp7
-rw-r--r--fnet/src/vespa/fnet/frt/values.h6
-rw-r--r--messagebus/src/vespa/messagebus/network/rpcsendv2.cpp7
-rw-r--r--searchcore/src/apps/vespa-feed-bm/storage_api_rpc_bm_feed_handler.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunkformat.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/docstore/value.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/docstore/visitcache.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/chunks.cpp2
-rw-r--r--storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp4
-rw-r--r--storage/src/vespa/storage/storageserver/rpc/storage_api_rpc_service.cpp3
-rw-r--r--vespalib/src/vespa/vespalib/data/databuffer.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/data/databuffer.h5
12 files changed, 25 insertions, 24 deletions
diff --git a/fnet/src/vespa/fnet/frt/values.cpp b/fnet/src/vespa/fnet/frt/values.cpp
index 3b37aa9a1bc..593bbd173c6 100644
--- a/fnet/src/vespa/fnet/frt/values.cpp
+++ b/fnet/src/vespa/fnet/frt/values.cpp
@@ -4,6 +4,7 @@
#include <vespa/fnet/databuffer.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/stash.h>
+#include <vespa/vespalib/data/databuffer.h>
#include <cassert>
static_assert(sizeof(uint8_t) == 1, "uint8_t must be 1 byte.");
@@ -300,6 +301,12 @@ FRT_Values::AddData(vespalib::alloc::Alloc && buf, uint32_t len) {
}
void
+FRT_Values::AddData(vespalib::DataBuffer && buf) {
+ const auto len = buf.getDataLen();
+ AddSharedData(&_stash.create<LocalBlob>(std::move(buf).stealBuffer(), len));
+}
+
+void
FRT_Values::AddData(const char *buf, uint32_t len) {
if (len > SHARED_LIMIT) {
return AddSharedData(&_stash.create<LocalBlob>(buf, len));
diff --git a/fnet/src/vespa/fnet/frt/values.h b/fnet/src/vespa/fnet/frt/values.h
index 2aa7551c423..bac1f609fbb 100644
--- a/fnet/src/vespa/fnet/frt/values.h
+++ b/fnet/src/vespa/fnet/frt/values.h
@@ -5,7 +5,10 @@
#include "isharedblob.h"
#include <cstring>
-namespace vespalib { class Stash; }
+namespace vespalib {
+ class Stash;
+ class DataBuffer;
+}
namespace vespalib::alloc { class Alloc; }
namespace fnet {
char * copyString(char *dst, const char *src, size_t len);
@@ -218,6 +221,7 @@ public:
FRT_StringValue *AddStringArray(uint32_t len);
void AddSharedData(FRT_ISharedBlob *blob);
void AddData(Alloc && buf, uint32_t len);
+ void AddData(vespalib::DataBuffer && buf);
void AddData(const char *buf, uint32_t len);
char *AddData(uint32_t len);
FRT_DataValue *AddDataArray(uint32_t len);
diff --git a/messagebus/src/vespa/messagebus/network/rpcsendv2.cpp b/messagebus/src/vespa/messagebus/network/rpcsendv2.cpp
index 4c5b93048bf..f7303ece20f 100644
--- a/messagebus/src/vespa/messagebus/network/rpcsendv2.cpp
+++ b/messagebus/src/vespa/messagebus/network/rpcsendv2.cpp
@@ -133,7 +133,7 @@ RPCSendV2::encodeRequest(FRT_RPCRequest &req, const Version &version, const Rout
args.AddInt32(toCompress.size());
const auto bufferLength = buf.getDataLen();
assert(bufferLength <= INT32_MAX);
- args.AddData(DataBuffer::stealBuffer(std::move(buf)), bufferLength);
+ args.AddData(std::move(buf).stealBuffer(), bufferLength);
}
namespace {
@@ -261,9 +261,8 @@ RPCSendV2::createResponse(FRT_Values & ret, const string & version, Reply & repl
ret.AddInt8(type);
ret.AddInt32(toCompress.size());
- const auto bufferLength = buf.getDataLen();
- assert(bufferLength <= INT32_MAX);
- ret.AddData(DataBuffer::stealBuffer(std::move(buf)), bufferLength);
+ assert(buf.getDataLen() <= INT32_MAX);
+ ret.AddData(std::move(buf));
}
diff --git a/searchcore/src/apps/vespa-feed-bm/storage_api_rpc_bm_feed_handler.cpp b/searchcore/src/apps/vespa-feed-bm/storage_api_rpc_bm_feed_handler.cpp
index f8952363509..c8d73444652 100644
--- a/searchcore/src/apps/vespa-feed-bm/storage_api_rpc_bm_feed_handler.cpp
+++ b/searchcore/src/apps/vespa-feed-bm/storage_api_rpc_bm_feed_handler.cpp
@@ -41,8 +41,7 @@ make_set_cluster_state_request() {
auto* params = req->GetParams();
params->AddInt8(static_cast<uint8_t>(encoded_bundle._compression_type));
params->AddInt32(encoded_bundle._uncompressed_length);
- const auto buf_len = encoded_bundle._buffer->getDataLen();
- params->AddData(vespalib::DataBuffer::stealBuffer(std::move(*encoded_bundle._buffer)), buf_len);
+ params->AddData(std::move(*encoded_bundle._buffer));
req->SetMethodName("setdistributionstates");
return req;
}
diff --git a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
index e9689e36180..afa7abb9ef8 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
@@ -12,7 +12,6 @@ using vespalib::compression::compress;
using vespalib::compression::decompress;
using vespalib::compression::computeMaxCompressedsize;
using vespalib::compression::CompressionConfig;
-using vespalib::DataBuffer;
ChunkException::ChunkException(const vespalib::string & msg, vespalib::stringref location) :
Exception(make_string("Illegal chunk: %s", msg.c_str()), location)
@@ -141,7 +140,7 @@ ChunkFormat::deserializeBody(vespalib::nbostream & is)
assert(uncompressed.getData() == uncompressed.getDead());
if (uncompressed.getData() != data.c_str()) {
const size_t sz(uncompressed.getDataLen());
- vespalib::nbostream(DataBuffer::stealBuffer(std::move(uncompressed)), sz).swap(_dataBuf);
+ vespalib::nbostream(std::move(uncompressed).stealBuffer(), sz).swap(_dataBuf);
} else {
_dataBuf = vespalib::nbostream(uncompressed.getData(), uncompressed.getDataLen());
}
diff --git a/searchlib/src/vespa/searchlib/docstore/value.cpp b/searchlib/src/vespa/searchlib/docstore/value.cpp
index 40d04b3d7fb..25cf93ac18b 100644
--- a/searchlib/src/vespa/searchlib/docstore/value.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/value.cpp
@@ -6,7 +6,6 @@
using vespalib::compression::compress;
using vespalib::compression::decompress;
-using vespalib::DataBuffer;
namespace search::docstore {
@@ -67,8 +66,8 @@ Value::set(vespalib::DataBuffer &&buf, ssize_t len, const CompressionConfig &com
_uncompressedSize = len;
_uncompressedCrc = XXH64(input.c_str(), input.size(), 0);
_buf = std::make_shared<Alloc>(compact(_compressedSize,(buf.getData() == compressed.getData())
- ? DataBuffer::stealBuffer(std::move(buf))
- : DataBuffer::stealBuffer(std::move(compressed))));
+ ? std::move(buf).stealBuffer()
+ : std::move(compressed).stealBuffer()));
assert(((type == CompressionConfig::NONE) &&
(len == ssize_t(_compressedSize))) ||
diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
index dada57c15b9..6990a0a3ed7 100644
--- a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
@@ -109,7 +109,7 @@ CompressedBlobSet::getBlobSet() const
decompress(_compression, getBufferSize(_positions),
ConstBufferRef(_buffer->c_str(), _buffer->size()), uncompressed, false);
}
- return BlobSet(_positions, DataBuffer::stealBuffer(std::move(uncompressed)));
+ return BlobSet(_positions, std::move(uncompressed).stealBuffer());
}
size_t CompressedBlobSet::size() const {
diff --git a/searchlib/src/vespa/searchlib/transactionlog/chunks.cpp b/searchlib/src/vespa/searchlib/transactionlog/chunks.cpp
index b06ff9397c4..edb12b4bf36 100644
--- a/searchlib/src/vespa/searchlib/transactionlog/chunks.cpp
+++ b/searchlib/src/vespa/searchlib/transactionlog/chunks.cpp
@@ -94,7 +94,7 @@ XXH64CompressedChunk::decompress(nbostream & is, uint32_t uncompressedLen) {
::decompress(_type, uncompressedLen, compressed, uncompressed, false);
nbostream data(uncompressed.getData(), uncompressed.getDataLen());
deserializeEntries(data);
- _backing = DataBuffer::stealBuffer(std::move(uncompressed));
+ _backing = std::move(uncompressed).stealBuffer();
is.adjustReadPos(is.size());
}
diff --git a/storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp b/storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp
index a65e8678a72..8b009e02f28 100644
--- a/storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp
+++ b/storage/src/tests/storageserver/rpc/cluster_controller_rpc_api_service_test.cpp
@@ -15,7 +15,6 @@
#include <vespa/vespalib/gtest/gtest.h>
#include <vector>
-using vespalib::DataBuffer;
namespace storage::rpc {
using document::FixedBucketSpaces;
@@ -83,8 +82,7 @@ struct SetStateFixture : FixtureBase {
auto* params = bound_request->GetParams();
params->AddInt8(static_cast<uint8_t>(encoded_bundle._compression_type));
params->AddInt32(uncompressed_length);
- const auto buf_len = encoded_bundle._buffer->getDataLen();
- params->AddData(DataBuffer::stealBuffer(std::move(*encoded_bundle._buffer)), buf_len);
+ params->AddData(std::move(*encoded_bundle._buffer));
bound_request->SetDetachedPT(&request_is_detached);
bound_request->SetReturnHandler(&return_handler);
diff --git a/storage/src/vespa/storage/storageserver/rpc/storage_api_rpc_service.cpp b/storage/src/vespa/storage/storageserver/rpc/storage_api_rpc_service.cpp
index 42af872da9b..c234f623d45 100644
--- a/storage/src/vespa/storage/storageserver/rpc/storage_api_rpc_service.cpp
+++ b/storage/src/vespa/storage/storageserver/rpc/storage_api_rpc_service.cpp
@@ -117,8 +117,7 @@ void compress_and_add_payload_to_rpc_params(mbus::BlobRef payload,
params.AddInt8(comp_type);
params.AddInt32(static_cast<uint32_t>(to_compress.size()));
- auto buffer_len = buf.getDataLen();
- params.AddData(vespalib::DataBuffer::stealBuffer(std::move(buf)), buffer_len);
+ params.AddData(std::move(buf));
}
} // anon ns
diff --git a/vespalib/src/vespa/vespalib/data/databuffer.cpp b/vespalib/src/vespa/vespalib/data/databuffer.cpp
index 39c0f3f7482..04c4b1e225b 100644
--- a/vespalib/src/vespa/vespalib/data/databuffer.cpp
+++ b/vespalib/src/vespa/vespalib/data/databuffer.cpp
@@ -155,7 +155,7 @@ DataBuffer::swap(DataBuffer &other)
}
vespalib::alloc::Alloc
-DataBuffer::stealBuffer()
+DataBuffer::stealBuffer() &&
{
assert( ! referencesExternalData() );
_externalBuf = nullptr;
diff --git a/vespalib/src/vespa/vespalib/data/databuffer.h b/vespalib/src/vespa/vespalib/data/databuffer.h
index 3229921e09c..7c4cd63a7b1 100644
--- a/vespalib/src/vespa/vespalib/data/databuffer.h
+++ b/vespalib/src/vespa/vespalib/data/databuffer.h
@@ -40,7 +40,6 @@ private:
char *_freept;
Alloc _buffer;
- Alloc stealBuffer();
public:
typedef std::unique_ptr<DataBuffer> UP;
DataBuffer(const DataBuffer &) = delete;
@@ -607,9 +606,7 @@ public:
**/
void swap(DataBuffer &other);
- static Alloc stealBuffer(DataBuffer && buf) {
- return buf.stealBuffer();
- }
+ Alloc stealBuffer() &&;
};
} // namespace vespalib