blob: c77def95edb8b8ee2df398f1c96507ed627434a9 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "lidreusedelayer.h"
#include "i_store.h"
#include <vespa/searchcorespi/index/ithreadingservice.h>
namespace proton::documentmetastore {
using searchcorespi::index::IThreadingService;
LidReuseDelayer::LidReuseDelayer(IThreadingService &writeService, IStore &documentMetaStore)
: _writeService(writeService),
_documentMetaStore(documentMetaStore),
_pendingLids()
{
}
LidReuseDelayer::~LidReuseDelayer() {
assert(_pendingLids.empty());
}
void
LidReuseDelayer::delayReuse(uint32_t lid)
{
assert(_writeService.master().isCurrentThread());
if (_documentMetaStore.getFreeListActive()) {
_pendingLids.push_back(lid);
}
}
void
LidReuseDelayer::delayReuse(const std::vector<uint32_t> &lids)
{
assert(_writeService.master().isCurrentThread());
if (_documentMetaStore.getFreeListActive() && !lids.empty()) {
_pendingLids.insert(_pendingLids.end(), lids.cbegin(), lids.cend());
}
}
std::vector<uint32_t>
LidReuseDelayer::getReuseLids()
{
std::vector<uint32_t> result;
assert(_writeService.master().isCurrentThread());
result = _pendingLids;
_pendingLids.clear();
return result;
}
}
|