]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:nil -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #pragma once | |
5 | ||
6 | #include "include/buffer.h" | |
7 | #include "node_types.h" | |
20effc67 | 8 | #include "value.h" |
f67539c2 TL |
9 | |
10 | namespace crimson::os::seastore::onode { | |
11 | ||
12 | /** | |
13 | * DeltaRecorder | |
14 | * | |
15 | * An abstracted class to encapsulate different implementations to apply delta | |
16 | * to a specific node layout. | |
17 | */ | |
18 | class DeltaRecorder { | |
19 | public: | |
20 | virtual ~DeltaRecorder() { | |
20effc67 TL |
21 | /* May be non-empty if transaction is abandoned without |
22 | * being submitted -- conflicts are a particularly common | |
23 | * example (denoted generally by returning crimson::ct_error::eagain). | |
24 | */ | |
f67539c2 TL |
25 | } |
26 | ||
27 | bool is_empty() const { | |
28 | return encoded.length() == 0; | |
29 | } | |
30 | ||
31 | ceph::bufferlist get_delta() { | |
f67539c2 TL |
32 | return std::move(encoded); |
33 | } | |
34 | ||
20effc67 TL |
35 | ValueDeltaRecorder* get_value_recorder() const { |
36 | assert(value_recorder); | |
37 | return value_recorder.get(); | |
38 | } | |
39 | ||
f67539c2 TL |
40 | virtual node_type_t node_type() const = 0; |
41 | virtual field_type_t field_type() const = 0; | |
42 | virtual void apply_delta(ceph::bufferlist::const_iterator&, | |
20effc67 TL |
43 | NodeExtentMutable&, |
44 | const NodeExtent&) = 0; | |
f67539c2 TL |
45 | |
46 | protected: | |
47 | DeltaRecorder() = default; | |
20effc67 TL |
48 | DeltaRecorder(const ValueBuilder& vb) |
49 | : value_recorder{vb.build_value_recorder(encoded)} {} | |
50 | ||
f67539c2 | 51 | ceph::bufferlist encoded; |
20effc67 | 52 | std::unique_ptr<ValueDeltaRecorder> value_recorder; |
f67539c2 TL |
53 | }; |
54 | ||
55 | } |