summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-10-05 21:45:37 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-10-05 21:45:37 +0000
commit4a8f5727a3b7d123f0e62279e109156f1ec53bf9 (patch)
tree1abdf8b68c938d1abf78199c856fc3ba259ebfaf /searchlib
parent43e2d929d983fdd9d2feaecfcdc385e1961a35b7 (diff)
Use ConstBufferRef and add some noexcept
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/docstore/chunk/chunk_test.cpp14
-rw-r--r--searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp6
-rw-r--r--searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunk.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/docstore/chunk.h5
-rw-r--r--searchlib/src/vespa/searchlib/docstore/compacter.cpp22
-rw-r--r--searchlib/src/vespa/searchlib/docstore/compacter.h7
-rw-r--r--searchlib/src/vespa/searchlib/docstore/filechunk.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/docstore/filechunk.h4
-rw-r--r--searchlib/src/vespa/searchlib/docstore/logdatastore.cpp26
-rw-r--r--searchlib/src/vespa/searchlib/docstore/logdatastore.h7
-rw-r--r--searchlib/src/vespa/searchlib/docstore/storebybucket.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/docstore/storebybucket.h4
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp21
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h4
-rw-r--r--searchlib/src/vespa/searchlib/fef/objectstore.h8
16 files changed, 79 insertions, 76 deletions
diff --git a/searchlib/src/tests/docstore/chunk/chunk_test.cpp b/searchlib/src/tests/docstore/chunk/chunk_test.cpp
index 28bd5208b73..d2e406d7cf4 100644
--- a/searchlib/src/tests/docstore/chunk/chunk_test.cpp
+++ b/searchlib/src/tests/docstore/chunk/chunk_test.cpp
@@ -19,10 +19,10 @@ TEST("require that Chunk obey limits")
{
Chunk c(0, Chunk::Config(256));
EXPECT_TRUE(c.hasRoom(1000)); // At least 1 is allowed no matter what the size is.
- c.append(1, "abc", 3);
+ c.append(1, {"abc", 3});
EXPECT_TRUE(c.hasRoom(229));
EXPECT_FALSE(c.hasRoom(230));
- c.append(2, "abc", 3);
+ c.append(2, {"abc", 3});
EXPECT_TRUE(c.hasRoom(20));
}
@@ -30,11 +30,11 @@ TEST("require that Chunk can produce unique list")
{
const char *d = "ABCDEF";
Chunk c(0, Chunk::Config(100));
- c.append(1, d, 1);
- c.append(2, d, 2);
- c.append(3, d, 3);
- c.append(2, d, 4);
- c.append(1, d, 5);
+ c.append(1, {d, 1});
+ c.append(2, {d, 2});
+ c.append(3, {d, 3});
+ c.append(2, {d, 4});
+ c.append(1, {d, 5});
EXPECT_EQUAL(5u, c.count());
const Chunk::LidList & all = c.getLids();
EXPECT_EQUAL(5u, all.size());
diff --git a/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp b/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp
index 64ae4dfd2f2..a0cb6c881cf 100644
--- a/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp
+++ b/searchlib/src/tests/docstore/file_chunk/file_chunk_test.cpp
@@ -43,10 +43,10 @@ struct BucketizerObserver : public IBucketizer {
document::BucketId getBucketOf(const vespalib::GenerationHandler::Guard &guard, uint32_t lid) const override {
(void) guard;
lids.push_back(lid);
- return document::BucketId();
+ return {};
}
vespalib::GenerationHandler::Guard getGuard() const override {
- return vespalib::GenerationHandler::Guard();
+ return {};
}
};
@@ -129,7 +129,7 @@ struct WriteFixture : public FixtureBase {
}
WriteFixture &append(uint32_t lid) {
vespalib::string data = getData(lid);
- chunk.append(nextSerialNum(), lid, data.c_str(), data.size(), CpuUsage::Category::WRITE);
+ chunk.append(nextSerialNum(), lid, {data.c_str(), data.size()}, CpuUsage::Category::WRITE);
return *this;
}
void updateLidMap(uint32_t docIdLimit) {
diff --git a/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp b/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp
index c7e0c59da12..053a2806b5d 100644
--- a/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp
+++ b/searchlib/src/tests/docstore/store_by_bucket/store_by_bucket_test.cpp
@@ -35,13 +35,13 @@ add(StoreByBucket & sbb, size_t i) {
EXPECT_EQUAL(userId(i), docId.getGlobalId().getLocationSpecificBits());
b.setUsedBits(USED_BITS);
vespalib::string s = createPayload(b);
- sbb.add(b, i%10, i, s.c_str(), s.size());
+ sbb.add(b, i%10, i, {s.c_str(), s.size()});
}
class VerifyBucketOrder : public StoreByBucket::IWrite {
public:
VerifyBucketOrder() : _lastLid(0), _lastBucketId(0), _uniqueUser(), _uniqueBucket() { }
- void write(BucketId bucketId, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz) override {
+ void write(BucketId bucketId, uint32_t chunkId, uint32_t lid, vespalib::ConstBufferRef data) override {
(void) chunkId;
EXPECT_LESS_EQUAL(_lastBucketId.toKey(), bucketId.toKey());
if (_lastBucketId != bucketId) {
@@ -54,7 +54,7 @@ public:
}
_lastLid = lid;
_lastBucketId = bucketId;
- EXPECT_EQUAL(0, memcmp(buffer, createPayload(bucketId).c_str(), sz));
+ EXPECT_EQUAL(0, memcmp(data.data(), createPayload(bucketId).c_str(), data.size()));
}
~VerifyBucketOrder() override;
private:
diff --git a/searchlib/src/vespa/searchlib/docstore/chunk.cpp b/searchlib/src/vespa/searchlib/docstore/chunk.cpp
index 60255af3521..1717595b973 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/chunk.cpp
@@ -8,15 +8,16 @@
namespace search {
LidMeta
-Chunk::append(uint32_t lid, const void * buffer, size_t len)
+Chunk::append(uint32_t lid, ConstBufferRef data)
{
vespalib::nbostream & os = getData();
size_t oldSz(os.size());
+ uint32_t len = data.size();
std::lock_guard guard(_lock);
- os << lid << static_cast<uint32_t>(len);
- os.write(buffer, len);
+ os << lid << len;
+ os.write(data.c_str(), len);
_lids.emplace_back(lid, len, oldSz);
- return LidMeta(lid, len);
+ return {lid, len};
}
ssize_t
diff --git a/searchlib/src/vespa/searchlib/docstore/chunk.h b/searchlib/src/vespa/searchlib/docstore/chunk.h
index 211165934e1..84e5a306f79 100644
--- a/searchlib/src/vespa/searchlib/docstore/chunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/chunk.h
@@ -59,6 +59,7 @@ class Chunk {
public:
using UP = std::unique_ptr<Chunk>;
using CompressionConfig = vespalib::compression::CompressionConfig;
+ using ConstBufferRef = vespalib::ConstBufferRef;
class Config {
public:
Config(size_t maxBytes) noexcept : _maxBytes(maxBytes) { }
@@ -84,7 +85,7 @@ public:
Chunk(uint32_t id, const Config & config);
Chunk(uint32_t id, const void * buffer, size_t len);
~Chunk();
- LidMeta append(uint32_t lid, const void * buffer, size_t len);
+ LidMeta append(uint32_t lid, ConstBufferRef data);
ssize_t read(uint32_t lid, vespalib::DataBuffer & buffer) const;
std::pair<size_t, vespalib::alloc::Alloc> read(uint32_t lid) const;
size_t count() const { return _lids.size(); }
@@ -96,7 +97,7 @@ public:
void pack(uint64_t lastSerial, vespalib::DataBuffer & buffer, CompressionConfig compression);
uint64_t getLastSerial() const { return _lastSerial; }
uint32_t getId() const { return _id; }
- vespalib::ConstBufferRef getLid(uint32_t lid) const;
+ ConstBufferRef getLid(uint32_t lid) const;
const vespalib::nbostream & getData() const;
bool hasRoom(size_t len) const;
vespalib::MemoryUsage getMemoryUsage() const;
diff --git a/searchlib/src/vespa/searchlib/docstore/compacter.cpp b/searchlib/src/vespa/searchlib/docstore/compacter.cpp
index e7c51161e52..29c4325d068 100644
--- a/searchlib/src/vespa/searchlib/docstore/compacter.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/compacter.cpp
@@ -18,10 +18,10 @@ namespace {
}
void
-Compacter::write(LockGuard guard, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz) {
+Compacter::write(LockGuard guard, uint32_t chunkId, uint32_t lid, ConstBufferRef data) {
(void) chunkId;
- FileChunk::FileId fileId= _ds.getActiveFileId(guard);
- _ds.write(std::move(guard), fileId, lid, buffer, sz);
+ FileChunk::FileId fileId = _ds.getActiveFileId(guard);
+ _ds.write(std::move(guard), fileId, lid, data);
}
BucketCompacter::BucketCompacter(size_t maxSignificantBucketBits, CompressionConfig compression, LogDataStore & ds,
@@ -41,8 +41,8 @@ BucketCompacter::BucketCompacter(size_t maxSignificantBucketBits, CompressionCon
_bucketizerGuard(),
_stat()
{
- for (size_t i(0); i < _tmpStore.size(); i++) {
- _tmpStore[i] = std::make_unique<StoreByBucket>(_backingMemory, executor, compression);
+ for (auto & partition : _tmpStore) {
+ partition = std::make_unique<StoreByBucket>(_backingMemory, executor, compression);
}
}
@@ -52,16 +52,16 @@ BucketCompacter::getDestinationId(const LockGuard & guard) const {
}
void
-BucketCompacter::write(LockGuard guard, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz)
+BucketCompacter::write(LockGuard guard, uint32_t chunkId, uint32_t lid, ConstBufferRef data)
{
if (_writeCount++ == 0) {
_bucketizerGuard = _bucketizer.getGuard();
_lastSample = vespalib::steady_clock::now();
}
guard.unlock();
- BucketId bucketId = (sz > 0) ? _bucketizer.getBucketOf(_bucketizerGuard, lid) : BucketId();
+ BucketId bucketId = (data.size() > 0) ? _bucketizer.getBucketOf(_bucketizerGuard, lid) : BucketId();
uint64_t sortableBucketId = bucketId.toKey();
- _tmpStore[(sortableBucketId >> _unSignificantBucketBits) % _tmpStore.size()]->add(bucketId, chunkId, lid, buffer, sz);
+ _tmpStore[(sortableBucketId >> _unSignificantBucketBits) % _tmpStore.size()]->add(bucketId, chunkId, lid, data);
if ((_writeCount % 1000) == 0) {
_bucketizerGuard = _bucketizer.getGuard();
vespalib::steady_time now = vespalib::steady_clock::now();
@@ -103,14 +103,14 @@ BucketCompacter::close()
}
void
-BucketCompacter::write(BucketId bucketId, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz)
+BucketCompacter::write(BucketId bucketId, uint32_t chunkId, uint32_t lid, ConstBufferRef data)
{
_stat[bucketId.getId()]++;
LockGuard guard(_ds.getLidGuard(lid));
- LidInfo lidInfo(_sourceFileId.getId(), chunkId, sz);
+ LidInfo lidInfo(_sourceFileId.getId(), chunkId, data.size());
if (_ds.getLid(_lidGuard, lid) == lidInfo) {
FileId fileId = getDestinationId(guard);
- _ds.write(std::move(guard), fileId, lid, buffer, sz);
+ _ds.write(std::move(guard), fileId, lid, data);
}
}
diff --git a/searchlib/src/vespa/searchlib/docstore/compacter.h b/searchlib/src/vespa/searchlib/docstore/compacter.h
index ce2713bdd81..3760729b40f 100644
--- a/searchlib/src/vespa/searchlib/docstore/compacter.h
+++ b/searchlib/src/vespa/searchlib/docstore/compacter.h
@@ -17,8 +17,9 @@ class Compacter : public IWriteData
{
public:
Compacter(LogDataStore & ds) : _ds(ds) { }
- void write(LockGuard guard, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz) override;
+ void write(LockGuard guard, uint32_t chunkId, uint32_t lid, ConstBufferRef data) override;
void close() override { }
+
private:
LogDataStore & _ds;
};
@@ -37,8 +38,8 @@ public:
using FileId = FileChunk::FileId;
BucketCompacter(size_t maxSignificantBucketBits, CompressionConfig compression, LogDataStore & ds,
Executor & executor, const IBucketizer & bucketizer, FileId source, FileId destination);
- void write(LockGuard guard, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz) override ;
- void write(BucketId bucketId, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz) override;
+ void write(LockGuard guard, uint32_t chunkId, uint32_t lid, ConstBufferRef data) override;
+ void write(BucketId bucketId, uint32_t chunkId, uint32_t lid, ConstBufferRef data) override;
void close() override;
private:
static constexpr size_t NUM_PARTITIONS = 256;
diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
index 6d0c025038a..4a411ed666e 100644
--- a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
@@ -285,9 +285,9 @@ appendChunks(FixedParams * args, Chunk::UP chunk)
if (args->db.getLid(args->lidReadGuard, e.getLid()) == lidInfo) {
auto guard(args->db.getLidGuard(e.getLid()));
if (args->db.getLid(args->lidReadGuard, e.getLid()) == lidInfo) {
- // I am still in use so I need to taken care of.
+ // I am still in use, so I need to be taken care of.
vespalib::ConstBufferRef data(chunk->getLid(e.getLid()));
- args->dest.write(std::move(guard), chunk->getId(), e.getLid(), data.c_str(), data.size());
+ args->dest.write(std::move(guard), chunk->getId(), e.getLid(), data);
}
}
}
diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.h b/searchlib/src/vespa/searchlib/docstore/filechunk.h
index 446a53de446..ec91dfc611a 100644
--- a/searchlib/src/vespa/searchlib/docstore/filechunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/filechunk.h
@@ -28,12 +28,12 @@ class DataStoreFileChunkStats;
class IWriteData
{
public:
- using UP = std::unique_ptr<IWriteData>;
using LockGuard = std::unique_lock<std::mutex>;
+ using ConstBufferRef = vespalib::ConstBufferRef;
virtual ~IWriteData() = default;
- virtual void write(LockGuard guard, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz) = 0;
+ virtual void write(LockGuard guard, uint32_t chunkId, uint32_t lid, ConstBufferRef data) = 0;
virtual void close() = 0;
};
diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
index ab9d032700d..6b793f8a47b 100644
--- a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
@@ -187,22 +187,22 @@ LogDataStore::write(uint64_t serialNum, uint32_t lid, const void * buffer, size_
{
std::unique_lock guard(_updateLock);
WriteableFileChunk & active = getActive(guard);
- write(std::move(guard), active, serialNum, lid, buffer, len, CpuCategory::WRITE);
+ write(std::move(guard), active, serialNum, lid, {buffer, len}, CpuCategory::WRITE);
}
void
-LogDataStore::write(MonitorGuard guard, FileId destinationFileId, uint32_t lid, const void * buffer, size_t len)
+LogDataStore::write(MonitorGuard guard, FileId destinationFileId, uint32_t lid, ConstBufferRef data)
{
auto & destination = static_cast<WriteableFileChunk &>(*_fileChunks[destinationFileId.getId()]);
- write(std::move(guard), destination, destination.getSerialNum(), lid, buffer, len, CpuCategory::COMPACT);
+ write(std::move(guard), destination, destination.getSerialNum(), lid, data, CpuCategory::COMPACT);
}
void
LogDataStore::write(MonitorGuard guard, WriteableFileChunk & destination,
- uint64_t serialNum, uint32_t lid, const void * buffer, size_t len,
+ uint64_t serialNum, uint32_t lid, ConstBufferRef data,
CpuUsage::Category cpu_category)
{
- LidInfo lm = destination.append(serialNum, lid, buffer, len, cpu_category);
+ LidInfo lm = destination.append(serialNum, lid, data, cpu_category);
setLid(guard, lid, lm);
if (destination.getFileId() == getActiveFileId(guard)) {
requireSpace(std::move(guard), destination, cpu_category);
@@ -263,7 +263,7 @@ vespalib::system_time
LogDataStore::getLastFlushTime() const
{
if (lastSyncToken() == 0) {
- return vespalib::system_time();
+ return {};
}
MonitorGuard guard(_updateLock);
vespalib::system_time timeStamp(getActive(guard).getModificationTime());
@@ -286,7 +286,7 @@ LogDataStore::remove(uint64_t serialNum, uint32_t lid)
if (lm.valid()) {
_fileChunks[lm.getFileId()]->remove(lid, lm.size());
}
- lm = getActive(guard).append(serialNum, lid, nullptr, 0, CpuCategory::WRITE);
+ lm = getActive(guard).append(serialNum, lid, {}, CpuCategory::WRITE);
assert( lm.empty() );
vespalib::atomic::store_ref_release(_lidInfo[lid], lm);
}
@@ -450,7 +450,7 @@ void LogDataStore::compactFile(FileId fileId)
NameId compactedNameId = fc->getNameId();
LOG(info, "Compacting file '%s' which has bloat '%2.2f' and bucket-spread '%1.4f",
fc->getName().c_str(), 100*fc->getDiskBloat()/double(fc->getDiskFootprint()), fc->getBucketSpread());
- IWriteData::UP compacter;
+ std::unique_ptr<IWriteData> compacter;
FileId destinationFileId = FileId::active();
if (_bucketizer) {
size_t disk_footprint = fc->getDiskFootprint();
@@ -645,7 +645,7 @@ LogDataStore::createWritableFile(FileId fileId, SerialNum serialNum, NameId name
if (fc && (fc->getNameId() == nameId)) {
LOG(error, "We already have a file registered with internal fileId=%u, and external nameId=%" PRIu64,
fileId.getId(), nameId.getId());
- return FileChunk::UP();
+ return {};
}
}
uint32_t docIdLimit = (getDocIdLimit() != 0) ? getDocIdLimit() : std::numeric_limits<uint32_t>::max();
@@ -721,7 +721,7 @@ LogDataStore::verifyModificationTime(const NameIdSet & partList)
vespalib::string datName(createDatFileName(nameId));
vespalib::string idxName(createIdxFileName(nameId));
vespalib::file_time prevDatTime = fs::last_write_time(fs::path(datName));
- vespalib::file_time prevIdxTime = fs::last_write_time(fs::path(idxName));;
+ vespalib::file_time prevIdxTime = fs::last_write_time(fs::path(idxName));
for (auto it(++partList.begin()), mt(partList.end()); it != mt; ++it) {
vespalib::string prevDatNam(datName);
vespalib::string prevIdxNam(idxName);
@@ -729,7 +729,7 @@ LogDataStore::verifyModificationTime(const NameIdSet & partList)
datName = createDatFileName(nameId);
idxName = createIdxFileName(nameId);
vespalib::file_time datTime = fs::last_write_time(fs::path(datName));
- vespalib::file_time idxTime = fs::last_write_time(fs::path(idxName));;
+ vespalib::file_time idxTime = fs::last_write_time(fs::path(idxName));
ns_log::Logger::LogLevel logLevel = ns_log::Logger::debug;
if ((datTime < prevDatTime) && hasNonHeaderData(datName)) {
VLOG(logLevel, "Older file '%s' is newer (%s) than file '%s' (%s)\nDirectory =\n%s",
@@ -992,10 +992,10 @@ class LogDataStore::WrapVisitor : public IWriteData
IDataStoreVisitor &_visitor;
public:
- void write(MonitorGuard guard, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz) override {
+ void write(MonitorGuard guard, uint32_t chunkId, uint32_t lid, ConstBufferRef data) override {
(void) chunkId;
guard.unlock();
- _visitor.visit(lid, buffer, sz);
+ _visitor.visit(lid, data.c_str(), data.size());
}
WrapVisitor(IDataStoreVisitor &visitor) : _visitor(visitor) { }
diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.h b/searchlib/src/vespa/searchlib/docstore/logdatastore.h
index 877446e510e..c6bddac2006 100644
--- a/searchlib/src/vespa/searchlib/docstore/logdatastore.h
+++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.h
@@ -71,6 +71,7 @@ public:
WriteableFileChunk::Config _fileConfig;
};
public:
+ using ConstBufferRef = vespalib::ConstBufferRef;
/**
* Construct a log based data store.
* All files are stored in base directory.
@@ -117,8 +118,8 @@ public:
Config & getConfig() { return _config; }
void write(MonitorGuard guard, WriteableFileChunk & destination, uint64_t serialNum, uint32_t lid,
- const void * buffer, size_t len, vespalib::CpuUsage::Category cpu_category);
- void write(MonitorGuard guard, FileId destinationFileId, uint32_t lid, const void * buffer, size_t len);
+ ConstBufferRef data, vespalib::CpuUsage::Category cpu_category);
+ void write(MonitorGuard guard, FileId destinationFileId, uint32_t lid, ConstBufferRef data);
/**
* This will spinn through the data and verify the content of both
@@ -155,7 +156,7 @@ public:
if (lid < getDocIdLimit()) {
return vespalib::atomic::load_ref_acquire(_lidInfo.acquire_elem_ref(lid));
} else {
- return LidInfo();
+ return {};
}
}
FileId getActiveFileId(const MonitorGuard & guard) const;
diff --git a/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp b/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp
index e733338587b..dbcbaafbbb7 100644
--- a/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/storebybucket.cpp
@@ -31,9 +31,9 @@ StoreByBucket::StoreByBucket(MemoryDataStore & backingMemory, Executor & executo
StoreByBucket::~StoreByBucket() = default;
void
-StoreByBucket::add(BucketId bucketId, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz)
+StoreByBucket::add(BucketId bucketId, uint32_t chunkId, uint32_t lid, ConstBufferRef data)
{
- if ( ! _current->hasRoom(sz)) {
+ if ( ! _current->hasRoom(data.size())) {
Chunk::UP tmpChunk = createChunk();
_current.swap(tmpChunk);
incChunksPosted();
@@ -42,7 +42,7 @@ StoreByBucket::add(BucketId bucketId, uint32_t chunkId, uint32_t lid, const void
});
_executor.execute(CpuUsage::wrap(std::move(task), CpuUsage::Category::COMPACT));
}
- _current->append(lid, buffer, sz);
+ _current->append(lid, data);
_where.emplace_back(bucketId, _current->getId(), chunkId, lid);
}
@@ -124,7 +124,7 @@ StoreByBucket::drain(IWrite & drainer)
_chunks.clear();
for (auto & idx : _where) {
vespalib::ConstBufferRef data(chunks[idx._id]->getLid(idx._lid));
- drainer.write(idx._bucketId, idx._chunkId, idx._lid, data.c_str(), data.size());
+ drainer.write(idx._bucketId, idx._chunkId, idx._lid, data);
}
}
diff --git a/searchlib/src/vespa/searchlib/docstore/storebybucket.h b/searchlib/src/vespa/searchlib/docstore/storebybucket.h
index 5d4b1ebdd94..6e52695d529 100644
--- a/searchlib/src/vespa/searchlib/docstore/storebybucket.h
+++ b/searchlib/src/vespa/searchlib/docstore/storebybucket.h
@@ -34,9 +34,9 @@ public:
public:
using BucketId=document::BucketId;
virtual ~IWrite() = default;
- virtual void write(BucketId bucketId, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz) = 0;
+ virtual void write(BucketId bucketId, uint32_t chunkId, uint32_t lid, ConstBufferRef data) = 0;
};
- void add(document::BucketId bucketId, uint32_t chunkId, uint32_t lid, const void *buffer, size_t sz);
+ void add(document::BucketId bucketId, uint32_t chunkId, uint32_t lid, ConstBufferRef data);
void close();
/// close() must have been called prior to calling getBucketCount() or drain()
void drain(IWrite & drain);
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
index 973287fc7bd..4cb924e379a 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
@@ -11,7 +11,6 @@
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/util/cpu_usage.h>
#include <vespa/vespalib/util/lambdatask.h>
-#include <vespa/vespalib/util/size_literals.h>
#include <vespa/log/log.h>
LOG_SETUP(".search.writeablefilechunk");
@@ -418,7 +417,7 @@ WriteableFileChunk::computeChunkMeta(const unique_lock & guard,
assert((size_t(tmp.getBuf().getData())%_alignment) == 0);
assert((dataLen%_alignment) == 0);
auto pcsp = std::make_shared<PendingChunk>(active.getLastSerial(), offset, dataLen);
- PendingChunk &pc(*pcsp.get());
+ PendingChunk &pc(*pcsp);
nbostream &os(pc.getSerializedIdx());
cmeta.serialize(os);
BucketDensityComputer bucketMap(_bucketizer);
@@ -722,21 +721,21 @@ WriteableFileChunk::waitForAllChunksFlushedToDisk() const
}
LidInfo
-WriteableFileChunk::append(uint64_t serialNum, uint32_t lid, const void * buffer, size_t len,
+WriteableFileChunk::append(uint64_t serialNum, uint32_t lid, vespalib::ConstBufferRef data,
CpuUsage::Category cpu_category)
{
assert( !frozen() );
- if ( ! _active->hasRoom(len)) {
+ if ( ! _active->hasRoom(data.size())) {
flush(false, _serialNum, cpu_category);
}
assert(serialNum >= _serialNum);
_serialNum = serialNum;
- _addedBytes += adjustSize(len);
+ _addedBytes += adjustSize(data.size());
_numLids++;
size_t oldSz(_active->size());
- LidMeta lm = _active->append(lid, buffer, len);
+ LidMeta lm = _active->append(lid, data);
setDiskFootprint(FileChunk::getDiskFootprint() - oldSz + _active->size());
- return LidInfo(getFileId().getId(), _active->getId(), lm.size());
+ return {getFileId().getId(), _active->getId(), lm.size()};
}
@@ -896,7 +895,7 @@ WriteableFileChunk::unconditionallyFlushPendingChunks(const unique_lock &flushGu
break;
std::shared_ptr<PendingChunk> pcsp = std::move(_pendingChunks.front());
_pendingChunks.pop_front();
- const PendingChunk &pc(*pcsp.get());
+ const PendingChunk &pc(*pcsp);
assert(_pendingIdx >= pc.getIdxLen());
assert(_pendingDat >= pc.getDataLen());
assert(datFileLen >= pc.getDataOffset() + pc.getDataLen());
@@ -932,9 +931,9 @@ WriteableFileChunk::getStats() const
{
DataStoreFileChunkStats stats = FileChunk::getStats();
uint64_t serialNum = getSerialNum();
- return DataStoreFileChunkStats(stats.diskUsage(), stats.diskBloat(), stats.maxBucketSpread(),
- serialNum, stats.lastFlushedSerialNum(), stats.docIdLimit(), stats.nameId());
-};
+ return {stats.diskUsage(), stats.diskBloat(), stats.maxBucketSpread(),
+ serialNum, stats.lastFlushedSerialNum(), stats.docIdLimit(), stats.nameId()};
+}
PendingChunk::PendingChunk(uint64_t lastSerial, uint64_t dataOffset, uint32_t dataLen)
: _idx(),
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
index 028915d28e0..f53b8491141 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
@@ -52,7 +52,7 @@ public:
ssize_t read(uint32_t lid, SubChunkId chunk, vespalib::DataBuffer & buffer) const override;
void read(LidInfoWithLidV::const_iterator begin, size_t count, IBufferVisitor & visitor) const override;
- LidInfo append(uint64_t serialNum, uint32_t lid, const void * buffer, size_t len,
+ LidInfo append(uint64_t serialNum, uint32_t lid, vespalib::ConstBufferRef data,
vespalib::CpuUsage::Category cpu_category);
void flush(bool block, uint64_t syncToken, vespalib::CpuUsage::Category cpu_category);
uint64_t getSerialNum() const { return _serialNum; }
@@ -79,7 +79,7 @@ private:
bool frozen() const override { return _frozen.load(std::memory_order_acquire); }
void waitForChunkFlushedToDisk(uint32_t chunkId) const;
void waitForAllChunksFlushedToDisk() const;
- void fileWriter(const uint32_t firstChunkId);
+ void fileWriter(uint32_t firstChunkId);
void internalFlush(uint32_t, uint64_t serialNum, vespalib::CpuUsage::Category cpu_category);
void enque(ProcessedChunkUP, vespalib::CpuUsage::Category cpu_category);
int32_t flushLastIfNonEmpty(bool force);
diff --git a/searchlib/src/vespa/searchlib/fef/objectstore.h b/searchlib/src/vespa/searchlib/fef/objectstore.h
index 7ba08284111..ddb001b0216 100644
--- a/searchlib/src/vespa/searchlib/fef/objectstore.h
+++ b/searchlib/src/vespa/searchlib/fef/objectstore.h
@@ -12,7 +12,7 @@ class Anything
{
public:
using UP = std::unique_ptr<Anything>;
- virtual ~Anything() { }
+ virtual ~Anything() = default;
};
/**
@@ -22,7 +22,7 @@ template<typename T>
class AnyWrapper : public Anything
{
public:
- AnyWrapper(T value) : _value(std::move(value)) { }
+ explicit AnyWrapper(T value) : _value(std::move(value)) { }
const T & getValue() const { return _value; }
static const T & getValue(const Anything & any) { return static_cast<const AnyWrapper &>(any).getValue(); }
private:
@@ -35,7 +35,7 @@ private:
class IObjectStore
{
public:
- virtual ~IObjectStore() { }
+ virtual ~IObjectStore() = default;
virtual void add(const vespalib::string & key, Anything::UP value) = 0;
virtual const Anything * get(const vespalib::string & key) const = 0;
};
@@ -47,7 +47,7 @@ class ObjectStore : public IObjectStore
{
public:
ObjectStore();
- ~ObjectStore();
+ ~ObjectStore() override;
void add(const vespalib::string & key, Anything::UP value) override;
const Anything * get(const vespalib::string & key) const override;
private: