diff options
author | Henning Baldersheim <balder@oath.com> | 2018-11-05 13:18:41 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-11-05 13:18:41 +0100 |
commit | a2590c561491ebc087e20fbafca8218240f1bb78 (patch) | |
tree | 0c11199416174e502b4c628ce26a46fda5bdecdd /searchlib | |
parent | b06d2c411b95ab40dce5a6f4b5f28bb23a573ac7 (diff) |
Nested namespace and related cleanup.
Diffstat (limited to 'searchlib')
25 files changed, 210 insertions, 596 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp b/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp index 142883e54d6..ba6ba0ef6ee 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstorebase.cpp @@ -3,11 +3,12 @@ #include "enumstorebase.h" #include "enumstore.h" #include <vespa/searchlib/datastore/datastore.hpp> -#include <vespa/vespalib/util/exceptions.h> #include <vespa/searchlib/btree/btreeiterator.hpp> #include <vespa/searchlib/btree/btreenode.hpp> #include <vespa/searchlib/util/bufferwriter.h> #include <vespa/searchlib/common/rcuvector.hpp> +#include <vespa/vespalib/util/exceptions.h> +#include <vespa/vespalib/stllike/asciistream.h> #include <vespa/log/log.h> LOG_SETUP(".searchlib.attribute.enumstorebase"); @@ -34,7 +35,7 @@ EnumStoreBase::EnumBufferType::calcClustersToAlloc(uint32_t bufferId, size_t siz size_t reservedElements = getReservedElements(bufferId); sizeNeeded = std::max(sizeNeeded, _minSizeNeeded); size_t usedElems = _activeUsedElems; - if (_lastUsedElems != NULL) { + if (_lastUsedElems != nullptr) { usedElems += *_lastUsedElems; } assert((usedElems % _clusterSize) == 0); @@ -62,7 +63,7 @@ EnumStoreBase::EnumBufferType::calcClustersToAlloc(uint32_t bufferId, size_t siz EnumStoreBase::EnumStoreBase(uint64_t initBufferSize, bool hasPostings) - : _enumDict(NULL), + : _enumDict(nullptr), _store(), _type(), _nextEnum(0), @@ -314,9 +315,7 @@ EnumStoreDictBase::EnumStoreDictBase(EnumStoreBase &enumStore) } -EnumStoreDictBase::~EnumStoreDictBase() -{ -} +EnumStoreDictBase::~EnumStoreDictBase() = default; template <typename Dictionary> @@ -327,9 +326,7 @@ EnumStoreDict<Dictionary>::EnumStoreDict(EnumStoreBase &enumStore) } template <typename Dictionary> -EnumStoreDict<Dictionary>::~EnumStoreDict() -{ -} +EnumStoreDict<Dictionary>::~EnumStoreDict() = default; template <typename Dictionary> @@ -418,7 +415,7 @@ EnumStoreDict<Dictionary>::removeUnusedEnums(const IndexSet &unused, iter != mt; ++iter) { it.lower_bound(_dict.getRoot(), *iter, cmp); assert(it.valid() && !cmp(*iter, it.getKey())); - if (Iterator::hasData() && fcmp != NULL) { + if (Iterator::hasData() && fcmp != nullptr) { typename Dictionary::DataType pidx(it.getData()); _dict.remove(it); if (!it.valid() || (*fcmp)(*iter, it.getKey())) diff --git a/searchlib/src/vespa/searchlib/attribute/postingstore.cpp b/searchlib/src/vespa/searchlib/attribute/postingstore.cpp index a0fa7e35054..e5fb1fa480a 100644 --- a/searchlib/src/vespa/searchlib/attribute/postingstore.cpp +++ b/searchlib/src/vespa/searchlib/attribute/postingstore.cpp @@ -7,8 +7,6 @@ #include <vespa/searchcommon/attribute/config.h> #include <vespa/searchcommon/attribute/status.h> -#include <vespa/log/log.h> -LOG_SETUP(".searchlib.attribute.posting_store"); namespace search::attribute { @@ -39,9 +37,7 @@ PostingStoreBase2::PostingStoreBase2(EnumPostingTree &dict, Status &status, } -PostingStoreBase2::~PostingStoreBase2() -{ -} +PostingStoreBase2::~PostingStoreBase2() = default; bool @@ -632,9 +628,7 @@ PostingStore<DataT>::getMemoryUsage() const return usage; } - template class PostingStore<BTreeNoLeafData>; - template class PostingStore<int32_t>; } diff --git a/searchlib/src/vespa/searchlib/btree/btreebuilder.cpp b/searchlib/src/vespa/searchlib/btree/btreebuilder.cpp index c07000090dc..133c5d245c9 100644 --- a/searchlib/src/vespa/searchlib/btree/btreebuilder.cpp +++ b/searchlib/src/vespa/searchlib/btree/btreebuilder.cpp @@ -1,21 +1,17 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "btreebuilder.h" #include "btreenode.hpp" #include "btreebuilder.hpp" namespace search::btree { -template class BTreeBuilder<uint32_t, uint32_t, - NoAggregated, +template class BTreeBuilder<uint32_t, uint32_t, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -template class BTreeBuilder<uint32_t, BTreeNoLeafData, - NoAggregated, +template class BTreeBuilder<uint32_t, BTreeNoLeafData, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -template class BTreeBuilder<uint32_t, int32_t, - MinMaxAggregated, +template class BTreeBuilder<uint32_t, int32_t, MinMaxAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS, MinMaxAggrCalc>; diff --git a/searchlib/src/vespa/searchlib/btree/btreebuilder.h b/searchlib/src/vespa/searchlib/btree/btreebuilder.h index 4527bbf4fb8..767f02d03ee 100644 --- a/searchlib/src/vespa/searchlib/btree/btreebuilder.h +++ b/searchlib/src/vespa/searchlib/btree/btreebuilder.h @@ -9,11 +9,7 @@ #include "minmaxaggrcalc.h" #include "btreeaggregator.h" -namespace search -{ - -namespace btree -{ +namespace search::btree { template <typename KeyT, typename DataT, @@ -24,21 +20,17 @@ template <typename KeyT, class BTreeBuilder { public: - typedef BTreeNodeAllocator<KeyT, DataT, AggrT, - INTERNAL_SLOTS, LEAF_SLOTS> NodeAllocatorType; - typedef typename NodeAllocatorType::BTreeRootBaseType BTreeRootBaseType; - typedef typename NodeAllocatorType::InternalNodeType InternalNodeType; - typedef typename NodeAllocatorType::LeafNodeType LeafNodeType; - typedef BTreeAggregator<KeyT, DataT, AggrT, - INTERNAL_SLOTS, - LEAF_SLOTS, - AggrCalcT> Aggregator; + using NodeAllocatorType = BTreeNodeAllocator<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS>; + using BTreeRootBaseType = typename NodeAllocatorType::BTreeRootBaseType; + using InternalNodeType = typename NodeAllocatorType::InternalNodeType; + using LeafNodeType = typename NodeAllocatorType::LeafNodeType; + using Aggregator = BTreeAggregator<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, AggrCalcT>; private: - typedef KeyT KeyType; - typedef DataT DataType; - typedef typename InternalNodeType::RefPair InternalNodeTypeRefPair; - typedef typename LeafNodeType::RefPair LeafNodeTypeRefPair; - typedef BTreeNode::Ref NodeRef; + using KeyType = KeyT; + using DataType = DataT; + using InternalNodeTypeRefPair = typename InternalNodeType::RefPair; + using LeafNodeTypeRefPair = typename LeafNodeType::RefPair; + using NodeRef = BTreeNode::Ref; NodeAllocatorType &_allocator; int _numInternalNodes; @@ -49,52 +41,30 @@ private: AggrCalcT _defaultAggrCalc; const AggrCalcT &_aggrCalc; - void - normalize(); - - void - allocNewLeafNode(); - - InternalNodeType * - createInternalNode(); + void normalize(); + void allocNewLeafNode(); + InternalNodeType *createInternalNode(); public: BTreeBuilder(NodeAllocatorType &allocator); - BTreeBuilder(NodeAllocatorType &allocator, const AggrCalcT &aggrCalc); - ~BTreeBuilder(); - void - recursiveDelete(NodeRef node); - - void - insert(const KeyT &key, const DataT &data); - - NodeRef - handover(); - - void - reuse(); - - void - clear(); + void recursiveDelete(NodeRef node); + void insert(const KeyT &key, const DataT &data); + NodeRef handover(); + void reuse(); + void clear(); }; -extern template class BTreeBuilder<uint32_t, uint32_t, - NoAggregated, +extern template class BTreeBuilder<uint32_t, uint32_t, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -extern template class BTreeBuilder<uint32_t, BTreeNoLeafData, - NoAggregated, +extern template class BTreeBuilder<uint32_t, BTreeNoLeafData, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -extern template class BTreeBuilder<uint32_t, int32_t, - MinMaxAggregated, +extern template class BTreeBuilder<uint32_t, int32_t, MinMaxAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS, MinMaxAggrCalc>; -} // namespace btree - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreebuilder.hpp b/searchlib/src/vespa/searchlib/btree/btreebuilder.hpp index 0816f80826c..fb912499c6c 100644 --- a/searchlib/src/vespa/searchlib/btree/btreebuilder.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreebuilder.hpp @@ -4,11 +4,7 @@ #include "btreebuilder.h" -namespace search -{ - -namespace btree -{ +namespace search::btree { template <typename KeyT, typename DataT, typename AggrT, size_t INTERNAL_SLOTS, size_t LEAF_SLOTS, class AggrCalcT> @@ -450,8 +446,4 @@ clear() assert(_numInternalNodes == 0); } - -} // namespace btree - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreeiterator.cpp b/searchlib/src/vespa/searchlib/btree/btreeiterator.cpp index 08ad4345289..9444cee975d 100644 --- a/searchlib/src/vespa/searchlib/btree/btreeiterator.cpp +++ b/searchlib/src/vespa/searchlib/btree/btreeiterator.cpp @@ -6,9 +6,6 @@ #include "btreeiterator.hpp" #include "btreenode.hpp" -#include <vespa/log/log.h> -LOG_SETUP(".searchlib.btree.breeiterator"); - namespace search::btree { template class BTreeIteratorBase<uint32_t, uint32_t, NoAggregated>; diff --git a/searchlib/src/vespa/searchlib/btree/btreeiterator.h b/searchlib/src/vespa/searchlib/btree/btreeiterator.h index 3955a4de27c..de9637c00f1 100644 --- a/searchlib/src/vespa/searchlib/btree/btreeiterator.h +++ b/searchlib/src/vespa/searchlib/btree/btreeiterator.h @@ -7,8 +7,7 @@ #include "btreetraits.h" #include <vespa/fastos/dynamiclibrary.h> -namespace search { -namespace btree { +namespace search::btree { template <typename, typename, typename, typename, typename, class> class BTreeInserter; @@ -871,21 +870,15 @@ private: void adjustGivenEntriesToRightLeafNode(); }; - extern template class BTreeIteratorBase<uint32_t, uint32_t, NoAggregated>; -extern template class BTreeIteratorBase<uint32_t, BTreeNoLeafData, - NoAggregated>; -extern template class BTreeIteratorBase<uint32_t, int32_t, - MinMaxAggregated>; +extern template class BTreeIteratorBase<uint32_t, BTreeNoLeafData, NoAggregated>; +extern template class BTreeIteratorBase<uint32_t, int32_t, MinMaxAggregated>; extern template class BTreeConstIterator<uint32_t, uint32_t, NoAggregated>; -extern template class BTreeConstIterator<uint32_t, BTreeNoLeafData, - NoAggregated>; -extern template class BTreeConstIterator<uint32_t, int32_t, - MinMaxAggregated>; +extern template class BTreeConstIterator<uint32_t, BTreeNoLeafData, NoAggregated>; +extern template class BTreeConstIterator<uint32_t, int32_t, MinMaxAggregated>; extern template class BTreeIterator<uint32_t, uint32_t, NoAggregated>; extern template class BTreeIterator<uint32_t, BTreeNoLeafData, NoAggregated>; extern template class BTreeIterator<uint32_t, int32_t, MinMaxAggregated>; -} // namespace search::btree -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/btree/btreeiterator.hpp b/searchlib/src/vespa/searchlib/btree/btreeiterator.hpp index 02b73ef53f6..b26f249c51b 100644 --- a/searchlib/src/vespa/searchlib/btree/btreeiterator.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreeiterator.hpp @@ -6,26 +6,11 @@ #include "btreeaggregator.h" #include "btreenode.hpp" #include <vespa/vespalib/util/hdr_abort.h> -#include <vespa/vespalib/stllike/asciistream.h> -namespace search { -namespace btree { +namespace search::btree { #define STRICT_BTREE_ITERATOR_SEEK -namespace { - -template <typename KeyT> -vespalib::string -keyToStr(const KeyT & key) -{ - vespalib::asciistream ss; - ss << key; - return ss.str(); -} - -} - template <typename KeyT, typename DataT, typename AggrT, uint32_t INTERNAL_SLOTS, uint32_t LEAF_SLOTS, uint32_t PATH_SIZE> BTreeIteratorBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS, PATH_SIZE>:: @@ -1373,6 +1358,4 @@ BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>::adjustGivenEntriesToRightL } } -} // namespace search::btree -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreenode.cpp b/searchlib/src/vespa/searchlib/btree/btreenode.cpp index a47c9de77b4..b3d7b60adb6 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenode.cpp +++ b/searchlib/src/vespa/searchlib/btree/btreenode.cpp @@ -1,14 +1,13 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "btreenode.h" #include "btreenode.hpp" namespace search::btree { NoAggregated BTreeNodeAggregatedWrap<NoAggregated>::_instance; + template <> -MinMaxAggregated BTreeNodeAggregatedWrap<MinMaxAggregated>::_instance = - MinMaxAggregated(); +MinMaxAggregated BTreeNodeAggregatedWrap<MinMaxAggregated>::_instance = MinMaxAggregated(); template class BTreeNodeDataWrap<uint32_t, 16>; template class BTreeNodeDataWrap<BTreeNoLeafData, 16>; @@ -23,8 +22,7 @@ template class BTreeLeafNode<uint32_t, uint32_t, NoAggregated, 16>; template class BTreeLeafNode<uint32_t, BTreeNoLeafData, NoAggregated, 16>; template class BTreeLeafNode<uint32_t, int32_t, MinMaxAggregated, 16>; template class BTreeLeafNodeTemp<uint32_t, uint32_t, NoAggregated, 16>; -template class BTreeLeafNodeTemp<uint32_t, int32_t, MinMaxAggregated, - 16>; +template class BTreeLeafNodeTemp<uint32_t, int32_t, MinMaxAggregated, 16>; template class BTreeLeafNodeTemp<uint32_t, BTreeNoLeafData, NoAggregated, 16>; } // namespace search::btree diff --git a/searchlib/src/vespa/searchlib/btree/btreenode.h b/searchlib/src/vespa/searchlib/btree/btreenode.h index d0f5d3a0ee2..7302b4d5203 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenode.h +++ b/searchlib/src/vespa/searchlib/btree/btreenode.h @@ -4,15 +4,14 @@ #include "noaggregated.h" #include "minmaxaggregated.h" +#include "btree_key_data.h" #include <vespa/searchlib/datastore/entryref.h> #include <vespa/searchlib/datastore/handle.h> #include <cassert> #include <utility> #include <cstddef> -#include "btree_key_data.h" -namespace search { -namespace datastore { +namespace search::datastore { template <typename, typename> class Allocator; template <typename> class BufferType; @@ -23,7 +22,7 @@ template <typename, typename ...> class Assigner; } -namespace btree { +namespace search::btree { template <typename, typename, typename, size_t, size_t> class BTreeNodeAllocator; template <typename, typename, typename, size_t, size_t> class BTreeNodeStore; @@ -506,5 +505,4 @@ extern template class BTreeLeafNodeTemp<uint32_t, int32_t, MinMaxAggregated, extern template class BTreeLeafNodeTemp<uint32_t, BTreeNoLeafData, NoAggregated, 16>; -} // namespace search::btree -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/btree/btreenode.hpp b/searchlib/src/vespa/searchlib/btree/btreenode.hpp index 3523641705b..dbf926a302c 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenode.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreenode.hpp @@ -5,8 +5,7 @@ #include "btreenode.h" #include <algorithm> -namespace search { -namespace btree { +namespace search::btree { namespace { @@ -381,7 +380,4 @@ BTreeLeafNode(const KeyDataType *smallArray, uint32_t arraySize) freeze(); } - -} // namespace search::btree -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreenodeallocator.cpp b/searchlib/src/vespa/searchlib/btree/btreenodeallocator.cpp index 9753e39a1d3..1a05d68b04f 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenodeallocator.cpp +++ b/searchlib/src/vespa/searchlib/btree/btreenodeallocator.cpp @@ -1,27 +1,20 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "btreenodeallocator.h" #include "btreenodeallocator.hpp" #include <vespa/vespalib/util/array.hpp> template class vespalib::Array<search::datastore::EntryRef>; -namespace search { -namespace btree { +namespace search::btree { -template class BTreeNodeAllocator<uint32_t, uint32_t, - NoAggregated, +template class BTreeNodeAllocator<uint32_t, uint32_t, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -template class BTreeNodeAllocator<uint32_t, BTreeNoLeafData, - NoAggregated, +template class BTreeNodeAllocator<uint32_t, BTreeNoLeafData, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -template class BTreeNodeAllocator<uint32_t, int32_t, - MinMaxAggregated, +template class BTreeNodeAllocator<uint32_t, int32_t, MinMaxAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -} // namespace btree - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/btree/btreenodeallocator.h b/searchlib/src/vespa/searchlib/btree/btreenodeallocator.h index 6d4b381ee28..46eca13823b 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenodeallocator.h +++ b/searchlib/src/vespa/searchlib/btree/btreenodeallocator.h @@ -2,21 +2,15 @@ #pragma once -#include <vector> -#include <deque> - #include "btreenode.h" -#include <vespa/vespalib/util/generationhandler.h> -#include <vespa/searchlib/util/memoryusage.h> #include "btreenodestore.h" #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/array.h> +#include <vespa/vespalib/util/generationhandler.h> +#include <vespa/searchlib/util/memoryusage.h> +#include <vector> -namespace search -{ - -namespace btree -{ +namespace search::btree { template <typename, typename, typename, size_t, size_t> class BTreeRootBase; @@ -28,23 +22,20 @@ template <typename KeyT, class BTreeNodeAllocator { public: - typedef BTreeInternalNode<KeyT, AggrT, INTERNAL_SLOTS> InternalNodeType; - typedef BTreeLeafNode<KeyT, DataT, AggrT, LEAF_SLOTS> LeafNodeType; - typedef typename InternalNodeType::RefPair InternalNodeTypeRefPair; - typedef typename LeafNodeType::RefPair LeafNodeTypeRefPair; - typedef BTreeRootBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS> - BTreeRootBaseType; - typedef vespalib::GenerationHandler::generation_t generation_t; - typedef BTreeNodeStore<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS> - NodeStore; + using InternalNodeType = BTreeInternalNode<KeyT, AggrT, INTERNAL_SLOTS>; + using LeafNodeType = BTreeLeafNode<KeyT, DataT, AggrT, LEAF_SLOTS>; + using InternalNodeTypeRefPair = typename InternalNodeType::RefPair; + using LeafNodeTypeRefPair = typename LeafNodeType::RefPair; + using BTreeRootBaseType = BTreeRootBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS>; + using generation_t = vespalib::GenerationHandler::generation_t; + using NodeStore = BTreeNodeStore<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS>; using EntryRef = datastore::EntryRef; using DataStoreBase = datastore::DataStoreBase; private: BTreeNodeAllocator(const BTreeNodeAllocator &rhs); - BTreeNodeAllocator & - operator=(const BTreeNodeAllocator &rhs); + BTreeNodeAllocator & operator=(const BTreeNodeAllocator &rhs); NodeStore _nodeStore; @@ -62,71 +53,54 @@ private: public: BTreeNodeAllocator(); - ~BTreeNodeAllocator(); - void - disableFreeLists() { + void disableFreeLists() { _nodeStore.disableFreeLists(); } - void - disableElemHoldList() - { + void disableElemHoldList() { _nodeStore.disableElemHoldList(); } /** * Allocate internal node. */ - InternalNodeTypeRefPair - allocInternalNode(uint8_t level); + InternalNodeTypeRefPair allocInternalNode(uint8_t level); /* * Allocate leaf node. */ - LeafNodeTypeRefPair - allocLeafNode(); - - InternalNodeTypeRefPair - thawNode(BTreeNode::Ref nodeRef, InternalNodeType *node); - - LeafNodeTypeRefPair - thawNode(BTreeNode::Ref nodeRef, LeafNodeType *node); - - BTreeNode::Ref - thawNode(BTreeNode::Ref node); + LeafNodeTypeRefPair allocLeafNode(); + InternalNodeTypeRefPair thawNode(BTreeNode::Ref nodeRef, InternalNodeType *node); + LeafNodeTypeRefPair thawNode(BTreeNode::Ref nodeRef, LeafNodeType *node); + BTreeNode::Ref thawNode(BTreeNode::Ref node); /** * hold internal node until freeze/generation constraint is satisfied. */ - void - holdNode(BTreeNode::Ref nodeRef, InternalNodeType *node); + void holdNode(BTreeNode::Ref nodeRef, InternalNodeType *node); /** * hold leaf node until freeze/generation constraint is satisfied. */ - void - holdNode(BTreeNode::Ref nodeRef, LeafNodeType *node); + void holdNode(BTreeNode::Ref nodeRef, LeafNodeType *node); /** * Mark that tree needs to be frozen. Tree must be kept alive until * freeze operation has completed. */ - void - needFreeze(BTreeRootBaseType *tree); + void needFreeze(BTreeRootBaseType *tree); /** * Freeze all nodes that are not already frozen. */ - void - freeze(); + void freeze(); /** * Try to free held nodes if nobody can be referencing them. */ - void - trimHoldLists(generation_t usedGen); + void trimHoldLists(generation_t usedGen); /** * Transfer nodes from hold1 lists to hold2 lists, they are no @@ -134,140 +108,89 @@ public: * older versions of the frozen structure must leave before elements * can be unheld. */ - void - transferHoldLists(generation_t generation); + void transferHoldLists(generation_t generation); - void - clearHoldLists(); + void clearHoldLists(); - static bool - isValidRef(BTreeNode::Ref ref) - { - return NodeStore::isValidRef(ref); - } + static bool isValidRef(BTreeNode::Ref ref) { return NodeStore::isValidRef(ref); } - bool - isLeafRef(BTreeNode::Ref ref) const - { + bool isLeafRef(BTreeNode::Ref ref) const { if (!isValidRef(ref)) return false; return _nodeStore.isLeafRef(ref); } - const InternalNodeType * - mapInternalRef(BTreeNode::Ref ref) const - { + const InternalNodeType *mapInternalRef(BTreeNode::Ref ref) const { return _nodeStore.mapInternalRef(ref); } - InternalNodeType * - mapInternalRef(BTreeNode::Ref ref) - { + InternalNodeType *mapInternalRef(BTreeNode::Ref ref) { return _nodeStore.mapInternalRef(ref); } - const LeafNodeType * - mapLeafRef(BTreeNode::Ref ref) const - { + const LeafNodeType *mapLeafRef(BTreeNode::Ref ref) const { return _nodeStore.mapLeafRef(ref); } - LeafNodeType * - mapLeafRef(BTreeNode::Ref ref) - { + LeafNodeType *mapLeafRef(BTreeNode::Ref ref) { return _nodeStore.mapLeafRef(ref); } template <typename NodeType> - const NodeType * - mapRef(BTreeNode::Ref ref) const - { + const NodeType *mapRef(BTreeNode::Ref ref) const { return _nodeStore.template mapRef<NodeType>(ref); } template <typename NodeType> - NodeType * - mapRef(BTreeNode::Ref ref) - { + NodeType *mapRef(BTreeNode::Ref ref) { return _nodeStore.template mapRef<NodeType>(ref); } - InternalNodeTypeRefPair - moveInternalNode(const InternalNodeType *node); - - LeafNodeTypeRefPair - moveLeafNode(const LeafNodeType *node); - - uint32_t - validLeaves(BTreeNode::Ref ref) const; + InternalNodeTypeRefPair moveInternalNode(const InternalNodeType *node); + LeafNodeTypeRefPair moveLeafNode(const LeafNodeType *node); + uint32_t validLeaves(BTreeNode::Ref ref) const; /* * Extract level from ref. */ - uint32_t - getLevel(BTreeNode::Ref ref) const; - - const KeyT & - getLastKey(BTreeNode::Ref node) const; - - const AggrT & - getAggregated(BTreeNode::Ref node) const; + uint32_t getLevel(BTreeNode::Ref ref) const; + const KeyT &getLastKey(BTreeNode::Ref node) const; + const AggrT &getAggregated(BTreeNode::Ref node) const; MemoryUsage getMemoryUsage() const; vespalib::string toString(BTreeNode::Ref ref) const; - vespalib::string toString(const BTreeNode * node) const; - bool - getCompacting(EntryRef ref) const - { - return _nodeStore.getCompacting(ref); - } - - std::vector<uint32_t> - startCompact() - { - return _nodeStore.startCompact(); - } + bool getCompacting(EntryRef ref) const { return _nodeStore.getCompacting(ref); } + std::vector<uint32_t> startCompact() { return _nodeStore.startCompact(); } - void - finishCompact(const std::vector<uint32_t> &toHold) - { + void finishCompact(const std::vector<uint32_t> &toHold) { return _nodeStore.finishCompact(toHold); } template <typename FunctionType> - void - foreach_key(EntryRef ref, FunctionType func) const - { + void foreach_key(EntryRef ref, FunctionType func) const { _nodeStore.foreach_key(ref, func); } template <typename FunctionType> - void - foreach(EntryRef ref, FunctionType func) const - { + void foreach(EntryRef ref, FunctionType func) const { _nodeStore.foreach(ref, func); } const NodeStore &getNodeStore() const { return _nodeStore; } }; -extern template class BTreeNodeAllocator<uint32_t, uint32_t, - NoAggregated, +extern template class BTreeNodeAllocator<uint32_t, uint32_t, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -extern template class BTreeNodeAllocator<uint32_t, BTreeNoLeafData, - NoAggregated, +extern template class BTreeNodeAllocator<uint32_t, BTreeNoLeafData, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -extern template class BTreeNodeAllocator<uint32_t, int32_t, - MinMaxAggregated, +extern template class BTreeNodeAllocator<uint32_t, int32_t, MinMaxAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -} // namespace btree - -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/btree/btreenodeallocator.hpp b/searchlib/src/vespa/searchlib/btree/btreenodeallocator.hpp index 4ea2035c73a..1a0df9e397b 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenodeallocator.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreenodeallocator.hpp @@ -8,8 +8,7 @@ #include <vespa/vespalib/util/array.hpp> #include "btreenodestore.hpp" -namespace search { -namespace btree { +namespace search::btree { template <typename KeyT, typename DataT, typename AggrT, size_t INTERNAL_SLOTS, size_t LEAF_SLOTS> @@ -432,7 +431,4 @@ toString(const BTreeNode * node) const return ss.str(); } - -} // namespace btree -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreenodestore.cpp b/searchlib/src/vespa/searchlib/btree/btreenodestore.cpp index 4408e59b610..bfb1e2fa6a1 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenodestore.cpp +++ b/searchlib/src/vespa/searchlib/btree/btreenodestore.cpp @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "btreenodestore.hpp" -#include "btreenode.h" #include "btreerootbase.h" #include "btreeroot.h" #include "btreenodeallocator.h" @@ -9,28 +8,14 @@ namespace search::btree { -template class BTreeNodeStore<uint32_t, uint32_t, - NoAggregated, +template class BTreeNodeStore<uint32_t, uint32_t, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -template class BTreeNodeStore<uint32_t, BTreeNoLeafData, - NoAggregated, +template class BTreeNodeStore<uint32_t, BTreeNoLeafData, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -template class BTreeNodeStore<uint32_t, int32_t, - MinMaxAggregated, +template class BTreeNodeStore<uint32_t, int32_t, MinMaxAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; - -typedef BTreeNodeStore<uint32_t, uint32_t, NoAggregated, - BTreeDefaultTraits::INTERNAL_SLOTS, - BTreeDefaultTraits::LEAF_SLOTS> MyNodeStore1; -typedef BTreeNodeStore<uint32_t, BTreeNoLeafData, NoAggregated, - BTreeDefaultTraits::INTERNAL_SLOTS, - BTreeDefaultTraits::LEAF_SLOTS> MyNodeStore2; -typedef BTreeNodeStore<uint32_t, int32_t, MinMaxAggregated, - BTreeDefaultTraits::INTERNAL_SLOTS, - BTreeDefaultTraits::LEAF_SLOTS> MyNodeStore3; - } diff --git a/searchlib/src/vespa/searchlib/btree/btreenodestore.h b/searchlib/src/vespa/searchlib/btree/btreenodestore.h index 7c818f30c00..00f5f5e8e70 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenodestore.h +++ b/searchlib/src/vespa/searchlib/btree/btreenodestore.h @@ -6,17 +6,12 @@ #include "btreetraits.h" #include <vespa/searchlib/datastore/datastore.h> -namespace search -{ - -namespace btree -{ +namespace search::btree { class BTreeNodeReclaimer { public: - static void reclaim(BTreeNode * node) - { + static void reclaim(BTreeNode * node) { node->unFreeze(); } }; @@ -30,18 +25,15 @@ class BTreeNodeBufferType : public datastore::BufferType<EntryType> using ParentType::_clusterSize; using CleanContext = typename ParentType::CleanContext; public: - BTreeNodeBufferType(uint32_t minClusters, - uint32_t maxClusters) + BTreeNodeBufferType(uint32_t minClusters, uint32_t maxClusters) : ParentType(1, minClusters, maxClusters) { _emptyEntry.freeze(); } - virtual void - initializeReservedElements(void *buffer, size_t reservedElements) override; + void initializeReservedElements(void *buffer, size_t reservedElements) override; - virtual void - cleanHold(void *buffer, uint64_t offset, uint64_t len, CleanContext cleanCtx) override; + void cleanHold(void *buffer, uint64_t offset, uint64_t len, CleanContext cleanCtx) override; }; @@ -80,141 +72,93 @@ public: ~BTreeNodeStore(); - void - disableFreeLists() { - _store.disableFreeLists(); - } + void disableFreeLists() { _store.disableFreeLists(); } + void disableElemHoldList() { _store.disableElemHoldList(); } - void - disableElemHoldList() - { - _store.disableElemHoldList(); - } + static bool isValidRef(EntryRef ref) { return ref.valid(); } - static bool - isValidRef(EntryRef ref) - { - return ref.valid(); - } - - bool - isLeafRef(EntryRef ref) const - { + bool isLeafRef(EntryRef ref) const { RefType iRef(ref); return _store.getTypeId(iRef.bufferId()) == NODETYPE_LEAF; } - const InternalNodeType * - mapInternalRef(EntryRef ref) const - { + const InternalNodeType *mapInternalRef(EntryRef ref) const { RefType iRef(ref); - return _store.getBufferEntry<InternalNodeType>(iRef.bufferId(), - iRef.offset()); + return _store.getBufferEntry<InternalNodeType>(iRef.bufferId(), iRef.offset()); } - InternalNodeType * - mapInternalRef(EntryRef ref) - { + InternalNodeType *mapInternalRef(EntryRef ref) { RefType iRef(ref); - return _store.getBufferEntry<InternalNodeType>(iRef.bufferId(), - iRef.offset()); + return _store.getBufferEntry<InternalNodeType>(iRef.bufferId(), iRef.offset()); } - const LeafNodeType * - mapLeafRef(EntryRef ref) const - { + const LeafNodeType *mapLeafRef(EntryRef ref) const { RefType iRef(ref); - return _store.getBufferEntry<LeafNodeType>(iRef.bufferId(), - iRef.offset()); + return _store.getBufferEntry<LeafNodeType>(iRef.bufferId(), iRef.offset()); } - LeafNodeType * - mapLeafRef(EntryRef ref) - { + LeafNodeType *mapLeafRef(EntryRef ref) { RefType iRef(ref); - return _store.getBufferEntry<LeafNodeType>(iRef.bufferId(), - iRef.offset()); + return _store.getBufferEntry<LeafNodeType>(iRef.bufferId(), iRef.offset()); } template <typename NodeType> - const NodeType * - mapRef(EntryRef ref) const - { + const NodeType *mapRef(EntryRef ref) const { RefType iRef(ref); - return _store.getBufferEntry<NodeType>(iRef.bufferId(), - iRef.offset()); + return _store.getBufferEntry<NodeType>(iRef.bufferId(), iRef.offset()); } template <typename NodeType> - NodeType * - mapRef(EntryRef ref) - { + NodeType *mapRef(EntryRef ref) { RefType iRef(ref); - return _store.getBufferEntry<NodeType>(iRef.bufferId(), - iRef.offset()); + return _store.getBufferEntry<NodeType>(iRef.bufferId(), iRef.offset()); } - LeafNodeTypeRefPair - allocNewLeafNode() { + LeafNodeTypeRefPair allocNewLeafNode() { return _store.allocator<LeafNodeType>(NODETYPE_LEAF).alloc(); } - LeafNodeTypeRefPair - allocLeafNode() { + LeafNodeTypeRefPair allocLeafNode() { return _store.freeListAllocator<LeafNodeType, BTreeNodeReclaimer>(NODETYPE_LEAF).alloc(); } - LeafNodeTypeRefPair - allocNewLeafNodeCopy(const LeafNodeType &rhs) { + LeafNodeTypeRefPair allocNewLeafNodeCopy(const LeafNodeType &rhs) { return _store.allocator<LeafNodeType>(NODETYPE_LEAF).alloc(rhs); } - LeafNodeTypeRefPair - allocLeafNodeCopy(const LeafNodeType &rhs) { + LeafNodeTypeRefPair allocLeafNodeCopy(const LeafNodeType &rhs) { return _store.freeListAllocator<LeafNodeType, BTreeNodeReclaimer>(NODETYPE_LEAF).alloc(rhs); } - InternalNodeTypeRefPair - allocNewInternalNode() { + InternalNodeTypeRefPair allocNewInternalNode() { return _store.allocator<InternalNodeType>(NODETYPE_INTERNAL).alloc(); } - InternalNodeTypeRefPair - allocInternalNode() { + InternalNodeTypeRefPair allocInternalNode() { return _store.freeListAllocator<InternalNodeType, BTreeNodeReclaimer>(NODETYPE_INTERNAL).alloc(); } - InternalNodeTypeRefPair - allocNewInternalNodeCopy(const InternalNodeType &rhs) { + InternalNodeTypeRefPair allocNewInternalNodeCopy(const InternalNodeType &rhs) { return _store.allocator<InternalNodeType>(NODETYPE_INTERNAL).alloc(rhs); } - InternalNodeTypeRefPair - allocInternalNodeCopy(const InternalNodeType &rhs) { + InternalNodeTypeRefPair allocInternalNodeCopy(const InternalNodeType &rhs) { return _store.freeListAllocator<InternalNodeType, BTreeNodeReclaimer>(NODETYPE_INTERNAL).alloc(rhs); } - void - holdElem(EntryRef ref) - { + void holdElem(EntryRef ref) { _store.holdElem(ref, 1); } - void - freeElem(EntryRef ref) - { + void freeElem(EntryRef ref) { _store.freeElem(ref, 1); } - std::vector<uint32_t> - startCompact(); + std::vector<uint32_t> startCompact(); - void - finishCompact(const std::vector<uint32_t> &toHold); + void finishCompact(const std::vector<uint32_t> &toHold); - void - transferHoldLists(generation_t generation) - { + void transferHoldLists(generation_t generation) { _store.transferHoldLists(generation); } @@ -224,15 +168,11 @@ public: } // Inherit doc from DataStoreBase - void - trimHoldLists(generation_t usedGen) - { + void trimHoldLists(generation_t usedGen) { _store.trimHoldLists(usedGen); } - void - clearHoldLists() - { + void clearHoldLists() { _store.clearHoldLists(); } @@ -247,9 +187,7 @@ public: } template <typename FunctionType> - void - foreach_key(EntryRef ref, FunctionType func) const - { + void foreach_key(EntryRef ref, FunctionType func) const { if (!ref.valid()) return; if (isLeafRef(ref)) { @@ -260,9 +198,7 @@ public: } template <typename FunctionType> - void - foreach(EntryRef ref, FunctionType func) const - { + void foreach(EntryRef ref, FunctionType func) const { if (!ref.valid()) return; if (isLeafRef(ref)) { @@ -273,20 +209,14 @@ public: } }; -extern template class BTreeNodeStore<uint32_t, uint32_t, - NoAggregated, +extern template class BTreeNodeStore<uint32_t, uint32_t, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -extern template class BTreeNodeStore<uint32_t, BTreeNoLeafData, - NoAggregated, +extern template class BTreeNodeStore<uint32_t, BTreeNoLeafData, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -extern template class BTreeNodeStore<uint32_t, int32_t, - MinMaxAggregated, +extern template class BTreeNodeStore<uint32_t, int32_t, MinMaxAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -} // namespace btree - -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreenodestore.hpp b/searchlib/src/vespa/searchlib/btree/btreenodestore.hpp index 2d16ecece8a..d005e9d7e3a 100644 --- a/searchlib/src/vespa/searchlib/btree/btreenodestore.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreenodestore.hpp @@ -5,11 +5,7 @@ #include "btreenodestore.h" #include <vespa/searchlib/datastore/datastore.hpp> -namespace search -{ - -namespace btree -{ +namespace search::btree { template <typename EntryType> void @@ -26,10 +22,7 @@ BTreeNodeBufferType<EntryType>::initializeReservedElements(void *buffer, size_t template <typename EntryType> void -BTreeNodeBufferType<EntryType>::cleanHold(void *buffer, - uint64_t offset, - uint64_t len, - CleanContext) +BTreeNodeBufferType<EntryType>::cleanHold(void *buffer, uint64_t offset, uint64_t len, CleanContext) { EntryType *e = static_cast<EntryType *>(buffer) + offset; for (size_t j = len; j != 0; --j) { @@ -70,14 +63,10 @@ std::vector<uint32_t> BTreeNodeStore<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS>:: startCompact() { - std::vector<uint32_t> iToHold = - _store.startCompact(NODETYPE_INTERNAL); - std::vector<uint32_t> lToHold = - _store.startCompact(NODETYPE_LEAF); + std::vector<uint32_t> iToHold = _store.startCompact(NODETYPE_INTERNAL); + std::vector<uint32_t> lToHold = _store.startCompact(NODETYPE_LEAF); std::vector<uint32_t> ret = iToHold; - for (std::vector<uint32_t>::const_iterator - i = lToHold.begin(), ie = lToHold.end(); i != ie; ++i) - ret.push_back(*i); + ret.insert(ret.end(), lToHold.begin(), lToHold.end()); return ret; } @@ -91,9 +80,4 @@ finishCompact(const std::vector<uint32_t> &toHold) _store.finishCompact(toHold); } - -} // namespace btree - -} // namespace search - - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreeroot.cpp b/searchlib/src/vespa/searchlib/btree/btreeroot.cpp index 60c44f7973e..a576b6ce1e0 100644 --- a/searchlib/src/vespa/searchlib/btree/btreeroot.cpp +++ b/searchlib/src/vespa/searchlib/btree/btreeroot.cpp @@ -6,9 +6,6 @@ #include "btreeroot.hpp" #include "btreenode.hpp" -#include <vespa/log/log.h> -LOG_SETUP(".searchlib.btree.btreeroot"); - namespace search::btree { template class BTreeRootT<uint32_t, uint32_t, NoAggregated>; @@ -16,8 +13,6 @@ template class BTreeRootT<uint32_t, BTreeNoLeafData, NoAggregated>; template class BTreeRootT<uint32_t, int32_t, MinMaxAggregated>; template class BTreeRoot<uint32_t, uint32_t, NoAggregated>; template class BTreeRoot<uint32_t, BTreeNoLeafData, NoAggregated>; -template class BTreeRoot<uint32_t, int32_t, MinMaxAggregated, - std::less<uint32_t>, - BTreeDefaultTraits, MinMaxAggrCalc>; +template class BTreeRoot<uint32_t, int32_t, MinMaxAggregated, std::less<uint32_t>, BTreeDefaultTraits, MinMaxAggrCalc>; } diff --git a/searchlib/src/vespa/searchlib/btree/btreeroot.h b/searchlib/src/vespa/searchlib/btree/btreeroot.h index 86dd47ca5fa..b5759a6a341 100644 --- a/searchlib/src/vespa/searchlib/btree/btreeroot.h +++ b/searchlib/src/vespa/searchlib/btree/btreeroot.h @@ -9,8 +9,7 @@ #include "noaggrcalc.h" #include "minmaxaggrcalc.h" -namespace search { -namespace btree { +namespace search::btree { template <typename, typename, typename, size_t, size_t> class BTreeNodeAllocator; @@ -80,30 +79,17 @@ public: where.emplace_back(_frozenRoot, _allocator); } - BTreeNode::Ref - getRoot() const - { - return _frozenRoot; - } - - size_t - size() const; - - const NodeAllocatorType & - getAllocator() const - { - return _allocator; - } + BTreeNode::Ref getRoot() const { return _frozenRoot; } + size_t size() const; + const NodeAllocatorType &getAllocator() const { return _allocator; } template <typename FunctionType> - void - foreach_key(FunctionType func) const { + void foreach_key(FunctionType func) const { _allocator.getNodeStore().foreach_key(_frozenRoot, func); } template <typename FunctionType> - void - foreach(FunctionType func) const { + void foreach(FunctionType func) const { _allocator.getNodeStore().foreach(_frozenRoot, func); } }; @@ -123,20 +109,12 @@ public: BTreeRootT(); ~BTreeRootT(); - void - clear(NodeAllocatorType &allocator); - - Iterator - find(const KeyType & key, const NodeAllocatorType &allocator, - CompareT comp = CompareT()) const; + void clear(NodeAllocatorType &allocator); - Iterator - lowerBound(const KeyType & key, const NodeAllocatorType & allocator, - CompareT comp = CompareT()) const; + Iterator find(const KeyType & key, const NodeAllocatorType &allocator, CompareT comp = CompareT()) const; - Iterator - upperBound(const KeyType & key, const NodeAllocatorType & allocator, - CompareT comp = CompareT()) const; + Iterator lowerBound(const KeyType & key, const NodeAllocatorType & allocator, CompareT comp = CompareT()) const; + Iterator upperBound(const KeyType & key, const NodeAllocatorType & allocator, CompareT comp = CompareT()) const; Iterator begin(const NodeAllocatorType &allocator) const { return Iterator(_root, allocator); @@ -146,22 +124,12 @@ public: return FrozenView(getFrozenRoot(), allocator); } - size_t - size(const NodeAllocatorType &allocator) const; - - size_t - frozenSize(const NodeAllocatorType &allocator) const; - + size_t size(const NodeAllocatorType &allocator) const; + size_t frozenSize(const NodeAllocatorType &allocator) const; vespalib::string toString(const NodeAllocatorType &allocator) const; - - size_t - bitSize(const NodeAllocatorType &allocator) const; - - size_t - bitSize(BTreeNode::Ref node, const NodeAllocatorType &allocator) const; - - void - thaw(Iterator &itr); + size_t bitSize(const NodeAllocatorType &allocator) const; + size_t bitSize(BTreeNode::Ref node, const NodeAllocatorType &allocator) const; + void thaw(Iterator &itr); }; @@ -244,9 +212,6 @@ extern template class BTreeRootT<uint32_t, int32_t, MinMaxAggregated>; extern template class BTreeRoot<uint32_t, uint32_t, NoAggregated>; extern template class BTreeRoot<uint32_t, BTreeNoLeafData, NoAggregated>; extern template class BTreeRoot<uint32_t, int32_t, MinMaxAggregated, - std::less<uint32_t>, - BTreeDefaultTraits, MinMaxAggrCalc>; - -} // namespace search::btree -} // namespace search + std::less<uint32_t>, BTreeDefaultTraits, MinMaxAggrCalc>; +} diff --git a/searchlib/src/vespa/searchlib/btree/btreeroot.hpp b/searchlib/src/vespa/searchlib/btree/btreeroot.hpp index 365a52aa8de..22703f2dfd2 100644 --- a/searchlib/src/vespa/searchlib/btree/btreeroot.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreeroot.hpp @@ -10,8 +10,7 @@ #include "btreeaggregator.hpp" #include <vespa/vespalib/stllike/asciistream.h> -namespace search { -namespace btree { +namespace search::btree { //----------------------- BTreeRoot ------------------------------------------// @@ -235,16 +234,11 @@ FrozenView::size() const template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT> -BTreeRootT<KeyT, DataT, AggrT, CompareT, TraitsT>::BTreeRootT() - : ParentType() -{ -} +BTreeRootT<KeyT, DataT, AggrT, CompareT, TraitsT>::BTreeRootT() = default; template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT> -BTreeRootT<KeyT, DataT, AggrT, CompareT, TraitsT>::~BTreeRootT() -{ -} +BTreeRootT<KeyT, DataT, AggrT, CompareT, TraitsT>::~BTreeRootT() = default; template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT> @@ -492,7 +486,4 @@ remove(Iterator &itr, itr.getAllocator().needFreeze(this); } - -} // namespace search::btree -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreerootbase.cpp b/searchlib/src/vespa/searchlib/btree/btreerootbase.cpp index 311cc3adf37..12394761bf9 100644 --- a/searchlib/src/vespa/searchlib/btree/btreerootbase.cpp +++ b/searchlib/src/vespa/searchlib/btree/btreerootbase.cpp @@ -3,24 +3,16 @@ #include "btreerootbase.h" #include "btreerootbase.hpp" -namespace search -{ +namespace search::btree { -namespace btree -{ - -template class BTreeRootBase<uint32_t, uint32_t, - NoAggregated, +template class BTreeRootBase<uint32_t, uint32_t, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -template class BTreeRootBase<uint32_t, BTreeNoLeafData, - NoAggregated, +template class BTreeRootBase<uint32_t, BTreeNoLeafData, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -template class BTreeRootBase<uint32_t, int32_t, - MinMaxAggregated, +template class BTreeRootBase<uint32_t, int32_t, MinMaxAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -} // namespace btree -} // namespace search +} diff --git a/searchlib/src/vespa/searchlib/btree/btreerootbase.h b/searchlib/src/vespa/searchlib/btree/btreerootbase.h index 124928ba708..ed4889214ca 100644 --- a/searchlib/src/vespa/searchlib/btree/btreerootbase.h +++ b/searchlib/src/vespa/searchlib/btree/btreerootbase.h @@ -7,8 +7,7 @@ #include "btreenodeallocator.h" #include <atomic> -namespace search { -namespace btree { +namespace search::btree { template <typename KeyT, typename DataT, @@ -35,87 +34,62 @@ protected: "BTree root reference size mismatch"); BTreeRootBase(); - BTreeRootBase(const BTreeRootBase &rhs); - BTreeRootBase &operator=(const BTreeRootBase &rhs); - ~BTreeRootBase(); public: - void - freeze(NodeAllocatorType &allocator); + void freeze(NodeAllocatorType &allocator); bool isFrozen() const { return (_root.ref() == _frozenRoot.load(std::memory_order_relaxed)); } - void - setRoot(BTreeNode::Ref newRoot, NodeAllocatorType &allocator) - { + void setRoot(BTreeNode::Ref newRoot, NodeAllocatorType &allocator) { bool oldFrozen = isFrozen(); _root = newRoot; if (oldFrozen && !isFrozen()) allocator.needFreeze(this); } - void - setRoots(BTreeNode::Ref newRoot) - { + void setRoots(BTreeNode::Ref newRoot) { _root = newRoot; _frozenRoot = newRoot.ref(); } - BTreeNode::Ref - getRoot() const - { + BTreeNode::Ref getRoot() const { return _root; } - BTreeNode::Ref - getFrozenRoot() const - { + BTreeNode::Ref getFrozenRoot() const { return BTreeNode::Ref(_frozenRoot.load(std::memory_order_acquire)); } - BTreeNode::Ref - getFrozenRootRelaxed() const - { + BTreeNode::Ref getFrozenRootRelaxed() const { return BTreeNode::Ref(_frozenRoot.load(std::memory_order_relaxed)); } - const AggrT & - getAggregated(const NodeAllocatorType &allocator) const - { + const AggrT &getAggregated(const NodeAllocatorType &allocator) const { return allocator.getAggregated(_root); } - void - recycle() - { + void recycle() { _root = BTreeNode::Ref(); _frozenRoot = BTreeNode::Ref().ref(); } protected: - void - recursiveDelete(BTreeNode::Ref node, NodeAllocatorType &allocator); + void recursiveDelete(BTreeNode::Ref node, NodeAllocatorType &allocator); }; -extern template class BTreeRootBase<uint32_t, uint32_t, - NoAggregated, +extern template class BTreeRootBase<uint32_t, uint32_t, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -extern template class BTreeRootBase<uint32_t, BTreeNoLeafData, - NoAggregated, +extern template class BTreeRootBase<uint32_t, BTreeNoLeafData, NoAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -extern template class BTreeRootBase<uint32_t, int32_t, - MinMaxAggregated, +extern template class BTreeRootBase<uint32_t, int32_t, MinMaxAggregated, BTreeDefaultTraits::INTERNAL_SLOTS, BTreeDefaultTraits::LEAF_SLOTS>; -} // namespace btree -} // namespace search - - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreerootbase.hpp b/searchlib/src/vespa/searchlib/btree/btreerootbase.hpp index 238dad266c5..0b4ef18aad9 100644 --- a/searchlib/src/vespa/searchlib/btree/btreerootbase.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreerootbase.hpp @@ -4,9 +4,7 @@ #include "btreerootbase.h" -namespace search { -namespace btree { - +namespace search::btree { template <typename KeyT, typename DataT, typename AggrT, size_t INTERNAL_SLOTS, size_t LEAF_SLOTS> @@ -70,8 +68,7 @@ template <typename KeyT, typename DataT, typename AggrT, size_t INTERNAL_SLOTS, size_t LEAF_SLOTS> void BTreeRootBase<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS>:: -recursiveDelete(BTreeNode::Ref node, - NodeAllocatorType &allocator) +recursiveDelete(BTreeNode::Ref node, NodeAllocatorType &allocator) { assert(allocator.isValidRef(node)); if (!allocator.isLeafRef(node)) { @@ -85,6 +82,4 @@ recursiveDelete(BTreeNode::Ref node, } } -} // namespace btree -} // namespace search - +} diff --git a/searchlib/src/vespa/searchlib/btree/btreestore.cpp b/searchlib/src/vespa/searchlib/btree/btreestore.cpp index 4467aad15d5..bead11295b3 100644 --- a/searchlib/src/vespa/searchlib/btree/btreestore.cpp +++ b/searchlib/src/vespa/searchlib/btree/btreestore.cpp @@ -4,25 +4,10 @@ #include "btreestore.hpp" #include "btreeiterator.hpp" -#include <vespa/log/log.h> -LOG_SETUP(".searchlib.btree.breestore"); - namespace search::btree { -template class BTreeStore<uint32_t, uint32_t, - NoAggregated, - std::less<uint32_t>, - BTreeDefaultTraits>; - -template class BTreeStore<uint32_t, BTreeNoLeafData, - NoAggregated, - std::less<uint32_t>, - BTreeDefaultTraits>; - -template class BTreeStore<uint32_t, int32_t, - MinMaxAggregated, - std::less<uint32_t>, - BTreeDefaultTraits, - MinMaxAggrCalc>; +template class BTreeStore<uint32_t, uint32_t, NoAggregated, std::less<uint32_t>, BTreeDefaultTraits>; +template class BTreeStore<uint32_t, BTreeNoLeafData, NoAggregated, std::less<uint32_t>, BTreeDefaultTraits>; +template class BTreeStore<uint32_t, int32_t, MinMaxAggregated, std::less<uint32_t>, BTreeDefaultTraits, MinMaxAggrCalc>; } diff --git a/searchlib/src/vespa/searchlib/btree/btreestore.hpp b/searchlib/src/vespa/searchlib/btree/btreestore.hpp index f97a647287f..b4d82a9e31a 100644 --- a/searchlib/src/vespa/searchlib/btree/btreestore.hpp +++ b/searchlib/src/vespa/searchlib/btree/btreestore.hpp @@ -3,16 +3,12 @@ #pragma once #include "btreestore.h" -#include <vespa/searchlib/bitcompression/compression.h> #include "btreebuilder.h" #include "btreebuilder.hpp" #include <vespa/searchlib/datastore/datastore.hpp> +#include <vespa/searchlib/bitcompression/compression.h> -namespace search -{ - -namespace btree -{ +namespace search::btree { template <typename KeyT, typename DataT, typename AggrT, typename CompareT, typename TraitsT, typename AggrCalcT> @@ -958,8 +954,4 @@ getAggregated(const EntryRef ref) const return a; } -} // namespace btree - -} // namespace search - - +} |