aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/datastore/compacting_buffers.cpp
blob: e350ef5056e3411c94864ecdfec775e3014cfe39 (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
37
38
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "compacting_buffers.h"
#include "datastorebase.h"
#include "entry_ref_filter.h"
#include <cassert>

namespace vespalib::datastore {

CompactingBuffers::CompactingBuffers(DataStoreBase& store, uint32_t num_buffers, uint32_t offset_bits, std::vector<uint32_t> buffer_ids)
    : _store(store),
      _num_buffers(num_buffers),
      _offset_bits(offset_bits),
      _buffer_ids(std::move(buffer_ids))
{
}

CompactingBuffers::~CompactingBuffers()
{
    assert(_buffer_ids.empty());
}

void
CompactingBuffers::finish()
{
    _store.finishCompact(_buffer_ids);
    _buffer_ids.clear();
}

EntryRefFilter
CompactingBuffers::make_entry_ref_filter() const
{
    EntryRefFilter filter(_num_buffers, _offset_bits);
    filter.add_buffers(_buffer_ids);
    return filter;
}

}