blob: 5fcb719aee2592e143392114640f5df1dd7d10a1 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/document/bucket/bucketid.h>
#include <vespa/storageapi/defs.h>
#include <iosfwd>
#include <stddef.h>
namespace storage::distributor {
/*
* Tracks the information required to identify the location of the newest replica
* for any given document. Newest here means the replica containing the document
* version with the highest mutation timestamp.
*/
struct NewestReplica {
api::Timestamp timestamp {0};
document::BucketId bucket_id;
uint16_t node {UINT16_MAX};
bool is_tombstone {false};
static NewestReplica of(api::Timestamp timestamp,
const document::BucketId& bucket_id,
uint16_t node,
bool is_tombstone) noexcept {
return {timestamp, bucket_id, node, is_tombstone};
}
static NewestReplica make_empty() {
return {api::Timestamp(0), document::BucketId(), 0, false};
}
bool operator==(const NewestReplica& rhs) const noexcept {
return ((timestamp == rhs.timestamp) &&
(bucket_id == rhs.bucket_id) &&
(node == rhs.node) &&
(is_tombstone == rhs.is_tombstone));
}
bool operator!=(const NewestReplica& rhs) const noexcept {
return !(*this == rhs);
}
};
std::ostream& operator<<(std::ostream&, const NewestReplica&);
}
|