1use std::{
5 fmt,
6 fmt::{Display, Formatter},
7 ops::Deref,
8};
9
10use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor};
11
12#[repr(transparent)]
13#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
14pub struct ColumnId(pub u64);
15
16impl ColumnId {
17 pub const REQUEST_HISTORY_TIMESTAMP: ColumnId = ColumnId(1);
18 pub const REQUEST_HISTORY_OPERATION: ColumnId = ColumnId(2);
19 pub const REQUEST_HISTORY_FINGERPRINT: ColumnId = ColumnId(3);
20 pub const REQUEST_HISTORY_TOTAL_DURATION: ColumnId = ColumnId(4);
21 pub const REQUEST_HISTORY_COMPUTE_DURATION: ColumnId = ColumnId(5);
22 pub const REQUEST_HISTORY_SUCCESS: ColumnId = ColumnId(6);
23 pub const REQUEST_HISTORY_STATEMENT_COUNT: ColumnId = ColumnId(7);
24 pub const REQUEST_HISTORY_NORMALIZED_RQL: ColumnId = ColumnId(8);
25
26 pub const STATEMENT_STATS_SNAPSHOT_TIMESTAMP: ColumnId = ColumnId(9);
27 pub const STATEMENT_STATS_FINGERPRINT: ColumnId = ColumnId(10);
28 pub const STATEMENT_STATS_NORMALIZED_RQL: ColumnId = ColumnId(11);
29 pub const STATEMENT_STATS_CALLS: ColumnId = ColumnId(12);
30 pub const STATEMENT_STATS_TOTAL_DURATION: ColumnId = ColumnId(13);
31 pub const STATEMENT_STATS_MEAN_DURATION: ColumnId = ColumnId(14);
32 pub const STATEMENT_STATS_MAX_DURATION: ColumnId = ColumnId(15);
33 pub const STATEMENT_STATS_MIN_DURATION: ColumnId = ColumnId(16);
34 pub const STATEMENT_STATS_TOTAL_ROWS: ColumnId = ColumnId(17);
35 pub const STATEMENT_STATS_ERRORS: ColumnId = ColumnId(18);
36
37 pub const RUNTIME_MEMORY_SNAPSHOTS_TS: ColumnId = ColumnId(1024);
38 pub const RUNTIME_MEMORY_SNAPSHOTS_SCOPE: ColumnId = ColumnId(1025);
39 pub const RUNTIME_MEMORY_SNAPSHOTS_METRIC: ColumnId = ColumnId(1026);
40 pub const RUNTIME_MEMORY_SNAPSHOTS_VALUE: ColumnId = ColumnId(1027);
41 pub const RUNTIME_MEMORY_SNAPSHOTS_UNIT: ColumnId = ColumnId(1028);
42 pub const RUNTIME_MEMORY_SNAPSHOTS_KIND: ColumnId = ColumnId(1029);
43 pub const RUNTIME_WATERMARKS_SNAPSHOTS_TS: ColumnId = ColumnId(1030);
44 pub const RUNTIME_WATERMARKS_SNAPSHOTS_SCOPE: ColumnId = ColumnId(1031);
45 pub const RUNTIME_WATERMARKS_SNAPSHOTS_METRIC: ColumnId = ColumnId(1032);
46 pub const RUNTIME_WATERMARKS_SNAPSHOTS_VALUE: ColumnId = ColumnId(1033);
47 pub const RUNTIME_WATERMARKS_SNAPSHOTS_UNIT: ColumnId = ColumnId(1034);
48 pub const RUNTIME_WATERMARKS_SNAPSHOTS_KIND: ColumnId = ColumnId(1035);
49 pub const RUNTIME_OPERATORS_SNAPSHOTS_TS: ColumnId = ColumnId(1036);
50 pub const RUNTIME_OPERATORS_SNAPSHOTS_SCOPE: ColumnId = ColumnId(1037);
51 pub const RUNTIME_OPERATORS_SNAPSHOTS_METRIC: ColumnId = ColumnId(1038);
52 pub const RUNTIME_OPERATORS_SNAPSHOTS_VALUE: ColumnId = ColumnId(1039);
53 pub const RUNTIME_OPERATORS_SNAPSHOTS_UNIT: ColumnId = ColumnId(1040);
54 pub const RUNTIME_OPERATORS_SNAPSHOTS_KIND: ColumnId = ColumnId(1041);
55 pub const INSTRUMENTS_SNAPSHOTS_TS: ColumnId = ColumnId(1042);
56 pub const INSTRUMENTS_SNAPSHOTS_SCOPE: ColumnId = ColumnId(1043);
57 pub const INSTRUMENTS_SNAPSHOTS_METRIC: ColumnId = ColumnId(1044);
58 pub const INSTRUMENTS_SNAPSHOTS_VALUE: ColumnId = ColumnId(1045);
59 pub const INSTRUMENTS_SNAPSHOTS_UNIT: ColumnId = ColumnId(1046);
60 pub const INSTRUMENTS_SNAPSHOTS_KIND: ColumnId = ColumnId(1047);
61 pub const PROFILER_SPANS_SNAPSHOTS_TS: ColumnId = ColumnId(1048);
62 pub const PROFILER_SPANS_SNAPSHOTS_CATEGORY: ColumnId = ColumnId(1049);
63 pub const PROFILER_SPANS_SNAPSHOTS_SPAN_NAME: ColumnId = ColumnId(1050);
64 pub const PROFILER_SPANS_SNAPSHOTS_DIM_1: ColumnId = ColumnId(1051);
65 pub const PROFILER_SPANS_SNAPSHOTS_DIM_2: ColumnId = ColumnId(1052);
66 pub const PROFILER_SPANS_SNAPSHOTS_CALLS: ColumnId = ColumnId(1053);
67 pub const PROFILER_SPANS_SNAPSHOTS_TOTAL: ColumnId = ColumnId(1054);
68 pub const PROFILER_SPANS_SNAPSHOTS_MIN: ColumnId = ColumnId(1055);
69 pub const PROFILER_SPANS_SNAPSHOTS_P50: ColumnId = ColumnId(1056);
70 pub const PROFILER_SPANS_SNAPSHOTS_P75: ColumnId = ColumnId(1057);
71 pub const PROFILER_SPANS_SNAPSHOTS_P90: ColumnId = ColumnId(1058);
72 pub const PROFILER_SPANS_SNAPSHOTS_P95: ColumnId = ColumnId(1059);
73 pub const PROFILER_SPANS_SNAPSHOTS_P98: ColumnId = ColumnId(1060);
74 pub const PROFILER_SPANS_SNAPSHOTS_P99: ColumnId = ColumnId(1061);
75 pub const PROFILER_SPANS_SNAPSHOTS_MAX: ColumnId = ColumnId(1062);
76 pub const PROFILER_SPANS_SNAPSHOTS_INPUT_ROWS: ColumnId = ColumnId(1063);
77 pub const PROFILER_SPANS_SNAPSHOTS_OUTPUT_ROWS: ColumnId = ColumnId(1064);
78 pub const PROFILER_SPANS_SNAPSHOTS_LOCK_WAIT: ColumnId = ColumnId(1065);
79 pub const READ_BUFFER_SNAPSHOTS_TS: ColumnId = ColumnId(1067);
80 pub const READ_BUFFER_SNAPSHOTS_SHARD: ColumnId = ColumnId(1068);
81 pub const READ_BUFFER_SNAPSHOTS_USED: ColumnId = ColumnId(1069);
82 pub const READ_BUFFER_SNAPSHOTS_LIMIT: ColumnId = ColumnId(1070);
83 pub const READ_BUFFER_SNAPSHOTS_PAGES: ColumnId = ColumnId(1071);
84 pub const READ_BUFFER_SNAPSHOTS_PAGE_CAP: ColumnId = ColumnId(1072);
85 pub const READ_BUFFER_SNAPSHOTS_PAYLOAD: ColumnId = ColumnId(1073);
86 pub const READ_BUFFER_SNAPSHOTS_ENTRIES: ColumnId = ColumnId(1074);
87 pub const READ_BUFFER_SNAPSHOTS_HOT_PAGES: ColumnId = ColumnId(1075);
88 pub const READ_BUFFER_SNAPSHOTS_COMPLETE_PAGES: ColumnId = ColumnId(1076);
89 pub const READ_BUFFER_SNAPSHOTS_BLOCKED_PAGES: ColumnId = ColumnId(1077);
90 pub const READ_BUFFER_SNAPSHOTS_WARMING: ColumnId = ColumnId(1078);
91 pub const READ_BUFFER_SNAPSHOTS_WARMS_STARTED: ColumnId = ColumnId(1079);
92 pub const READ_BUFFER_SNAPSHOTS_WARMS_COMPLETED: ColumnId = ColumnId(1080);
93 pub const READ_BUFFER_SNAPSHOTS_WARMS_DIRTY_ABORTED: ColumnId = ColumnId(1081);
94 pub const READ_BUFFER_SNAPSHOTS_WARMS_ABORTED: ColumnId = ColumnId(1082);
95 pub const READ_BUFFER_SNAPSHOTS_PAGES_WARM_BLOCKED: ColumnId = ColumnId(1083);
96 pub const READ_BUFFER_SNAPSHOTS_PAGES_EVICTED: ColumnId = ColumnId(1084);
97 pub const READ_BUFFER_SNAPSHOTS_COMPLETE_PAGES_INVALIDATED: ColumnId = ColumnId(1085);
98 pub const READ_BUFFER_SNAPSHOTS_POINT_HITS: ColumnId = ColumnId(1086);
99 pub const READ_BUFFER_SNAPSHOTS_PREVIOUS_HITS: ColumnId = ColumnId(1087);
100 pub const READ_BUFFER_SNAPSHOTS_POINT_MISSES: ColumnId = ColumnId(1088);
101 pub const READ_BUFFER_SNAPSHOTS_RANGE_SERVED: ColumnId = ColumnId(1089);
102 pub const READ_BUFFER_SNAPSHOTS_RANGE_GAPS: ColumnId = ColumnId(1090);
103 pub const EPOCH_SNAPSHOTS_TS: ColumnId = ColumnId(1091);
104 pub const EPOCH_SNAPSHOTS_SAMPLES: ColumnId = ColumnId(1092);
105 pub const EPOCH_SNAPSHOTS_DURABLE_SAMPLES: ColumnId = ColumnId(1093);
106 pub const EPOCH_SNAPSHOTS_COVERAGE: ColumnId = ColumnId(1094);
107 pub const EPOCH_SNAPSHOTS_GUARANTEED_COVERAGE: ColumnId = ColumnId(1095);
108 pub const EPOCH_SNAPSHOTS_PRUNED: ColumnId = ColumnId(1096);
109 pub const EPOCH_SNAPSHOTS_FLOOR_NONE_RETURNS: ColumnId = ColumnId(1097);
110 pub const LIFECYCLE_SNAPSHOTS_TS: ColumnId = ColumnId(1098);
111 pub const LIFECYCLE_SNAPSHOTS_CLASS: ColumnId = ColumnId(1099);
112 pub const LIFECYCLE_SNAPSHOTS_BINDING: ColumnId = ColumnId(1100);
113 pub const LIFECYCLE_SNAPSHOTS_FLOOR_VERSION: ColumnId = ColumnId(1101);
114 pub const LIFECYCLE_SNAPSHOTS_BACKLOG_HINT: ColumnId = ColumnId(1102);
115 pub const LIFECYCLE_SNAPSHOTS_WORK_DONE: ColumnId = ColumnId(1105);
116 pub const LIFECYCLE_SNAPSHOTS_SLICES: ColumnId = ColumnId(1106);
117 pub const LIFECYCLE_SNAPSHOTS_STUCK_SLICES: ColumnId = ColumnId(1107);
118 pub const LIFECYCLE_SNAPSHOTS_BUDGET_EXHAUSTED_SLICES: ColumnId = ColumnId(1108);
119 pub const LIFECYCLE_SNAPSHOTS_GATED_SLICES: ColumnId = ColumnId(1109);
120 pub const STORAGE_SNAPSHOTS_TS: ColumnId = ColumnId(1110);
121 pub const STORAGE_SNAPSHOTS_OBJECT_KIND: ColumnId = ColumnId(1111);
122 pub const STORAGE_SNAPSHOTS_ID: ColumnId = ColumnId(1112);
123 pub const STORAGE_SNAPSHOTS_NAMESPACE_ID: ColumnId = ColumnId(1113);
124 pub const STORAGE_SNAPSHOTS_TIER: ColumnId = ColumnId(1114);
125 pub const STORAGE_SNAPSHOTS_LIVE_KEY_BYTES: ColumnId = ColumnId(1115);
126 pub const STORAGE_SNAPSHOTS_LIVE_VALUE_BYTES: ColumnId = ColumnId(1116);
127 pub const STORAGE_SNAPSHOTS_LIVE_BYTES: ColumnId = ColumnId(1117);
128 pub const STORAGE_SNAPSHOTS_LIVE_COUNT: ColumnId = ColumnId(1118);
129 pub const STORAGE_SNAPSHOTS_SUPERSEDED_KEY_BYTES: ColumnId = ColumnId(1119);
130 pub const STORAGE_SNAPSHOTS_SUPERSEDED_VALUE_BYTES: ColumnId = ColumnId(1120);
131 pub const STORAGE_SNAPSHOTS_SUPERSEDED_BYTES: ColumnId = ColumnId(1121);
132 pub const STORAGE_SNAPSHOTS_SUPERSEDED_COUNT: ColumnId = ColumnId(1122);
133 pub const STORAGE_SNAPSHOTS_TOTAL_BYTES: ColumnId = ColumnId(1123);
134 pub const CDC_SNAPSHOTS_TS: ColumnId = ColumnId(1124);
135 pub const CDC_SNAPSHOTS_OBJECT_KIND: ColumnId = ColumnId(1125);
136 pub const CDC_SNAPSHOTS_ID: ColumnId = ColumnId(1126);
137 pub const CDC_SNAPSHOTS_NAMESPACE_ID: ColumnId = ColumnId(1127);
138 pub const CDC_SNAPSHOTS_KEY_BYTES: ColumnId = ColumnId(1128);
139 pub const CDC_SNAPSHOTS_VALUE_BYTES: ColumnId = ColumnId(1129);
140 pub const CDC_SNAPSHOTS_TOTAL_BYTES: ColumnId = ColumnId(1130);
141 pub const CDC_SNAPSHOTS_COUNT: ColumnId = ColumnId(1131);
142 pub const SOURCE_COMPLETENESS_OBJECT_ID: ColumnId = ColumnId(1132);
143 pub const SOURCE_COMPLETENESS_COMPLETE_THROUGH: ColumnId = ColumnId(1133);
144 pub const FLOW_STATE_SNAPSHOTS_TS: ColumnId = ColumnId(1134);
145 pub const FLOW_STATE_SNAPSHOTS_OPERATOR: ColumnId = ColumnId(1135);
146 pub const FLOW_STATE_SNAPSHOTS_KEYSPACE: ColumnId = ColumnId(1137);
147 pub const FLOW_STATE_SNAPSHOTS_PHASE: ColumnId = ColumnId(1138);
148 pub const FLOW_STATE_SNAPSHOTS_KEYS: ColumnId = ColumnId(1139);
149 pub const FLOW_STATE_SNAPSHOTS_KEY_BYTES: ColumnId = ColumnId(1140);
150 pub const FLOW_STATE_SNAPSHOTS_VALUE_BYTES: ColumnId = ColumnId(1141);
151 pub const FLOW_STATE_SNAPSHOTS_TOTAL_BYTES: ColumnId = ColumnId(1142);
152
153 pub const RUNTIME_MEMORY_SNAPSHOTS_COLUMNS: [ColumnId; 6] = [
154 Self::RUNTIME_MEMORY_SNAPSHOTS_TS,
155 Self::RUNTIME_MEMORY_SNAPSHOTS_SCOPE,
156 Self::RUNTIME_MEMORY_SNAPSHOTS_METRIC,
157 Self::RUNTIME_MEMORY_SNAPSHOTS_VALUE,
158 Self::RUNTIME_MEMORY_SNAPSHOTS_UNIT,
159 Self::RUNTIME_MEMORY_SNAPSHOTS_KIND,
160 ];
161
162 pub const RUNTIME_WATERMARKS_SNAPSHOTS_COLUMNS: [ColumnId; 6] = [
163 Self::RUNTIME_WATERMARKS_SNAPSHOTS_TS,
164 Self::RUNTIME_WATERMARKS_SNAPSHOTS_SCOPE,
165 Self::RUNTIME_WATERMARKS_SNAPSHOTS_METRIC,
166 Self::RUNTIME_WATERMARKS_SNAPSHOTS_VALUE,
167 Self::RUNTIME_WATERMARKS_SNAPSHOTS_UNIT,
168 Self::RUNTIME_WATERMARKS_SNAPSHOTS_KIND,
169 ];
170
171 pub const RUNTIME_OPERATORS_SNAPSHOTS_COLUMNS: [ColumnId; 6] = [
172 Self::RUNTIME_OPERATORS_SNAPSHOTS_TS,
173 Self::RUNTIME_OPERATORS_SNAPSHOTS_SCOPE,
174 Self::RUNTIME_OPERATORS_SNAPSHOTS_METRIC,
175 Self::RUNTIME_OPERATORS_SNAPSHOTS_VALUE,
176 Self::RUNTIME_OPERATORS_SNAPSHOTS_UNIT,
177 Self::RUNTIME_OPERATORS_SNAPSHOTS_KIND,
178 ];
179
180 pub const INSTRUMENTS_SNAPSHOTS_COLUMNS: [ColumnId; 6] = [
181 Self::INSTRUMENTS_SNAPSHOTS_TS,
182 Self::INSTRUMENTS_SNAPSHOTS_SCOPE,
183 Self::INSTRUMENTS_SNAPSHOTS_METRIC,
184 Self::INSTRUMENTS_SNAPSHOTS_VALUE,
185 Self::INSTRUMENTS_SNAPSHOTS_UNIT,
186 Self::INSTRUMENTS_SNAPSHOTS_KIND,
187 ];
188
189 pub const PROFILER_SPANS_SNAPSHOTS_COLUMNS: [ColumnId; 18] = [
190 Self::PROFILER_SPANS_SNAPSHOTS_TS,
191 Self::PROFILER_SPANS_SNAPSHOTS_CATEGORY,
192 Self::PROFILER_SPANS_SNAPSHOTS_SPAN_NAME,
193 Self::PROFILER_SPANS_SNAPSHOTS_DIM_1,
194 Self::PROFILER_SPANS_SNAPSHOTS_DIM_2,
195 Self::PROFILER_SPANS_SNAPSHOTS_CALLS,
196 Self::PROFILER_SPANS_SNAPSHOTS_TOTAL,
197 Self::PROFILER_SPANS_SNAPSHOTS_MIN,
198 Self::PROFILER_SPANS_SNAPSHOTS_P50,
199 Self::PROFILER_SPANS_SNAPSHOTS_P75,
200 Self::PROFILER_SPANS_SNAPSHOTS_P90,
201 Self::PROFILER_SPANS_SNAPSHOTS_P95,
202 Self::PROFILER_SPANS_SNAPSHOTS_P98,
203 Self::PROFILER_SPANS_SNAPSHOTS_P99,
204 Self::PROFILER_SPANS_SNAPSHOTS_MAX,
205 Self::PROFILER_SPANS_SNAPSHOTS_INPUT_ROWS,
206 Self::PROFILER_SPANS_SNAPSHOTS_OUTPUT_ROWS,
207 Self::PROFILER_SPANS_SNAPSHOTS_LOCK_WAIT,
208 ];
209
210 pub const READ_BUFFER_SNAPSHOTS_COLUMNS: [ColumnId; 24] = [
211 Self::READ_BUFFER_SNAPSHOTS_TS,
212 Self::READ_BUFFER_SNAPSHOTS_SHARD,
213 Self::READ_BUFFER_SNAPSHOTS_USED,
214 Self::READ_BUFFER_SNAPSHOTS_LIMIT,
215 Self::READ_BUFFER_SNAPSHOTS_PAGES,
216 Self::READ_BUFFER_SNAPSHOTS_PAGE_CAP,
217 Self::READ_BUFFER_SNAPSHOTS_PAYLOAD,
218 Self::READ_BUFFER_SNAPSHOTS_ENTRIES,
219 Self::READ_BUFFER_SNAPSHOTS_HOT_PAGES,
220 Self::READ_BUFFER_SNAPSHOTS_COMPLETE_PAGES,
221 Self::READ_BUFFER_SNAPSHOTS_BLOCKED_PAGES,
222 Self::READ_BUFFER_SNAPSHOTS_WARMING,
223 Self::READ_BUFFER_SNAPSHOTS_WARMS_STARTED,
224 Self::READ_BUFFER_SNAPSHOTS_WARMS_COMPLETED,
225 Self::READ_BUFFER_SNAPSHOTS_WARMS_DIRTY_ABORTED,
226 Self::READ_BUFFER_SNAPSHOTS_WARMS_ABORTED,
227 Self::READ_BUFFER_SNAPSHOTS_PAGES_WARM_BLOCKED,
228 Self::READ_BUFFER_SNAPSHOTS_PAGES_EVICTED,
229 Self::READ_BUFFER_SNAPSHOTS_COMPLETE_PAGES_INVALIDATED,
230 Self::READ_BUFFER_SNAPSHOTS_POINT_HITS,
231 Self::READ_BUFFER_SNAPSHOTS_PREVIOUS_HITS,
232 Self::READ_BUFFER_SNAPSHOTS_POINT_MISSES,
233 Self::READ_BUFFER_SNAPSHOTS_RANGE_SERVED,
234 Self::READ_BUFFER_SNAPSHOTS_RANGE_GAPS,
235 ];
236
237 pub const EPOCH_SNAPSHOTS_COLUMNS: [ColumnId; 7] = [
238 Self::EPOCH_SNAPSHOTS_TS,
239 Self::EPOCH_SNAPSHOTS_SAMPLES,
240 Self::EPOCH_SNAPSHOTS_DURABLE_SAMPLES,
241 Self::EPOCH_SNAPSHOTS_COVERAGE,
242 Self::EPOCH_SNAPSHOTS_GUARANTEED_COVERAGE,
243 Self::EPOCH_SNAPSHOTS_PRUNED,
244 Self::EPOCH_SNAPSHOTS_FLOOR_NONE_RETURNS,
245 ];
246
247 pub const LIFECYCLE_SNAPSHOTS_COLUMNS: [ColumnId; 10] = [
248 Self::LIFECYCLE_SNAPSHOTS_TS,
249 Self::LIFECYCLE_SNAPSHOTS_CLASS,
250 Self::LIFECYCLE_SNAPSHOTS_BINDING,
251 Self::LIFECYCLE_SNAPSHOTS_FLOOR_VERSION,
252 Self::LIFECYCLE_SNAPSHOTS_BACKLOG_HINT,
253 Self::LIFECYCLE_SNAPSHOTS_WORK_DONE,
254 Self::LIFECYCLE_SNAPSHOTS_SLICES,
255 Self::LIFECYCLE_SNAPSHOTS_STUCK_SLICES,
256 Self::LIFECYCLE_SNAPSHOTS_BUDGET_EXHAUSTED_SLICES,
257 Self::LIFECYCLE_SNAPSHOTS_GATED_SLICES,
258 ];
259
260 pub const STORAGE_SNAPSHOTS_COLUMNS: [ColumnId; 14] = [
261 Self::STORAGE_SNAPSHOTS_TS,
262 Self::STORAGE_SNAPSHOTS_OBJECT_KIND,
263 Self::STORAGE_SNAPSHOTS_ID,
264 Self::STORAGE_SNAPSHOTS_NAMESPACE_ID,
265 Self::STORAGE_SNAPSHOTS_TIER,
266 Self::STORAGE_SNAPSHOTS_LIVE_KEY_BYTES,
267 Self::STORAGE_SNAPSHOTS_LIVE_VALUE_BYTES,
268 Self::STORAGE_SNAPSHOTS_LIVE_BYTES,
269 Self::STORAGE_SNAPSHOTS_LIVE_COUNT,
270 Self::STORAGE_SNAPSHOTS_SUPERSEDED_KEY_BYTES,
271 Self::STORAGE_SNAPSHOTS_SUPERSEDED_VALUE_BYTES,
272 Self::STORAGE_SNAPSHOTS_SUPERSEDED_BYTES,
273 Self::STORAGE_SNAPSHOTS_SUPERSEDED_COUNT,
274 Self::STORAGE_SNAPSHOTS_TOTAL_BYTES,
275 ];
276
277 pub const CDC_SNAPSHOTS_COLUMNS: [ColumnId; 8] = [
278 Self::CDC_SNAPSHOTS_TS,
279 Self::CDC_SNAPSHOTS_OBJECT_KIND,
280 Self::CDC_SNAPSHOTS_ID,
281 Self::CDC_SNAPSHOTS_NAMESPACE_ID,
282 Self::CDC_SNAPSHOTS_KEY_BYTES,
283 Self::CDC_SNAPSHOTS_VALUE_BYTES,
284 Self::CDC_SNAPSHOTS_TOTAL_BYTES,
285 Self::CDC_SNAPSHOTS_COUNT,
286 ];
287
288 pub const SOURCE_COMPLETENESS_COLUMNS: [ColumnId; 2] =
289 [Self::SOURCE_COMPLETENESS_OBJECT_ID, Self::SOURCE_COMPLETENESS_COMPLETE_THROUGH];
290
291 pub const FLOW_STATE_SNAPSHOTS_COLUMNS: [ColumnId; 8] = [
292 Self::FLOW_STATE_SNAPSHOTS_TS,
293 Self::FLOW_STATE_SNAPSHOTS_OPERATOR,
294 Self::FLOW_STATE_SNAPSHOTS_KEYSPACE,
295 Self::FLOW_STATE_SNAPSHOTS_PHASE,
296 Self::FLOW_STATE_SNAPSHOTS_KEYS,
297 Self::FLOW_STATE_SNAPSHOTS_KEY_BYTES,
298 Self::FLOW_STATE_SNAPSHOTS_VALUE_BYTES,
299 Self::FLOW_STATE_SNAPSHOTS_TOTAL_BYTES,
300 ];
301}
302
303impl Deref for ColumnId {
304 type Target = u64;
305
306 fn deref(&self) -> &Self::Target {
307 &self.0
308 }
309}
310
311impl PartialEq<u64> for ColumnId {
312 fn eq(&self, other: &u64) -> bool {
313 self.0.eq(other)
314 }
315}
316
317impl From<ColumnId> for u64 {
318 fn from(value: ColumnId) -> Self {
319 value.0
320 }
321}
322
323impl Serialize for ColumnId {
324 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
325 where
326 S: Serializer,
327 {
328 serializer.serialize_u64(self.0)
329 }
330}
331
332impl<'de> Deserialize<'de> for ColumnId {
333 fn deserialize<D>(deserializer: D) -> Result<ColumnId, D::Error>
334 where
335 D: Deserializer<'de>,
336 {
337 struct U64Visitor;
338
339 impl Visitor<'_> for U64Visitor {
340 type Value = ColumnId;
341
342 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
343 formatter.write_str("an unsigned 64-bit number")
344 }
345
346 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
347 Ok(ColumnId(value))
348 }
349 }
350
351 deserializer.deserialize_u64(U64Visitor)
352 }
353}
354
355#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
356pub enum IndexId {
357 Primary(PrimaryKeyId),
358}
359
360impl IndexId {
361 pub fn as_u64(&self) -> u64 {
362 match self {
363 IndexId::Primary(id) => id.0,
364 }
365 }
366
367 pub fn primary(id: impl Into<PrimaryKeyId>) -> Self {
368 IndexId::Primary(id.into())
369 }
370
371 pub fn next(&self) -> IndexId {
372 match self {
373 IndexId::Primary(primary) => IndexId::Primary(PrimaryKeyId(primary.0 + 1)),
374 }
375 }
376
377 pub fn prev(&self) -> IndexId {
378 match self {
379 IndexId::Primary(primary) => IndexId::Primary(PrimaryKeyId(primary.0.wrapping_sub(1))),
380 }
381 }
382}
383
384impl Deref for IndexId {
385 type Target = u64;
386
387 fn deref(&self) -> &Self::Target {
388 match self {
389 IndexId::Primary(id) => &id.0,
390 }
391 }
392}
393
394impl PartialEq<u64> for IndexId {
395 fn eq(&self, other: &u64) -> bool {
396 self.as_u64().eq(other)
397 }
398}
399
400impl From<IndexId> for u64 {
401 fn from(value: IndexId) -> Self {
402 value.as_u64()
403 }
404}
405
406impl Serialize for IndexId {
407 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
408 where
409 S: Serializer,
410 {
411 serializer.serialize_u64(self.as_u64())
412 }
413}
414
415impl<'de> Deserialize<'de> for IndexId {
416 fn deserialize<D>(deserializer: D) -> Result<IndexId, D::Error>
417 where
418 D: Deserializer<'de>,
419 {
420 struct U64Visitor;
421
422 impl Visitor<'_> for U64Visitor {
423 type Value = IndexId;
424
425 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
426 formatter.write_str("an unsigned 64-bit number")
427 }
428
429 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
430 Ok(IndexId::Primary(PrimaryKeyId(value)))
431 }
432 }
433
434 deserializer.deserialize_u64(U64Visitor)
435 }
436}
437
438#[repr(transparent)]
439#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
440pub struct ColumnPropertyId(pub u64);
441
442impl Deref for ColumnPropertyId {
443 type Target = u64;
444
445 fn deref(&self) -> &Self::Target {
446 &self.0
447 }
448}
449
450impl PartialEq<u64> for ColumnPropertyId {
451 fn eq(&self, other: &u64) -> bool {
452 self.0.eq(other)
453 }
454}
455
456impl From<ColumnPropertyId> for u64 {
457 fn from(value: ColumnPropertyId) -> Self {
458 value.0
459 }
460}
461
462impl Serialize for ColumnPropertyId {
463 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
464 where
465 S: Serializer,
466 {
467 serializer.serialize_u64(self.0)
468 }
469}
470
471impl<'de> Deserialize<'de> for ColumnPropertyId {
472 fn deserialize<D>(deserializer: D) -> Result<ColumnPropertyId, D::Error>
473 where
474 D: Deserializer<'de>,
475 {
476 struct U64Visitor;
477
478 impl Visitor<'_> for U64Visitor {
479 type Value = ColumnPropertyId;
480
481 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
482 formatter.write_str("an unsigned 64-bit number")
483 }
484
485 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
486 Ok(ColumnPropertyId(value))
487 }
488 }
489
490 deserializer.deserialize_u64(U64Visitor)
491 }
492}
493
494#[repr(transparent)]
495#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
496pub struct NamespaceId(pub u64);
497
498impl Display for NamespaceId {
499 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
500 Display::fmt(&self.0, f)
501 }
502}
503
504impl Deref for NamespaceId {
505 type Target = u64;
506
507 fn deref(&self) -> &Self::Target {
508 &self.0
509 }
510}
511
512impl PartialEq<u64> for NamespaceId {
513 fn eq(&self, other: &u64) -> bool {
514 self.0.eq(other)
515 }
516}
517
518impl From<NamespaceId> for u64 {
519 fn from(value: NamespaceId) -> Self {
520 value.0
521 }
522}
523
524impl Serialize for NamespaceId {
525 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
526 where
527 S: Serializer,
528 {
529 serializer.serialize_u64(self.0)
530 }
531}
532
533impl<'de> Deserialize<'de> for NamespaceId {
534 fn deserialize<D>(deserializer: D) -> Result<NamespaceId, D::Error>
535 where
536 D: Deserializer<'de>,
537 {
538 struct U64Visitor;
539
540 impl Visitor<'_> for U64Visitor {
541 type Value = NamespaceId;
542
543 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
544 formatter.write_str("an unsigned 64-bit number")
545 }
546
547 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
548 Ok(NamespaceId(value))
549 }
550 }
551
552 deserializer.deserialize_u64(U64Visitor)
553 }
554}
555
556#[repr(transparent)]
557#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
558pub struct TableId(pub u64);
559
560impl Display for TableId {
561 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
562 Display::fmt(&self.0, f)
563 }
564}
565
566impl Deref for TableId {
567 type Target = u64;
568
569 fn deref(&self) -> &Self::Target {
570 &self.0
571 }
572}
573
574impl PartialEq<u64> for TableId {
575 fn eq(&self, other: &u64) -> bool {
576 self.0.eq(other)
577 }
578}
579
580impl From<TableId> for u64 {
581 fn from(value: TableId) -> Self {
582 value.0
583 }
584}
585
586impl TableId {
587 pub const SOURCE_COMPLETENESS: TableId = TableId(1034);
588
589 #[inline]
590 pub fn to_u64(self) -> u64 {
591 self.0
592 }
593}
594
595impl From<i32> for TableId {
596 fn from(value: i32) -> Self {
597 Self(value as u64)
598 }
599}
600
601impl From<u64> for TableId {
602 fn from(value: u64) -> Self {
603 Self(value)
604 }
605}
606
607impl Serialize for TableId {
608 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
609 where
610 S: Serializer,
611 {
612 serializer.serialize_u64(self.0)
613 }
614}
615
616impl<'de> Deserialize<'de> for TableId {
617 fn deserialize<D>(deserializer: D) -> Result<TableId, D::Error>
618 where
619 D: Deserializer<'de>,
620 {
621 struct U64Visitor;
622
623 impl Visitor<'_> for U64Visitor {
624 type Value = TableId;
625
626 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
627 formatter.write_str("an unsigned 64-bit number")
628 }
629
630 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
631 Ok(TableId(value))
632 }
633 }
634
635 deserializer.deserialize_u64(U64Visitor)
636 }
637}
638
639#[repr(transparent)]
640#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
641pub struct ViewId(pub u64);
642
643impl Display for ViewId {
644 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
645 Display::fmt(&self.0, f)
646 }
647}
648
649impl Deref for ViewId {
650 type Target = u64;
651
652 fn deref(&self) -> &Self::Target {
653 &self.0
654 }
655}
656
657impl PartialEq<u64> for ViewId {
658 fn eq(&self, other: &u64) -> bool {
659 self.0.eq(other)
660 }
661}
662
663impl From<ViewId> for u64 {
664 fn from(value: ViewId) -> Self {
665 value.0
666 }
667}
668
669impl ViewId {
670 #[inline]
671 pub fn to_u64(self) -> u64 {
672 self.0
673 }
674}
675
676impl From<i32> for ViewId {
677 fn from(value: i32) -> Self {
678 Self(value as u64)
679 }
680}
681
682impl From<u64> for ViewId {
683 fn from(value: u64) -> Self {
684 Self(value)
685 }
686}
687
688impl Serialize for ViewId {
689 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
690 where
691 S: Serializer,
692 {
693 serializer.serialize_u64(self.0)
694 }
695}
696
697impl<'de> Deserialize<'de> for ViewId {
698 fn deserialize<D>(deserializer: D) -> Result<ViewId, D::Error>
699 where
700 D: Deserializer<'de>,
701 {
702 struct U64Visitor;
703
704 impl Visitor<'_> for U64Visitor {
705 type Value = ViewId;
706
707 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
708 formatter.write_str("an unsigned 64-bit number")
709 }
710
711 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
712 Ok(ViewId(value))
713 }
714 }
715
716 deserializer.deserialize_u64(U64Visitor)
717 }
718}
719
720#[repr(transparent)]
721#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
722pub struct PrimaryKeyId(pub u64);
723
724impl Display for PrimaryKeyId {
725 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
726 Display::fmt(&self.0, f)
727 }
728}
729
730impl Deref for PrimaryKeyId {
731 type Target = u64;
732
733 fn deref(&self) -> &Self::Target {
734 &self.0
735 }
736}
737
738impl PartialEq<u64> for PrimaryKeyId {
739 fn eq(&self, other: &u64) -> bool {
740 self.0.eq(other)
741 }
742}
743
744impl From<PrimaryKeyId> for u64 {
745 fn from(value: PrimaryKeyId) -> Self {
746 value.0
747 }
748}
749
750impl From<i32> for PrimaryKeyId {
751 fn from(value: i32) -> Self {
752 Self(value as u64)
753 }
754}
755
756impl From<u64> for PrimaryKeyId {
757 fn from(value: u64) -> Self {
758 Self(value)
759 }
760}
761
762impl Serialize for PrimaryKeyId {
763 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
764 where
765 S: Serializer,
766 {
767 serializer.serialize_u64(self.0)
768 }
769}
770
771impl<'de> Deserialize<'de> for PrimaryKeyId {
772 fn deserialize<D>(deserializer: D) -> Result<PrimaryKeyId, D::Error>
773 where
774 D: Deserializer<'de>,
775 {
776 struct U64Visitor;
777
778 impl Visitor<'_> for U64Visitor {
779 type Value = PrimaryKeyId;
780
781 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
782 formatter.write_str("an unsigned 64-bit number")
783 }
784
785 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
786 Ok(PrimaryKeyId(value))
787 }
788 }
789
790 deserializer.deserialize_u64(U64Visitor)
791 }
792}
793
794#[repr(transparent)]
795#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
796pub struct RelationshipId(pub u64);
797
798impl Display for RelationshipId {
799 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
800 Display::fmt(&self.0, f)
801 }
802}
803
804impl Deref for RelationshipId {
805 type Target = u64;
806
807 fn deref(&self) -> &Self::Target {
808 &self.0
809 }
810}
811
812impl PartialEq<u64> for RelationshipId {
813 fn eq(&self, other: &u64) -> bool {
814 self.0.eq(other)
815 }
816}
817
818impl From<RelationshipId> for u64 {
819 fn from(value: RelationshipId) -> Self {
820 value.0
821 }
822}
823
824impl From<i32> for RelationshipId {
825 fn from(value: i32) -> Self {
826 Self(value as u64)
827 }
828}
829
830impl From<u64> for RelationshipId {
831 fn from(value: u64) -> Self {
832 Self(value)
833 }
834}
835
836impl Serialize for RelationshipId {
837 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
838 where
839 S: Serializer,
840 {
841 serializer.serialize_u64(self.0)
842 }
843}
844
845impl<'de> Deserialize<'de> for RelationshipId {
846 fn deserialize<D>(deserializer: D) -> Result<RelationshipId, D::Error>
847 where
848 D: Deserializer<'de>,
849 {
850 struct U64Visitor;
851
852 impl Visitor<'_> for U64Visitor {
853 type Value = RelationshipId;
854
855 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
856 formatter.write_str("an unsigned 64-bit number")
857 }
858
859 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
860 Ok(RelationshipId(value))
861 }
862 }
863
864 deserializer.deserialize_u64(U64Visitor)
865 }
866}
867
868#[repr(transparent)]
869#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
870pub struct RingBufferId(pub u64);
871
872impl RingBufferId {
873 pub const REQUEST_HISTORY: RingBufferId = RingBufferId(1);
874 pub const STATEMENT_STATS: RingBufferId = RingBufferId(2);
875}
876
877impl Display for RingBufferId {
878 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
879 Display::fmt(&self.0, f)
880 }
881}
882
883impl Deref for RingBufferId {
884 type Target = u64;
885
886 fn deref(&self) -> &Self::Target {
887 &self.0
888 }
889}
890
891impl PartialEq<u64> for RingBufferId {
892 fn eq(&self, other: &u64) -> bool {
893 self.0.eq(other)
894 }
895}
896
897impl From<RingBufferId> for u64 {
898 fn from(value: RingBufferId) -> Self {
899 value.0
900 }
901}
902
903impl RingBufferId {
904 #[inline]
905 pub fn to_u64(self) -> u64 {
906 self.0
907 }
908}
909
910impl From<i32> for RingBufferId {
911 fn from(value: i32) -> Self {
912 Self(value as u64)
913 }
914}
915
916impl From<u64> for RingBufferId {
917 fn from(value: u64) -> Self {
918 Self(value)
919 }
920}
921
922impl Serialize for RingBufferId {
923 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
924 where
925 S: Serializer,
926 {
927 serializer.serialize_u64(self.0)
928 }
929}
930
931impl<'de> Deserialize<'de> for RingBufferId {
932 fn deserialize<D>(deserializer: D) -> Result<RingBufferId, D::Error>
933 where
934 D: Deserializer<'de>,
935 {
936 struct U64Visitor;
937
938 impl Visitor<'_> for U64Visitor {
939 type Value = RingBufferId;
940
941 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
942 formatter.write_str("an unsigned 64-bit number")
943 }
944
945 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
946 Ok(RingBufferId(value))
947 }
948 }
949
950 deserializer.deserialize_u64(U64Visitor)
951 }
952}
953
954#[repr(transparent)]
955#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
956pub struct QueueId(pub u64);
957
958impl Display for QueueId {
959 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
960 Display::fmt(&self.0, f)
961 }
962}
963
964impl Deref for QueueId {
965 type Target = u64;
966
967 fn deref(&self) -> &Self::Target {
968 &self.0
969 }
970}
971
972impl PartialEq<u64> for QueueId {
973 fn eq(&self, other: &u64) -> bool {
974 self.0.eq(other)
975 }
976}
977
978impl From<QueueId> for u64 {
979 fn from(value: QueueId) -> Self {
980 value.0
981 }
982}
983
984impl QueueId {
985 #[inline]
986 pub fn to_u64(self) -> u64 {
987 self.0
988 }
989}
990
991impl From<i32> for QueueId {
992 fn from(value: i32) -> Self {
993 Self(value as u64)
994 }
995}
996
997impl From<u64> for QueueId {
998 fn from(value: u64) -> Self {
999 Self(value)
1000 }
1001}
1002
1003impl Serialize for QueueId {
1004 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1005 where
1006 S: Serializer,
1007 {
1008 serializer.serialize_u64(self.0)
1009 }
1010}
1011
1012impl<'de> Deserialize<'de> for QueueId {
1013 fn deserialize<D>(deserializer: D) -> Result<QueueId, D::Error>
1014 where
1015 D: Deserializer<'de>,
1016 {
1017 struct U64Visitor;
1018
1019 impl Visitor<'_> for U64Visitor {
1020 type Value = QueueId;
1021
1022 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1023 formatter.write_str("an unsigned 64-bit number")
1024 }
1025
1026 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1027 Ok(QueueId(value))
1028 }
1029 }
1030
1031 deserializer.deserialize_u64(U64Visitor)
1032 }
1033}
1034
1035#[repr(transparent)]
1036#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1037pub struct ProcedureId(u64);
1038
1039impl ProcedureId {
1040 pub const SYSTEM_RESERVED_START: u64 = 1 << 48;
1041
1042 pub const SYSTEM_CONFIG_SET: ProcedureId = ProcedureId::persistent(1);
1043
1044 pub const fn persistent(id: u64) -> Self {
1045 assert!(id < Self::SYSTEM_RESERVED_START, "persistent ProcedureId must be below SYSTEM_RESERVED_START");
1046 Self(id)
1047 }
1048
1049 pub const fn ephemeral(id: u64) -> Self {
1050 assert!(
1051 id >= Self::SYSTEM_RESERVED_START,
1052 "ephemeral ProcedureId must be at or above SYSTEM_RESERVED_START"
1053 );
1054 Self(id)
1055 }
1056
1057 pub const fn from_raw(id: u64) -> Self {
1058 Self(id)
1059 }
1060
1061 pub const fn is_ephemeral(&self) -> bool {
1062 self.0 >= Self::SYSTEM_RESERVED_START
1063 }
1064}
1065
1066impl Display for ProcedureId {
1067 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1068 Display::fmt(&self.0, f)
1069 }
1070}
1071
1072impl Deref for ProcedureId {
1073 type Target = u64;
1074
1075 fn deref(&self) -> &Self::Target {
1076 &self.0
1077 }
1078}
1079
1080impl PartialEq<u64> for ProcedureId {
1081 fn eq(&self, other: &u64) -> bool {
1082 self.0.eq(other)
1083 }
1084}
1085
1086impl From<ProcedureId> for u64 {
1087 fn from(value: ProcedureId) -> Self {
1088 value.0
1089 }
1090}
1091
1092impl Serialize for ProcedureId {
1093 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1094 where
1095 S: Serializer,
1096 {
1097 serializer.serialize_u64(self.0)
1098 }
1099}
1100
1101impl<'de> Deserialize<'de> for ProcedureId {
1102 fn deserialize<D>(deserializer: D) -> Result<ProcedureId, D::Error>
1103 where
1104 D: Deserializer<'de>,
1105 {
1106 struct U64Visitor;
1107
1108 impl Visitor<'_> for U64Visitor {
1109 type Value = ProcedureId;
1110
1111 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1112 formatter.write_str("an unsigned 64-bit number")
1113 }
1114
1115 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1116 Ok(ProcedureId::from_raw(value))
1117 }
1118 }
1119
1120 deserializer.deserialize_u64(U64Visitor)
1121 }
1122}
1123
1124#[repr(transparent)]
1125#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1126pub struct TestId(pub u64);
1127
1128impl Display for TestId {
1129 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1130 Display::fmt(&self.0, f)
1131 }
1132}
1133
1134impl Deref for TestId {
1135 type Target = u64;
1136
1137 fn deref(&self) -> &Self::Target {
1138 &self.0
1139 }
1140}
1141
1142impl PartialEq<u64> for TestId {
1143 fn eq(&self, other: &u64) -> bool {
1144 self.0.eq(other)
1145 }
1146}
1147
1148impl From<TestId> for u64 {
1149 fn from(value: TestId) -> Self {
1150 value.0
1151 }
1152}
1153
1154impl From<i32> for TestId {
1155 fn from(value: i32) -> Self {
1156 Self(value as u64)
1157 }
1158}
1159
1160impl From<u64> for TestId {
1161 fn from(value: u64) -> Self {
1162 Self(value)
1163 }
1164}
1165
1166impl Serialize for TestId {
1167 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1168 where
1169 S: Serializer,
1170 {
1171 serializer.serialize_u64(self.0)
1172 }
1173}
1174
1175impl<'de> Deserialize<'de> for TestId {
1176 fn deserialize<D>(deserializer: D) -> Result<TestId, D::Error>
1177 where
1178 D: Deserializer<'de>,
1179 {
1180 struct U64Visitor;
1181
1182 impl Visitor<'_> for U64Visitor {
1183 type Value = TestId;
1184
1185 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1186 formatter.write_str("an unsigned 64-bit number")
1187 }
1188
1189 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1190 Ok(TestId(value))
1191 }
1192 }
1193
1194 deserializer.deserialize_u64(U64Visitor)
1195 }
1196}
1197
1198#[repr(transparent)]
1199#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1200pub struct SubscriptionId(pub u64);
1201
1202impl Display for SubscriptionId {
1203 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1204 Display::fmt(&self.0, f)
1205 }
1206}
1207
1208impl Deref for SubscriptionId {
1209 type Target = u64;
1210
1211 fn deref(&self) -> &Self::Target {
1212 &self.0
1213 }
1214}
1215
1216impl PartialEq<u64> for SubscriptionId {
1217 fn eq(&self, other: &u64) -> bool {
1218 self.0.eq(other)
1219 }
1220}
1221
1222impl From<SubscriptionId> for u64 {
1223 fn from(value: SubscriptionId) -> Self {
1224 value.0
1225 }
1226}
1227
1228impl From<u64> for SubscriptionId {
1229 fn from(value: u64) -> Self {
1230 Self(value)
1231 }
1232}
1233
1234impl Serialize for SubscriptionId {
1235 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1236 where
1237 S: Serializer,
1238 {
1239 serializer.serialize_u64(self.0)
1240 }
1241}
1242
1243impl<'de> Deserialize<'de> for SubscriptionId {
1244 fn deserialize<D>(deserializer: D) -> Result<SubscriptionId, D::Error>
1245 where
1246 D: Deserializer<'de>,
1247 {
1248 struct U64Visitor;
1249
1250 impl Visitor<'_> for U64Visitor {
1251 type Value = SubscriptionId;
1252
1253 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1254 formatter.write_str("an unsigned 64-bit number")
1255 }
1256
1257 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1258 Ok(SubscriptionId(value))
1259 }
1260 }
1261
1262 deserializer.deserialize_u64(U64Visitor)
1263 }
1264}
1265
1266#[repr(transparent)]
1267#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1268pub struct SequenceId(pub u64);
1269
1270impl Deref for SequenceId {
1271 type Target = u64;
1272
1273 fn deref(&self) -> &Self::Target {
1274 &self.0
1275 }
1276}
1277
1278impl PartialEq<u64> for SequenceId {
1279 fn eq(&self, other: &u64) -> bool {
1280 self.0.eq(other)
1281 }
1282}
1283
1284impl Serialize for SequenceId {
1285 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1286 where
1287 S: Serializer,
1288 {
1289 serializer.serialize_u64(self.0)
1290 }
1291}
1292
1293impl<'de> Deserialize<'de> for SequenceId {
1294 fn deserialize<D>(deserializer: D) -> Result<SequenceId, D::Error>
1295 where
1296 D: Deserializer<'de>,
1297 {
1298 struct U64Visitor;
1299
1300 impl Visitor<'_> for U64Visitor {
1301 type Value = SequenceId;
1302
1303 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1304 formatter.write_str("an unsigned 64-bit number")
1305 }
1306
1307 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1308 Ok(SequenceId(value))
1309 }
1310 }
1311
1312 deserializer.deserialize_u64(U64Visitor)
1313 }
1314}
1315
1316#[repr(transparent)]
1317#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1318pub struct SubscriptionColumnId(pub u64);
1319
1320impl Display for SubscriptionColumnId {
1321 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1322 Display::fmt(&self.0, f)
1323 }
1324}
1325
1326impl Deref for SubscriptionColumnId {
1327 type Target = u64;
1328
1329 fn deref(&self) -> &Self::Target {
1330 &self.0
1331 }
1332}
1333
1334impl PartialEq<u64> for SubscriptionColumnId {
1335 fn eq(&self, other: &u64) -> bool {
1336 self.0.eq(other)
1337 }
1338}
1339
1340impl From<SubscriptionColumnId> for u64 {
1341 fn from(value: SubscriptionColumnId) -> Self {
1342 value.0
1343 }
1344}
1345
1346impl From<i32> for SubscriptionColumnId {
1347 fn from(value: i32) -> Self {
1348 Self(value as u64)
1349 }
1350}
1351
1352impl From<u64> for SubscriptionColumnId {
1353 fn from(value: u64) -> Self {
1354 Self(value)
1355 }
1356}
1357
1358impl Serialize for SubscriptionColumnId {
1359 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1360 where
1361 S: Serializer,
1362 {
1363 serializer.serialize_u64(self.0)
1364 }
1365}
1366
1367impl<'de> Deserialize<'de> for SubscriptionColumnId {
1368 fn deserialize<D>(deserializer: D) -> Result<SubscriptionColumnId, D::Error>
1369 where
1370 D: Deserializer<'de>,
1371 {
1372 struct U64Visitor;
1373
1374 impl Visitor<'_> for U64Visitor {
1375 type Value = SubscriptionColumnId;
1376
1377 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1378 formatter.write_str("an unsigned 64-bit number")
1379 }
1380
1381 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1382 Ok(SubscriptionColumnId(value))
1383 }
1384 }
1385
1386 deserializer.deserialize_u64(U64Visitor)
1387 }
1388}
1389
1390#[repr(transparent)]
1391#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1392pub struct SeriesId(pub u64);
1393
1394impl Display for SeriesId {
1395 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1396 Display::fmt(&self.0, f)
1397 }
1398}
1399
1400impl Deref for SeriesId {
1401 type Target = u64;
1402
1403 fn deref(&self) -> &Self::Target {
1404 &self.0
1405 }
1406}
1407
1408impl PartialEq<u64> for SeriesId {
1409 fn eq(&self, other: &u64) -> bool {
1410 self.0.eq(other)
1411 }
1412}
1413
1414impl From<SeriesId> for u64 {
1415 fn from(value: SeriesId) -> Self {
1416 value.0
1417 }
1418}
1419
1420impl SeriesId {
1421 pub const RUNTIME_MEMORY_SNAPSHOTS: SeriesId = SeriesId(1024);
1422 pub const RUNTIME_WATERMARKS_SNAPSHOTS: SeriesId = SeriesId(1025);
1423 pub const RUNTIME_OPERATORS_SNAPSHOTS: SeriesId = SeriesId(1026);
1424 pub const PROFILER_SPANS_SNAPSHOTS: SeriesId = SeriesId(1027);
1425 pub const INSTRUMENTS_SNAPSHOTS: SeriesId = SeriesId(1028);
1426 pub const READ_BUFFER_SNAPSHOTS: SeriesId = SeriesId(1029);
1427 pub const EPOCH_SNAPSHOTS: SeriesId = SeriesId(1030);
1428 pub const LIFECYCLE_SNAPSHOTS: SeriesId = SeriesId(1031);
1429 pub const STORAGE_SNAPSHOTS: SeriesId = SeriesId(1032);
1430 pub const CDC_SNAPSHOTS: SeriesId = SeriesId(1033);
1431 pub const FLOW_STATE_SNAPSHOTS: SeriesId = SeriesId(1035);
1432
1433 #[inline]
1434 pub fn to_u64(self) -> u64 {
1435 self.0
1436 }
1437}
1438
1439impl From<i32> for SeriesId {
1440 fn from(value: i32) -> Self {
1441 Self(value as u64)
1442 }
1443}
1444
1445impl From<u64> for SeriesId {
1446 fn from(value: u64) -> Self {
1447 Self(value)
1448 }
1449}
1450
1451impl Serialize for SeriesId {
1452 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1453 where
1454 S: Serializer,
1455 {
1456 serializer.serialize_u64(self.0)
1457 }
1458}
1459
1460impl<'de> Deserialize<'de> for SeriesId {
1461 fn deserialize<D>(deserializer: D) -> Result<SeriesId, D::Error>
1462 where
1463 D: Deserializer<'de>,
1464 {
1465 struct U64Visitor;
1466
1467 impl Visitor<'_> for U64Visitor {
1468 type Value = SeriesId;
1469
1470 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1471 formatter.write_str("an unsigned 64-bit number")
1472 }
1473
1474 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1475 Ok(SeriesId(value))
1476 }
1477 }
1478
1479 deserializer.deserialize_u64(U64Visitor)
1480 }
1481}
1482
1483#[repr(transparent)]
1484#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1485pub struct HandlerId(pub u64);
1486
1487impl Display for HandlerId {
1488 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1489 Display::fmt(&self.0, f)
1490 }
1491}
1492
1493impl Deref for HandlerId {
1494 type Target = u64;
1495
1496 fn deref(&self) -> &Self::Target {
1497 &self.0
1498 }
1499}
1500
1501impl PartialEq<u64> for HandlerId {
1502 fn eq(&self, other: &u64) -> bool {
1503 self.0.eq(other)
1504 }
1505}
1506
1507impl From<HandlerId> for u64 {
1508 fn from(value: HandlerId) -> Self {
1509 value.0
1510 }
1511}
1512
1513impl From<i32> for HandlerId {
1514 fn from(value: i32) -> Self {
1515 Self(value as u64)
1516 }
1517}
1518
1519impl From<u64> for HandlerId {
1520 fn from(value: u64) -> Self {
1521 Self(value)
1522 }
1523}
1524
1525impl Serialize for HandlerId {
1526 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1527 where
1528 S: Serializer,
1529 {
1530 serializer.serialize_u64(self.0)
1531 }
1532}
1533
1534impl<'de> Deserialize<'de> for HandlerId {
1535 fn deserialize<D>(deserializer: D) -> Result<HandlerId, D::Error>
1536 where
1537 D: Deserializer<'de>,
1538 {
1539 struct U64Visitor;
1540
1541 impl Visitor<'_> for U64Visitor {
1542 type Value = HandlerId;
1543
1544 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1545 formatter.write_str("an unsigned 64-bit number")
1546 }
1547
1548 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1549 Ok(HandlerId(value))
1550 }
1551 }
1552
1553 deserializer.deserialize_u64(U64Visitor)
1554 }
1555}
1556
1557#[repr(transparent)]
1558#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1559pub struct MigrationId(pub u64);
1560
1561impl Display for MigrationId {
1562 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1563 Display::fmt(&self.0, f)
1564 }
1565}
1566
1567impl Deref for MigrationId {
1568 type Target = u64;
1569
1570 fn deref(&self) -> &Self::Target {
1571 &self.0
1572 }
1573}
1574
1575impl PartialEq<u64> for MigrationId {
1576 fn eq(&self, other: &u64) -> bool {
1577 self.0.eq(other)
1578 }
1579}
1580
1581impl From<MigrationId> for u64 {
1582 fn from(value: MigrationId) -> Self {
1583 value.0
1584 }
1585}
1586
1587impl From<i32> for MigrationId {
1588 fn from(value: i32) -> Self {
1589 Self(value as u64)
1590 }
1591}
1592
1593impl From<u64> for MigrationId {
1594 fn from(value: u64) -> Self {
1595 Self(value)
1596 }
1597}
1598
1599impl Serialize for MigrationId {
1600 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1601 where
1602 S: Serializer,
1603 {
1604 serializer.serialize_u64(self.0)
1605 }
1606}
1607
1608impl<'de> Deserialize<'de> for MigrationId {
1609 fn deserialize<D>(deserializer: D) -> Result<MigrationId, D::Error>
1610 where
1611 D: Deserializer<'de>,
1612 {
1613 struct U64Visitor;
1614
1615 impl Visitor<'_> for U64Visitor {
1616 type Value = MigrationId;
1617
1618 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1619 formatter.write_str("an unsigned 64-bit number")
1620 }
1621
1622 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1623 Ok(MigrationId(value))
1624 }
1625 }
1626
1627 deserializer.deserialize_u64(U64Visitor)
1628 }
1629}
1630
1631#[repr(transparent)]
1632#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1633pub struct MigrationEventId(pub u64);
1634
1635impl Display for MigrationEventId {
1636 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1637 Display::fmt(&self.0, f)
1638 }
1639}
1640
1641impl Deref for MigrationEventId {
1642 type Target = u64;
1643
1644 fn deref(&self) -> &Self::Target {
1645 &self.0
1646 }
1647}
1648
1649impl PartialEq<u64> for MigrationEventId {
1650 fn eq(&self, other: &u64) -> bool {
1651 self.0.eq(other)
1652 }
1653}
1654
1655impl From<MigrationEventId> for u64 {
1656 fn from(value: MigrationEventId) -> Self {
1657 value.0
1658 }
1659}
1660
1661impl From<i32> for MigrationEventId {
1662 fn from(value: i32) -> Self {
1663 Self(value as u64)
1664 }
1665}
1666
1667impl From<u64> for MigrationEventId {
1668 fn from(value: u64) -> Self {
1669 Self(value)
1670 }
1671}
1672
1673impl Serialize for MigrationEventId {
1674 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1675 where
1676 S: Serializer,
1677 {
1678 serializer.serialize_u64(self.0)
1679 }
1680}
1681
1682impl<'de> Deserialize<'de> for MigrationEventId {
1683 fn deserialize<D>(deserializer: D) -> Result<MigrationEventId, D::Error>
1684 where
1685 D: Deserializer<'de>,
1686 {
1687 struct U64Visitor;
1688
1689 impl Visitor<'_> for U64Visitor {
1690 type Value = MigrationEventId;
1691
1692 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1693 formatter.write_str("an unsigned 64-bit number")
1694 }
1695
1696 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1697 Ok(MigrationEventId(value))
1698 }
1699 }
1700
1701 deserializer.deserialize_u64(U64Visitor)
1702 }
1703}
1704
1705#[repr(transparent)]
1706#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1707pub struct SourceId(pub u64);
1708
1709impl Display for SourceId {
1710 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1711 Display::fmt(&self.0, f)
1712 }
1713}
1714
1715impl Deref for SourceId {
1716 type Target = u64;
1717
1718 fn deref(&self) -> &Self::Target {
1719 &self.0
1720 }
1721}
1722
1723impl PartialEq<u64> for SourceId {
1724 fn eq(&self, other: &u64) -> bool {
1725 self.0.eq(other)
1726 }
1727}
1728
1729impl From<SourceId> for u64 {
1730 fn from(value: SourceId) -> Self {
1731 value.0
1732 }
1733}
1734
1735impl From<u64> for SourceId {
1736 fn from(value: u64) -> Self {
1737 Self(value)
1738 }
1739}
1740
1741impl Serialize for SourceId {
1742 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1743 where
1744 S: Serializer,
1745 {
1746 serializer.serialize_u64(self.0)
1747 }
1748}
1749
1750impl<'de> Deserialize<'de> for SourceId {
1751 fn deserialize<D>(deserializer: D) -> Result<SourceId, D::Error>
1752 where
1753 D: Deserializer<'de>,
1754 {
1755 struct U64Visitor;
1756
1757 impl Visitor<'_> for U64Visitor {
1758 type Value = SourceId;
1759
1760 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1761 formatter.write_str("an unsigned 64-bit number")
1762 }
1763
1764 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1765 Ok(SourceId(value))
1766 }
1767 }
1768
1769 deserializer.deserialize_u64(U64Visitor)
1770 }
1771}
1772
1773#[repr(transparent)]
1774#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1775pub struct BindingId(pub u64);
1776
1777impl Display for BindingId {
1778 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1779 Display::fmt(&self.0, f)
1780 }
1781}
1782
1783impl Deref for BindingId {
1784 type Target = u64;
1785
1786 fn deref(&self) -> &Self::Target {
1787 &self.0
1788 }
1789}
1790
1791impl PartialEq<u64> for BindingId {
1792 fn eq(&self, other: &u64) -> bool {
1793 self.0.eq(other)
1794 }
1795}
1796
1797impl From<BindingId> for u64 {
1798 fn from(value: BindingId) -> Self {
1799 value.0
1800 }
1801}
1802
1803impl From<u64> for BindingId {
1804 fn from(value: u64) -> Self {
1805 Self(value)
1806 }
1807}
1808
1809impl Serialize for BindingId {
1810 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1811 where
1812 S: Serializer,
1813 {
1814 serializer.serialize_u64(self.0)
1815 }
1816}
1817
1818impl<'de> Deserialize<'de> for BindingId {
1819 fn deserialize<D>(deserializer: D) -> Result<BindingId, D::Error>
1820 where
1821 D: Deserializer<'de>,
1822 {
1823 struct U64Visitor;
1824
1825 impl Visitor<'_> for U64Visitor {
1826 type Value = BindingId;
1827
1828 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1829 formatter.write_str("an unsigned 64-bit number")
1830 }
1831
1832 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1833 Ok(BindingId(value))
1834 }
1835 }
1836
1837 deserializer.deserialize_u64(U64Visitor)
1838 }
1839}
1840
1841#[repr(transparent)]
1842#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1843pub struct ColumnSnapshotId(pub u64);
1844
1845impl Display for ColumnSnapshotId {
1846 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1847 Display::fmt(&self.0, f)
1848 }
1849}
1850
1851impl Deref for ColumnSnapshotId {
1852 type Target = u64;
1853
1854 fn deref(&self) -> &Self::Target {
1855 &self.0
1856 }
1857}
1858
1859impl PartialEq<u64> for ColumnSnapshotId {
1860 fn eq(&self, other: &u64) -> bool {
1861 self.0.eq(other)
1862 }
1863}
1864
1865impl From<ColumnSnapshotId> for u64 {
1866 fn from(value: ColumnSnapshotId) -> Self {
1867 value.0
1868 }
1869}
1870
1871impl From<u64> for ColumnSnapshotId {
1872 fn from(value: u64) -> Self {
1873 Self(value)
1874 }
1875}
1876
1877impl Serialize for ColumnSnapshotId {
1878 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1879 where
1880 S: Serializer,
1881 {
1882 serializer.serialize_u64(self.0)
1883 }
1884}
1885
1886impl<'de> Deserialize<'de> for ColumnSnapshotId {
1887 fn deserialize<D>(deserializer: D) -> Result<ColumnSnapshotId, D::Error>
1888 where
1889 D: Deserializer<'de>,
1890 {
1891 struct U64Visitor;
1892
1893 impl Visitor<'_> for U64Visitor {
1894 type Value = ColumnSnapshotId;
1895
1896 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1897 formatter.write_str("an unsigned 64-bit number")
1898 }
1899
1900 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1901 Ok(ColumnSnapshotId(value))
1902 }
1903 }
1904
1905 deserializer.deserialize_u64(U64Visitor)
1906 }
1907}
1908
1909#[repr(transparent)]
1910#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
1911pub struct SinkId(pub u64);
1912
1913impl Display for SinkId {
1914 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
1915 Display::fmt(&self.0, f)
1916 }
1917}
1918
1919impl Deref for SinkId {
1920 type Target = u64;
1921
1922 fn deref(&self) -> &Self::Target {
1923 &self.0
1924 }
1925}
1926
1927impl PartialEq<u64> for SinkId {
1928 fn eq(&self, other: &u64) -> bool {
1929 self.0.eq(other)
1930 }
1931}
1932
1933impl From<SinkId> for u64 {
1934 fn from(value: SinkId) -> Self {
1935 value.0
1936 }
1937}
1938
1939impl From<u64> for SinkId {
1940 fn from(value: u64) -> Self {
1941 Self(value)
1942 }
1943}
1944
1945impl Serialize for SinkId {
1946 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1947 where
1948 S: Serializer,
1949 {
1950 serializer.serialize_u64(self.0)
1951 }
1952}
1953
1954impl<'de> Deserialize<'de> for SinkId {
1955 fn deserialize<D>(deserializer: D) -> Result<SinkId, D::Error>
1956 where
1957 D: Deserializer<'de>,
1958 {
1959 struct U64Visitor;
1960
1961 impl Visitor<'_> for U64Visitor {
1962 type Value = SinkId;
1963
1964 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1965 formatter.write_str("an unsigned 64-bit number")
1966 }
1967
1968 fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E> {
1969 Ok(SinkId(value))
1970 }
1971 }
1972
1973 deserializer.deserialize_u64(U64Visitor)
1974 }
1975}
1976
1977pub(crate) const RESERVED_USER_ID_START: u64 = 16385;
1978
1979const RESERVED_NAMESPACE_IDS: [u64; 24] = [
1980 NamespaceId::ROOT.0,
1981 NamespaceId::SYSTEM.0,
1982 NamespaceId::DEFAULT.0,
1983 NamespaceId::SYSTEM_CONFIG.0,
1984 NamespaceId::SYSTEM_METRICS.0,
1985 NamespaceId::SYSTEM_METRICS_STORAGE.0,
1986 NamespaceId::SYSTEM_METRICS_CDC.0,
1987 NamespaceId::SYSTEM_PROCEDURES.0,
1988 NamespaceId::SYSTEM_BINDINGS.0,
1989 NamespaceId::RQL.0,
1990 NamespaceId::SYSTEM_METRICS_PROFILER.0,
1991 NamespaceId::SYSTEM_METRICS_PROFILER_SPANS.0,
1992 NamespaceId::SYSTEM_METRICS_RUNTIME.0,
1993 NamespaceId::SYSTEM_METRICS_RUNTIME_MEMORY.0,
1994 NamespaceId::SYSTEM_METRICS_RUNTIME_WATERMARKS.0,
1995 NamespaceId::SYSTEM_METRICS_RUNTIME_OPERATORS.0,
1996 NamespaceId::SYSTEM_METRICS_READ_BUFFER.0,
1997 NamespaceId::SYSTEM_METRICS_INSTRUMENTS.0,
1998 NamespaceId::SYSTEM_METRICS_EPOCH.0,
1999 NamespaceId::SYSTEM_METRICS_LIFECYCLE.0,
2000 NamespaceId::SYSTEM_SOURCE.0,
2001 NamespaceId::STORAGE.0,
2002 NamespaceId::SYSTEM_METRICS_FLOW.0,
2003 NamespaceId::SYSTEM_METRICS_FLOW_STATE.0,
2004];
2005
2006const RESERVED_SOURCE_IDS: [u64; 14] = [
2007 RingBufferId::REQUEST_HISTORY.0,
2008 RingBufferId::STATEMENT_STATS.0,
2009 SeriesId::RUNTIME_MEMORY_SNAPSHOTS.0,
2010 SeriesId::RUNTIME_WATERMARKS_SNAPSHOTS.0,
2011 SeriesId::RUNTIME_OPERATORS_SNAPSHOTS.0,
2012 SeriesId::PROFILER_SPANS_SNAPSHOTS.0,
2013 SeriesId::INSTRUMENTS_SNAPSHOTS.0,
2014 SeriesId::READ_BUFFER_SNAPSHOTS.0,
2015 SeriesId::EPOCH_SNAPSHOTS.0,
2016 SeriesId::LIFECYCLE_SNAPSHOTS.0,
2017 SeriesId::STORAGE_SNAPSHOTS.0,
2018 SeriesId::CDC_SNAPSHOTS.0,
2019 SeriesId::FLOW_STATE_SNAPSHOTS.0,
2020 TableId::SOURCE_COMPLETENESS.0,
2021];
2022
2023const RESERVED_RINGBUFFER_COLUMNS: [ColumnId; 18] = [
2024 ColumnId::REQUEST_HISTORY_TIMESTAMP,
2025 ColumnId::REQUEST_HISTORY_OPERATION,
2026 ColumnId::REQUEST_HISTORY_FINGERPRINT,
2027 ColumnId::REQUEST_HISTORY_TOTAL_DURATION,
2028 ColumnId::REQUEST_HISTORY_COMPUTE_DURATION,
2029 ColumnId::REQUEST_HISTORY_SUCCESS,
2030 ColumnId::REQUEST_HISTORY_STATEMENT_COUNT,
2031 ColumnId::REQUEST_HISTORY_NORMALIZED_RQL,
2032 ColumnId::STATEMENT_STATS_SNAPSHOT_TIMESTAMP,
2033 ColumnId::STATEMENT_STATS_FINGERPRINT,
2034 ColumnId::STATEMENT_STATS_NORMALIZED_RQL,
2035 ColumnId::STATEMENT_STATS_CALLS,
2036 ColumnId::STATEMENT_STATS_TOTAL_DURATION,
2037 ColumnId::STATEMENT_STATS_MEAN_DURATION,
2038 ColumnId::STATEMENT_STATS_MAX_DURATION,
2039 ColumnId::STATEMENT_STATS_MIN_DURATION,
2040 ColumnId::STATEMENT_STATS_TOTAL_ROWS,
2041 ColumnId::STATEMENT_STATS_ERRORS,
2042];
2043
2044const RESERVED_COLUMN_GROUPS: [&[ColumnId]; 12] = [
2045 &RESERVED_RINGBUFFER_COLUMNS,
2046 &ColumnId::RUNTIME_MEMORY_SNAPSHOTS_COLUMNS,
2047 &ColumnId::RUNTIME_WATERMARKS_SNAPSHOTS_COLUMNS,
2048 &ColumnId::RUNTIME_OPERATORS_SNAPSHOTS_COLUMNS,
2049 &ColumnId::INSTRUMENTS_SNAPSHOTS_COLUMNS,
2050 &ColumnId::PROFILER_SPANS_SNAPSHOTS_COLUMNS,
2051 &ColumnId::READ_BUFFER_SNAPSHOTS_COLUMNS,
2052 &ColumnId::EPOCH_SNAPSHOTS_COLUMNS,
2053 &ColumnId::LIFECYCLE_SNAPSHOTS_COLUMNS,
2054 &ColumnId::STORAGE_SNAPSHOTS_COLUMNS,
2055 &ColumnId::CDC_SNAPSHOTS_COLUMNS,
2056 &ColumnId::SOURCE_COMPLETENESS_COLUMNS,
2057];
2058
2059const fn reserved_u64_all_below(values: &[u64], limit: u64) -> bool {
2060 let mut i = 0;
2061 while i < values.len() {
2062 if values[i] >= limit {
2063 return false;
2064 }
2065 i += 1;
2066 }
2067 true
2068}
2069
2070const fn reserved_u64_has_duplicate(values: &[u64]) -> bool {
2071 let mut i = 0;
2072 while i < values.len() {
2073 let mut j = i + 1;
2074 while j < values.len() {
2075 if values[i] == values[j] {
2076 return true;
2077 }
2078 j += 1;
2079 }
2080 i += 1;
2081 }
2082 false
2083}
2084
2085const fn reserved_columns_all_below(groups: &[&[ColumnId]], limit: u64) -> bool {
2086 let mut g = 0;
2087 while g < groups.len() {
2088 let group = groups[g];
2089 let mut i = 0;
2090 while i < group.len() {
2091 if group[i].0 >= limit {
2092 return false;
2093 }
2094 i += 1;
2095 }
2096 g += 1;
2097 }
2098 true
2099}
2100
2101const fn reserved_columns_has_duplicate(groups: &[&[ColumnId]]) -> bool {
2102 let mut g1 = 0;
2103 while g1 < groups.len() {
2104 let mut i1 = 0;
2105 while i1 < groups[g1].len() {
2106 let value = groups[g1][i1].0;
2107 let mut g2 = g1;
2108 let mut i2 = i1 + 1;
2109 while g2 < groups.len() {
2110 while i2 < groups[g2].len() {
2111 if groups[g2][i2].0 == value {
2112 return true;
2113 }
2114 i2 += 1;
2115 }
2116 g2 += 1;
2117 i2 = 0;
2118 }
2119 i1 += 1;
2120 }
2121 g1 += 1;
2122 }
2123 false
2124}
2125
2126const _: () = {
2127 assert!(
2128 reserved_u64_all_below(&RESERVED_SOURCE_IDS, RESERVED_USER_ID_START),
2129 "reserved system source id leaks into the user range"
2130 );
2131 assert!(!reserved_u64_has_duplicate(&RESERVED_SOURCE_IDS), "duplicate reserved system source id");
2132 assert!(
2133 reserved_columns_all_below(&RESERVED_COLUMN_GROUPS, RESERVED_USER_ID_START),
2134 "reserved system column id leaks into the user range"
2135 );
2136 assert!(!reserved_columns_has_duplicate(&RESERVED_COLUMN_GROUPS), "duplicate reserved system column id");
2137 assert!(
2138 reserved_u64_all_below(&RESERVED_NAMESPACE_IDS, RESERVED_USER_ID_START),
2139 "reserved system namespace id leaks into the user range"
2140 );
2141 assert!(!reserved_u64_has_duplicate(&RESERVED_NAMESPACE_IDS), "duplicate reserved system namespace id");
2142};
2143
2144#[cfg(test)]
2145mod reserved_id_tests {
2146 use std::collections::HashSet;
2147
2148 use super::{ColumnId, RingBufferId, SeriesId};
2149
2150 const USER_ID_START: u64 = 16385;
2151
2152 fn reserved_series_ids() -> [SeriesId; 10] {
2153 [
2154 SeriesId::RUNTIME_MEMORY_SNAPSHOTS,
2155 SeriesId::RUNTIME_WATERMARKS_SNAPSHOTS,
2156 SeriesId::RUNTIME_OPERATORS_SNAPSHOTS,
2157 SeriesId::INSTRUMENTS_SNAPSHOTS,
2158 SeriesId::PROFILER_SPANS_SNAPSHOTS,
2159 SeriesId::READ_BUFFER_SNAPSHOTS,
2160 SeriesId::EPOCH_SNAPSHOTS,
2161 SeriesId::LIFECYCLE_SNAPSHOTS,
2162 SeriesId::STORAGE_SNAPSHOTS,
2163 SeriesId::CDC_SNAPSHOTS,
2164 ]
2165 }
2166
2167 fn reserved_column_arrays() -> [&'static [ColumnId]; 10] {
2168 [
2169 &ColumnId::RUNTIME_MEMORY_SNAPSHOTS_COLUMNS,
2170 &ColumnId::RUNTIME_WATERMARKS_SNAPSHOTS_COLUMNS,
2171 &ColumnId::RUNTIME_OPERATORS_SNAPSHOTS_COLUMNS,
2172 &ColumnId::INSTRUMENTS_SNAPSHOTS_COLUMNS,
2173 &ColumnId::PROFILER_SPANS_SNAPSHOTS_COLUMNS,
2174 &ColumnId::READ_BUFFER_SNAPSHOTS_COLUMNS,
2175 &ColumnId::EPOCH_SNAPSHOTS_COLUMNS,
2176 &ColumnId::LIFECYCLE_SNAPSHOTS_COLUMNS,
2177 &ColumnId::STORAGE_SNAPSHOTS_COLUMNS,
2178 &ColumnId::CDC_SNAPSHOTS_COLUMNS,
2179 ]
2180 }
2181
2182 #[test]
2183 fn system_series_ids_are_reserved_unique_and_below_user_range() {
2184 let mut seen = HashSet::new();
2185 assert!(seen.insert(RingBufferId::REQUEST_HISTORY.0), "ringbuffer source id setup");
2186 assert!(seen.insert(RingBufferId::STATEMENT_STATS.0), "ringbuffer source id setup");
2187
2188 for id in reserved_series_ids() {
2189 assert!(id.0 < USER_ID_START, "system series id {} leaks into the user range", id.0);
2190 assert!(
2191 seen.insert(id.0),
2192 "system series id {} collides with another reserved source id",
2193 id.0
2194 );
2195 }
2196 }
2197
2198 #[test]
2199 fn system_column_ids_are_reserved_unique_and_below_user_range() {
2200 let mut seen = HashSet::new();
2201 for ringbuffer_column in 1..=18u64 {
2202 assert!(seen.insert(ringbuffer_column), "ringbuffer column id setup");
2203 }
2204
2205 let mut count = 0;
2206 for array in reserved_column_arrays() {
2207 for &id in array {
2208 assert!(id.0 < USER_ID_START, "system column id {} leaks into the user range", id.0);
2209 assert!(
2210 seen.insert(id.0),
2211 "system column id {} collides with another reserved column id",
2212 id.0
2213 );
2214 count += 1;
2215 }
2216 }
2217
2218 assert_eq!(count, 4 * 6 + 18 + 24 + 7 + 10 + 14 + 8, "expected exactly 105 reserved system column ids");
2219 }
2220
2221 #[test]
2222 fn snapshot_column_arrays_have_expected_widths() {
2223 let arrays = reserved_column_arrays();
2226 for array in &arrays[..4] {
2227 assert_eq!(array.len(), 6, "long-format snapshot series must declare 6 column ids");
2228 }
2229 assert_eq!(arrays[4].len(), 18, "spans snapshot series must declare 18 column ids");
2230 assert_eq!(arrays[5].len(), 24, "read_buffer snapshot series must declare 24 column ids");
2231 assert_eq!(arrays[6].len(), 7, "epoch snapshot series must declare 7 column ids");
2232 assert_eq!(arrays[7].len(), 10, "lifecycle snapshot series must declare 10 column ids");
2233 assert_eq!(arrays[8].len(), 14, "storage snapshot series must declare 14 column ids");
2234 assert_eq!(arrays[9].len(), 8, "cdc snapshot series must declare 8 column ids");
2235 }
2236}