1 | /* |
2 | * record_ce.c |
3 | * |
4 | * Copyright (C) 2016 Aerospike, Inc. |
5 | * |
6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
7 | * license agreements. |
8 | * |
9 | * This program is free software: you can redistribute it and/or modify it under |
10 | * the terms of the GNU Affero General Public License as published by the Free |
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
12 | * later version. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
17 | * details. |
18 | * |
19 | * You should have received a copy of the GNU Affero General Public License |
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
21 | */ |
22 | |
23 | //========================================================== |
24 | // Includes. |
25 | // |
26 | |
27 | #include <stdbool.h> |
28 | #include <stdint.h> |
29 | |
30 | #include "citrusleaf/cf_atomic.h" |
31 | #include "citrusleaf/cf_digest.h" |
32 | |
33 | #include "fault.h" |
34 | |
35 | #include "base/datamodel.h" |
36 | #include "base/index.h" |
37 | #include "storage/storage.h" |
38 | |
39 | |
40 | //========================================================== |
41 | // Public API. |
42 | // |
43 | |
44 | uint32_t |
45 | clock_skew_stop_writes_sec() |
46 | { |
47 | return 0; |
48 | } |
49 | |
50 | bool |
51 | as_record_handle_clock_skew(as_namespace* ns, uint64_t skew_ms) |
52 | { |
53 | return false; |
54 | } |
55 | |
56 | uint16_t |
57 | plain_generation(uint16_t regime_generation, const as_namespace* ns) |
58 | { |
59 | return regime_generation; |
60 | } |
61 | |
62 | void |
63 | as_record_set_lut(as_record *r, uint32_t regime, uint64_t now_ms, |
64 | const as_namespace* ns) |
65 | { |
66 | // Note - last-update-time is not allowed to go backwards! |
67 | if (r->last_update_time < now_ms) { |
68 | r->last_update_time = now_ms; |
69 | } |
70 | } |
71 | |
72 | void |
73 | as_record_increment_generation(as_record *r, const as_namespace* ns) |
74 | { |
75 | // The generation might wrap - 0 is reserved as "uninitialized". |
76 | if (++r->generation == 0) { |
77 | r->generation = 1; |
78 | } |
79 | } |
80 | |
81 | bool |
82 | as_record_is_live(const as_record* r) |
83 | { |
84 | return true; |
85 | } |
86 | |
87 | int |
88 | as_record_get_live(as_index_tree* tree, const cf_digest* keyd, |
89 | as_index_ref* r_ref, as_namespace* ns) |
90 | { |
91 | return as_index_get_vlock(tree, keyd, r_ref); |
92 | } |
93 | |
94 | int |
95 | as_record_exists_live(as_index_tree* tree, const cf_digest* keyd, |
96 | as_namespace* ns) |
97 | { |
98 | return as_record_exists(tree, keyd); |
99 | } |
100 | |
101 | void |
102 | as_record_drop_stats(as_record* r, as_namespace* ns) |
103 | { |
104 | as_namespace_release_set_id(ns, as_index_get_set_id(r)); |
105 | |
106 | cf_atomic64_decr(&ns->n_objects); |
107 | } |
108 | |
109 | int |
110 | as_record_write_from_pickle(as_storage_rd* rd) |
111 | { |
112 | cf_assert(as_bin_inuse_has(rd), AS_RECORD, "unexpected binless pickle" ); |
113 | |
114 | return as_storage_record_write(rd); |
115 | } |
116 | |
117 | |
118 | //========================================================== |
119 | // Private API - for enterprise separation only. |
120 | // |
121 | |
122 | int |
123 | record_resolve_conflict_cp(uint16_t left_gen, uint64_t left_lut, |
124 | uint16_t right_gen, uint64_t right_lut) |
125 | { |
126 | cf_crash(AS_RECORD, "CE code called record_resolve_conflict_cp()" ); |
127 | |
128 | return 0; |
129 | } |
130 | |