aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-09-26 18:38:58 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-09-26 18:38:58 +0000
commit4ada4ab6551d15432749b4b06d838194297f687d (patch)
treef583b018daae2b566ef39d08c4539693ec60c2d7 /searchlib
parent69655b7a638e3588b46cbed18d9a644d8b82d9ed (diff)
Replace the dangerous stealBuffer method with a static one that requires std::move to make destruction more visible.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp2
-rw-r--r--searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributefilebufferwriter.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributememoryfilebufferwriter.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attrvector.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunkformat.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/docstore/value.cpp7
-rw-r--r--searchlib/src/vespa/searchlib/docstore/visitcache.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/transactionlog/chunks.cpp2
15 files changed, 22 insertions, 15 deletions
diff --git a/searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp b/searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp
index eeabbf23c27..1e3531dc78e 100644
--- a/searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp
+++ b/searchlib/src/tests/attribute/attributefilewriter/attributefilewriter_test.cpp
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
-#include <vespa/vespalib/stllike/string.h>
#include <vespa/searchlib/attribute/attributefilewriter.h>
#include <vespa/searchlib/attribute/attributefilebufferwriter.h>
#include <vespa/searchlib/attribute/attribute_header.h>
@@ -10,6 +9,7 @@
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/searchlib/common/fileheadercontext.h>
#include <vespa/searchlib/index/dummyfileheadercontext.h>
+#include <vespa/vespalib/data/databuffer.h>
#include <vespa/fastos/file.h>
#include <vespa/log/log.h>
diff --git a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
index d8761f69d71..2a5b8014299 100644
--- a/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
+++ b/searchlib/src/tests/attribute/enumeratedsave/enumeratedsave_test.cpp
@@ -10,7 +10,6 @@
#include <vespa/searchlib/attribute/attributememorysavetarget.h>
#include <vespa/searchlib/attribute/attributesaver.h>
#include <vespa/searchlib/attribute/multinumericattribute.h>
-#include <vespa/searchlib/attribute/multistringattribute.h>
#include <vespa/searchlib/attribute/singlenumericattribute.h>
#include <vespa/searchlib/attribute/singlestringattribute.h>
#include <vespa/searchlib/queryeval/executeinfo.h>
@@ -21,6 +20,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/searchlib/util/bufferwriter.h>
#include <vespa/vespalib/util/compress.h>
+#include <vespa/vespalib/data/databuffer.h>
#include <vespa/searchlib/attribute/attributevector.hpp>
diff --git a/searchlib/src/vespa/searchlib/attribute/attributefilebufferwriter.cpp b/searchlib/src/vespa/searchlib/attribute/attributefilebufferwriter.cpp
index 341112f9b22..4efd64f72dd 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributefilebufferwriter.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributefilebufferwriter.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "attributefilebufferwriter.h"
+#include <vespa/vespalib/data/databuffer.h>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp b/searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp
index 415c00cb8fd..829720e9c3e 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributefilewriter.cpp
@@ -6,6 +6,7 @@
#include <vespa/vespalib/data/fileheader.h>
#include <vespa/searchlib/common/fileheadercontext.h>
#include <vespa/searchlib/common/tunefileinfo.h>
+#include <vespa/vespalib/data/databuffer.h>
#include <vespa/fastos/file.h>
#include <vespa/log/log.h>
diff --git a/searchlib/src/vespa/searchlib/attribute/attributememoryfilebufferwriter.cpp b/searchlib/src/vespa/searchlib/attribute/attributememoryfilebufferwriter.cpp
index b354566616b..454cc486f70 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributememoryfilebufferwriter.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributememoryfilebufferwriter.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "attributememoryfilebufferwriter.h"
+#include <vespa/vespalib/data/databuffer.h>
namespace search {
@@ -11,9 +12,7 @@ AttributeMemoryFileBufferWriter(IAttributeFileWriter &memoryFileWriter)
}
-AttributeMemoryFileBufferWriter::~AttributeMemoryFileBufferWriter()
-{
-}
+AttributeMemoryFileBufferWriter::~AttributeMemoryFileBufferWriter() = default;
void
diff --git a/searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp b/searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp
index c28b7e9d20b..8d412364815 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributememoryfilewriter.cpp
@@ -2,6 +2,7 @@
#include "attributememoryfilewriter.h"
#include "attributememoryfilebufferwriter.h"
+#include <vespa/vespalib/data/databuffer.h>
namespace search {
@@ -18,9 +19,7 @@ AttributeMemoryFileWriter::AttributeMemoryFileWriter()
}
-AttributeMemoryFileWriter::~AttributeMemoryFileWriter()
-{
-}
+AttributeMemoryFileWriter::~AttributeMemoryFileWriter() = default;
AttributeMemoryFileWriter::Buffer
diff --git a/searchlib/src/vespa/searchlib/attribute/attrvector.cpp b/searchlib/src/vespa/searchlib/attribute/attrvector.cpp
index 59771d7ffae..80f72aaea25 100644
--- a/searchlib/src/vespa/searchlib/attribute/attrvector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attrvector.cpp
@@ -4,6 +4,7 @@
#include "attrvector.hpp"
#include "iattributesavetarget.h"
#include "load_utils.h"
+#include <vespa/vespalib/data/databuffer.h>
#include <vespa/log/log.h>
LOG_SETUP(".searchlib.attribute.attr_vector");
diff --git a/searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h b/searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h
index bb00124c9fc..94e16b37e9d 100644
--- a/searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h
+++ b/searchlib/src/vespa/searchlib/attribute/iattributefilewriter.h
@@ -2,8 +2,9 @@
#pragma once
-#include <vespa/vespalib/data/databuffer.h>
+#include <memory>
+namespace vespalib { class DataBuffer; }
namespace search {
class BufferWriter;
diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
index e1ab47ed434..bbe8c9c8327 100644
--- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
@@ -8,6 +8,7 @@
#include <vespa/searchlib/query/query_term_simple.h>
#include <vespa/searchlib/queryeval/emptysearch.h>
#include <vespa/searchlib/common/bitvectoriterator.h>
+#include <vespa/vespalib/data/databuffer.h>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp b/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp
index db8636f47c3..3c26e960a06 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp
@@ -2,6 +2,7 @@
#include "singlenumericattributesaver.h"
#include "iattributesavetarget.h"
+#include <vespa/vespalib/data/databuffer.h>
using vespalib::GenerationHandler;
diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
index 6eff0da06e8..fd2631ac63d 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
@@ -7,6 +7,7 @@
#include "iattributesavetarget.h"
#include <vespa/searchlib/query/query_term_simple.h>
#include <vespa/searchlib/queryeval/emptysearch.h>
+#include <vespa/vespalib/data/databuffer.h>
namespace search {
diff --git a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
index fbbdcff3c5d..e9689e36180 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp
@@ -12,6 +12,7 @@ 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)
@@ -140,7 +141,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(uncompressed.stealBuffer(), sz).swap(_dataBuf);
+ vespalib::nbostream(DataBuffer::stealBuffer(std::move(uncompressed)), 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 09725b447cd..40d04b3d7fb 100644
--- a/searchlib/src/vespa/searchlib/docstore/value.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/value.cpp
@@ -1,12 +1,12 @@
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "value.h"
-#include <vespa/vespalib/data/databuffer.h>
#include <vespa/vespalib/util/compressor.h>
#include <xxhash.h>
using vespalib::compression::compress;
using vespalib::compression::decompress;
+using vespalib::DataBuffer;
namespace search::docstore {
@@ -66,8 +66,9 @@ Value::set(vespalib::DataBuffer &&buf, ssize_t len, const CompressionConfig &com
_compression = type;
_uncompressedSize = len;
_uncompressedCrc = XXH64(input.c_str(), input.size(), 0);
- _buf = std::make_shared<Alloc>(compact(_compressedSize,
- (buf.getData() == compressed.getData()) ? buf.stealBuffer() : compressed.stealBuffer()));
+ _buf = std::make_shared<Alloc>(compact(_compressedSize,(buf.getData() == compressed.getData())
+ ? DataBuffer::stealBuffer(std::move(buf))
+ : DataBuffer::stealBuffer(std::move(compressed))));
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 e8504480b7d..dada57c15b9 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, uncompressed.stealBuffer());
+ return BlobSet(_positions, DataBuffer::stealBuffer(std::move(uncompressed)));
}
size_t CompressedBlobSet::size() const {
diff --git a/searchlib/src/vespa/searchlib/transactionlog/chunks.cpp b/searchlib/src/vespa/searchlib/transactionlog/chunks.cpp
index a78db61429d..b06ff9397c4 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 = uncompressed.stealBuffer();
+ _backing = DataBuffer::stealBuffer(std::move(uncompressed));
is.adjustReadPos(is.size());
}