aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/btree/btree.hpp
blob: 0d0337cd00a1bc9a972344863777936b0d2d4130 (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "btree.h"

namespace vespalib::btree {

template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
          typename TraitsT, class AggrCalcT>
BTree<KeyT, DataT, AggrT, CompareT, TraitsT, AggrCalcT>::BTree()
    : _alloc(),
      _tree()
{
}

template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
          typename TraitsT, class AggrCalcT>
BTree<KeyT, DataT, AggrT, CompareT, TraitsT, AggrCalcT>::~BTree()
{
    clear();
    _alloc.freeze();
    _alloc.reclaim_all_memory();
}

template <typename KeyT, typename DataT, typename AggrT, typename CompareT,
          typename TraitsT, class AggrCalcT>
void
BTree<KeyT, DataT, AggrT, CompareT, TraitsT, AggrCalcT>::compact_worst(const datastore::CompactionStrategy& compaction_strategy)
{
    auto compacting_buffers = _alloc.start_compact_worst(compaction_strategy);
    _tree.move_nodes(_alloc);
    compacting_buffers->finish();
}

}