@yaks/sqlite 0.0.0-stage → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1596 -2
  3. package/_dist/archetype.d.ts +75 -0
  4. package/_dist/archetype.d.ts.map +1 -0
  5. package/_dist/branches.d.ts +23 -0
  6. package/_dist/branches.d.ts.map +1 -0
  7. package/_dist/budget.d.ts +52 -0
  8. package/_dist/budget.d.ts.map +1 -0
  9. package/_dist/bundle.d.ts +2 -0
  10. package/_dist/bundle.d.ts.map +1 -0
  11. package/_dist/cache.d.ts +24 -0
  12. package/_dist/cache.d.ts.map +1 -0
  13. package/_dist/catalog.d.ts +9 -0
  14. package/_dist/catalog.d.ts.map +1 -0
  15. package/_dist/check.d.ts +4 -0
  16. package/_dist/check.d.ts.map +1 -0
  17. package/_dist/db.d.ts +36 -0
  18. package/_dist/db.d.ts.map +1 -0
  19. package/_dist/ddl.d.ts +143 -0
  20. package/_dist/ddl.d.ts.map +1 -0
  21. package/_dist/doom.d.ts +22 -0
  22. package/_dist/doom.d.ts.map +1 -0
  23. package/_dist/follow.d.ts +74 -0
  24. package/_dist/follow.d.ts.map +1 -0
  25. package/_dist/history-shapes.d.ts +3 -0
  26. package/_dist/history-shapes.d.ts.map +1 -0
  27. package/_dist/history.d.ts +18 -0
  28. package/_dist/history.d.ts.map +1 -0
  29. package/_dist/inspect.d.ts +43 -0
  30. package/_dist/inspect.d.ts.map +1 -0
  31. package/_dist/jsonb.d.ts +17 -0
  32. package/_dist/jsonb.d.ts.map +1 -0
  33. package/_dist/layout.d.ts +7 -0
  34. package/_dist/layout.d.ts.map +1 -0
  35. package/_dist/ledger.d.ts +41 -0
  36. package/_dist/ledger.d.ts.map +1 -0
  37. package/_dist/meta.d.ts +89 -0
  38. package/_dist/meta.d.ts.map +1 -0
  39. package/_dist/migration.d.ts +41 -0
  40. package/_dist/migration.d.ts.map +1 -0
  41. package/_dist/mod.d.ts +201 -0
  42. package/_dist/mod.d.ts.map +1 -0
  43. package/_dist/mode.d.ts +14 -0
  44. package/_dist/mode.d.ts.map +1 -0
  45. package/_dist/overlay.d.ts +30 -0
  46. package/_dist/overlay.d.ts.map +1 -0
  47. package/_dist/owe.d.ts +180 -0
  48. package/_dist/owe.d.ts.map +1 -0
  49. package/_dist/physical.d.ts +89 -0
  50. package/_dist/physical.d.ts.map +1 -0
  51. package/_dist/point.d.ts +10 -0
  52. package/_dist/point.d.ts.map +1 -0
  53. package/_dist/raise.d.ts +22 -0
  54. package/_dist/raise.d.ts.map +1 -0
  55. package/_dist/read-db.d.ts +9 -0
  56. package/_dist/read-db.d.ts.map +1 -0
  57. package/_dist/read-store.d.ts +10 -0
  58. package/_dist/read-store.d.ts.map +1 -0
  59. package/_dist/read.d.ts +59 -0
  60. package/_dist/read.d.ts.map +1 -0
  61. package/_dist/reader.d.ts +11 -0
  62. package/_dist/reader.d.ts.map +1 -0
  63. package/_dist/rules.d.ts +19 -0
  64. package/_dist/rules.d.ts.map +1 -0
  65. package/_dist/service.d.ts +12 -0
  66. package/_dist/service.d.ts.map +1 -0
  67. package/_dist/shape.d.ts +12 -0
  68. package/_dist/shape.d.ts.map +1 -0
  69. package/_dist/statements.d.ts +4 -0
  70. package/_dist/statements.d.ts.map +1 -0
  71. package/_dist/survey.d.ts +31 -0
  72. package/_dist/survey.d.ts.map +1 -0
  73. package/_dist/tools.d.ts +15 -0
  74. package/_dist/tools.d.ts.map +1 -0
  75. package/_dist/trash.d.ts +18 -0
  76. package/_dist/trash.d.ts.map +1 -0
  77. package/_dist/unit.d.ts +11 -0
  78. package/_dist/unit.d.ts.map +1 -0
  79. package/_dist/vocab.d.ts +6 -0
  80. package/_dist/vocab.d.ts.map +1 -0
  81. package/_dist/write.d.ts +169 -0
  82. package/_dist/write.d.ts.map +1 -0
  83. package/answer.js +110 -0
  84. package/answer.js.map +1 -0
  85. package/answer.ts +122 -0
  86. package/archetype.js +730 -0
  87. package/archetype.js.map +1 -0
  88. package/archetype.ts +790 -0
  89. package/binary_cases.ts +240 -0
  90. package/branches.js +195 -0
  91. package/branches.js.map +1 -0
  92. package/branches.ts +257 -0
  93. package/budget.js +89 -0
  94. package/budget.js.map +1 -0
  95. package/budget.ts +117 -0
  96. package/builtin.js +34 -0
  97. package/builtin.js.map +1 -0
  98. package/builtin.ts +31 -0
  99. package/bundle.js +21 -0
  100. package/bundle.js.map +1 -0
  101. package/bundle.ts +22 -0
  102. package/buried.js +95 -0
  103. package/buried.js.map +1 -0
  104. package/buried.ts +124 -0
  105. package/cache.js +153 -0
  106. package/cache.js.map +1 -0
  107. package/cache.ts +154 -0
  108. package/cache_worker.ts +16 -0
  109. package/catalog.js +173 -0
  110. package/catalog.js.map +1 -0
  111. package/catalog.ts +224 -0
  112. package/check.js +80 -0
  113. package/check.js.map +1 -0
  114. package/check.ts +92 -0
  115. package/checkpoint.js +98 -0
  116. package/checkpoint.js.map +1 -0
  117. package/checkpoint.ts +129 -0
  118. package/checkpoint_worker.ts +37 -0
  119. package/db.js +170 -0
  120. package/db.js.map +1 -0
  121. package/db.ts +173 -0
  122. package/ddl.js +1441 -0
  123. package/ddl.js.map +1 -0
  124. package/ddl.ts +1508 -0
  125. package/deno.json +1 -0
  126. package/doom.js +59 -0
  127. package/doom.js.map +1 -0
  128. package/doom.ts +75 -0
  129. package/driver.js +69 -0
  130. package/driver.js.map +1 -0
  131. package/driver.ts +101 -0
  132. package/error.js +30 -0
  133. package/error.js.map +1 -0
  134. package/error.ts +46 -0
  135. package/ffi/LICENSE +202 -0
  136. package/ffi/blob.js +99 -0
  137. package/ffi/blob.js.map +1 -0
  138. package/ffi/blob.ts +156 -0
  139. package/ffi/constants.js +65 -0
  140. package/ffi/constants.js.map +1 -0
  141. package/ffi/constants.ts +67 -0
  142. package/ffi/database.js +613 -0
  143. package/ffi/database.js.map +1 -0
  144. package/ffi/database.ts +931 -0
  145. package/ffi/ffi.js +535 -0
  146. package/ffi/ffi.js.map +1 -0
  147. package/ffi/ffi.ts +604 -0
  148. package/ffi/mod.js +15 -0
  149. package/ffi/mod.js.map +1 -0
  150. package/ffi/mod.ts +28 -0
  151. package/ffi/statement.js +555 -0
  152. package/ffi/statement.js.map +1 -0
  153. package/ffi/statement.ts +788 -0
  154. package/ffi/util.js +32 -0
  155. package/ffi/util.js.map +1 -0
  156. package/ffi/util.ts +48 -0
  157. package/follow.js +342 -0
  158. package/follow.js.map +1 -0
  159. package/follow.ts +401 -0
  160. package/history-branch.js +166 -0
  161. package/history-branch.js.map +1 -0
  162. package/history-branch.ts +140 -0
  163. package/history-shapes.js +254 -0
  164. package/history-shapes.js.map +1 -0
  165. package/history-shapes.ts +268 -0
  166. package/history.js +620 -0
  167. package/history.js.map +1 -0
  168. package/history.ts +674 -0
  169. package/inspect.js +120 -0
  170. package/inspect.js.map +1 -0
  171. package/inspect.ts +164 -0
  172. package/jsonb.js +73 -0
  173. package/jsonb.js.map +1 -0
  174. package/jsonb.ts +108 -0
  175. package/layout.js +22 -0
  176. package/layout.js.map +1 -0
  177. package/layout.ts +26 -0
  178. package/ledger.js +210 -0
  179. package/ledger.js.map +1 -0
  180. package/ledger.ts +210 -0
  181. package/legacy.js +4 -0
  182. package/legacy.js.map +1 -0
  183. package/legacy.ts +3 -0
  184. package/maintenance.js +148 -0
  185. package/maintenance.js.map +1 -0
  186. package/maintenance.ts +154 -0
  187. package/measure.js +133 -0
  188. package/measure.js.map +1 -0
  189. package/measure.ts +167 -0
  190. package/measure_worker.ts +18 -0
  191. package/memo.js +1250 -0
  192. package/memo.js.map +1 -0
  193. package/memo.ts +1480 -0
  194. package/meta.js +265 -0
  195. package/meta.js.map +1 -0
  196. package/meta.ts +321 -0
  197. package/migration.js +272 -0
  198. package/migration.js.map +1 -0
  199. package/migration.ts +286 -0
  200. package/mod.js +1103 -0
  201. package/mod.js.map +1 -0
  202. package/mod.ts +1762 -0
  203. package/mode.js +192 -0
  204. package/mode.js.map +1 -0
  205. package/mode.ts +207 -0
  206. package/native.js +544 -0
  207. package/native.js.map +1 -0
  208. package/native.ts +544 -0
  209. package/overlay.js +408 -0
  210. package/overlay.js.map +1 -0
  211. package/overlay.ts +485 -0
  212. package/owe.js +719 -0
  213. package/owe.js.map +1 -0
  214. package/owe.ts +873 -0
  215. package/package.json +99 -4
  216. package/physical.js +350 -0
  217. package/physical.js.map +1 -0
  218. package/physical.ts +434 -0
  219. package/plan.js +78 -0
  220. package/plan.js.map +1 -0
  221. package/plan.ts +104 -0
  222. package/point.js +81 -0
  223. package/point.js.map +1 -0
  224. package/point.ts +52 -0
  225. package/population.js +639 -0
  226. package/population.js.map +1 -0
  227. package/population.ts +630 -0
  228. package/purge.js +117 -0
  229. package/purge.js.map +1 -0
  230. package/purge.ts +127 -0
  231. package/raise.js +270 -0
  232. package/raise.js.map +1 -0
  233. package/raise.ts +316 -0
  234. package/read-db.js +381 -0
  235. package/read-db.js.map +1 -0
  236. package/read-db.ts +282 -0
  237. package/read-store.js +74 -0
  238. package/read-store.js.map +1 -0
  239. package/read-store.ts +86 -0
  240. package/read.js +1100 -0
  241. package/read.js.map +1 -0
  242. package/read.ts +1441 -0
  243. package/reader.js +141 -0
  244. package/reader.js.map +1 -0
  245. package/reader.ts +159 -0
  246. package/rules.js +88 -0
  247. package/rules.js.map +1 -0
  248. package/rules.ts +113 -0
  249. package/service.js +27 -0
  250. package/service.js.map +1 -0
  251. package/service.ts +41 -0
  252. package/shape.js +76 -0
  253. package/shape.js.map +1 -0
  254. package/shape.ts +108 -0
  255. package/sparse_presence_fixture.ts +45 -0
  256. package/sqlitepath.js +24 -0
  257. package/sqlitepath.js.map +1 -0
  258. package/sqlitepath.ts +29 -0
  259. package/statements.js +78 -0
  260. package/statements.js.map +1 -0
  261. package/statements.ts +96 -0
  262. package/survey.js +135 -0
  263. package/survey.js.map +1 -0
  264. package/survey.ts +196 -0
  265. package/tools.js +17 -0
  266. package/tools.js.map +1 -0
  267. package/tools.ts +50 -0
  268. package/trash.js +144 -0
  269. package/trash.js.map +1 -0
  270. package/trash.ts +187 -0
  271. package/unit.js +215 -0
  272. package/unit.js.map +1 -0
  273. package/unit.ts +211 -0
  274. package/versions.js +115 -0
  275. package/versions.js.map +1 -0
  276. package/versions.ts +110 -0
  277. package/vocab.js +19 -0
  278. package/vocab.js.map +1 -0
  279. package/vocab.json +27 -0
  280. package/vocab.ts +19 -0
  281. package/watch.js +33 -0
  282. package/watch.js.map +1 -0
  283. package/watch.ts +42 -0
  284. package/write.js +1164 -0
  285. package/write.js.map +1 -0
  286. package/write.ts +1356 -0
  287. package/written.js +200 -0
  288. package/written.js.map +1 -0
  289. package/written.ts +202 -0
package/cache.js ADDED
@@ -0,0 +1,153 @@
1
+ // Rebuildable SQLite caches stay at their path and inode: another process may
2
+ // still have them open. Deno's own caches are open in this one too, through
3
+ // the SQLite built into Deno, so a cache is opened only through that copy
4
+ // (./builtin.ts). Their file-URL columns identify entries nobody can use
5
+ // once the source is gone; deleting and vacuuming returns their pages in place.
6
+ // A trim waits on the disk, on file checks, a vacuum and its lock, so a
7
+ // process runs it on a thread of its own (./cache_worker.ts).
8
+ import * as io from "@yaks/file/io";
9
+ import { col, oneOf, select, table } from "@yaks/sql";
10
+ import { builtin } from "./builtin.js";
11
+ import { busy, malformed } from "./error.js";
12
+ import { unit } from "./unit.js";
13
+ /** The bytes a cache and its SQLite WAL occupy, without the shared-memory
14
+ * index, whose size is unrelated to the bytes stored. */ export let held = async (path)=>{
15
+ let sizes = await Promise.all([
16
+ path,
17
+ path + '-wal'
18
+ ].map(async (p)=>{
19
+ try {
20
+ return (await io.stat(p)).size;
21
+ } catch (error) {
22
+ if (io.isNotFound(error)) return 0;
23
+ throw error;
24
+ }
25
+ }));
26
+ return sizes.reduce((sum, n)=>sum + n, 0);
27
+ };
28
+ let missing = (specifier)=>{
29
+ try {
30
+ io.statSync(io.fileURLToPath(specifier));
31
+ return false;
32
+ } catch (error) {
33
+ if (io.isNotFound(error) || io.isNotADirectory(error)) return true;
34
+ if (io.isPermissionDenied(error)) return false;
35
+ throw error;
36
+ }
37
+ };
38
+ /** Remove entries for missing local files through a cache's declared columns.
39
+ * Remote specifiers and unreadable local files stay cached. */ export let prune = (db, tables, gone = missing)=>{
40
+ let removed = 0;
41
+ for (let [name, key] of Object.entries(tables)){
42
+ let rows = db.query(select({
43
+ distinct: true,
44
+ cols: [
45
+ col(key)
46
+ ],
47
+ from: table(name),
48
+ where: {
49
+ t: 'op',
50
+ op: 'like',
51
+ parts: [
52
+ col(key),
53
+ {
54
+ t: 'val',
55
+ v: 'file:%'
56
+ }
57
+ ]
58
+ }
59
+ }));
60
+ let stale = rows.map((r)=>String(r[key])).filter(gone);
61
+ if (!stale.length) continue;
62
+ let change = {
63
+ t: 'delete',
64
+ from: name,
65
+ where: oneOf(col(key), stale)
66
+ };
67
+ removed += unit(db, ()=>db.run?.(change) ?? (db.query(change), stale.length));
68
+ }
69
+ return removed;
70
+ };
71
+ /** Vacuum and truncate the WAL. False while another connection reads the
72
+ * cache: the vacuumed pages stay in the WAL until a later pass. */ let compact = (db)=>{
73
+ db.query({
74
+ t: 'vacuum'
75
+ });
76
+ let [checkpoint] = db.query({
77
+ t: 'pragma',
78
+ name: 'wal_checkpoint',
79
+ value: 'truncate'
80
+ });
81
+ return !checkpoint?.busy;
82
+ };
83
+ let shrink = async (path, cache)=>{
84
+ let db = builtin(path);
85
+ try {
86
+ db.query({
87
+ t: 'pragma',
88
+ name: 'busy_timeout',
89
+ value: 1000
90
+ });
91
+ prune(db, cache.tables);
92
+ if (!compact(db) || await held(path) <= cache.most) return;
93
+ unit(db, ()=>{
94
+ for (let name of Object.keys(cache.tables)){
95
+ db.query({
96
+ t: 'delete',
97
+ from: name
98
+ });
99
+ }
100
+ });
101
+ compact(db);
102
+ } finally{
103
+ db.close();
104
+ }
105
+ };
106
+ /** A malformed cache is rebuildable, not data: its files are removed, WAL
107
+ * first, so the owner rebuilds it at the same path. */ let discard = async (path)=>{
108
+ for (let p of [
109
+ path + '-wal',
110
+ path + '-shm',
111
+ path
112
+ ]){
113
+ await io.remove(p).catch((error)=>{
114
+ if (!io.isNotFound(error)) throw error;
115
+ });
116
+ }
117
+ };
118
+ /** Trim a cache over budget in place. Missing sources go first; if its live
119
+ * entries still exceed the budget, clear its rebuildable tables. The database
120
+ * and its WAL are never unlinked while it is readable, including while another
121
+ * connection uses it; a malformed one is removed for its owner to rebuild. A
122
+ * cache another connection holds busy waits for the next pass. Returns bytes
123
+ * reclaimed. A cache that does not exist is left absent. Its file checks and
124
+ * vacuum block the calling thread; {@link threaded} runs it on its own. */ export let trim = async (path, cache)=>{
125
+ let before = await held(path);
126
+ if (before <= cache.most) return 0;
127
+ try {
128
+ await shrink(path, cache);
129
+ } catch (error) {
130
+ if (malformed(error)) await discard(path);
131
+ else if (!busy(error)) throw error;
132
+ }
133
+ return Math.max(0, before - await held(path));
134
+ };
135
+ /** {@link trim} on a thread of its own, so no disk stall holds the caller's. */ export let threaded = (path, cache)=>new Promise((resolve, reject)=>{
136
+ let worker = new Worker(new URL('./cache_worker.ts', import.meta.url), {
137
+ type: 'module'
138
+ });
139
+ worker.onmessage = ({ data })=>{
140
+ worker.terminate();
141
+ 'value' in data ? resolve(data.value) : reject(new Error(data.error));
142
+ };
143
+ worker.onerror = (e)=>{
144
+ e.preventDefault();
145
+ worker.terminate();
146
+ reject(e.error ?? new Error(e.message));
147
+ };
148
+ worker.postMessage({
149
+ path,
150
+ cache
151
+ });
152
+ });
153
+ //# sourceMappingURL=cache.js.map
package/cache.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sources":["./cache.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,4EAA4E;AAC5E,0EAA0E;AAC1E,yEAAyE;AACzE,gFAAgF;AAChF,wEAAwE;AACxE,8DAA8D;AAC9D,YAAY,6BAAkC;AAC9C,SAAS,GAAG,EAAe,KAAK,EAAE,MAAM,EAAE,KAAK,yBAA8B;AAC7E,SAA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B,IAAI,CAAC,KAAK,QAAQ,MAAM;EAC/B;EACA,OAAO,KAAK,GAAG,CAAC,GAAG,SAAS,MAAM,KAAK;AACzC,EAAC;AAKD,8EAA8E,GAC9E,OAAO,IAAI,WAAW,CAAC,MAAc,QACnC,IAAI,QAAQ,CAAC,SAAS;IACpB,IAAI,SAAS,IAAI,OAAO,IAAI,IAAI,qBAAqB,YAAY,GAAG,GAAG;MACrE,MAAM;IACR;IACA,OAAO,SAAS,GAAG,CAAC,EAAE,IAAI,EAAyB;MACjD,OAAO,SAAS;MAChB,WAAW,OAAO,QAAQ,KAAK,KAAK,IAAI,OAAO,IAAI,MAAM,KAAK,KAAK;IACrE;IACA,OAAO,OAAO,GAAG,CAAC;MAChB,EAAE,cAAc;MAChB,OAAO,SAAS;MAChB,OAAO,EAAE,KAAK,IAAI,IAAI,MAAM,EAAE,OAAO;IACvC;IACA,OAAO,WAAW,CAAC;MAAE;MAAM;IAAM;EACnC,GAAE"}
package/cache.ts ADDED
@@ -0,0 +1,154 @@
1
+ // Rebuildable SQLite caches stay at their path and inode: another process may
2
+ // still have them open. Deno's own caches are open in this one too, through
3
+ // the SQLite built into Deno, so a cache is opened only through that copy
4
+ // (./builtin.ts). Their file-URL columns identify entries nobody can use
5
+ // once the source is gone; deleting and vacuuming returns their pages in place.
6
+ // A trim waits on the disk, on file checks, a vacuum and its lock, so a
7
+ // process runs it on a thread of its own (./cache_worker.ts).
8
+ import * as io from '@yaks/file/io'
9
+ import { col, type Driver, oneOf, select, table } from '@yaks/sql'
10
+ import { builtin } from './builtin.js'
11
+ import { busy, malformed } from './error.js'
12
+ import { unit } from './unit.js'
13
+
14
+ /** A rebuildable database's byte budget and its tables' file-URL columns.
15
+ * Tables not named here, such as cache version metadata, are kept. */
16
+ export type Cache = { most: number; tables: Record<string, string> }
17
+
18
+ /** The bytes a cache and its SQLite WAL occupy, without the shared-memory
19
+ * index, whose size is unrelated to the bytes stored. */
20
+ export let held = async (path: string): Promise<number> => {
21
+ let sizes = await Promise.all([path, path + '-wal'].map(async (p) => {
22
+ try {
23
+ return (await io.stat(p)).size
24
+ } catch (error) {
25
+ if (io.isNotFound(error)) return 0
26
+ throw error
27
+ }
28
+ }))
29
+ return sizes.reduce((sum, n) => sum + n, 0)
30
+ }
31
+
32
+ let missing = (specifier: string): boolean => {
33
+ try {
34
+ io.statSync(io.fileURLToPath(specifier))
35
+ return false
36
+ } catch (error) {
37
+ if (io.isNotFound(error) || io.isNotADirectory(error)) return true
38
+ if (io.isPermissionDenied(error)) return false
39
+ throw error
40
+ }
41
+ }
42
+
43
+ /** Remove entries for missing local files through a cache's declared columns.
44
+ * Remote specifiers and unreadable local files stay cached. */
45
+ export let prune = (
46
+ db: Driver,
47
+ tables: Cache['tables'],
48
+ gone: (specifier: string) => boolean = missing,
49
+ ): number => {
50
+ let removed = 0
51
+ for (let [name, key] of Object.entries(tables)) {
52
+ let rows = db.query(select({
53
+ distinct: true,
54
+ cols: [col(key)],
55
+ from: table(name),
56
+ where: {
57
+ t: 'op',
58
+ op: 'like',
59
+ parts: [col(key), { t: 'val', v: 'file:%' }],
60
+ },
61
+ }))
62
+ let stale = rows.map((r) => String(r[key])).filter(gone)
63
+ if (!stale.length) continue
64
+ let change = {
65
+ t: 'delete' as const,
66
+ from: name,
67
+ where: oneOf(col(key), stale),
68
+ }
69
+ removed += unit(
70
+ db,
71
+ () => db.run?.(change) ?? (db.query(change), stale.length),
72
+ )
73
+ }
74
+ return removed
75
+ }
76
+
77
+ /** Vacuum and truncate the WAL. False while another connection reads the
78
+ * cache: the vacuumed pages stay in the WAL until a later pass. */
79
+ let compact = (db: Driver): boolean => {
80
+ db.query({ t: 'vacuum' })
81
+ let [checkpoint] = db.query({
82
+ t: 'pragma',
83
+ name: 'wal_checkpoint',
84
+ value: 'truncate',
85
+ })
86
+ return !checkpoint?.busy
87
+ }
88
+
89
+ let shrink = async (path: string, cache: Cache) => {
90
+ let db = builtin(path)
91
+ try {
92
+ db.query({ t: 'pragma', name: 'busy_timeout', value: 1000 })
93
+ prune(db, cache.tables)
94
+ if (!compact(db) || await held(path) <= cache.most) return
95
+ unit(db, () => {
96
+ for (let name of Object.keys(cache.tables)) {
97
+ db.query({ t: 'delete', from: name })
98
+ }
99
+ })
100
+ compact(db)
101
+ } finally {
102
+ db.close()
103
+ }
104
+ }
105
+
106
+ /** A malformed cache is rebuildable, not data: its files are removed, WAL
107
+ * first, so the owner rebuilds it at the same path. */
108
+ let discard = async (path: string) => {
109
+ for (let p of [path + '-wal', path + '-shm', path]) {
110
+ await io.remove(p).catch((error) => {
111
+ if (!io.isNotFound(error)) throw error
112
+ })
113
+ }
114
+ }
115
+
116
+ /** Trim a cache over budget in place. Missing sources go first; if its live
117
+ * entries still exceed the budget, clear its rebuildable tables. The database
118
+ * and its WAL are never unlinked while it is readable, including while another
119
+ * connection uses it; a malformed one is removed for its owner to rebuild. A
120
+ * cache another connection holds busy waits for the next pass. Returns bytes
121
+ * reclaimed. A cache that does not exist is left absent. Its file checks and
122
+ * vacuum block the calling thread; {@link threaded} runs it on its own. */
123
+ export let trim = async (path: string, cache: Cache): Promise<number> => {
124
+ let before = await held(path)
125
+ if (before <= cache.most) return 0
126
+ try {
127
+ await shrink(path, cache)
128
+ } catch (error) {
129
+ if (malformed(error)) await discard(path)
130
+ else if (!busy(error)) throw error
131
+ }
132
+ return Math.max(0, before - await held(path))
133
+ }
134
+
135
+ /** What the trim thread answers. */
136
+ export type Trimmed = { value: number } | { error: string }
137
+
138
+ /** {@link trim} on a thread of its own, so no disk stall holds the caller's. */
139
+ export let threaded = (path: string, cache: Cache): Promise<number> =>
140
+ new Promise((resolve, reject) => {
141
+ let worker = new Worker(new URL('./cache_worker.ts', import.meta.url), {
142
+ type: 'module',
143
+ })
144
+ worker.onmessage = ({ data }: MessageEvent<Trimmed>) => {
145
+ worker.terminate()
146
+ 'value' in data ? resolve(data.value) : reject(new Error(data.error))
147
+ }
148
+ worker.onerror = (e) => {
149
+ e.preventDefault()
150
+ worker.terminate()
151
+ reject(e.error ?? new Error(e.message))
152
+ }
153
+ worker.postMessage({ path, cache })
154
+ })
@@ -0,0 +1,16 @@
1
+ /// <reference no-default-lib="true" />
2
+ /// <reference lib="deno.worker" />
3
+ // The thread a cache is trimmed on (./cache.ts): its file checks, vacuum and
4
+ // lock waits hold this thread, never its caller's.
5
+ import { type Cache, trim, type Trimmed } from './cache.ts'
6
+
7
+ self.onmessage = async (
8
+ { data: { path, cache } }: MessageEvent<{ path: string; cache: Cache }>,
9
+ ) => {
10
+ let tell = (said: Trimmed) => self.postMessage(said)
11
+ try {
12
+ tell({ value: await trim(path, cache) })
13
+ } catch (e) {
14
+ tell({ error: e instanceof Error ? e.stack ?? e.message : String(e) })
15
+ }
16
+ }
package/catalog.js ADDED
@@ -0,0 +1,173 @@
1
+ import { Unpointed } from "./error.js";
2
+ // Immutable table sets and a connection-revision snapshot: planning reads no
3
+ // persistent rows until a catalog mutation or rollback invalidates that snapshot.
4
+ import { Archetypes, namingOf, satisfies } from "@yaks/archetype/sets";
5
+ import { and, archetypeSet, col, isNull, not, oneOf, select, table } from "@yaks/sql/core";
6
+ import { revision } from "@yaks/sql/core";
7
+ import { tableVersion } from "./versions.js";
8
+ let caches = new WeakMap();
9
+ let cacheFor = (driver)=>{
10
+ let cache = caches.get(driver), naming = namingFor(driver);
11
+ if (cache?.naming != naming) {
12
+ cache = {
13
+ naming,
14
+ sets: new Archetypes(naming),
15
+ text: new Map()
16
+ };
17
+ caches.set(driver, cache);
18
+ }
19
+ return cache;
20
+ };
21
+ /** How this connection's descriptors name components: by the identities of
22
+ * the vocabulary its statements are written with (@yaks/archetype
23
+ * `namingOf`). */ export let namingFor = (driver)=>namingOf(driver.stored?.v);
24
+ /** A cache of sets named as this connection's descriptors name them. */ export let setsFor = (driver)=>new Archetypes(namingFor(driver));
25
+ /** The set of the components `tables` names, as this connection's
26
+ * descriptors describe it: its eid and descriptor. */ export let setOf = (driver, tables)=>cacheFor(driver).sets.intern(tables);
27
+ /** Decode a descriptor once, independent of its transaction-local row id:
28
+ * the set it describes, under the names this connection's statements write. */ export function descriptor(driver, text) {
29
+ let cache = cacheFor(driver);
30
+ let a = cache.text.get(text);
31
+ if (!a) {
32
+ a = cache.sets.decode(text);
33
+ cache.text.set(text, a);
34
+ }
35
+ return a;
36
+ }
37
+ function snapshot(driver, pending) {
38
+ let cache = cacheFor(driver);
39
+ let v = revision(driver, 'catalog');
40
+ if (cache.version == v && cache.set) return cache.set;
41
+ // An incomplete catalog is corruption, never permission for the planner
42
+ // to discover presence in component tables. The writer repairs it.
43
+ let missing = driver.query(select({
44
+ cols: [
45
+ col('eid')
46
+ ],
47
+ from: table('entity'),
48
+ where: and(isNull(col('archetype')), ...pending?.size ? [
49
+ not(oneOf(col('id'), [
50
+ ...pending.keys()
51
+ ]))
52
+ ] : [])
53
+ }));
54
+ if (missing.length) throw new Unpointed(missing.map((r)=>String(r.eid)));
55
+ cache.version = v;
56
+ return cache.set = fresh(driver).descriptors;
57
+ }
58
+ // The descriptors this connection holds, read again only where one may have
59
+ // moved since (@yaks/sql `revision`).
60
+ let fresh = (driver)=>{
61
+ let cache = cacheFor(driver);
62
+ let version = revision(driver, 'descriptors');
63
+ if (cache.descriptorVersion != version || !cache.descriptors) {
64
+ // SQLite's data_version hears every peer commit. The table's own clock
65
+ // distinguishes a changed descriptor from an unrelated graph write,
66
+ // without rereading the entire catalog. Schema changes still invalidate
67
+ // it, even when a table or its triggers were replaced outside the graph.
68
+ // A store owning its file keeps no clock: every statement that could
69
+ // move a descriptor passes through it, and only those move the revision.
70
+ let clock = driver.file ? tableVersion(driver, 'archetype') : undefined;
71
+ let schema = revision(driver, 'schema');
72
+ if (!cache.descriptors || clock === undefined || cache.tableVersion != clock || cache.schemaVersion != schema) {
73
+ let ids = new Map();
74
+ let all = select({
75
+ cols: [
76
+ col('entity'),
77
+ col('tables')
78
+ ],
79
+ from: table('archetype')
80
+ });
81
+ for (let row of driver.query(all)){
82
+ let a = descriptor(driver, String(row.tables));
83
+ ids.set(a.eid, Number(row.entity));
84
+ }
85
+ cache.descriptors = archetypeSet(cache.sets, ids);
86
+ cache.ids = ids;
87
+ }
88
+ cache.tableVersion = clock;
89
+ cache.schemaVersion = schema;
90
+ cache.descriptorVersion = version;
91
+ }
92
+ return cache;
93
+ };
94
+ /** Every descriptor the file holds, as the set it describes by its entity
95
+ * id: the very read the catalog keeps (`catalog`), so a look at them all
96
+ * after an install costs the planner nothing, and none again while no
97
+ * statement moves one. Unlike a plan's catalog it asks nothing of owners. */ export let standing = (driver)=>{
98
+ let { ids, sets } = fresh(driver);
99
+ return new Map([
100
+ ...ids
101
+ ].map(([eid, id])=>[
102
+ id,
103
+ sets.get(eid)
104
+ ]));
105
+ };
106
+ /**
107
+ * Descriptors this connection wrote, by entity id and table set, where they
108
+ * are all that moved one since revision `from` (@yaks/sql `revision`): a
109
+ * catalog current then takes them in and stays current, so the next plan
110
+ * reads none of the descriptors it held. Any other catalog is read again.
111
+ */ export function described(driver, from, rows) {
112
+ let cache = cacheFor(driver);
113
+ if (!cache.ids || cache.descriptorVersion != from) return;
114
+ let was = cache.descriptors;
115
+ for (let { id, tables } of rows){
116
+ cache.ids.set(descriptor(driver, tables).eid, id);
117
+ }
118
+ cache.descriptors = archetypeSet(cache.sets, cache.ids);
119
+ cache.descriptorVersion = revision(driver, 'descriptors');
120
+ if (driver.file) cache.tableVersion = tableVersion(driver, 'archetype');
121
+ if (cache.set == was) cache.set = cache.descriptors;
122
+ }
123
+ /**
124
+ * A lazy, single-plan catalog snapshot. Value-only queries do not need it;
125
+ * the first component-presence or kind predicate loads it and all others share
126
+ * that snapshot.
127
+ * Create one per compile, not once per connection. Compile and execute inside
128
+ * the same transaction, so another writer cannot change the catalog between.
129
+ */ export function catalog(driver, pending) {
130
+ let loaded = false;
131
+ let current;
132
+ let moved;
133
+ let shapes = ()=>moved ??= typeof pending == 'function' ? pending() : pending;
134
+ let cache = cacheFor(driver);
135
+ let choose = (predicate)=>{
136
+ if (!loaded) {
137
+ current = snapshot(driver, shapes());
138
+ loaded = true;
139
+ }
140
+ return current?.(predicate);
141
+ };
142
+ if (pending) {
143
+ Object.defineProperty(choose, 'pending', {
144
+ get: ()=>{
145
+ let pending = shapes();
146
+ return pending?.size ? {
147
+ ids: [
148
+ ...pending.keys()
149
+ ],
150
+ matching: (predicate)=>[
151
+ ...pending
152
+ ].filter(([, tables])=>satisfies(predicate, {
153
+ tables
154
+ })).map(([id])=>id)
155
+ } : undefined;
156
+ }
157
+ });
158
+ }
159
+ return Object.defineProperty(choose, 'held', {
160
+ get: ()=>{
161
+ if (shapes()?.size) return true;
162
+ if (!cache.descriptors) return false;
163
+ let version = revision(driver, 'descriptors');
164
+ if (cache.descriptorVersion == version) return true;
165
+ if (cache.tableVersion === undefined || cache.schemaVersion != revision(driver, 'schema') || cache.tableVersion != tableVersion(driver, 'archetype')) return false;
166
+ // Only descriptor freshness is proven. snapshot() still checks for
167
+ // corrupt owners before handing this set to a plan.
168
+ cache.descriptorVersion = version;
169
+ return true;
170
+ }
171
+ });
172
+ }
173
+ //# sourceMappingURL=catalog.js.map
package/catalog.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sources":["./catalog.ts"],"names":[],"mappings":"AAAA,SAAS,SAAS,qBAAoB;AACtC,6EAA6E;AAC7E,kFAAkF;AAClF,SAEE,UAAU,EAEV,QAAQ,EACR,SAAS,oCAC6B;AACxC,SACE,GAAG,EAEH,YAAY,EACZ,GAAG,EAEH,MAAM,EACN,GAAG,EACH,KAAK,EACL,MAAM,EACN,KAAK,8BAC2B;AAClC,SAAS,QAAQ,8BAAmC;AACpD,SAAS,YAAY,wBAAuB;AAE5C,IAAI,SAAS,IAAI;AAajB,IAAI,WAAW,CAAC;EACd,IAAI,QAAQ,OAAO,GAAG,CAAC,SAAS,SAAS,UAAU;EACnD,IAAI,OAAO,UAAU,QAAQ;IAC3B,QAAQ;MAAE;MAAQ,MAAM,IAAI,WAAW;MAAS,MAAM,IA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