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
// 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 safety violations that would otherwise make a
//! decoder read or write out of bounds, plus conformance violations that can make
//! search or tokenization return wrong answers. It is surfaced through
//! recoverable validation and infallible operations:
//!
//! * **Recoverable validation** — the validation family returns a `Result` for
//! buffers a consumer deserialized from storage.
//! * Dictionary validation has two levels:
//! * [`CompactDictionary::validate_safety`](crate::CompactDictionary::validate_safety)
//! is the cheap safety trust boundary: it seals raw `(bytes, offsets)` into
//! a dictionary that the unchecked decoder can read safely, without
//! inspecting token contents.
//! * [`CompactDictionary::validate`](crate::CompactDictionary::validate)
//! additionally checks sortedness, uniqueness, and alphabet completeness for
//! semantically correct search and tokenization.
//! * **Infallible operations** — 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, or prevent a search tokenizer from making progress — these are
/// exactly the obligations an unsafe safety-level constructor must uphold. A
/// safety-valid dictionary can still be semantically malformed. **Conformance**
/// violations decode safely but make search/tokenize give wrong answers.
/// `validate_safety` checks only the former; `validate` checks both.
/// 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 !