1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "btreenode.h"
#include "btreenodeallocator.h"
#include "btreerootbase.h"
#include "btreeaggregator.h"
#include "noaggrcalc.h"
#include "minmaxaggrcalc.h"
#include "btreeiterator.h"
namespace vespalib::btree {
template <typename KeyT,
typename DataT,
typename AggrT,
size_t INTERNAL_SLOTS,
size_t LEAF_SLOTS,
class AggrCalcT>
class BTreeRemoverBase
{
public:
using NodeAllocatorType = BTreeNodeAllocator<KeyT, DataT, AggrT,
INTERNAL_SLOTS,
LEAF_SLOTS>;
using Aggregator = BTreeAggregator<KeyT, DataT, AggrT,
INTERNAL_SLOTS,
LEAF_SLOTS,
AggrCalcT>;
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;
template <typename NodeType, typename NodeTypeRefPair,
class Iterator>
static void
steal(InternalNodeType *pNode,
BTreeNode::Ref sNodeRef,
NodeType *sNode,
uint32_t idx,
NodeAllocatorType &allocator,
const AggrCalcT &aggrCalc,
Iterator &itr,
uint32_t level);
};
template <typename KeyT,
typename DataT,
typename AggrT,
typename CompareT = std::less<KeyT>,
typename TraitsT = BTreeDefaultTraits,
class AggrCalcT = NoAggrCalc>
class BTreeRemover : public BTreeRemoverBase<KeyT, DataT, AggrT,
TraitsT::INTERNAL_SLOTS,
TraitsT::LEAF_SLOTS,
AggrCalcT>
{
public:
using ParentType = BTreeRemoverBase<KeyT, DataT, AggrT,
TraitsT::INTERNAL_SLOTS,
TraitsT::LEAF_SLOTS,
AggrCalcT>;
using NodeAllocatorType = BTreeNodeAllocator<KeyT, DataT, AggrT,
TraitsT::INTERNAL_SLOTS,
TraitsT::LEAF_SLOTS>;
using Aggregator = BTreeAggregator<KeyT, DataT, AggrT,
TraitsT::INTERNAL_SLOTS,
TraitsT::LEAF_SLOTS,
AggrCalcT>;
using InternalNodeType = BTreeInternalNode<KeyT, AggrT, TraitsT::INTERNAL_SLOTS>;
using LeafNodeType = BTreeLeafNode<KeyT, DataT, AggrT, TraitsT::LEAF_SLOTS>;
using KeyType = KeyT;
using DataType = DataT;
using InternalNodeTypeRefPair = typename InternalNodeType::RefPair;
using LeafNodeTypeRefPair = typename LeafNodeType::RefPair;
using Iterator = BTreeIterator<KeyT, DataT, AggrT, CompareT, TraitsT>;
static void
remove(BTreeNode::Ref &root, Iterator &itr, const AggrCalcT &aggrCalc);
};
extern template class BTreeRemover<uint32_t, uint32_t, NoAggregated>;
extern template class BTreeRemover<uint32_t, BTreeNoLeafData, NoAggregated>;
extern template class BTreeRemover<uint32_t, int32_t, MinMaxAggregated,
std::less<uint32_t>, BTreeDefaultTraits, MinMaxAggrCalc>;
}
|