summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-12-03 14:09:30 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-12-03 14:33:04 +0000
commit6f3518ff56336aa3c185280684a99ec5266d9c58 (patch)
tree396a6c62286a879a79b5b6f50a0276fa0ceabc15 /searchlib
parent35311886fd9576abf77955bb4041c4500bb7beef (diff)
Ensure that we do not get more resizing than necessary.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
index 4da09868216..2c0d10abd33 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
@@ -484,11 +484,19 @@ void
WriteableFileChunk::updateChunkInfo(const ProcessedChunkQ & chunks, const ChunkMetaV & cmetaV, size_t sz)
{
std::lock_guard guard(_lock);
+ uint32_t maxChunkId(0);
+ for (const auto & chunk : chunks) {
+ maxChunkId = std::max(chunk->getChunkId(), maxChunkId);
+ }
+ if (maxChunkId >= _chunkInfo.size()) {
+ _chunkInfo.reserve(vespalib::roundUp2inN(maxChunkId+1));
+ }
size_t nettoSz(sz);
for (size_t i(0); i < chunks.size(); i++) {
const ProcessedChunk & chunk = *chunks[i];
assert(_chunkMap.find(chunk.getChunkId()) == _chunkMap.begin());
const Chunk & active = *_chunkMap.begin()->second;
+ assert(active.getId() == chunk.getChunkId());
if (active.getId() >= _chunkInfo.size()) {
_chunkInfo.resize(active.getId()+1);
}