-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTermPack.h
More file actions
78 lines (59 loc) · 2.24 KB
/
Copy pathTermPack.h
File metadata and controls
78 lines (59 loc) · 2.24 KB
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
#ifndef UPDATE_LITE_TERMPACK_H
#define UPDATE_LITE_TERMPACK_H
#include <cstdint>
#include <vector>
#include <cassert>
#include "Consolidation.h"
namespace IndexUpdate {
class TermPack {
unsigned tpId;
unsigned tpMembersCount;
uint64_t tpEpochUpdates;
uint64_t tpEpochQueries;
uint64_t tpNormalizedUpdates;
uint64_t tpUBPostings;
uint64_t tpEvictedPostings;
uint64_t tpExtraSeeks;
uint64_t tpTokens;
std::vector<uint64_t> tpSegments;
public:
TermPack(unsigned id=0, unsigned members=0, uint64_t upd=0, uint64_t qs=0 )
: tpId(id),tpMembersCount(members),
tpEpochUpdates(upd),tpEpochQueries(qs),
tpUBPostings(0), tpEvictedPostings(0),
tpExtraSeeks(0),tpTokens(0.0)
{}
uint64_t addUBPostings() {
assert(tpNormalizedUpdates);
tpUBPostings += tpNormalizedUpdates;
return tpNormalizedUpdates;
}
uint64_t evictAll() {
auto evicted = tpUBPostings;
tpEvictedPostings += evicted;
tpUBPostings = 0;
return evicted;
}
std::vector<uint64_t>& unsafeGetSegments() { return tpSegments; }
const std::vector<uint64_t>& segments() const { return tpSegments; }
uint64_t updates() const { return tpEpochUpdates; }
uint64_t members() const { return tpMembersCount; }
uint64_t extraSeeks() const { return tpExtraSeeks; }
double convertSeeksToTokens(double tokens) {
tpExtraSeeks = 0;
tpTokens += tokens;
return tpTokens;
}
void reduceTokens(double tokens) { tpTokens -= tokens;}
ReadIO query() {
if(tpSegments.empty()) //what do you know, no evictions
return ReadIO(0,0);
tpExtraSeeks += tpSegments.size()-1;
return ReadIO(meanDiskLength(), tpSegments.size());
};
uint64_t meanDiskLength() const { return tpEvictedPostings/tpMembersCount; }
static void normalizeUpdates(std::vector<TermPack> &tpacks, double reduceTo = 1<<14);
};
bool operator<(const TermPack& a,const TermPack& b);
}
#endif //UPDATE_LITE_TERMPACK_H