summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunk.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp16
2 files changed, 16 insertions, 2 deletions
diff --git a/searchlib/src/vespa/searchlib/docstore/chunk.cpp b/searchlib/src/vespa/searchlib/docstore/chunk.cpp
index c7976fd15ae..847cd3623c3 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/chunk.cpp
@@ -79,7 +79,7 @@ Chunk::Chunk(uint32_t id, const void * buffer, size_t len, bool skipcrc) :
os >> _lastSerial;
}
-Chunk::~Chunk() { }
+Chunk::~Chunk() = default;
vespalib::ConstBufferRef
Chunk::getLid(uint32_t lid) const
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
index 70295d81a93..d12a3a54a93 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
@@ -203,6 +203,13 @@ seek_past(LidInfoWithLidV::const_iterator begin, LidInfoWithLidV::const_iterator
return begin;
}
+struct LidAndBuffer {
+ LidAndBuffer(uint32_t lid, uint32_t sz, vespalib::alloc::Alloc buf) : _lid(lid), _size(sz), _buf(std::move(buf)) {}
+ uint32_t _lid;
+ uint32_t _size;
+ vespalib::alloc::Alloc _buf;
+};
+
}
void
@@ -211,6 +218,7 @@ WriteableFileChunk::read(LidInfoWithLidV::const_iterator begin, size_t count, IB
if (count == 0) { return; }
if (!frozen()) {
vespalib::hash_map<uint32_t, ChunkInfo> chunksOnFile;
+ std::vector<LidAndBuffer> buffers;
{
LockGuard guard(_lock);
for (size_t i(0); i < count; i++) {
@@ -225,12 +233,18 @@ WriteableFileChunk::read(LidInfoWithLidV::const_iterator begin, size_t count, IB
assert(chunk == _active->getId());
buffer = _active->getLid(li.getLid());
}
- visitor.visit(li.getLid(), buffer);
+ auto copy = vespalib::alloc::Alloc::alloc(buffer.size());
+ memcpy(copy.get(), buffer.data(), buffer.size());
+ buffers.emplace_back(li.getLid(), buffer.size(), std::move(copy));
} else {
chunksOnFile[chunk] = _chunkInfo[chunk];
}
}
}
+ for (auto & entry : buffers) {
+ visitor.visit(entry._lid, vespalib::ConstBufferRef(entry._buf.get(), entry._size));
+ entry._buf = vespalib::alloc::Alloc();
+ }
for (auto & it : chunksOnFile) {
auto first = find_first(begin, it.first);
auto last = seek_past(first, begin + count, it.first);