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
/*
* Copyright (c) 2025-2026 Anton Kundenko <singaraiona@gmail.com>
* All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* idxop.h -- Per-vector accelerator indices.
*
* A vector with RAY_ATTR_HAS_INDEX set carries a child ray_t of type
* RAY_INDEX in its nullmap[0..7] slot. The index ray_t holds:
* - the kind (hash / sort / zone / bloom)
* - kind-specific payload (keys vec, perm vec, min/max, bloom bits)
* - a snapshot of the parent's original 16-byte nullmap union plus
* the relevant attrs bits, so detach can restore the vector to its
* pre-attach state byte-for-byte.
*
* Attach precondition: parent must not be a slice, must not already
* carry an index, must be COW'd to rc==1 by the caller's path.
*
* Mutation invalidates: any in-place write to the parent vector must
* call ray_index_drop() first — a stale index is a wrong-answer bug.
*/
/* Index kinds. Stored in ray_index_t.kind. */
typedef enum ray_idx_kind_t;
/* The payload stored inside data[] of a RAY_INDEX ray_t. */
typedef struct ray_index_t;
/* Inline accessor — returns ray_index_t* for a RAY_INDEX block. */
static inline ray_index_t*
/* == */
/* Build an accelerator and attach. Numeric types only for v1
* (BOOL/U8/I16/I32/I64/F32/F64/DATE/TIME/TIMESTAMP — RAY_STR/RAY_SYM/RAY_GUID
* deferred until the str_pool/sym_dict displacement sweep is complete).
* On success, *vp is the (possibly new) parent vector with HAS_INDEX set.
* On failure, *vp is unchanged and a RAY_ERROR is returned. */
ray_t* ;
ray_t* ;
ray_t* ;
ray_t* ;
/* Drop any attached index from *vp. No-op if none. Restores the
* pre-attach nullmap state byte-for-byte. Returns *vp. */
ray_t* ;
/* == */
static inline bool
/* Returns RAY_IDX_NONE if no index is attached. */
static inline ray_idx_kind_t
/* Returns a fresh RAY_DICT with {kind, length, ...kind-specific...}
* or RAY_NULL_OBJ when no index is attached. */
ray_t* ;
/* ===== Internal helpers (used by retain/release/detach in heap.c
* and by mutation paths in vec.c) ===== */
/* Release the saved-nullmap pointers carried by a RAY_INDEX ray_t.
* Invoked from ray_release_owned_refs when the index ray_t is freed. */
void ;
/* Retain the saved-nullmap pointers carried by a RAY_INDEX ray_t.
* Invoked from ray_retain_owned_refs after a copy of the index ray_t. */
void ;
/* Release per-kind payload children (keys/table/perm/bits...). */
void ;
/* Retain per-kind payload children. */
void ;
/* == */
ray_t* ; /* (.idx.zone v) -> v with zone attached */
ray_t* ; /* (.idx.hash v) -> v with hash attached */
ray_t* ; /* (.idx.sort v) -> v with sort attached */
ray_t* ; /* (.idx.bloom v) -> v with bloom attached */
ray_t* ; /* (.idx.drop v) -> v with index removed */
ray_t* ; /* (.idx.has? v) -> 0b/1b */
ray_t* ; /* (.idx.info v) -> dict of metadata */
/* RAY_IDXOP_H */