interplane.Get Omega
Read in your language

cortex

aien-dev/cortex

Brought by drakestapleton

branch main Branches Tags History

cortex / tests / fts / t_like.om

176 lines · 3050 bytes Raw Blame History
1note ===== tests/fts/t_like.om : LIKE differential harness =====
2note usage: t_like DUMP PATTERNS > out ; per pattern "p<i> ok|err n=<k> <hex bitmap>" where bit j
3note is set when entity j (dump order = rowid order) has canonical_name LIKE p OR content LIKE p
4note (answered as the server does: like_find for the '%' literal '%' patterns like_lit accepts,
5note like_test for the others)
6note content bytes span tcb, tcb1, tcb2 (16 MiB each; one pool holds at most 16777216 elements):
7note the live content passed 16 MiB on 2026-10-26 (16834750 bytes, 6641 entities; trap 3)
8global tcb uchar 16777216
9global tcb1 uchar 16777216
10global tcb2 uchar 16777216
11global tco ulong 65536
12global tnb uchar 1048576
13global tno ulong 65536
14global tbm uchar 65536
15text tlk1 " ok n="
16text tlk2 " err n="
17fn main to int
18nen = t_lload
19fp = t_open 2
20put tibn 0 0
21put tibp 0 0
22pi = ulong 0
23while t_need fp 4 bound 999999
24t_rdpat fp
25t_lone pi nen
26pi = add pi 1
27end
28t_flush
29ret 0
30end
31note skip the FTS rows, load the entities (name, content) into tnb/tcb
32fn t_lload to ulong
33fd = t_open 1
34z = t_need fd 12
35put tibp 0 8
36nf = t_u32
37for r ulong nf
38z = t_need fd 8
39row = t_u64
40for k ulong 5
41b = t_rdsb fd
42end
43z = t_need fd 1
44put tibp 0 add get tibp 0 1
45end
46z = t_need fd 4
47nen = t_u32
48co = ulong 0
49no = ulong 0
50for e ulong nen
51z = t_need fd 8
52row = t_u64
53b = t_rdsb fd
54put tno e no
55no = t_cpn no
56t_rdct fd
57put tco e co
58co = t_cpc co
59end
60put tno nen no
61put tco nen co
62ret nen
63end
64fn t_cpn o ulong to ulong
65n = get tsbn 0
66for i ulong n
67put tnb add o i get tsb i
68end
69ret add o n
70end
71fn t_cpc o ulong to ulong
72n = get qctl 0
73for i ulong n
74tc_put add o i get qct i
75end
76ret add o n
77end
78fn t_rdpat fp int to void
79n = t_u32
80z = t_need fp n
81p = get tibp 0
82for i ulong n
83put qlp i get tib add p i
84end
85put tibp 0 add p n
86put qlpl 0 n
87end
88fn t_lone pi ulong nen ulong to void
89for i ulong add div nen 8 1
90put tbm i 0
91end
92ok = like_set
93lit = like_lit
94c = ulong 0
95if ok
96for e ulong nen
97if t_lent e lit
98t_bset e
99c = add c 1
100end
101end
102end
103t_ch 112
104t_dec pi
105if ok
106for i ulong len tlk1
107t_ch ulong get tlk1 i
108end
109else
110for i ulong len tlk2
111t_ch ulong get tlk2 i
112end
113end
114t_dec c
115t_ch 32
116for i ulong div add nen 7 8
117t_hex ulong get tbm i 2
118end
119t_ch 10
120end
121fn t_lent e ulong lit bool to bool
122a = get tno e
123n = sub get tno add e 1 a
124for i ulong n
125put qct i get tnb add a i
126end
127put qctl 0 n
128if t_lt lit
129ret true
130end
131a = get tco e
132n = sub get tco add e 1 a
133for i ulong n
134put qct i tc_get add a i
135end
136put qctl 0 n
137ret t_lt lit
138end
139fn t_lt lit bool to bool
140if lit
141ret like_find
142end
143ret like_test
144end
145fn t_bset e ulong to void
146k = div e 8
147v = ulong get tbm k
148put tbm k uchar or v shl ulong 1 rem e 8
149end
150
151fn tc_put i ulong v uchar to void
152k = div i 16777216
153j = rem i 16777216
154note Omega has no elif (it parses as an assignment to a local named elif), so each branch
155note returns on its own
156if eq k 0
157put tcb j v
158ret
159end
160if eq k 1
161put tcb1 j v
162ret
163end
164put tcb2 j v
165end
166fn tc_get i ulong to uchar
167k = div i 16777216
168j = rem i 16777216
169if eq k 0
170ret get tcb j
171end
172if eq k 1
173ret get tcb1 j
174end
175ret get tcb2 j
176end