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
/*
* 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.
*/
/* The import dictionary: a symbol file one converter builds alone.
*
* Interned strings are appended straight into the mapped file as its STRL
* records ([u32 len | bytes], position i = i-th record), so the file is the
* dictionary's storage: nothing is copied out at the end and its pages are
* the page cache's to write back and evict. In memory there are only the
* record offsets and a hash index split into shards; a hit is found
* without a lock, and new strings are added under one. Position 0 is "". POSIX only:
* ray_symimp_create returns NULL elsewhere, and on any failure to set up,
* and the caller keeps the ordinary domain. */
typedef struct ray_symimp_s ray_symimp_t;
/* Create (truncating) the symbol file at `path`. `count` receives the
* number of entries as they are added. */
ray_symimp_t* ;
/* Position of each string, adding the new ones; thread-safe. hashes[i] is
* ray_hash_bytes of strs[i], all 64 bits (shard, home slot and tag come
* from separate bits). False on allocation or file growth failure. */
bool ;
/* Write the header count and start writing back what was added since the
* last call; `durable` cuts the file to its records and syncs it. */
ray_err_t ;
void ;
/* What the interning did, for the converters' RAY_CSV_TRACE: the counts
* since the last call (which resets them), then the sizes now. The counts
* are kept only for a dictionary created under RAY_CSV_TRACE, their only
* reader (zero otherwise: the lookups then touch none of them); the sizes
* always. */
typedef struct ray_symimp_stats_s ray_symimp_stats_t;
void ;
/* The shard tables' bytes now: none from the first ray_symimp_reserve on
* (freed then, as nothing reads them after it, unless a lookup was in
* flight: kept to ray_symimp_free). */
int64_t ;
/* Records placed by the caller (table/symgrp.h, the grouped import), which
* keeps its own index: positions [*pos0, *pos0 + n) and `bytes` bytes of
* records from file offset *off0, the file grown (and its blocks allocated)
* to hold them. The records are then written with ray_symimp_put, from any
* thread, each range by one writer. From the first reserve on,
* ray_symimp_intern_batch fails and no string is added (a call in flight
* may still return what it found): its shard tables miss these records (and
* are freed then, unless a lookup is in flight). */
bool ;
void ;
/* Or written by the caller with ray_symimp_write (pwrite: no page of the
* mapping is faulted in for it), its offset noted with ray_symimp_place. */
void ;
bool ;
/* Start writing back file bytes [off, off + len): records the caller has
* written, ray_symimp_sync covering everything reserved at once. */
void ;
/* Record `pos` of the file, written: its bytes (in the mapping) and length,
* and the offset of its length prefix. */
const char* ;
int64_t ;
/* Entries (positions) the file holds, the records written of all but those
* reserved and not yet put. */
int64_t ;
/* Ask for file bytes [off, off + len) to be read ahead (MADV_WILLNEED). */
void ;