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
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors
//! The one vocabulary for "these compressed buffers are malformed", plus the
//! panic helper that surfaces it.
//!
//! A [`ColumnView`](crate::ColumnView) / dictionary view is built from buffers a
//! consumer deserialized from storage, so its arrays may be corrupt.
//! [`InvalidColumn`] enumerates the structural violations that would otherwise
//! make a decoder read or write out of bounds. It is surfaced two ways:
//!
//! * **Recoverable** — the `validate` family returns a `Result` for buffers a
//! consumer deserialized from storage. Two distinct roles:
//! * [`CompactDictionary::validate`](crate::CompactDictionary::validate) is the
//! *trust boundary*: it seals raw `(bytes, offsets)` into a trusted dictionary,
//! which is what lets the decoder read tokens unchecked. Validate once, then
//! decode on the fast (unchecked) path.
//! * [`ColumnView::validate`](crate::ColumnView::validate) is a *pre-flight*, not
//! a fast-path gate: the decode kernels bounds-check every code and row offset
//! regardless, so it unlocks nothing faster. It just reports the same
//! violations up front, as a `Result`, instead of as a mid-decode panic.
//! * **Infallible** — operations that are infallible by signature (the convenience
//! decoders, the per-row/per-code guards) panic on malformed data through
//! [`panic_malformed`], with a message derived from `InvalidColumn`'s `Display`.
//!
//! Bad *arguments* to the fallible encoding API (`compress`/`train`/`parse`) are a
//! separate domain ([`Error`](crate::Error)).
/// A violation found while validating compressed buffers.
///
/// Two kinds. **Safety** violations would let an unchecked decoder read or write
/// out of bounds — these are exactly the obligations an `unsafe new_unchecked`
/// caller must uphold to avoid UB. **Conformance** violations decode safely but
/// make search / tokenize give *wrong answers*. The `validate` family checks both,
/// so a trusted dictionary is fully conformant — indistinguishable from a
/// trainer-built one.
/// Panic for a malformed column/dictionary, message derived from
/// `InvalidColumn`'s `Display`. `#[cold]` + `#[inline(never)]` so a caller's
/// guard is laid out as a never-taken branch.
pub !