diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2019-04-15 11:02:20 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2019-04-15 11:02:20 +0200 |
commit | 70b88d986f9993a336d243ea8233416defa3d0e3 (patch) | |
tree | d5e46d06d2557dcc7ab084e381d19f88fa431117 /searchlib | |
parent | 98f61ea4b4ff2db092ec7665a806366ac30fea95 (diff) |
Style fixes.
Diffstat (limited to 'searchlib')
43 files changed, 190 insertions, 439 deletions
diff --git a/searchlib/src/vespa/searchlib/bitcompression/compression.h b/searchlib/src/vespa/searchlib/bitcompression/compression.h index 482a9d8b6bb..c6b3c4de3a2 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/compression.h +++ b/searchlib/src/vespa/searchlib/bitcompression/compression.h @@ -723,8 +723,8 @@ public: EncodeContext64Base() : search::ComprFileEncodeContext(), - _valI(NULL), - _valE(NULL), + _valI(nullptr), + _valE(nullptr), _cacheInt(0), _cacheFree(64), _fileWriteBias(64) @@ -1128,9 +1128,9 @@ public: DecodeContext64Base() : search::ComprFileDecodeContext(), - _valI(NULL), - _valE(NULL), - _realValE(NULL), + _valI(nullptr), + _valE(nullptr), + _realValE(nullptr), _val(0), _cacheInt(0), _preRead(0), @@ -1230,9 +1230,9 @@ public: void emptyBuffer(uint64_t newBitPosition) override { _fileReadBias = newBitPosition; - _valI = NULL; - _valE = NULL; - _realValE = NULL; + _valI = nullptr; + _valE = nullptr; + _realValE = nullptr; _preRead = 0; } @@ -1286,8 +1286,8 @@ public: DecodeContext64(const uint64_t *compr, int bitOffset) : DecodeContext64Base(compr + 1, - NULL, - NULL, + nullptr, + nullptr, 0, EC::bswap(*compr), 64 - bitOffset) @@ -1306,8 +1306,8 @@ public: int bitOffset, uint64_t bitLength) : DecodeContext64Base(compr + 1, - NULL, - NULL, + nullptr, + nullptr, 0, EC::bswap(*compr), 64 - bitOffset) @@ -1490,14 +1490,14 @@ public: FeatureDecodeContext() : ParentClass(), - _readContext(NULL) + _readContext(nullptr) { } FeatureDecodeContext(const uint64_t *compr, int bitOffset) : ParentClass(compr, bitOffset), - _readContext(NULL) + _readContext(nullptr) { } @@ -1505,7 +1505,7 @@ public: int bitOffset, uint64_t bitLength) : ParentClass(compr, bitOffset, bitLength), - _readContext(NULL) + _readContext(nullptr) { } @@ -1630,7 +1630,7 @@ public: public: FeatureEncodeContext() : ParentClass(), - _writeContext(NULL) + _writeContext(nullptr) { } diff --git a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp index ddf617d37ed..77a6d5bd86b 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.cpp @@ -10,9 +10,7 @@ #include <vespa/log/log.h> LOG_SETUP(".pagedict4"); -namespace search { - -namespace bitcompression { +namespace search::bitcompression { namespace { @@ -1511,7 +1509,7 @@ PageDict4PLookupRes() _startOffset(), _wordNum(1u), _res(false), - _nextWord(NULL) + _nextWord(nullptr) { } @@ -1759,8 +1757,7 @@ PageDict4Reader::~PageDict4Reader() { } -namespace -{ +namespace { template <typename CheckVector> void checkWordOffset(CheckVector &skip, uint32_t &skipAdjust, uint32_t wordOffset, uint32_t wordEntryLen) @@ -2233,6 +2230,4 @@ PageDict4Reader::readOverflowCounts(vespalib::string &word, } } -} // namespace bitcompression - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.h b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.h index dc0ea3a5201..af05a71e518 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/pagedict4.h +++ b/searchlib/src/vespa/searchlib/bitcompression/pagedict4.h @@ -6,12 +6,7 @@ #include <vespa/vespalib/stllike/string.h> #include "countcompression.h" -namespace search -{ - -namespace bitcompression -{ - +namespace search::bitcompression { class PageDict4StartOffset { @@ -315,7 +310,7 @@ public: * L1 data (word ref delta, offset to counts, data file delta) * counts (sparse count) * padding - * word strings (LCP + suffix + NULL) + * word strings (LCP + suffix + NUL) * * Alternate layout for overflow page: * @@ -822,7 +817,4 @@ public: Counts &counts); }; -} // namespace bitcompression - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp index 65b7b236525..442304de6c9 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp +++ b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.cpp @@ -25,19 +25,12 @@ namespace { vespalib::string PosOccId = "PosOcc.3"; vespalib::string PosOccIdCooked = "PosOcc.3.Cooked"; - -} - -namespace { - vespalib::string EG64PosOccId = "EG64PosOcc.3"; // Dynamic k values vespalib::string EG64PosOccId2 = "EG64PosOcc.2"; // Fixed k values } -namespace search { - -namespace bitcompression { +namespace search::bitcompression { PosOccFieldParams::PosOccFieldParams() @@ -214,14 +207,14 @@ PosOccFieldParams::writeHeader(vespalib::GenericHeader &header, PosOccFieldsParams::PosOccFieldsParams() : _numFields(0u), - _fieldParams(NULL), + _fieldParams(nullptr), _params() { } PosOccFieldsParams::PosOccFieldsParams(const PosOccFieldsParams &rhs) : _numFields(0u), - _fieldParams(NULL), + _fieldParams(nullptr), _params(rhs._params) { cacheParamsRef(); @@ -1337,6 +1330,4 @@ template class EGPosOccDecodeContextCooked<false>; template class EGPosOccEncodeContext<true>; template class EGPosOccEncodeContext<false>; -} // namespace index - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.h b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.h index 6eb6cac46b6..e6ff98da9c9 100644 --- a/searchlib/src/vespa/searchlib/bitcompression/posocccompression.h +++ b/searchlib/src/vespa/searchlib/bitcompression/posocccompression.h @@ -27,11 +27,7 @@ #define K_VALUE_POSOCC_ELEMENTID 0 #define K_VALUE_POSOCC_ELEMENTWEIGHT 9 -namespace search -{ - -namespace index -{ +namespace search::index { class DocIdAndPosOccFeatures : public DocIdAndFeatures { @@ -59,16 +55,9 @@ public: } }; -} // namespace search::index +} -} // namespace search - - -namespace search -{ - -namespace bitcompression -{ +namespace search::bitcompression { class PosOccFieldParams { @@ -123,12 +112,12 @@ public: void cacheParamsRef() { _numFields = _params.size(); - _fieldParams = _params.empty() ? NULL : &_params[0]; + _fieldParams = _params.empty() ? nullptr : &_params[0]; } void assertCachedParamsRef() const { assert(_numFields == _params.size()); - assert(_fieldParams == (_params.empty() ? NULL : &_params[0])); + assert(_fieldParams == (_params.empty() ? nullptr : &_params[0])); } uint32_t getNumFields() const { return _numFields; } @@ -474,6 +463,4 @@ extern template class EGPosOccDecodeContextCooked<false>; extern template class EGPosOccEncodeContext<true>; extern template class EGPosOccEncodeContext<false>; -} // namespace bitcompression - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp index b898405be07..9c17c998c28 100644 --- a/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/bitvectordictionary.cpp @@ -9,7 +9,6 @@ LOG_SETUP(".diskindex.bitvectordictionary"); namespace search::diskindex { - BitVectorDictionary::BitVectorDictionary() : _docIdLimit(), _entries(), diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.h b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.h index 071cf37443d..00645810d62 100644 --- a/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.h +++ b/searchlib/src/vespa/searchlib/diskindex/bitvectorfile.h @@ -10,7 +10,6 @@ namespace search::diskindex { - class BitVectorFileWrite : public BitVectorIdxFileWrite { private: diff --git a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h index 47894764976..671ee88e85b 100644 --- a/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h +++ b/searchlib/src/vespa/searchlib/diskindex/bitvectoridxfile.h @@ -10,7 +10,6 @@ namespace search::common { class FileHeaderContext; } - namespace search::diskindex { class BitVectorIdxFileWrite diff --git a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp index 9a6144e9635..90c6970c476 100644 --- a/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/diskindex.cpp @@ -427,7 +427,7 @@ createBlueprintHelper(LookupCache & cache, DiskIndex & diskIndex, const IRequest return Blueprint::UP(new EmptyBlueprint(field)); } -} // namespace <unnamed> +} Blueprint::UP DiskIndex::createBlueprint(const IRequestContext & requestContext, const FieldSpec &field, const Node &term) diff --git a/searchlib/src/vespa/searchlib/diskindex/fusion.cpp b/searchlib/src/vespa/searchlib/diskindex/fusion.cpp index 4fa472c2584..8e58853e826 100644 --- a/searchlib/src/vespa/searchlib/diskindex/fusion.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/fusion.cpp @@ -482,7 +482,7 @@ Fusion::readSchemaFiles() OldIndexIterator oldIndexIt = _oldIndexes.begin(); OldIndexIterator oldIndexIte = _oldIndexes.end(); - for(; oldIndexIt != oldIndexIte; ++oldIndexIt) { + for (; oldIndexIt != oldIndexIte; ++oldIndexIt) { OldIndex &oi = **oldIndexIt; vespalib::string oldcfname = oi.getPath() + "/schema.txt"; Schema::SP schema(new Schema); diff --git a/searchlib/src/vespa/searchlib/diskindex/fusion.h b/searchlib/src/vespa/searchlib/diskindex/fusion.h index 9b5806d93d9..520aa7b2203 100644 --- a/searchlib/src/vespa/searchlib/diskindex/fusion.h +++ b/searchlib/src/vespa/searchlib/diskindex/fusion.h @@ -9,11 +9,7 @@ #include <vector> #include <string> -namespace search { - -template <class IN> -class PostingPriorityQueue; -} +namespace search { template <class IN> class PostingPriorityQueue; } namespace search::common { class TuneFileIndexing; diff --git a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_header.cpp b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_header.cpp index 3adb32f8681..5288d054ef0 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_header.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_header.cpp @@ -4,8 +4,7 @@ #include "zc4_posting_params.h" #include <vespa/searchlib/bitcompression/compression.h> -namespace search::diskindex -{ +namespace search::diskindex { Zc4PostingHeader::Zc4PostingHeader() : _has_more(false), diff --git a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer.cpp b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer.cpp index 0eb59a383a5..477db7095ed 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer.cpp @@ -8,8 +8,7 @@ using search::index::DocIdAndFeatures; using search::index::PostingListCounts; using search::index::PostingListParams; -namespace search::diskindex -{ +namespace search::diskindex { template <bool bigEndian> Zc4PostingWriter<bigEndian>::Zc4PostingWriter(PostingListCounts &counts) diff --git a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer.h b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer.h index 8dc5e249d52..f2c96af8901 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer.h +++ b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer.h @@ -6,8 +6,7 @@ namespace search::index { class DocIdAndFeatures; } -namespace search::diskindex -{ +namespace search::diskindex { /* * Class used to write posting lists of type "Zc.4" and "Zc.5" (dynamic k). diff --git a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.cpp b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.cpp index 485610c2ebd..51f7a2ea151 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.cpp @@ -6,8 +6,7 @@ using search::index::PostingListCounts; using search::index::PostingListParams; -namespace search::diskindex -{ +namespace search::diskindex { Zc4PostingWriterBase::Zc4PostingWriterBase(PostingListCounts &counts) : _minChunkDocs(1 << 30), diff --git a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.h b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.h index ba781c11564..e803fc692c3 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.h +++ b/searchlib/src/vespa/searchlib/diskindex/zc4_posting_writer_base.h @@ -11,8 +11,7 @@ class PostingListCounts; class PostingListParams; } -namespace search::diskindex -{ +namespace search::diskindex { /* * Base class for writing posting lists that might have basic skip info. diff --git a/searchlib/src/vespa/searchlib/diskindex/zcbuf.cpp b/searchlib/src/vespa/searchlib/diskindex/zcbuf.cpp index e2f5e68758e..f5c1ee19af9 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcbuf.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zcbuf.cpp @@ -57,4 +57,4 @@ ZcBuf::expand() _valE = _mallocStart + newSize - zcSlack(); } -} // namespace search::diskindex +} diff --git a/searchlib/src/vespa/searchlib/diskindex/zcbuf.h b/searchlib/src/vespa/searchlib/diskindex/zcbuf.h index c89506ee02a..c7caeb09733 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcbuf.h +++ b/searchlib/src/vespa/searchlib/diskindex/zcbuf.h @@ -81,4 +81,4 @@ public: } }; -} // namespace search::diskindex +} diff --git a/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp b/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp index e850f169adc..01e2a597cca 100644 --- a/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/zcposting.cpp @@ -856,4 +856,4 @@ ZcPostingSeqWrite::ZcPostingSeqWrite(PostingListCountFileSeqWrite *countFile) _writer.set_dynamic_k(true); } -} // namespace search::diskindex +} diff --git a/searchlib/src/vespa/searchlib/index/bitvectorkeys.h b/searchlib/src/vespa/searchlib/index/bitvectorkeys.h index a6cd0022371..895f485e260 100644 --- a/searchlib/src/vespa/searchlib/index/bitvectorkeys.h +++ b/searchlib/src/vespa/searchlib/index/bitvectorkeys.h @@ -2,14 +2,9 @@ #pragma once -namespace search -{ +namespace search::index { -namespace index -{ - -class BitVectorWordSingleKey -{ +class BitVectorWordSingleKey { public: uint64_t _wordNum; uint32_t _numDocs; @@ -35,7 +30,4 @@ public: } }; -} // namespace index - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/index/dictionaryfile.cpp b/searchlib/src/vespa/searchlib/index/dictionaryfile.cpp index da21363f854..abb8434440e 100644 --- a/searchlib/src/vespa/searchlib/index/dictionaryfile.cpp +++ b/searchlib/src/vespa/searchlib/index/dictionaryfile.cpp @@ -3,38 +3,23 @@ #include "dictionaryfile.h" #include <vespa/fastos/file.h> -namespace search { -namespace index { +namespace search::index { +DictionaryFileSeqRead::~DictionaryFileSeqRead() = default; -DictionaryFileSeqRead::~DictionaryFileSeqRead() -{ -} - - -DictionaryFileSeqWrite::~DictionaryFileSeqWrite() -{ -} - +DictionaryFileSeqWrite::~DictionaryFileSeqWrite() = default; DictionaryFileRandRead::DictionaryFileRandRead() : _memoryMapped(false) { } - -DictionaryFileRandRead::~DictionaryFileRandRead() -{ -} - +DictionaryFileRandRead::~DictionaryFileRandRead() = default; void DictionaryFileRandRead::afterOpen(FastOS_FileInterface &file) { - _memoryMapped = file.MemoryMapPtr(0) != NULL; + _memoryMapped = file.MemoryMapPtr(0) != nullptr; } - -} // namespace index - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/index/dictionaryfile.h b/searchlib/src/vespa/searchlib/index/dictionaryfile.h index d4de6dd0af6..8a2a216cae6 100644 --- a/searchlib/src/vespa/searchlib/index/dictionaryfile.h +++ b/searchlib/src/vespa/searchlib/index/dictionaryfile.h @@ -9,17 +9,14 @@ class FastOS_FileInterface; -namespace search { +namespace search::common { class FileHeaderContext; } -namespace common { class FileHeaderContext; } - -namespace index { +namespace search::index { /** * Interface for dictionary file containing words and counts for words. */ -class DictionaryFileSeqRead : public PostingListCountFileSeqRead -{ +class DictionaryFileSeqRead : public PostingListCountFileSeqRead { public: DictionaryFileSeqRead() { } ~DictionaryFileSeqRead(); @@ -40,9 +37,7 @@ public: /** * Interface for dictionary file containing words and count for words. */ -class DictionaryFileSeqWrite : public PostingListCountFileSeqWrite -{ -protected: +class DictionaryFileSeqWrite : public PostingListCountFileSeqWrite { public: DictionaryFileSeqWrite() { } ~DictionaryFileSeqWrite(); @@ -57,8 +52,7 @@ public: /** * Interface for dictionary file containing words and counts. */ -class DictionaryFileRandRead -{ +class DictionaryFileRandRead { protected: // Can be examined after open bool _memoryMapped; @@ -86,6 +80,4 @@ protected: void afterOpen(FastOS_FileInterface &file); }; -} // namespace index - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/index/docbuilder.cpp b/searchlib/src/vespa/searchlib/index/docbuilder.cpp index 67c82b92baf..6c2050d08cd 100644 --- a/searchlib/src/vespa/searchlib/index/docbuilder.cpp +++ b/searchlib/src/vespa/searchlib/index/docbuilder.cpp @@ -125,7 +125,7 @@ makeUP(T *p) return std::unique_ptr<T>(p); } -} // namespace +} namespace docbuilderkludge { @@ -151,8 +151,7 @@ enum TokenType { using namespace docbuilderkludge; -namespace -{ +namespace { Annotation::UP makeTokenType(linguistics::TokenType type) @@ -163,8 +162,7 @@ makeTokenType(linguistics::TokenType type) } -namespace search { -namespace index { +namespace search::index { VESPA_IMPLEMENT_EXCEPTION(DocBuilderError, vespalib::Exception); @@ -176,7 +174,6 @@ DocBuilder::FieldHandle::FieldHandle(const document::Field & dfield, const Schem _value = dfield.createValue(); } - DocBuilder::CollectionFieldHandle::CollectionFieldHandle(const document::Field & dfield, const Schema::Field & field) : FieldHandle(dfield, field), _elementWeight(1) @@ -186,7 +183,7 @@ DocBuilder::CollectionFieldHandle::CollectionFieldHandle(const document::Field & void DocBuilder::CollectionFieldHandle::startElement(int32_t weight) { - assert(_element.get() == NULL); + assert(!_element); _elementWeight = weight; const CollectionFieldValue * value = dynamic_cast<CollectionFieldValue *>(_value.get()); _element = value->createNested(); @@ -206,17 +203,16 @@ DocBuilder::CollectionFieldHandle::endElement() } else { throw Error(vespalib::make_string("Field '%s' not compatible", _sfield.getName().c_str())); } - _element.reset(NULL); + _element.reset(nullptr); } - DocBuilder::IndexFieldHandle::IndexFieldHandle(const FixedTypeRepo & repo, const document::Field & dfield, const Schema::Field & sfield) : CollectionFieldHandle(dfield, sfield), _str(), _strSymbols(0u), - _spanList(NULL), + _spanList(nullptr), _spanTree(), - _lastSpan(NULL), + _lastSpan(nullptr), _spanStart(0u), _autoAnnotate(true), _autoSpace(true), @@ -238,7 +234,6 @@ DocBuilder::IndexFieldHandle::IndexFieldHandle(const FixedTypeRepo & repo, const startAnnotate(); } - void DocBuilder::IndexFieldHandle::append(const vespalib::string &val) { @@ -246,11 +241,10 @@ DocBuilder::IndexFieldHandle::append(const vespalib::string &val) _str += val; } - void DocBuilder::IndexFieldHandle::addStr(const vespalib::string &val) { - assert(_spanTree.get() != NULL); + assert(_spanTree); if (val.empty()) return; if (!_skipAutoSpace && _autoSpace) @@ -269,18 +263,16 @@ DocBuilder::IndexFieldHandle::addStr(const vespalib::string &val) } } - void DocBuilder::IndexFieldHandle::addSpace() { addNoWordStr(" "); } - void DocBuilder::IndexFieldHandle::addNoWordStr(const vespalib::string &val) { - assert(_spanTree.get() != NULL); + assert(_spanTree); if (val.empty()) return; _spanStart = _strSymbols; @@ -299,7 +291,6 @@ DocBuilder::IndexFieldHandle::addNoWordStr(const vespalib::string &val) _skipAutoSpace = true; } - void DocBuilder::IndexFieldHandle::addTokenizedString(const vespalib::string &val, bool urlMode) @@ -336,7 +327,6 @@ DocBuilder::IndexFieldHandle::addTokenizedString(const vespalib::string &val, } } - void DocBuilder::IndexFieldHandle::addSpan(size_t start, size_t len) { @@ -344,7 +334,6 @@ DocBuilder::IndexFieldHandle::addSpan(size_t start, size_t len) _lastSpan = &span; } - void DocBuilder::IndexFieldHandle::addSpan() { @@ -354,54 +343,48 @@ DocBuilder::IndexFieldHandle::addSpan() _spanStart = endPos; } - void DocBuilder::IndexFieldHandle::addSpaceTokenAnnotation() { - assert(_spanTree.get() != NULL); - assert(_lastSpan != NULL); + assert(_spanTree); + assert(_lastSpan != nullptr); _spanTree->annotate(*_lastSpan, makeTokenType(linguistics::SPACE)); } - void DocBuilder::IndexFieldHandle::addNumericTokenAnnotation() { - assert(_spanTree.get() != NULL); - assert(_lastSpan != NULL); + assert(_spanTree); + assert(_lastSpan != nullptr); _spanTree->annotate(*_lastSpan, makeTokenType(linguistics::NUMERIC)); } - void DocBuilder::IndexFieldHandle::addAlphabeticTokenAnnotation() { - assert(_spanTree.get() != NULL); - assert(_lastSpan != NULL); + assert(_spanTree); + assert(_lastSpan != nullptr); _spanTree->annotate(*_lastSpan, makeTokenType(linguistics::ALPHABETIC)); } - void DocBuilder::IndexFieldHandle::addTermAnnotation() { - assert(_spanTree.get() != NULL); - assert(_lastSpan != NULL); + assert(_spanTree); + assert(_lastSpan != nullptr); _spanTree->annotate(*_lastSpan, *AnnotationType::TERM); } - void DocBuilder::IndexFieldHandle::addTermAnnotation(const vespalib::string &val) { - assert(_spanTree.get() != NULL); - assert(_lastSpan != NULL); + assert(_spanTree); + assert(_lastSpan != nullptr); _spanTree->annotate(*_lastSpan, makeUP(new Annotation(*AnnotationType::TERM, makeUP(new StringFieldValue(val))))); } - void DocBuilder::IndexFieldHandle::onEndElement() { @@ -424,8 +407,8 @@ DocBuilder::IndexFieldHandle::onEndElement() } else { _spanTree.reset(); } - _spanList = NULL; - _lastSpan = NULL; + _spanList = nullptr; + _lastSpan = nullptr; _spanStart = 0u; _strSymbols = 0u; _str.clear(); @@ -433,7 +416,6 @@ DocBuilder::IndexFieldHandle::onEndElement() startAnnotate(); } - void DocBuilder::IndexFieldHandle::onEndField() { @@ -441,7 +423,6 @@ DocBuilder::IndexFieldHandle::onEndField() onEndElement(); } - void DocBuilder::IndexFieldHandle::startAnnotate() { @@ -450,21 +431,18 @@ DocBuilder::IndexFieldHandle::startAnnotate() _spanTree.reset(new SpanTree(linguistics::SPANTREE_NAME, std::move(span_list))); } - void DocBuilder::IndexFieldHandle::setAutoAnnotate(bool autoAnnotate) { _autoAnnotate = autoAnnotate; } - void DocBuilder::IndexFieldHandle::setAutoSpace(bool autoSpace) { _autoSpace = autoSpace; } - void DocBuilder::IndexFieldHandle::startSubField(const vespalib::string &subField) { @@ -473,8 +451,6 @@ DocBuilder::IndexFieldHandle::startSubField(const vespalib::string &subField) _subField = subField; } - - void DocBuilder::IndexFieldHandle::endSubField() { @@ -494,8 +470,8 @@ DocBuilder::IndexFieldHandle::endSubField() trees.emplace_back(std::move(_spanTree)); value->setSpanTrees(trees, _repo); sValue->setValue(f, *fval); - _spanList = NULL; - _lastSpan = NULL; + _spanList = nullptr; + _lastSpan = nullptr; _spanStart = 0u; _strSymbols = 0u; _str.clear(); @@ -504,8 +480,6 @@ DocBuilder::IndexFieldHandle::endSubField() _subField.clear(); } - - DocBuilder::AttributeFieldHandle:: AttributeFieldHandle(const document::Field &dfield, const Schema::Field &sfield) @@ -516,7 +490,7 @@ AttributeFieldHandle(const document::Field &dfield, void DocBuilder::AttributeFieldHandle::addStr(const vespalib::string & val) { - if (_element.get() != NULL) { + if (_element) { insertStr(_sfield, _element.get(), val); } else { insertStr(_sfield, _value.get(), val); @@ -526,7 +500,7 @@ DocBuilder::AttributeFieldHandle::addStr(const vespalib::string & val) void DocBuilder::AttributeFieldHandle::addInt(int64_t val) { - if (_element.get() != NULL) { + if (_element) { insertInt(_sfield, _element.get(), val); } else { insertInt(_sfield, _value.get(), val); @@ -536,7 +510,7 @@ DocBuilder::AttributeFieldHandle::addInt(int64_t val) void DocBuilder::AttributeFieldHandle::addFloat(double val) { - if (_element.get() != NULL) { + if (_element) { insertFloat(_sfield, _element.get(), val); } else { insertFloat(_sfield, _value.get(), val); @@ -547,37 +521,34 @@ void DocBuilder::AttributeFieldHandle::addPredicate( std::unique_ptr<vespalib::Slime> val) { - if (_element.get() != NULL) { + if (_element) { insertPredicate(_sfield, _element.get(), std::move(val)); } else { insertPredicate(_sfield, _value.get(), std::move(val)); } } - void DocBuilder::AttributeFieldHandle::addTensor( std::unique_ptr<vespalib::tensor::Tensor> val) { - if (_element.get() != NULL) { + if (_element) { insertTensor(_sfield, _element.get(), std::move(val)); } else { insertTensor(_sfield, _value.get(), std::move(val)); } } - void DocBuilder::AttributeFieldHandle::addPosition(int32_t xpos, int32_t ypos) { - if (_element.get() != NULL) { + if (_element) { insertPosition(_sfield, _element.get(), xpos, ypos); } else { insertPosition(_sfield, _value.get(), xpos, ypos); } } - DocBuilder::SummaryFieldHandle:: SummaryFieldHandle(const document::Field & dfield, const Schema::Field & sfield) @@ -588,7 +559,7 @@ SummaryFieldHandle(const document::Field & dfield, void DocBuilder::SummaryFieldHandle::addStr(const vespalib::string & val) { - if (_element.get() != NULL) { + if (_element) { insertStr(_sfield, _element.get(), val); } else { insertStr(_sfield, _value.get(), val); @@ -598,7 +569,7 @@ DocBuilder::SummaryFieldHandle::addStr(const vespalib::string & val) void DocBuilder::SummaryFieldHandle::addInt(int64_t val) { - if (_element.get() != NULL) { + if (_element) { insertInt(_sfield, _element.get(), val); } else { insertInt(_sfield, _value.get(), val); @@ -608,25 +579,23 @@ DocBuilder::SummaryFieldHandle::addInt(int64_t val) void DocBuilder::SummaryFieldHandle::addFloat(double val) { - if (_element.get() != NULL) { + if (_element) { insertFloat(_sfield, _element.get(), val); } else { insertFloat(_sfield, _value.get(), val); } } - void DocBuilder::SummaryFieldHandle::addRaw(const void *buf, size_t len) { - if (_element.get() != NULL) { + if (_element) { insertRaw(_sfield, _element.get(), buf, len); } else { insertRaw(_sfield, _value.get(), buf, len); } } - DocBuilder::DocumentHandle::DocumentHandle(document::Document &doc, const vespalib::string & docId) : _type(&doc.getType()), @@ -637,7 +606,6 @@ DocBuilder::DocumentHandle::DocumentHandle(document::Document &doc, (void) docId; } - DocBuilder::DocBuilder(const Schema &schema) : _schema(schema), _doctypes_config(DocTypeBuilder(schema).makeConfig()), @@ -670,7 +638,7 @@ DocBuilder::endDocument() DocBuilder & DocBuilder::startIndexField(const vespalib::string & name) { - assert(_handleDoc->getFieldHandle().get() == NULL); + assert(!_handleDoc->getFieldHandle()); uint32_t field_id = _schema.getIndexFieldId(name); assert(field_id != Schema::UNKNOWN_FIELD_ID); _handleDoc->startIndexField(_schema.getIndexField(field_id)); @@ -681,7 +649,7 @@ DocBuilder::startIndexField(const vespalib::string & name) DocBuilder & DocBuilder::startAttributeField(const vespalib::string & name) { - assert(_handleDoc->getFieldHandle().get() == NULL); + assert(!_handleDoc->getFieldHandle()); uint32_t field_id = _schema.getIndexFieldId(name); assert(field_id == Schema::UNKNOWN_FIELD_ID); field_id = _schema.getAttributeFieldId(name); @@ -694,7 +662,7 @@ DocBuilder::startAttributeField(const vespalib::string & name) DocBuilder & DocBuilder::startSummaryField(const vespalib::string & name) { - assert(_handleDoc->getFieldHandle().get() == NULL); + assert(!_handleDoc->getFieldHandle()); uint32_t field_id = _schema.getIndexFieldId(name); assert(field_id == Schema::UNKNOWN_FIELD_ID); field_id = _schema.getAttributeFieldId(name); @@ -709,16 +677,16 @@ DocBuilder::startSummaryField(const vespalib::string & name) DocBuilder & DocBuilder::endField() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->endField(); - _currDoc = NULL; + _currDoc = nullptr; return *this; } DocBuilder & DocBuilder::startElement(int32_t weight) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->startElement(weight); return *this; } @@ -726,7 +694,7 @@ DocBuilder::startElement(int32_t weight) DocBuilder & DocBuilder::endElement() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->endElement(); return *this; } @@ -734,7 +702,7 @@ DocBuilder::endElement() DocBuilder & DocBuilder::addStr(const vespalib::string & str) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addStr(str); return *this; } @@ -742,7 +710,7 @@ DocBuilder::addStr(const vespalib::string & str) DocBuilder & DocBuilder::addSpace() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addSpace(); return *this; } @@ -750,7 +718,7 @@ DocBuilder::addSpace() DocBuilder & DocBuilder::addNoWordStr(const vespalib::string & str) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addNoWordStr(str); return *this; } @@ -758,7 +726,7 @@ DocBuilder::addNoWordStr(const vespalib::string & str) DocBuilder & DocBuilder::addTokenizedString(const vespalib::string &str) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addTokenizedString(str, false); return *this; } @@ -766,7 +734,7 @@ DocBuilder::addTokenizedString(const vespalib::string &str) DocBuilder & DocBuilder::addUrlTokenizedString(const vespalib::string &str) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addTokenizedString(str, true); return *this; } @@ -774,7 +742,7 @@ DocBuilder::addUrlTokenizedString(const vespalib::string &str) DocBuilder & DocBuilder::addInt(int64_t val) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addInt(val); return *this; } @@ -782,146 +750,129 @@ DocBuilder::addInt(int64_t val) DocBuilder & DocBuilder::addFloat(double val) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addFloat(val); return *this; } - DocBuilder & DocBuilder::addPredicate(std::unique_ptr<vespalib::Slime> val) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addPredicate(std::move(val)); return *this; } - DocBuilder & DocBuilder::addTensor(std::unique_ptr<vespalib::tensor::Tensor> val) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addTensor(std::move(val)); return *this; } - DocBuilder & DocBuilder::addSpan(size_t start, size_t len) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addSpan(start, len); return *this; } - DocBuilder & DocBuilder::addSpan() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addSpan(); return *this; } - DocBuilder & DocBuilder::addSpaceTokenAnnotation() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addSpaceTokenAnnotation(); return *this; } - DocBuilder & DocBuilder::addNumericTokenAnnotation() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addNumericTokenAnnotation(); return *this; } - DocBuilder & DocBuilder::addAlphabeticTokenAnnotation() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addAlphabeticTokenAnnotation(); return *this; } - DocBuilder& DocBuilder::addTermAnnotation() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addTermAnnotation(); return *this; } - DocBuilder & DocBuilder::addTermAnnotation(const vespalib::string &val) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addTermAnnotation(val); return *this; } - DocBuilder & DocBuilder::addPosition(int32_t xpos, int32_t ypos) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addPosition(xpos, ypos); return *this; } - DocBuilder & DocBuilder::addRaw(const void *buf, size_t len) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->addRaw(buf, len); return *this; } - DocBuilder & DocBuilder::startSubField(const vespalib::string &subField) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->startSubField(subField); return *this; } - DocBuilder & DocBuilder::endSubField() { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->endSubField(); return *this; } - DocBuilder & DocBuilder::setAutoAnnotate(bool autoAnnotate) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->setAutoAnnotate(autoAnnotate); return *this; } - DocBuilder & DocBuilder::setAutoSpace(bool autoSpace) { - assert(_currDoc != NULL); + assert(_currDoc != nullptr); _currDoc->getFieldHandle()->setAutoSpace(autoSpace); return *this; } - -} // namespace search::index -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/index/docbuilder.h b/searchlib/src/vespa/searchlib/index/docbuilder.h index 73c60304f50..729ec963927 100644 --- a/searchlib/src/vespa/searchlib/index/docbuilder.h +++ b/searchlib/src/vespa/searchlib/index/docbuilder.h @@ -13,9 +13,9 @@ #include <vespa/vespalib/util/exception.h> #include <vespa/vespalib/util/stringfmt.h> -namespace vespalib { namespace tensor { class Tensor; } } -namespace search { -namespace index { +namespace vespalib::tensor { class Tensor; } + +namespace search::index { VESPA_DEFINE_EXCEPTION(DocBuilderError, vespalib::Exception); @@ -23,8 +23,7 @@ VESPA_DEFINE_EXCEPTION(DocBuilderError, vespalib::Exception); * Builder class used to generate a search document that corresponds * to an index schema. **/ -class DocBuilder -{ +class DocBuilder { public: typedef DocBuilderError Error; @@ -153,8 +152,7 @@ private: /** * Class for handling the construction of the content of an index field. **/ - class IndexFieldHandle : public CollectionFieldHandle - { + class IndexFieldHandle : public CollectionFieldHandle { vespalib::string _str; // adjusted as word comes along size_t _strSymbols; // symbols in string, assuming UTF8 document::SpanList *_spanList; // owned by _spanTree @@ -198,8 +196,7 @@ private: /** * Class for handling the construction of the content of an attribute field. **/ - class AttributeFieldHandle : public CollectionFieldHandle - { + class AttributeFieldHandle : public CollectionFieldHandle { public: AttributeFieldHandle(const document::Field & dfield, const Schema::Field & sfield); void addStr(const vespalib::string & val) override; @@ -248,7 +245,7 @@ private: void endField() { _fieldHandle->onEndField(); _doc->setValue(_type->getField(_fieldHandle->getField().getName()), *_fieldHandle->getValue()); - _fieldHandle.reset(static_cast<FieldHandle *>(NULL)); + _fieldHandle.reset(static_cast<FieldHandle *>(nullptr)); } void endDocument(const document::Document::UP & doc) { (void) doc; @@ -306,5 +303,4 @@ public: document::DocumenttypesConfig getDocumenttypesConfig() const { return _doctypes_config; } }; -} // namespace search::index -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/index/docidandfeatures.h b/searchlib/src/vespa/searchlib/index/docidandfeatures.h index a9329c9fa01..d1d44f78aa6 100644 --- a/searchlib/src/vespa/searchlib/index/docidandfeatures.h +++ b/searchlib/src/vespa/searchlib/index/docidandfeatures.h @@ -18,8 +18,7 @@ namespace search::index { * * Present as member in DocIdAndFeatures. */ -class WordDocFeatures -{ +class WordDocFeatures { public: // TODO: add support for user features @@ -32,8 +31,7 @@ public: * * Present as vector element in DocIdAndFeatures. */ -class WordDocFieldFeatures -{ +class WordDocFieldFeatures { public: uint32_t _numElements; // Number of array indexes // TODO: add support for user features @@ -52,8 +50,7 @@ public: * * Present as vector element in DocIdAndFeatures. */ -class WordDocElementFeatures -{ +class WordDocElementFeatures { public: uint32_t _elementId; // Array index uint32_t _numOccs; @@ -101,8 +98,7 @@ public: * * Present as vector element in DocIdAndFeatures. */ -class WordDocElementWordPosFeatures -{ +class WordDocElementWordPosFeatures { public: uint32_t _wordPos; // TODO: add support for user features @@ -124,8 +120,7 @@ public: * (word, doc) pair, used by index fusion to shuffle information from * input files to the output file without having to know all the details. */ -class DocIdAndFeatures -{ +class DocIdAndFeatures { public: uint32_t _docId; // Current Docid // generic feature data, flattened to avoid excessive allocator usage diff --git a/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp b/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp index f79e394e535..2bc81947e70 100644 --- a/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp +++ b/searchlib/src/vespa/searchlib/index/doctypebuilder.cpp @@ -66,17 +66,8 @@ insertStructType(document::DocumenttypesConfig::Documenttype & cfg, cfg.datatype.back().id = structType.getId(); } -} - -DocTypeBuilder::DocTypeBuilder(const Schema &schema) - : _schema(schema), - _iFields() -{ - _iFields.setup(schema); -} - -namespace { using namespace document::config_builder; + TypeOrId makeCollection(TypeOrId datatype, Schema::CollectionType collection_type) { switch (collection_type) { @@ -103,7 +94,14 @@ struct TypeCache { } }; -} // namespace +} + +DocTypeBuilder::DocTypeBuilder(const Schema &schema) + : _schema(schema), + _iFields() +{ + _iFields.setup(schema); +} document::DocumenttypesConfig DocTypeBuilder::makeConfig() const { using namespace document::config_builder; diff --git a/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.cpp b/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.cpp index e5e582b673b..adee1820fcc 100644 --- a/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.cpp +++ b/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.cpp @@ -21,19 +21,16 @@ DummyFileHeaderContext::DummyFileHeaderContext() assert(!_hostName.empty()); } - DummyFileHeaderContext::~DummyFileHeaderContext() { } - void DummyFileHeaderContext::disableFileName() { _disableFileName = true; } - void DummyFileHeaderContext::addTags(vespalib::GenericHeader &header, const vespalib::string &name) const @@ -53,7 +50,6 @@ DummyFileHeaderContext::addTags(vespalib::GenericHeader &header, header.putTag(Tag("DummyFileHeaderContext", "enabled")); } - void DummyFileHeaderContext::setCreator(const vespalib::string &creator) { diff --git a/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.h b/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.h index bc8f91ab0d4..e91ba860c48 100644 --- a/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.h +++ b/searchlib/src/vespa/searchlib/index/dummyfileheadercontext.h @@ -5,11 +5,9 @@ namespace vespalib { class GenericHeader; } -namespace search { -namespace index { +namespace search::index { -class DummyFileHeaderContext : public common::FileHeaderContext -{ +class DummyFileHeaderContext : public common::FileHeaderContext { bool _disableFileName; vespalib::string _hostName; pid_t _pid; @@ -23,6 +21,4 @@ public: static void setCreator(const vespalib::string &creator); }; -} // namespace index - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/index/indexbuilder.cpp b/searchlib/src/vespa/searchlib/index/indexbuilder.cpp index a07c203194d..6b88c51e6cc 100644 --- a/searchlib/src/vespa/searchlib/index/indexbuilder.cpp +++ b/searchlib/src/vespa/searchlib/index/indexbuilder.cpp @@ -8,6 +8,6 @@ IndexBuilder::IndexBuilder(const Schema &schema) : _schema(schema) { } -IndexBuilder::~IndexBuilder() { } +IndexBuilder::~IndexBuilder() = default; } diff --git a/searchlib/src/vespa/searchlib/index/indexbuilder.h b/searchlib/src/vespa/searchlib/index/indexbuilder.h index e5769ccdb75..66ca740a20c 100644 --- a/searchlib/src/vespa/searchlib/index/indexbuilder.h +++ b/searchlib/src/vespa/searchlib/index/indexbuilder.h @@ -3,17 +3,12 @@ #include <vespa/vespalib/stllike/string.h> -namespace search -{ - -namespace index -{ +namespace search::index { class Schema; class WordDocElementWordPosFeatures; -class IndexBuilder -{ +class IndexBuilder { protected: const Schema &_schema; @@ -55,8 +50,4 @@ public: // TODO: methods for document summary. }; - -} // namespace index - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/index/postinglistcountfile.cpp b/searchlib/src/vespa/searchlib/index/postinglistcountfile.cpp index 178053c8145..90319970457 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistcountfile.cpp +++ b/searchlib/src/vespa/searchlib/index/postinglistcountfile.cpp @@ -8,12 +8,10 @@ PostingListCountFileSeqRead::PostingListCountFileSeqRead() { } - PostingListCountFileSeqRead::~PostingListCountFileSeqRead() { } - void PostingListCountFileSeqRead:: getParams(PostingListParams ¶ms) @@ -21,17 +19,14 @@ getParams(PostingListParams ¶ms) params.clear(); } - PostingListCountFileSeqWrite::PostingListCountFileSeqWrite() { } - PostingListCountFileSeqWrite::~PostingListCountFileSeqWrite() { } - void PostingListCountFileSeqWrite:: setParams(const PostingListParams ¶ms) @@ -39,7 +34,6 @@ setParams(const PostingListParams ¶ms) (void) params; } - void PostingListCountFileSeqWrite:: getParams(PostingListParams ¶ms) diff --git a/searchlib/src/vespa/searchlib/index/postinglistcountfile.h b/searchlib/src/vespa/searchlib/index/postinglistcountfile.h index 30c6963f228..cf6440fd6fb 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistcountfile.h +++ b/searchlib/src/vespa/searchlib/index/postinglistcountfile.h @@ -5,11 +5,9 @@ #include "postinglistcounts.h" #include <vespa/searchlib/common/tunefileinfo.h> -namespace search { +namespace search::common { class FileHeaderContext; } -namespace common { class FileHeaderContext; } - -namespace index { +namespace search::index { class PostingListCounts; class PostingListHandle; @@ -24,8 +22,7 @@ class PostingListHandle; * allowing for less data in posting list files being duplicated from * the count file. */ -class PostingListCountFileSeqRead -{ +class PostingListCountFileSeqRead { public: PostingListCountFileSeqRead(); @@ -48,8 +45,7 @@ public: }; -class PostingListCountFileSeqWrite -{ +class PostingListCountFileSeqWrite { public: PostingListCountFileSeqWrite(); @@ -78,8 +74,4 @@ public: virtual void getParams(PostingListParams ¶ms); }; - -} // namespace index - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/index/postinglistcounts.h b/searchlib/src/vespa/searchlib/index/postinglistcounts.h index c6e51dc7d87..102b61ad927 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistcounts.h +++ b/searchlib/src/vespa/searchlib/index/postinglistcounts.h @@ -12,8 +12,7 @@ namespace search::index { * where in the posting list files to read data. A posting list with * 64 or fewer documents does not have skip info. */ -class PostingListCounts -{ +class PostingListCounts { public: /* * Nested class for describing a segment of a large posting list. @@ -87,8 +86,7 @@ public: void swap(PostingListCounts & a, PostingListCounts & b); -class PostingListOffsetAndCounts -{ +class PostingListOffsetAndCounts { public: uint64_t _offset; uint64_t _accNumDocs; // Used by prefix search for now. diff --git a/searchlib/src/vespa/searchlib/index/postinglistfile.cpp b/searchlib/src/vespa/searchlib/index/postinglistfile.cpp index a9b9417b684..a9dee8282ed 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistfile.cpp +++ b/searchlib/src/vespa/searchlib/index/postinglistfile.cpp @@ -11,11 +11,7 @@ PostingListFileSeqRead::PostingListFileSeqRead() { } - -PostingListFileSeqRead::~PostingListFileSeqRead() -{ -} - +PostingListFileSeqRead::~PostingListFileSeqRead() = default; void PostingListFileSeqRead:: @@ -24,7 +20,6 @@ getParams(PostingListParams ¶ms) params.clear(); } - void PostingListFileSeqRead:: setFeatureParams(const PostingListParams ¶ms) @@ -32,7 +27,6 @@ setFeatureParams(const PostingListParams ¶ms) (void) params; } - void PostingListFileSeqRead:: getFeatureParams(PostingListParams ¶ms) @@ -40,18 +34,15 @@ getFeatureParams(PostingListParams ¶ms) params.clear(); } - PostingListFileSeqWrite::PostingListFileSeqWrite() : _counts() { } - PostingListFileSeqWrite::~PostingListFileSeqWrite() { } - void PostingListFileSeqWrite:: setParams(const PostingListParams ¶ms) @@ -59,7 +50,6 @@ setParams(const PostingListParams ¶ms) (void) params; } - void PostingListFileSeqWrite:: getParams(PostingListParams ¶ms) @@ -67,7 +57,6 @@ getParams(PostingListParams ¶ms) params.clear(); } - void PostingListFileSeqWrite:: setFeatureParams(const PostingListParams ¶ms) @@ -75,7 +64,6 @@ setFeatureParams(const PostingListParams ¶ms) (void) params; } - void PostingListFileSeqWrite:: getFeatureParams(PostingListParams ¶ms) @@ -83,26 +71,22 @@ getFeatureParams(PostingListParams ¶ms) params.clear(); } - PostingListFileRandRead:: PostingListFileRandRead() : _memoryMapped(false) { } - PostingListFileRandRead::~PostingListFileRandRead() { } - void PostingListFileRandRead::afterOpen(FastOS_FileInterface &file) { - _memoryMapped = file.MemoryMapPtr(0) != NULL; + _memoryMapped = file.MemoryMapPtr(0) != nullptr; } - PostingListFileRandReadPassThrough:: PostingListFileRandReadPassThrough(PostingListFileRandRead *lower, bool ownLower) @@ -111,14 +95,12 @@ PostingListFileRandReadPassThrough(PostingListFileRandRead *lower, { } - PostingListFileRandReadPassThrough::~PostingListFileRandReadPassThrough() { if (_ownLower) delete _lower; } - search::queryeval::SearchIterator * PostingListFileRandReadPassThrough:: createIterator(const PostingListCounts &counts, @@ -129,7 +111,6 @@ createIterator(const PostingListCounts &counts, return _lower->createIterator(counts, handle, matchData, usebitVector); } - void PostingListFileRandReadPassThrough:: readPostingList(const PostingListCounts &counts, @@ -141,7 +122,6 @@ readPostingList(const PostingListCounts &counts, handle); } - bool PostingListFileRandReadPassThrough::open(const vespalib::string &name, const TuneFileRandRead &tuneFileRead) @@ -151,7 +131,6 @@ PostingListFileRandReadPassThrough::open(const vespalib::string &name, return ret; } - bool PostingListFileRandReadPassThrough::close() { diff --git a/searchlib/src/vespa/searchlib/index/postinglistfile.h b/searchlib/src/vespa/searchlib/index/postinglistfile.h index 61247ef3197..194ac519a19 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistfile.h +++ b/searchlib/src/vespa/searchlib/index/postinglistfile.h @@ -8,11 +8,9 @@ class FastOS_FileInterface; -namespace search { +namespace search::common { class FileHeaderContext; } -namespace common { class FileHeaderContext; } - -namespace index { +namespace search::index { class DocIdAndFeatures; @@ -20,8 +18,7 @@ class DocIdAndFeatures; * Interface for posting list files containing document ids and features * for words. */ -class PostingListFileSeqRead -{ +class PostingListFileSeqRead { protected: PostingListCounts _counts; unsigned int _residueDocs; // Docids left to read for word @@ -100,8 +97,7 @@ public: * Interface for posting list files containing document ids and features * for words. */ -class PostingListFileSeqWrite -{ +class PostingListFileSeqWrite { protected: PostingListCounts _counts; public: @@ -160,8 +156,7 @@ public: * Interface for posting list files containing document ids and features * for words. */ -class PostingListFileRandRead -{ +class PostingListFileRandRead { protected: // Can be examined after open bool _memoryMapped; @@ -215,8 +210,7 @@ protected: /** * Passthrough class. */ -class PostingListFileRandReadPassThrough : public PostingListFileRandRead -{ +class PostingListFileRandReadPassThrough : public PostingListFileRandRead { protected: PostingListFileRandRead *_lower; bool _ownLower; @@ -238,7 +232,4 @@ public: bool close() override; }; - -} // namespace index - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/index/postinglisthandle.cpp b/searchlib/src/vespa/searchlib/index/postinglisthandle.cpp index 2323b08ff86..570ebdf3d7c 100644 --- a/searchlib/src/vespa/searchlib/index/postinglisthandle.cpp +++ b/searchlib/src/vespa/searchlib/index/postinglisthandle.cpp @@ -3,9 +3,7 @@ #include "postinglisthandle.h" #include <vespa/searchlib/index/postinglistfile.h> -namespace search { - -namespace index { +namespace search::index { search::queryeval::SearchIterator * PostingListHandle::createIterator(const PostingListCounts &counts, @@ -16,7 +14,4 @@ PostingListHandle::createIterator(const PostingListCounts &counts, return _file->createIterator(counts, *this, matchData, useBitVector); } - -} // namespace index - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/index/postinglisthandle.h b/searchlib/src/vespa/searchlib/index/postinglisthandle.h index 595021a418c..0454687d961 100644 --- a/searchlib/src/vespa/searchlib/index/postinglisthandle.h +++ b/searchlib/src/vespa/searchlib/index/postinglisthandle.h @@ -5,11 +5,10 @@ #include <memory> namespace search { class BitVector; } -namespace search { namespace queryeval { class SearchIterator; } } -namespace search { namespace fef { class TermFieldMatchDataArray; } } +namespace search::queryeval { class SearchIterator; } +namespace search::fef { class TermFieldMatchDataArray; } -namespace search { -namespace index { +namespace search::index { class PostingListFileRandRead; @@ -18,8 +17,7 @@ class PostingListFileRandRead; * posting list file, or referencing a chunk of memory containing the * posting list (if the file was memory mapped). */ -class PostingListHandle -{ +class PostingListHandle { public: typedef std::unique_ptr<PostingListHandle> UP; // Key portion @@ -36,20 +34,20 @@ public: size_t _allocSize; // Size of allocated memory PostingListHandle() - : _file(NULL), + : _file(nullptr), _bitOffset(0), _bitLength(0), _firstSegment(0), _numSegments(0), _bitOffsetMem(0), - _mem(NULL), - _allocMem(NULL), + _mem(nullptr), + _allocMem(nullptr), _allocSize(0) { } ~PostingListHandle() { - if (_allocMem != NULL) + if (_allocMem != nullptr) free(_allocMem); } @@ -73,16 +71,13 @@ public: _firstSegment = 0; _numSegments = 0; _bitOffsetMem = 0; - _mem = NULL; - if (_allocMem != NULL) { + _mem = nullptr; + if (_allocMem != nullptr) { free(_allocMem); - _allocMem = NULL; + _allocMem = nullptr; } _allocSize = 0; } }; - -} // namespace search::index -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/index/postinglistparams.cpp b/searchlib/src/vespa/searchlib/index/postinglistparams.cpp index 76f149b248a..1fb96206ba6 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistparams.cpp +++ b/searchlib/src/vespa/searchlib/index/postinglistparams.cpp @@ -22,7 +22,6 @@ PostingListParams::isSet(const vespalib::string &key) const return false; } - void PostingListParams::setStr(const vespalib::string &key, const vespalib::string &val) @@ -30,7 +29,6 @@ PostingListParams::setStr(const vespalib::string &key, _map[key] = val; } - const vespalib::string & PostingListParams::getStr(const vespalib::string &key) const { @@ -42,21 +40,18 @@ PostingListParams::getStr(const vespalib::string &key) const return empty; } - void PostingListParams::clear() { _map.clear(); } - void PostingListParams::erase(const vespalib::string &key) { _map.erase(key); } - bool PostingListParams::operator!=(const PostingListParams &rhs) const { @@ -74,7 +69,6 @@ PostingListParams::set(const vespalib::string &key, _map[key] = os.str(); } - template <typename TYPE> void PostingListParams::get(const vespalib::string &key, @@ -90,7 +84,6 @@ PostingListParams::get(const vespalib::string &key, } } - template void PostingListParams::set<bool>(const vespalib::string &key, const bool &val); @@ -99,7 +92,6 @@ template void PostingListParams::get<bool>(const vespalib::string &key, bool &val) const; - template void PostingListParams::set<int32_t>(const vespalib::string &key, const int32_t &val); @@ -116,7 +108,6 @@ template void PostingListParams::get<uint32_t>(const vespalib::string &key, uint32_t &val) const; - template void PostingListParams::set<uint64_t>(const vespalib::string &key, const uint64_t &val); diff --git a/searchlib/src/vespa/searchlib/index/postinglistparams.h b/searchlib/src/vespa/searchlib/index/postinglistparams.h index 083d598ff69..e75ecd29056 100644 --- a/searchlib/src/vespa/searchlib/index/postinglistparams.h +++ b/searchlib/src/vespa/searchlib/index/postinglistparams.h @@ -4,14 +4,9 @@ #include <map> #include <vespa/vespalib/stllike/string.h> -namespace search -{ +namespace search::index { -namespace index -{ - -class PostingListParams -{ +class PostingListParams { typedef std::map<vespalib::string, vespalib::string> Map; Map _map; public: @@ -42,7 +37,4 @@ public: operator!=(const PostingListParams &rhs) const; }; -} // namespace index - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/index/schema_index_fields.h b/searchlib/src/vespa/searchlib/index/schema_index_fields.h index 4dbcdcdb781..c0c55653469 100644 --- a/searchlib/src/vespa/searchlib/index/schema_index_fields.h +++ b/searchlib/src/vespa/searchlib/index/schema_index_fields.h @@ -9,8 +9,7 @@ namespace search::index { /** * Fields from an index schema to be used for indexing **/ -class SchemaIndexFields -{ +class SchemaIndexFields { public: using FieldIdVector = std::vector<uint32_t>; using UriFieldIdVector = std::vector<UriField>; diff --git a/searchlib/src/vespa/searchlib/index/schemautil.cpp b/searchlib/src/vespa/searchlib/index/schemautil.cpp index 64ca5b692ca..622779a1269 100644 --- a/searchlib/src/vespa/searchlib/index/schemautil.cpp +++ b/searchlib/src/vespa/searchlib/index/schemautil.cpp @@ -50,7 +50,6 @@ SchemaUtil::getIndexSettings(const Schema &schema, somePositions && !someNotPositions); } - bool SchemaUtil::IndexIterator::hasOldFields(const Schema &oldSchema, bool phrases) const @@ -71,7 +70,6 @@ SchemaUtil::IndexIterator::hasOldFields(const Schema &oldSchema, return oldField.hasPhrases(); } - bool SchemaUtil::IndexIterator::hasMatchingOldFields(const Schema &oldSchema, bool phrases) const @@ -97,7 +95,6 @@ SchemaUtil::IndexIterator::hasMatchingOldFields(const Schema &oldSchema, return true; } - bool SchemaUtil::validateIndexField(const Schema::IndexField &field) { @@ -137,7 +134,6 @@ SchemaUtil::validateIndexField(const Schema::IndexField &field) return ok; } - bool SchemaUtil::addIndexField(Schema &schema, const Schema::IndexField &field) @@ -157,7 +153,6 @@ SchemaUtil::addIndexField(Schema &schema, return ok; } - bool SchemaUtil::validateSchema(const Schema &schema) { @@ -186,7 +181,6 @@ SchemaUtil::validateSchema(const Schema &schema) return ok; } - bool SchemaUtil::getIndexIds(const Schema &schema, schema::DataType dataType, diff --git a/searchlib/src/vespa/searchlib/index/schemautil.h b/searchlib/src/vespa/searchlib/index/schemautil.h index cd404092a5c..a678e335ebb 100644 --- a/searchlib/src/vespa/searchlib/index/schemautil.h +++ b/searchlib/src/vespa/searchlib/index/schemautil.h @@ -4,16 +4,12 @@ #include <vespa/searchcommon/common/schema.h> -namespace search { +namespace search::index { -namespace index { - -class SchemaUtil -{ +class SchemaUtil { public: - class IndexSettings - { + class IndexSettings { schema::DataType _dataType; bool _error; // Schema is bad. bool _prefix; @@ -73,8 +69,7 @@ public: } }; - class IndexIterator - { + class IndexIterator { const Schema &_schema; uint32_t _index; @@ -166,8 +161,4 @@ public: static bool getIndexIds(const Schema &schema, schema::DataType dataType, std::vector<uint32_t> &indexes); }; - -} // namespace search::index - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/index/uri_field.cpp b/searchlib/src/vespa/searchlib/index/uri_field.cpp index a5b5ec2b337..30b78c24410 100644 --- a/searchlib/src/vespa/searchlib/index/uri_field.cpp +++ b/searchlib/src/vespa/searchlib/index/uri_field.cpp @@ -16,7 +16,6 @@ UriField::UriField() { } - bool UriField::valid(const Schema &schema, uint32_t fieldId, @@ -35,7 +34,6 @@ UriField::valid(const Schema &schema, return true; } - bool UriField::broken(const Schema &schema, const Schema::CollectionType & @@ -64,7 +62,6 @@ UriField::valid(const Schema &schema, valid(schema, _fragment, collectionType); } - void UriField::setup(const Schema &schema, const vespalib::string &field) @@ -79,7 +76,6 @@ UriField::setup(const Schema &schema, _hostname = schema.getIndexFieldId(field + ".hostname"); } - void UriField::markUsed(UsedFieldsMap &usedFields, uint32_t field) @@ -91,7 +87,6 @@ UriField::markUsed(UsedFieldsMap &usedFields, usedFields[field] = true; } - void UriField::markUsed(UsedFieldsMap &usedFields) const { |