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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright The Infino Authors
//! Public types + entry points for update / delete operations.
//!
//! Mutations follow the buffer + commit shape that `append()`
//! already uses:
//!
//! 1. `update()` / `delete()` resolve the predicate against the
//! current manifest snapshot, capture the matching `_id` set,
//! pre-reserve any resources the WAL will need (an `_id`
//! range + a fresh superfile UUID for updates), and stash a
//! pending entry on the writer.
//! 2. `commit()` flushes the buffered work atomically from the
//! caller's perspective: pending appends are written first,
//! then each buffered update drives its WAL pipeline through
//! append + tombstone phases, then each buffered delete
//! drives its tombstone phase.
//!
//! Durability is the commit barrier: a writer dropped without
//! `commit()` returning `Ok` discards every buffered entry. Same
//! shape as `append()`'s buffer.
//!
//! ## What's here
//!
//! - [`PendingUpdate`] / [`PendingDelete`] — values returned from
//! the corresponding writer entry points. Carry `matched` so the
//! caller can decide whether to proceed; the actual `MutationStats`
//! surfaces on the next `commit()` call.
//! - [`CommitResult`] — aggregate returned from a successful
//! `commit()`. Contains one [`MutationStats`] per buffered
//! mutation, in buffer order.
//! - [`CommitError`] — typed failures from `commit()`, including
//! `PartialCommit { committed_wal_ids, cause }` for the
//! recoverable mid-flush case.
//! - [`MutationError`] — typed failures surfaced at
//! `update()` / `delete()` call time (schema mismatch,
//! cardinality, cap exceeded, storage).
use Error;
use crate::;
/// Per-call outcome from one `delete` / `update`. Returned by the
/// public `Supertable::update` / `Supertable::delete` (which fold
/// writer + commit) and carried, one per buffered mutation, in
/// `CommitResult.outcomes`.
///
/// The public surface is the three count accessors (`matched`,
/// `n_tombstoned`, `n_not_found`); the recovery-only `wal_id` stays
/// `pub(crate)`, so it never enters the public API.
/// `#[non_exhaustive]` keeps the type open to growth.
/// Cap on the number of rows one mutation call can target.
/// Bounds memory usage in the WAL state doc (tombstone_progress
/// grows linearly with this) and bounds per-call latency.
///
/// Callers whose predicate exceeds this should narrow it and
/// reissue.
pub const MAX_TARGETS_PER_MUTATION: usize = 100_000;
/// Typed failures from `delete` / `update`. Each variant is
/// surfaced at call time; no partial state is left behind on
/// any of these paths.
/// Value returned from [`SupertableWriter::update`]. Carries the
/// count of rows the predicate resolved to at call time so the
/// caller can decide whether to proceed to `commit()`. Captured
/// by value rather than reference because `update()` returns
/// after stashing the pending entry on the writer — the caller
/// doesn't otherwise hold a handle to that entry.
///
/// [`SupertableWriter::update`]: crate::supertable::writer::SupertableWriter::update
/// Value returned from [`SupertableWriter::delete`].
///
/// [`SupertableWriter::delete`]: crate::supertable::writer::SupertableWriter::delete
/// Aggregate result of a successful [`SupertableWriter::commit`].
/// One [`MutationStats`] per buffered update / delete, in
/// buffer order. Pending appends don't appear as outcome entries
/// — they're a separate concern from the WAL-driven mutation
/// path and surface only through the manifest swap.
///
/// [`SupertableWriter::commit`]: crate::supertable::writer::SupertableWriter::commit
/// Typed failures from [`SupertableWriter::commit`]. The buffered
/// append phase is one transaction (commit fails atomically if a
/// shard build fails); each buffered mutation is its own
/// recoverable boundary, so a mid-buffer failure surfaces
/// `PartialCommit` listing the WALs that did land durably.
///
/// [`SupertableWriter::commit`]: crate::supertable::writer::SupertableWriter::commit