quiverdb 0.9.9 → 0.9.11
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.
- package/libs/linux-x86_64/libquiver.so +0 -0
- package/libs/linux-x86_64/libquiver.so.0 +0 -0
- package/libs/linux-x86_64/libquiver_c.so +0 -0
- package/libs/macos-aarch64/libquiver.0.dylib +0 -0
- package/libs/macos-aarch64/libquiver_c.dylib +0 -0
- package/libs/windows-x86_64/libquiver.dll +0 -0
- package/libs/windows-x86_64/libquiver_c.dll +0 -0
- package/package.json +1 -1
- package/src/database.ts +1 -1
- package/src/loader.ts +1 -1
- package/src/lua-api.ts +26 -12
- package/src/time-series.ts +2 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/src/database.ts
CHANGED
package/src/loader.ts
CHANGED
|
@@ -123,7 +123,7 @@ const timeSeriesSymbols = {
|
|
|
123
123
|
returns: I32,
|
|
124
124
|
},
|
|
125
125
|
quiver_database_read_time_series_row: { args: [P, BUF, BUF, BUF, BUF, P, P, P], returns: I32 },
|
|
126
|
-
|
|
126
|
+
quiver_database_upsert_time_series_row: { args: [P, BUF, BUF, I64, P, P, P, USIZE], returns: I32 },
|
|
127
127
|
quiver_database_update_time_series_group: {
|
|
128
128
|
args: [P, BUF, BUF, I64, P, P, P, P, USIZE, USIZE],
|
|
129
129
|
returns: I32,
|
package/src/lua-api.ts
CHANGED
|
@@ -42,8 +42,8 @@ Lua values map to Quiver column values as follows:
|
|
|
42
42
|
|
|
43
43
|
| Lua value | Quiver value | Notes |
|
|
44
44
|
| ------------------ | ------------ | ---------------------------------------------- |
|
|
45
|
-
| integer | INTEGER |
|
|
46
|
-
| number (float) | REAL |
|
|
45
|
+
| integer | INTEGER | Also accepted for REAL columns (coerced to real). |
|
|
46
|
+
| number (float) | REAL | A float is rejected for an INTEGER column. |
|
|
47
47
|
| string | TEXT | Also used for \`date_time\` columns (ISO 8601). |
|
|
48
48
|
| \`nil\` | NULL | In query params, file paths, and ts rows. |
|
|
49
49
|
| table (1-indexed) | array | Used for vectors/sets and column-oriented data.|
|
|
@@ -60,8 +60,9 @@ datetime surface — there are no DateTime wrapper helpers, unlike Julia/Dart/Py
|
|
|
60
60
|
|
|
61
61
|
## Critical rules
|
|
62
62
|
|
|
63
|
-
- **
|
|
64
|
-
|
|
63
|
+
- **Type coercion.** An integer is accepted for a REAL column (coerced to real on insert); a float
|
|
64
|
+
is rejected for an INTEGER column. Other type mismatches raise a validation error and roll the
|
|
65
|
+
whole script back.
|
|
65
66
|
- **Errors abort the script.** Any error thrown by a \`db:\` call stops the script and surfaces as
|
|
66
67
|
\`Failed to run Lua script: <message>\`. Validation failures roll back whatever the current
|
|
67
68
|
transaction covered.
|
|
@@ -78,6 +79,10 @@ datetime surface — there are no DateTime wrapper helpers, unlike Julia/Dart/Py
|
|
|
78
79
|
see (it is captured). Arrays are 1-indexed (iterate with \`ipairs\`); reading a NULL yields \`nil\`,
|
|
79
80
|
writing \`nil\` stores NULL where NULL is accepted (query params, ts rows, file columns — but NOT
|
|
80
81
|
element scalar attributes; see CRUD).
|
|
82
|
+
- **Embedding harness may restrict further.** The library itself allows transactions and the
|
|
83
|
+
(sandboxed) CSV/file operations below. A host that runs your script (e.g. a hosted \`run_lua\`
|
|
84
|
+
tool) may disable some of them and report \`disabled in the run_lua sandbox\` — that limit comes
|
|
85
|
+
from the harness, not from quiverdb.
|
|
81
86
|
|
|
82
87
|
---
|
|
83
88
|
|
|
@@ -152,11 +157,16 @@ db:update_element("Collection", id, { some_integer = 999 })
|
|
|
152
157
|
\`\`\`
|
|
153
158
|
|
|
154
159
|
Notes:
|
|
160
|
+
- **\`update_element\` / \`delete_element\` require an existing id.** Targeting an id that does not
|
|
161
|
+
exist throws \`Element not found: <id> in collection '<collection>'\` (no silent no-op). Use
|
|
162
|
+
\`read_element_ids\` to get valid ids.
|
|
155
163
|
- **Empty arrays are skipped.** An attribute whose value is \`{}\` writes no vector/set (the element
|
|
156
164
|
type can't be inferred from an empty array), so it is silently dropped.
|
|
157
|
-
- **No \`nil\` scalar attributes.**
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
- **No \`nil\` scalar attributes.** In Lua a key set to \`nil\` is dropped from the table, so
|
|
166
|
+
\`{ x = nil }\` is identical to \`{}\`; an update/create table that ends up with no attributes
|
|
167
|
+
**throws** (\`element must have at least one attribute\`). To leave a column unchanged, omit the
|
|
168
|
+
key — you cannot set a scalar to NULL via the element table. (\`nil\` → NULL is only accepted by
|
|
169
|
+
\`upsert_time_series_row\` and \`update_time_series_files\`.)
|
|
160
170
|
|
|
161
171
|
---
|
|
162
172
|
|
|
@@ -264,7 +274,7 @@ db:update_time_series_group("Items", "data", id, ts) -- write the whole group
|
|
|
264
274
|
\`\`\`
|
|
265
275
|
|
|
266
276
|
**DO NOT pass an array of row tables** (\`{ { date_time = ..., value = ... }, ... }\`) — that is the
|
|
267
|
-
\`
|
|
277
|
+
\`upsert_time_series_row\` shape, not this one. Doing so raises
|
|
268
278
|
\`stack index -1, expected string, received number\` (the integer array indices 1, 2, 3 are not
|
|
269
279
|
column names). Each value of the top-level table must be an **array**, not a scalar.
|
|
270
280
|
|
|
@@ -283,13 +293,13 @@ column names). Each value of the top-level table must be an **array**, not a sca
|
|
|
283
293
|
- Integer values are accepted for REAL columns (converted on insert). Booleans, functions, and
|
|
284
294
|
other unsupported Lua types throw \`column '...' has unsupported Lua type\`.
|
|
285
295
|
|
|
286
|
-
### Append/upsert a single row (\`
|
|
296
|
+
### Append/upsert a single row (\`upsert_time_series_row\` — ROW-oriented, the one exception)
|
|
287
297
|
|
|
288
298
|
Unlike the column-oriented group update above, this takes **one row table of scalars** (dimension
|
|
289
299
|
column + value column(s)), and upserts that single row:
|
|
290
300
|
|
|
291
301
|
\`\`\`lua
|
|
292
|
-
db:
|
|
302
|
+
db:upsert_time_series_row("Items", "data", id, {
|
|
293
303
|
date_time = "2024-01-04T00:00:00",
|
|
294
304
|
value = 40.0,
|
|
295
305
|
})
|
|
@@ -367,7 +377,9 @@ entirely.
|
|
|
367
377
|
## Query (parameterized SQL)
|
|
368
378
|
|
|
369
379
|
Positional \`?\` placeholders; \`params\` is an optional 1-indexed array. Each returns the first
|
|
370
|
-
column of the first row as the requested type, or \`nil\` if there is no result.
|
|
380
|
+
column of the first row as the requested type, or \`nil\` if there is no result. The number of
|
|
381
|
+
\`params\` must match the number of \`?\` placeholders exactly — a mismatch (too few or too many)
|
|
382
|
+
throws rather than binding NULL or ignoring extras.
|
|
371
383
|
|
|
372
384
|
\`\`\`lua
|
|
373
385
|
db:query_string(sql, params) -- string or nil
|
|
@@ -477,7 +489,9 @@ db:csv_to_bin(path)
|
|
|
477
489
|
|
|
478
490
|
local e = (quiver.expression(r) + 10.0) * 2.0 -- files auto-wrap; scalars either side
|
|
479
491
|
e = quiver.abs(e); e = quiver.sqrt(e) -- also quiver.log / quiver.exp
|
|
480
|
-
|
|
492
|
+
local cond_e = quiver.gt(e, 3.0) -- gt/lt/gte/lte/eq/neq -> 1.0/0.0 (NaN -> NaN)
|
|
493
|
+
cond_e = cond_e & ~quiver.lt(e, 1.0) -- boolean logic via & | ~ operators (and/or/not are keywords)
|
|
494
|
+
e = quiver.ifelse(cond_e, then_e, else_e) -- build cond_e with comparison + logical operators
|
|
481
495
|
e = e:aggregate("stage", "sum") -- sum/mean/min/max/percentile
|
|
482
496
|
e = e:aggregate("stage", "percentile", 0.9) -- percentile needs the fraction
|
|
483
497
|
e = e:aggregate_agents("mean") -- collapse the label axis
|
package/src/time-series.ts
CHANGED
|
@@ -318,7 +318,7 @@ Database.prototype.updateTimeSeriesGroup = function (
|
|
|
318
318
|
);
|
|
319
319
|
};
|
|
320
320
|
|
|
321
|
-
Database.prototype.
|
|
321
|
+
Database.prototype.upsertTimeSeriesRow = function (
|
|
322
322
|
this: Database,
|
|
323
323
|
collection: string,
|
|
324
324
|
group: string,
|
|
@@ -366,7 +366,7 @@ Database.prototype.addTimeSeriesRow = function (
|
|
|
366
366
|
keepalive.push(dataTable);
|
|
367
367
|
|
|
368
368
|
check(
|
|
369
|
-
lib.
|
|
369
|
+
lib.quiver_database_upsert_time_series_row(
|
|
370
370
|
this._handle,
|
|
371
371
|
collBuf.buf,
|
|
372
372
|
grpBuf.buf,
|