blob: 65e028119a247e798628d33e83fc041fbd7d5cd7 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "compaction_context.h"
#include "compacting_buffers.h"
#include "i_compactable.h"
namespace vespalib::datastore {
CompactionContext::CompactionContext(ICompactable& store,
std::unique_ptr<CompactingBuffers> compacting_buffers)
: _store(store),
_compacting_buffers(std::move(compacting_buffers)),
_filter(_compacting_buffers->make_entry_ref_filter())
{
}
CompactionContext::~CompactionContext()
{
_compacting_buffers->finish();
}
void
CompactionContext::compact(vespalib::ArrayRef<AtomicEntryRef> refs)
{
for (auto &atomic_entry_ref : refs) {
auto ref = atomic_entry_ref.load_relaxed();
if (ref.valid() && _filter.has(ref)) {
EntryRef newRef = _store.move(ref);
atomic_entry_ref.store_release(newRef);
}
}
}
}
|