aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-14 09:00:50 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-03-14 09:00:50 +0000
commitfcaa8409c8db254496e0b16faba37f0a930243c5 (patch)
tree52d2039aa6eb06e945d1985c6caf7f815c52f8b2
parent6b105cae53bbfef618e987b6b0ef313fe9bb1b79 (diff)
Use std::vector instead of vespalib::Array
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunk.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunk.h28
-rw-r--r--searchlib/src/vespa/searchlib/docstore/filechunk.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/docstore/filechunk.h3
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h7
-rw-r--r--vespalib/src/vespa/vespalib/util/compressionconfig.h12
7 files changed, 30 insertions, 39 deletions
diff --git a/searchlib/src/vespa/searchlib/docstore/chunk.cpp b/searchlib/src/vespa/searchlib/docstore/chunk.cpp
index e83b190a7c0..a8982c28805 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/chunk.cpp
@@ -15,7 +15,7 @@ Chunk::append(uint32_t lid, const void * buffer, size_t len)
std::lock_guard guard(_lock);
os << lid << static_cast<uint32_t>(len);
os.write(buffer, len);
- _lids.push_back(Entry(lid, len, oldSz));
+ _lids.emplace_back(lid, len, oldSz);
return LidMeta(lid, len);
}
@@ -91,7 +91,7 @@ Chunk::Chunk(uint32_t id, const void * buffer, size_t len, bool skipcrc) :
ssize_t oldRp(os.rp());
os >> lid >> sz;
os.adjustReadPos(sz);
- _lids.push_back(Entry(lid, sz, oldRp));
+ _lids.emplace_back(lid, sz, oldRp);
}
os >> _lastSerial;
}
@@ -143,8 +143,8 @@ Chunk::getUniqueLids() const
}
LidList unique;
unique.reserve(last.size());
- for (auto it(last.begin()), mt(last.end()); it != mt; it++) {
- unique.push_back(it->second);
+ for (const auto & entry : last) {
+ unique.emplace_back(entry.second);
}
return unique;
}
diff --git a/searchlib/src/vespa/searchlib/docstore/chunk.h b/searchlib/src/vespa/searchlib/docstore/chunk.h
index 93fc98311cd..e274572c96b 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/chunk.h
@@ -21,17 +21,12 @@ class ChunkFormat;
class ChunkMeta {
public:
- ChunkMeta() :
- _offset(0),
- _lastSerial(0),
- _size(0),
- _numEntries(0)
- { }
- ChunkMeta(uint64_t offset, uint32_t size, uint64_t lastSerial, uint32_t numEntries) :
- _offset(offset),
- _lastSerial(lastSerial),
- _size(size),
- _numEntries(numEntries)
+ ChunkMeta() noexcept : ChunkMeta(0, 0, 0, 0) { }
+ ChunkMeta(uint64_t offset, uint32_t size, uint64_t lastSerial, uint32_t numEntries) noexcept
+ : _offset(offset),
+ _lastSerial(lastSerial),
+ _size(size),
+ _numEntries(numEntries)
{ }
uint32_t getNumEntries() const { return _numEntries; }
uint32_t getSize() const { return _size; }
@@ -49,8 +44,8 @@ private:
class LidMeta {
public:
- LidMeta() noexcept : _lid(0), _size(0) { }
- LidMeta(uint32_t lid, uint32_t sz) : _lid(lid), _size(sz) { }
+ LidMeta() noexcept : LidMeta(0, 0) { }
+ LidMeta(uint32_t lid, uint32_t sz) noexcept : _lid(lid), _size(sz) { }
uint32_t getLid() const { return _lid; }
uint32_t size() const { return _size; }
vespalib::nbostream & deserialize(vespalib::nbostream & is);
@@ -66,15 +61,15 @@ public:
using CompressionConfig = vespalib::compression::CompressionConfig;
class Config {
public:
- Config(size_t maxBytes) : _maxBytes(maxBytes) { }
+ Config(size_t maxBytes) noexcept : _maxBytes(maxBytes) { }
size_t getMaxBytes() const { return _maxBytes; }
private:
size_t _maxBytes;
};
class Entry {
public:
- Entry() : _lid(0), _sz(0), _offset(0) { }
- Entry(uint32_t lid, uint32_t sz, uint32_t offset) : _lid(lid), _sz(sz), _offset(offset) { }
+ Entry() noexcept : Entry(0, 0, 0 ) { }
+ Entry(uint32_t lid, uint32_t sz, uint32_t offset) noexcept : _lid(lid), _sz(sz), _offset(offset) { }
uint32_t getLid() const { return _lid; }
uint32_t size() const { return _sz + 2*4; }
uint32_t netSize() const { return _sz; }
@@ -101,7 +96,6 @@ public:
void pack(uint64_t lastSerial, vespalib::DataBuffer & buffer, CompressionConfig compression);
uint64_t getLastSerial() const { return _lastSerial; }
uint32_t getId() const { return _id; }
- bool validSerial() const { return getLastSerial() != static_cast<uint64_t>(-1l); }
vespalib::ConstBufferRef getLid(uint32_t lid) const;
const vespalib::nbostream & getData() const;
bool hasRoom(size_t len) const;
diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
index 60ba449cdf6..d7922fcca2a 100644
--- a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
@@ -129,7 +129,7 @@ public:
}
};
-using TmpChunkMetaV = vespalib::Array<TmpChunkMeta>;
+using TmpChunkMetaV = std::vector<TmpChunkMeta>;
namespace {
@@ -181,7 +181,7 @@ FileChunk::updateLidMap(const unique_lock &guard, ISetLid &ds, uint64_t serialNu
tempVector.reserve(fileSize/(sizeof(ChunkMeta)+sizeof(LidMeta)));
while ( ! is.empty() && is.good()) {
const int64_t lastKnownGoodPos = _idxHeaderLen + is.rp();
- tempVector.push_back(TmpChunkMeta());
+ tempVector.emplace_back();
TmpChunkMeta & chunkMeta(tempVector.back());
try {
chunkMeta.deserialize(is);
@@ -238,7 +238,7 @@ FileChunk::updateLidMap(const unique_lock &guard, ISetLid &ds, uint64_t serialNu
}
serialNum = chunkMeta.getLastSerial();
addNumBuckets(bucketMap.getNumBuckets());
- _chunkInfo.push_back(ChunkInfo(chunkMeta.getOffset(), chunkMeta.getSize(), chunkMeta.getLastSerial()));
+ _chunkInfo.emplace_back(chunkMeta.getOffset(), chunkMeta.getSize(), chunkMeta.getLastSerial());
assert(serialNum >= _lastPersistedSerialNum.load(std::memory_order_relaxed));
_lastPersistedSerialNum.store(serialNum, std::memory_order_relaxed);
}
diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.h b/searchlib/src/vespa/searchlib/docstore/filechunk.h
index a29f7c511c5..9e8623060fb 100644
--- a/searchlib/src/vespa/searchlib/docstore/filechunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/filechunk.h
@@ -8,7 +8,6 @@
#include "randread.h"
#include <vespa/searchlib/common/tunefileinfo.h>
#include <vespa/vespalib/stllike/hash_map.h>
-#include <vespa/vespalib/util/array.h>
#include <vespa/vespalib/util/cpu_usage.h>
#include <vespa/vespalib/util/generationhandler.h>
#include <vespa/vespalib/util/memoryusage.h>
@@ -238,7 +237,7 @@ protected:
static uint32_t readDocIdLimit(vespalib::GenericHeader &header);
static void writeDocIdLimit(vespalib::GenericHeader &header, uint32_t docIdLimit);
- using ChunkInfoVector = vespalib::Array<ChunkInfo>;
+ using ChunkInfoVector = std::vector<ChunkInfo, vespalib::allocator_large<ChunkInfo>>;
const IBucketizer * _bucketizer;
size_t _addedBytes;
TuneFileSummary _tune;
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
index bdaa23dad35..c642d8b30f0 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
@@ -9,7 +9,6 @@
#include <vespa/vespalib/data/fileheader.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
-#include <vespa/vespalib/util/array.hpp>
#include <vespa/vespalib/util/cpu_usage.h>
#include <vespa/vespalib/util/lambdatask.h>
#include <vespa/vespalib/util/size_literals.h>
@@ -78,7 +77,7 @@ WriteableFileChunk::
WriteableFileChunk(vespalib::Executor &executor,
FileId fileId, NameId nameId,
const vespalib::string &baseName,
- SerialNum initialSerialNum,
+ uint64_t initialSerialNum,
uint32_t docIdLimit,
const Config &config,
const TuneFileSummary &tune,
@@ -101,7 +100,7 @@ WriteableFileChunk(vespalib::Executor &executor,
_idxFileSize(0),
_currentDiskFootprint(0),
_nextChunkId(1),
- _active(new Chunk(0, Chunk::Config(config.getMaxChunkBytes()))),
+ _active(std::make_unique<Chunk>(0, Chunk::Config(config.getMaxChunkBytes()))),
_alignment(1),
_granularity(1),
_maxChunkSize(0x100000),
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
index 37bb925f11e..defa9a382c8 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
@@ -4,7 +4,6 @@
#include "filechunk.h"
#include <vespa/vespalib/util/executor.h>
-#include <vespa/searchlib/transactionlog/syncproxy.h>
#include <vespa/fastos/file.h>
#include <map>
#include <deque>
@@ -24,9 +23,9 @@ public:
{
public:
using CompressionConfig = vespalib::compression::CompressionConfig;
- Config() : Config({CompressionConfig::LZ4, 9, 60}, 0x10000) { }
+ Config() noexcept : Config({CompressionConfig::LZ4, 9, 60}, 0x10000) { }
- Config(CompressionConfig compression, size_t maxChunkBytes)
+ Config(CompressionConfig compression, size_t maxChunkBytes) noexcept
: _compression(compression),
_maxChunkBytes(maxChunkBytes)
{ }
@@ -107,7 +106,7 @@ private:
const Chunk& get_chunk(uint32_t chunk) const;
Config _config;
- SerialNum _serialNum;
+ uint64_t _serialNum;
std::atomic<bool> _frozen;
// Lock order is _writeLock, _flushLock, _lock
mutable std::mutex _lock;
diff --git a/vespalib/src/vespa/vespalib/util/compressionconfig.h b/vespalib/src/vespa/vespalib/util/compressionconfig.h
index 2a09fa7e086..726264f9fd7 100644
--- a/vespalib/src/vespa/vespalib/util/compressionconfig.h
+++ b/vespalib/src/vespa/vespalib/util/compressionconfig.h
@@ -31,16 +31,16 @@ struct CompressionConfig {
CompressionConfig(Type t, uint8_t lvl, uint8_t minRes, size_t minSz) noexcept
: minSize(minSz), type(t), compressionLevel(lvl), threshold(minRes) {}
- bool operator==(const CompressionConfig& o) const {
+ bool operator==(const CompressionConfig& o) const noexcept {
return (type == o.type
&& compressionLevel == o.compressionLevel
&& threshold == o.threshold);
}
- bool operator!=(const CompressionConfig& o) const {
+ bool operator!=(const CompressionConfig& o) const noexcept {
return !operator==(o);
}
- static Type toType(uint32_t val) {
+ static Type toType(uint32_t val) noexcept {
switch (val) {
case 1: return NONE_MULTI;
case 2: return HISTORIC_2;
@@ -52,7 +52,7 @@ struct CompressionConfig {
default: return NONE;
}
}
- static Type toType(const char * val) {
+ static Type toType(const char * val) noexcept {
if (strncasecmp(val, "lz4", 3) == 0) {
return LZ4;
} if (strncasecmp(val, "zstd", 4) == 0) {
@@ -60,11 +60,11 @@ struct CompressionConfig {
}
return NONE;
}
- static bool isCompressed(Type type) {
+ static bool isCompressed(Type type) noexcept {
return (type != CompressionConfig::NONE &&
type != CompressionConfig::UNCOMPRESSABLE);
}
- bool useCompression() const { return isCompressed(type); }
+ bool useCompression() const noexcept { return isCompressed(type); }
uint32_t minSize;
Type type;