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
//
// Unified Query Algebra
//
// Copyright (c) 2023-2026 Cognica, Inc.
//
//! Provider record codecs for the shared occurrence commit resolver.
mod clusters;
mod resolve;
mod statistics;
#[cfg(test)]
mod tests;
use crate::{inverted_index::IndexedFieldRevision, read_control::StorageReadControl};
use uqa_core::memory::BudgetedVec;
use super::VersionResult;
/// Complete record identities eligible for an evaluated occurrence replacement.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum OccurrenceRecordKind {
Score(u64),
Positions,
Cluster(u64),
Statistics,
Format,
Cache,
}
/// Related records in the same stable index scope. Cache addresses are scan prefixes; all other addresses are complete keys.
#[derive(Clone, Copy)]
pub enum OccurrenceRelatedKey {
Structure,
Format,
Score,
Positions,
Skips,
BlockMax,
}
/// Borrowed column projections preserve provider payload ownership during decoding. Common storage owns cluster merging and checked field-counter arithmetic.
pub enum OccurrenceRecordValue<'a> {
Score(&'a [u8]),
Positions(&'a [u8]),
Cluster {
score: &'a [u8],
positions: &'a [u8],
},
Statistics {
revision: IndexedFieldRevision,
doc_count: u64,
total_length: u64,
},
Format(&'a [u8]),
}
/// Physical addressing and row codecs only. Methods must validate complete keys, keep related addresses within the original object generation and charge temporary allocations to `control`. They perform no I/O, index algorithms or application callbacks.
pub trait OccurrenceRecordLayout: Send + Sync {
fn kind(&self, key: &[u8], control: &StorageReadControl)
-> VersionResult<OccurrenceRecordKind>;
fn related_key(
&self,
key: &[u8],
related: OccurrenceRelatedKey,
control: &StorageReadControl,
) -> VersionResult<BudgetedVec<u8>>;
fn decode<'a>(
&self,
key: &[u8],
value: &'a [u8],
control: &StorageReadControl,
) -> VersionResult<OccurrenceRecordValue<'a>>;
/// Encode the merged value with the key and immutable row fields from an original, evaluated or current record. This may enforce narrower native scalar bounds before any publication occurs.
fn encode(
&self,
key: &[u8],
template: &[u8],
value: OccurrenceRecordValue<'_>,
control: &StorageReadControl,
) -> VersionResult<BudgetedVec<u8>>;
}
pub(super) use resolve::resolve;