diff options
Diffstat (limited to 'searchlib/src')
20 files changed, 101 insertions, 158 deletions
diff --git a/searchlib/src/tests/transactionlog/translogclient_test.cpp b/searchlib/src/tests/transactionlog/translogclient_test.cpp index 4156cb15966..74b0761320f 100644 --- a/searchlib/src/tests/transactionlog/translogclient_test.cpp +++ b/searchlib/src/tests/transactionlog/translogclient_test.cpp @@ -4,8 +4,10 @@ #include <vespa/vespalib/testkit/testapp.h> #include <vespa/vespalib/objects/identifiable.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> -#include <vespa/log/log.h> +#include <vespa/fastos/file.h> #include <map> + +#include <vespa/log/log.h> LOG_SETUP("translogclient_test"); using namespace search; diff --git a/searchlib/src/vespa/searchlib/features/foreachfeature.cpp b/searchlib/src/vespa/searchlib/features/foreachfeature.cpp index 3cef8c12c6c..a67d8001a36 100644 --- a/searchlib/src/vespa/searchlib/features/foreachfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/foreachfeature.cpp @@ -4,18 +4,16 @@ #include "valuefeature.h" #include "utils.h" -#include <boost/algorithm/string/replace.hpp> #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/util/stringfmt.h> -#include <vespa/vespalib/util/vstringfmt.h> +#include <boost/algorithm/string/replace.hpp> #include <vespa/log/log.h> LOG_SETUP(".features.foreachfeature"); using namespace search::fef; -namespace search { -namespace features { +namespace search::features { template <typename CO, typename OP> ForeachExecutor<CO, OP>::ForeachExecutor(const CO & condition, uint32_t numInputs) : @@ -149,7 +147,7 @@ ForeachBlueprint::setup(const IIndexEnvironment & env, if (_dimension == TERMS) { uint32_t maxTerms = util::strToNum<uint32_t>(env.getProperties().lookup(getBaseName(), "maxTerms").get("16")); for (uint32_t i = 0; i < maxTerms; ++i) { - defineInput(boost::algorithm::replace_all_copy(feature, variable, vespalib::make_vespa_string("%u", i))); + defineInput(boost::algorithm::replace_all_copy(feature, variable, vespalib::make_string("%u", i))); ++_num_inputs; } } else { @@ -186,5 +184,4 @@ ForeachBlueprint::createExecutor(const IQueryEnvironment &, vespalib::Stash &sta } -} // namespace features -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp b/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp index f357df250b4..62c9efc6739 100644 --- a/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp +++ b/searchlib/src/vespa/searchlib/fef/parametervalidator.cpp @@ -3,13 +3,12 @@ #include "parametervalidator.h" #include "fieldtype.h" #include "fieldinfo.h" -#include <vespa/vespalib/util/vstringfmt.h> +#include <vespa/vespalib/util/stringfmt.h> #include <boost/lexical_cast.hpp> -using vespalib::make_vespa_string; +using vespalib::make_string; -namespace search { -namespace fef { +namespace search::fef { using CollectionType = FieldInfo::CollectionType; @@ -56,27 +55,27 @@ ParameterValidator::validateField(ParameterType::Enum type, ParameterCollection: { const FieldInfo * field = _indexEnv.getFieldByName(_params[i]); if (field == NULL) { - throw ValidateException(make_vespa_string("Param[%zu]: Field '%s' was not found in the index environment", + throw ValidateException(make_string("Param[%zu]: Field '%s' was not found in the index environment", i, _params[i].c_str())); } if (type == ParameterType::INDEX_FIELD) { if (field->type() != FieldType::INDEX) { - throw ValidateException(make_vespa_string("Param[%zu]: Expected field '%s' to be an index field, but it was not", + throw ValidateException(make_string("Param[%zu]: Expected field '%s' to be an index field, but it was not", i, _params[i].c_str())); } } else if (type == ParameterType::ATTRIBUTE_FIELD) { if (field->type() != FieldType::ATTRIBUTE) { - throw ValidateException(make_vespa_string("Param[%zu]: Expected field '%s' to be an attribute field, but it was not", + throw ValidateException(make_string("Param[%zu]: Expected field '%s' to be an attribute field, but it was not", i, _params[i].c_str())); } } else if (type == ParameterType::ATTRIBUTE) { if (!field->hasAttribute()) { - throw ValidateException(make_vespa_string("Param[%zu]: Expected field '%s' to support attribute lookup, but it does not", + throw ValidateException(make_string("Param[%zu]: Expected field '%s' to support attribute lookup, but it does not", i, _params[i].c_str())); } } if (!checkCollectionType(collection, field->collection())) { - throw ValidateException(make_vespa_string("Param[%zu]: field '%s' has inappropriate collection type", + throw ValidateException(make_string("Param[%zu]: field '%s' has inappropriate collection type", i, _params[i].c_str())); } result.addParameter(Parameter(type, _params[i]).setField(field)); @@ -90,7 +89,7 @@ ParameterValidator::validateNumber(ParameterType::Enum type, size_t i, Result & int64_t intVal = static_cast<int64_t>(doubleVal); result.addParameter(Parameter(type, _params[i]).setInteger(intVal).setDouble(doubleVal)); } catch (const boost::bad_lexical_cast &) { - throw ValidateException(make_vespa_string("Param[%zu]: Could not convert '%s' to a number", i, _params[i].c_str())); + throw ValidateException(make_string("Param[%zu]: Could not convert '%s' to a number", i, _params[i].c_str())); } } @@ -103,11 +102,11 @@ ParameterValidator::validate(const ParameterDescriptions::Description & desc) if (minParams > _params.size() || ((_params.size() - desc.getParams().size()) % desc.getRepeat() != 0)) { - throw ValidateException(make_vespa_string("Expected %zd+%zdx parameter(s), but got %zd", + throw ValidateException(make_string("Expected %zd+%zdx parameter(s), but got %zd", minParams, desc.getRepeat(), _params.size())); } } else if (desc.getParams().size() != _params.size()) { - throw ValidateException(make_vespa_string("Expected %zd parameter(s), but got %zd", desc.getParams().size(), _params.size())); + throw ValidateException(make_string("Expected %zd parameter(s), but got %zd", desc.getParams().size(), _params.size())); } for (size_t i = 0; i < _params.size(); ++i) { ParamDescItem param = desc.getParam(i); @@ -160,5 +159,4 @@ ParameterValidator::validate() return invalid; } -} // namespace fef -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp index cae3e769c5b..6274bd083de 100644 --- a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp @@ -8,14 +8,14 @@ * ALL RIGHTS RESERVED */ #include "simplequerystack.h" -#include <vespa/vespalib/util/vstringfmt.h> #include <vespa/vespalib/util/compress.h> #include <vespa/vespalib/objects/nbo.h> +#include <vespa/vespalib/util/stringfmt.h> #include <vespa/log/log.h> LOG_SETUP(".search.simplequerystack"); -using vespalib::make_vespa_string; +using vespalib::make_string; namespace search { @@ -174,24 +174,24 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf) int64_t tmpLong(0); p += vespalib::compress::Integer::decompress(tmpLong, p); metaStr.append("(w:"); - metaStr.append(make_vespa_string("%ld", tmpLong)); + metaStr.append(make_string("%ld", tmpLong)); metaStr.append(")"); } if (search::ParseItem::getFeature_UniqueId(rawtype)) { p += vespalib::compress::Integer::decompressPositive(tmp, p); metaStr.append("(u:"); - metaStr.append(make_vespa_string("%ld", tmp)); + metaStr.append(make_string("%ld", tmp)); metaStr.append(")"); } if (search::ParseItem::getFeature_Flags(rawtype)) { flags = *p++; metaStr.append("(f:"); - metaStr.append(make_vespa_string("%d", flags)); + metaStr.append(make_string("%d", flags)); metaStr.append(")"); } if (search::ParseItem::GetCreator(flags) != search::ParseItem::CREA_ORIG) { metaStr.append("(c:"); - metaStr.append(make_vespa_string("%d", search::ParseItem::GetCreator(flags))); + metaStr.append(make_string("%d", search::ParseItem::GetCreator(flags))); metaStr.append(")"); } @@ -207,7 +207,7 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf) case search::ParseItem::ITEM_ANY: p += vespalib::compress::Integer::decompressPositive(tmp, p); arity = tmp; - result.append(make_vespa_string("%c/%d~", _G_ItemName[type], arity)); + result.append(make_string("%c/%d~", _G_ItemName[type], arity)); break; case search::ParseItem::ITEM_WEAK_AND: case search::ParseItem::ITEM_NEAR: @@ -221,9 +221,9 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf) idxRefLen = tmp; idxRef = p; p += idxRefLen; - result.append(make_vespa_string("%c/%d/%d/%d:%.*s~", _G_ItemName[type], arity, arg1, idxRefLen, idxRefLen, idxRef)); + result.append(make_string("%c/%d/%d/%d:%.*s~", _G_ItemName[type], arity, arg1, idxRefLen, idxRefLen, idxRef)); } else { - result.append(make_vespa_string("%c/%d/%d~", _G_ItemName[type], arity, arg1)); + result.append(make_string("%c/%d/%d~", _G_ItemName[type], arity, arg1)); } break; @@ -242,7 +242,7 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf) termRefLen = tmp; termRef = p; p += termRefLen; - result.append(make_vespa_string("%c/%d:%.*s/%d:%.*s~", _G_ItemName[type], + result.append(make_string("%c/%d:%.*s/%d:%.*s~", _G_ItemName[type], idxRefLen, idxRefLen, idxRef, termRefLen, termRefLen, termRef)); break; @@ -251,14 +251,14 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf) termRefLen = tmp; termRef = p; p += termRefLen; - result.append(make_vespa_string("%c/%d:%.*s~", _G_ItemName[type], + result.append(make_string("%c/%d:%.*s~", _G_ItemName[type], termRefLen, termRefLen, termRef)); break; case search::ParseItem::ITEM_PURE_WEIGHTED_LONG: tmp = vespalib::nbo::n2h(*reinterpret_cast<const uint64_t *>(p)); p += sizeof(uint64_t); - result.append(make_vespa_string("%c/%lu", _G_ItemName[type], tmp)); + result.append(make_string("%c/%lu", _G_ItemName[type], tmp)); break; case search::ParseItem::ITEM_PHRASE: @@ -278,10 +278,10 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf) p += sizeof(double); double thresholdBoostFactor = vespalib::nbo::n2h(*reinterpret_cast<const double *>(p)); // thresholdBoostFactor p += sizeof(double); - result.append(make_vespa_string("%c/%d/%d:%.*s(%u,%f,%f)~", _G_ItemName[type], arity, idxRefLen, + result.append(make_string("%c/%d/%d:%.*s(%u,%f,%f)~", _G_ItemName[type], arity, idxRefLen, idxRefLen, idxRef, targetNumHits, scoreThreshold, thresholdBoostFactor)); } else { - result.append(make_vespa_string("%c/%d/%d:%.*s~", _G_ItemName[type], arity, idxRefLen, + result.append(make_string("%c/%d/%d:%.*s~", _G_ItemName[type], arity, idxRefLen, idxRefLen, idxRef)); } break; @@ -292,25 +292,25 @@ SimpleQueryStack::StackbufToString(const vespalib::stringref &theBuf) idxRef = p; p += idxRefLen; size_t feature_count = ReadCompressedPositiveInt(p); - result.append(make_vespa_string( + result.append(make_string( "%c/%d:%.*s/%zu(", _G_ItemName[type], idxRefLen, idxRefLen, idxRef, feature_count)); for (size_t i = 0; i < feature_count; ++i) { vespalib::string key = ReadString(p); vespalib::string value = ReadString(p); uint64_t sub_queries = ReadUint64(p); - result.append(make_vespa_string("%s:%s:%lx", key.c_str(), value.c_str(), sub_queries)); + result.append(make_string("%s:%s:%lx", key.c_str(), value.c_str(), sub_queries)); if (i < feature_count - 1) { result.append(','); } } size_t range_feature_count = ReadCompressedPositiveInt(p); - result.append(make_vespa_string(")/%zu(", range_feature_count)); + result.append(make_string(")/%zu(", range_feature_count)); for (size_t i = 0; i < range_feature_count; ++i) { vespalib::string key = ReadString(p); uint64_t value = ReadUint64(p); uint64_t sub_queries = ReadUint64(p); - result.append(make_vespa_string("%s:%zu:%lx", key.c_str(), value, sub_queries)); + result.append(make_string("%s:%zu:%lx", key.c_str(), value, sub_queries)); if (i < range_feature_count - 1) { result.append(','); } diff --git a/searchlib/src/vespa/searchlib/transactionlog/common.cpp b/searchlib/src/vespa/searchlib/transactionlog/common.cpp index 8dd4d7abbcc..a84e27b2e53 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/common.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/common.cpp @@ -3,9 +3,7 @@ #include "common.h" #include <vespa/fastos/file.h> -namespace search { - -namespace transactionlog { +namespace search::transactionlog { using vespalib::nbostream; using vespalib::nbostream_longlivedbuf; @@ -104,4 +102,3 @@ bool Packet::add(const Packet::Entry & e) } } -} diff --git a/searchlib/src/vespa/searchlib/transactionlog/common.h b/searchlib/src/vespa/searchlib/transactionlog/common.h index 4b8e6575c4c..65ef8f363c0 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/common.h +++ b/searchlib/src/vespa/searchlib/transactionlog/common.h @@ -5,8 +5,7 @@ #include <vespa/vespalib/objects/nbostream.h> #include <vespa/vespalib/util/buffer.h> -namespace search { -namespace transactionlog { +namespace search::transactionlog { /// This represents a type of the entry. Fx update,remove typedef uint32_t Type; @@ -96,5 +95,3 @@ public: }; } -} - diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp index 82e700620e5..a324e42ab24 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp @@ -1,17 +1,15 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "domain.h" -#include <limits> -#include <vespa/vespalib/util/vstringfmt.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/closuretask.h> +#include <vespa/fastos/file.h> #include <vespa/log/log.h> LOG_SETUP(".transactionlog.domain"); using vespalib::string; using vespalib::make_string; -using vespalib::make_vespa_string; using vespalib::LockGuard; using vespalib::makeTask; using vespalib::makeClosure; @@ -20,11 +18,7 @@ using vespalib::MonitorGuard; using search::common::FileHeaderContext; using std::runtime_error; -namespace search -{ - -namespace transactionlog -{ +namespace search::transactionlog { Domain::Domain(const string &domainName, const string & baseDir, @@ -420,4 +414,3 @@ Domain::scanDir() } } -} diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.h b/searchlib/src/vespa/searchlib/transactionlog/domain.h index 8b64232b000..f70ce7654c1 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domain.h +++ b/searchlib/src/vespa/searchlib/transactionlog/domain.h @@ -5,8 +5,7 @@ #include <vespa/searchlib/transactionlog/session.h> #include <vespa/vespalib/util/threadstackexecutor.h> -namespace search { -namespace transactionlog { +namespace search::transactionlog { struct PartInfo { SerialNumRange range; @@ -122,5 +121,3 @@ private: }; } -} - diff --git a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp index 03bb1c4e043..ebe3c07c1df 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/domainpart.cpp @@ -3,13 +3,12 @@ #include "domainpart.h" #include <vespa/vespalib/util/crc.h> #include <vespa/vespalib/xxhash/xxhash.h> -#include <vespa/vespalib/util/vstringfmt.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/data/fileheader.h> #include <vespa/searchlib/common/fileheadercontext.h> #include <vespa/fastlib/io/bufferedfile.h> -#include <vespa/log/log.h> +#include <vespa/log/log.h> LOG_SETUP(".transactionlog.domainpart"); using vespalib::make_string; @@ -24,13 +23,10 @@ using vespalib::alloc::Alloc; using search::common::FileHeaderContext; using std::runtime_error; -namespace search { - -namespace transactionlog { +namespace search::transactionlog { namespace { - void handleSync(FastOS_FileInterface &file) __attribute__ ((noinline)); @@ -187,7 +183,7 @@ DomainPart::buildPacketMapping(bool allowTruncate) { Fast_BufferedFile transLog; transLog.EnableDirectIO(); - if ( ! transLog.OpenReadOnly(_transLog.GetFileName())) { + if ( ! transLog.OpenReadOnly(_transLog->GetFileName())) { throw runtime_error(make_string("Failed opening '%s' for buffered readinf with direct io.", transLog.GetFileName())); } int64_t fSize(transLog.GetSize()); @@ -285,20 +281,20 @@ DomainPart::DomainPart(const string & name, _byteSize(0), _packets(), _fileName(make_string("%s/%s-%016" PRIu64, baseDir.c_str(), name.c_str(), s)), - _transLog(_fileName.c_str()), + _transLog(std::make_unique<FastOS_File>(_fileName.c_str())), _skipList(), _headerLen(0), _writeLock(), _writtenSerial(0), _syncedSerial(0) { - if (_transLog.OpenReadOnly()) { + if (_transLog->OpenReadOnly()) { int64_t currPos = buildPacketMapping(allowTruncate); - if ( ! _transLog.Close() ) { - throw runtime_error(make_string("Failed closing file '%s' after reading.", _transLog.GetFileName())); + if ( ! _transLog->Close() ) { + throw runtime_error(make_string("Failed closing file '%s' after reading.", _transLog->GetFileName())); } - if ( ! _transLog.OpenWriteOnlyExisting() ) { - string e(make_string("Failed opening existing file '%s' for writing: %s", _transLog.GetFileName(), getLastErrorString().c_str())); + if ( ! _transLog->OpenWriteOnlyExisting() ) { + string e(make_string("Failed opening existing file '%s' for writing: %s", _transLog->GetFileName(), getLastErrorString().c_str())); LOG(error, "%s", e.c_str()); throw runtime_error(e); } @@ -309,8 +305,8 @@ DomainPart::DomainPart(const string & name, } _byteSize = currPos; } else { - if ( ! _transLog.OpenWriteOnly()) { - string e(make_string("Failed opening new file '%s' for writing: '%s'", _transLog.GetFileName(), getLastErrorString().c_str())); + if ( ! _transLog->OpenWriteOnly()) { + string e(make_string("Failed opening new file '%s' for writing: '%s'", _transLog->GetFileName(), getLastErrorString().c_str())); LOG(error, "%s", e.c_str()); throw runtime_error(e); @@ -318,11 +314,11 @@ DomainPart::DomainPart(const string & name, writeHeader(fileHeaderContext); _byteSize = _headerLen; } - if ( ! _transLog.SetPosition(_transLog.GetSize()) ) { + if ( ! _transLog->SetPosition(_transLog->GetSize()) ) { throw runtime_error(make_string("Failed moving write pointer to the end of the file %s(%" PRIu64 ").", - _transLog.GetFileName(), _transLog.GetSize())); + _transLog->GetFileName(), _transLog->GetSize())); } - handleSync(_transLog); + handleSync(*_transLog); _writtenSerial = _range.to(); _syncedSerial = _writtenSerial; } @@ -337,12 +333,12 @@ DomainPart::writeHeader(const FileHeaderContext &fileHeaderContext) { typedef vespalib::GenericHeader::Tag Tag; FileHeader header; - assert(_transLog.IsOpened()); - assert(_transLog.IsWriteMode()); - assert(_transLog.GetPosition() == 0); - fileHeaderContext.addTags(header, _transLog.GetFileName()); + assert(_transLog->IsOpened()); + assert(_transLog->IsWriteMode()); + assert(_transLog->GetPosition() == 0); + fileHeaderContext.addTags(header, _transLog->GetFileName()); header.putTag(Tag("desc", "Transaction log domain part file")); - _headerLen = header.writeFile(_transLog); + _headerLen = header.writeFile(*_transLog); } bool @@ -356,15 +352,15 @@ DomainPart::close() * hole. XXX: Feed latency spike due to lack of delayed open * for new domainpart. */ - handleSync(_transLog); - _transLog.dropFromCache(); - retval = _transLog.Close(); + handleSync(*_transLog); + _transLog->dropFromCache(); + retval = _transLog->Close(); LockGuard wguard(_writeLock); _syncedSerial = _writtenSerial; } if ( ! retval ) { throw runtime_error(make_string("Failed closing file '%s' of size %" PRId64 ".", - _transLog.GetFileName(), _transLog.GetSize())); + _transLog->GetFileName(), _transLog->GetSize())); } { LockGuard guard(_lock); @@ -374,9 +370,14 @@ DomainPart::close() } bool +DomainPart::isClosed() const { + return ! _transLog->IsOpened(); +} + +bool DomainPart::openAndFind(FastOS_FileInterface &file, const SerialNum &from) { - bool retval(file.OpenReadOnly(_transLog.GetFileName())); + bool retval(file.OpenReadOnly(_transLog->GetFileName())); if (retval) { int64_t pos(_headerLen); LockGuard guard(_lock); @@ -397,7 +398,7 @@ DomainPart::erase(SerialNum to) bool retval(true); if (to > _range.to()) { close(); - _transLog.Delete(); + _transLog->Delete(); } else { _range.from(std::max(to, _range.from())); } @@ -407,7 +408,7 @@ DomainPart::erase(SerialNum to) void DomainPart::commit(SerialNum firstSerial, const Packet &packet) { - int64_t firstPos(_transLog.GetPosition()); + int64_t firstPos(_transLog->GetPosition()); nbostream_longlivedbuf h(packet.getHandle().c_str(), packet.getHandle().size()); if (_range.from() == 0) { _range.from(firstSerial); @@ -419,7 +420,7 @@ DomainPart::commit(SerialNum firstSerial, const Packet &packet) Packet::Entry entry; entry.deserialize(h); if (_range.to() < entry.serial()) { - write(_transLog, entry); + write(*_transLog, entry); _sz++; _range.to(entry.serial()); } else { @@ -457,7 +458,7 @@ void DomainPart::sync() syncSerial = _writtenSerial; } LockGuard guard(_fileLock); - handleSync(_transLog); + handleSync(*_transLog); LockGuard wguard(_writeLock); if (_syncedSerial < syncSerial) { _syncedSerial = syncSerial; @@ -675,4 +676,3 @@ int32_t DomainPart::calcCrc(Crc version, const void * buf, size_t sz) } } -} diff --git a/searchlib/src/vespa/searchlib/transactionlog/domainpart.h b/searchlib/src/vespa/searchlib/transactionlog/domainpart.h index 03d0ad2120f..2af0a43d03c 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domainpart.h +++ b/searchlib/src/vespa/searchlib/transactionlog/domainpart.h @@ -2,18 +2,16 @@ #pragma once #include "common.h" +#include <vespa/vespalib/util/sync.h> +#include <vespa/vespalib/util/memory.h> #include <map> #include <vector> #include <atomic> -#include <vespa/vespalib/util/sync.h> -#include <vespa/vespalib/util/memory.h> -#include <vespa/fastos/file.h> -namespace search { +class FastOS_FileInterface; -namespace common { class FileHeaderContext; } - -namespace transactionlog { +namespace search::common { class FileHeaderContext; } +namespace search::transactionlog { class DomainPart { private: @@ -54,7 +52,7 @@ public: size_t byteSize() const { return _byteSize.load(std::memory_order_acquire); } - bool isClosed() const { return ! _transLog.IsOpened(); } + bool isClosed() const; private: bool openAndFind(FastOS_FileInterface &file, const SerialNum &from); int64_t buildPacketMapping(bool allowTruncate); @@ -101,7 +99,7 @@ private: std::atomic<uint64_t> _byteSize; PacketList _packets; vespalib::string _fileName; - FastOS_File _transLog; + std::unique_ptr<FastOS_FileInterface> _transLog; SkipList _skipList; uint32_t _headerLen; vespalib::Lock _writeLock; @@ -111,5 +109,3 @@ private: }; } -} - diff --git a/searchlib/src/vespa/searchlib/transactionlog/nosyncproxy.h b/searchlib/src/vespa/searchlib/transactionlog/nosyncproxy.h index 5d7d7ca3f64..d890495bb1b 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/nosyncproxy.h +++ b/searchlib/src/vespa/searchlib/transactionlog/nosyncproxy.h @@ -4,8 +4,7 @@ #include "syncproxy.h" -namespace search { -namespace transactionlog { +namespace search::transactionlog { class NoSyncProxy : public SyncProxy { @@ -16,4 +15,3 @@ public: }; } -} diff --git a/searchlib/src/vespa/searchlib/transactionlog/session.cpp b/searchlib/src/vespa/searchlib/transactionlog/session.cpp index f17b3cba6ad..302e0c12dda 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/session.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/session.cpp @@ -10,8 +10,7 @@ LOG_SETUP(".transactionlog.session"); using vespalib::LockGuard; -namespace search { -namespace transactionlog { +namespace search::transactionlog { namespace { const double NEVER(-1.0); @@ -281,4 +280,3 @@ Session::sendDone() } } -} diff --git a/searchlib/src/vespa/searchlib/transactionlog/session.h b/searchlib/src/vespa/searchlib/transactionlog/session.h index 1f5f1af9623..26e448540c3 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/session.h +++ b/searchlib/src/vespa/searchlib/transactionlog/session.h @@ -9,8 +9,7 @@ class FastOS_FileInterface; -namespace search { -namespace transactionlog { +namespace search::transactionlog { class Domain; class DomainPart; @@ -94,5 +93,3 @@ private: }; } -} - diff --git a/searchlib/src/vespa/searchlib/transactionlog/syncproxy.h b/searchlib/src/vespa/searchlib/transactionlog/syncproxy.h index 009e4d9de8e..a2623ea3236 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/syncproxy.h +++ b/searchlib/src/vespa/searchlib/transactionlog/syncproxy.h @@ -4,10 +4,7 @@ #include <vespa/searchlib/common/serialnum.h> -namespace search -{ -namespace transactionlog -{ +namespace search::transactionlog { class SyncProxy { @@ -17,6 +14,3 @@ public: }; } - -} - diff --git a/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp b/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp index 60efcf485d8..fe708f52a93 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.cpp @@ -1,14 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "trans_log_server_explorer.h" -#include "domain.h" #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/fastos/file.h> + using vespalib::slime::Inserter; using vespalib::slime::Cursor; -namespace search { -namespace transactionlog { +namespace search::transactionlog { namespace { @@ -66,5 +66,4 @@ TransLogServerExplorer::get_child(vespalib::stringref name) const return std::unique_ptr<vespalib::StateExplorer>(new DomainExplorer(std::move(domain))); } -} // namespace search::transactionlog -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.h b/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.h index 9e125b2142e..65d3a687bc9 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.h +++ b/searchlib/src/vespa/searchlib/transactionlog/trans_log_server_explorer.h @@ -5,8 +5,7 @@ #include "translogserver.h" #include <vespa/vespalib/net/state_explorer.h> -namespace search { -namespace transactionlog { +namespace search::transactionlog { /** * Class used to explore the state of a transaction log server. @@ -23,5 +22,4 @@ public: virtual std::unique_ptr<StateExplorer> get_child(vespalib::stringref name) const override; }; -} // namespace search::transactionlog -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp b/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp index 5af7c293916..af2e8ad47a1 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp @@ -11,8 +11,7 @@ LOG_SETUP(".translogclient"); using namespace std::chrono_literals; -namespace search { -namespace transactionlog { +namespace search::transactionlog { namespace { const double NEVER(-1.0); @@ -408,4 +407,3 @@ TransLogClient::Visitor::~Visitor() } } -} diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h index 6ae48cdfff6..e7aca212b07 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h +++ b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h @@ -7,11 +7,9 @@ #include <vespa/fnet/frt/invokable.h> #include <mutex> -namespace search { +namespace search::common { class FileHeaderContext; } -namespace common { class FileHeaderContext; } - -namespace transactionlog { +namespace search::transactionlog { class TransLogServerExplorer; @@ -100,5 +98,3 @@ private: }; } -} - diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp b/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp index fbc1694a8a0..b84d7854457 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.cpp @@ -8,8 +8,7 @@ LOG_SETUP(".translogserverapp"); using search::common::FileHeaderContext; -namespace search { -namespace transactionlog { +namespace search::transactionlog { TransLogServerApp::TransLogServerApp(const config::ConfigUri & tlsConfigUri, const FileHeaderContext & fileHeaderContext) @@ -40,14 +39,8 @@ DomainPart::Crc getCrc(searchlib::TranslogserverConfig::Crcmethod crcType) void TransLogServerApp::start() { std::shared_ptr<searchlib::TranslogserverConfig> c = _tlsConfig.get(); - _tls.reset(new TransLogServer(c->servername, - c->listenport, - c->basedir, - _fileHeaderContext, - c->filesizemax, - c->usefsync, - c->maxthreads, - getCrc(c->crcmethod))); + _tls.reset(new TransLogServer(c->servername, c->listenport, c->basedir, _fileHeaderContext, + c->filesizemax, c->usefsync, c->maxthreads, getCrc(c->crcmethod))); } TransLogServerApp::~TransLogServerApp() @@ -63,4 +56,3 @@ void TransLogServerApp::configure(std::unique_ptr<searchlib::TranslogserverConfi } } -} diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h b/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h index c36b58b4696..35fa994d1e4 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h +++ b/searchlib/src/vespa/searchlib/transactionlog/translogserverapp.h @@ -7,12 +7,9 @@ #include <vespa/vespalib/util/ptrholder.h> namespace config { class ConfigUri; } +namespace search::common { class FileHeaderContext; } -namespace search { - -namespace common { class FileHeaderContext; } - -namespace transactionlog { +namespace search::transactionlog { class TransLogServerApp : public config::IFetcherCallback<searchlib::TranslogserverConfig> { @@ -36,5 +33,4 @@ public: void start(); }; -} // namespace transactionlog -} // namespace search +} |