vectrojs 0.0.1 → 0.1.1

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 (63) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +828 -4
  3. package/bin/vectro.mjs +82 -0
  4. package/dist/vectro.wasm +0 -0
  5. package/mcp/server.mjs +288 -0
  6. package/package.json +84 -6
  7. package/src/arrow.mjs +905 -0
  8. package/src/bitpack.mjs +135 -0
  9. package/src/browser.mjs +129 -0
  10. package/src/bytes.mjs +60 -0
  11. package/src/csv-kernel.mjs +205 -0
  12. package/src/csv.mjs +270 -0
  13. package/src/dataset.mjs +1763 -0
  14. package/src/dates.mjs +139 -0
  15. package/src/emitter.mjs +109 -0
  16. package/src/engine.mjs +881 -0
  17. package/src/files-browser.mjs +104 -0
  18. package/src/files-node.mjs +59 -0
  19. package/src/frames.mjs +191 -0
  20. package/src/fuse.mjs +512 -0
  21. package/src/interp.mjs +305 -0
  22. package/src/join.mjs +534 -0
  23. package/src/kernels.mjs +312 -0
  24. package/src/ndjson.mjs +136 -0
  25. package/src/node.mjs +120 -0
  26. package/src/pack.mjs +114 -0
  27. package/src/parallel-sort.mjs +99 -0
  28. package/src/partition-kernels.mjs +388 -0
  29. package/src/partition.mjs +395 -0
  30. package/src/plan.mjs +551 -0
  31. package/src/portable.mjs +21 -0
  32. package/src/rank-kernels.mjs +81 -0
  33. package/src/rows.mjs +91 -0
  34. package/src/serve/catalog.mjs +148 -0
  35. package/src/serve/flight.mjs +270 -0
  36. package/src/serve/formats.mjs +87 -0
  37. package/src/serve/http.mjs +182 -0
  38. package/src/serve/index.mjs +9 -0
  39. package/src/serve/odata.mjs +291 -0
  40. package/src/serve/pg.mjs +588 -0
  41. package/src/serve/pgcatalog.mjs +220 -0
  42. package/src/serve/pgtypes.mjs +199 -0
  43. package/src/sketch.mjs +75 -0
  44. package/src/sort-kernels.mjs +117 -0
  45. package/src/sort.mjs +102 -0
  46. package/src/split-worker-core.mjs +252 -0
  47. package/src/split-worker-node.mjs +8 -0
  48. package/src/split-worker.mjs +7 -0
  49. package/src/split.mjs +741 -0
  50. package/src/sql.mjs +1558 -0
  51. package/src/sqltext.mjs +132 -0
  52. package/src/static-kernels.mjs +164 -0
  53. package/src/stream-worker.mjs +553 -0
  54. package/src/table-kernels.mjs +323 -0
  55. package/src/table.mjs +2247 -0
  56. package/src/textmap.mjs +159 -0
  57. package/src/vectors.mjs +138 -0
  58. package/src/wasm.mjs +254 -0
  59. package/src/window.mjs +160 -0
  60. package/src/worker-browser.mjs +21 -0
  61. package/src/worker-loop.mjs +106 -0
  62. package/src/worker.mjs +22 -0
  63. package/src/zones.mjs +75 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,89 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ A performance release. No API changes.
6
+
7
+ **Faster group-by**
8
+ - SQL `SUM` no longer computes a hidden count of non-missing values when the
9
+ column has none missing, and sum, mean, min and max skip the per-row
10
+ missing-value check on such columns.
11
+ - On many threads, a group-by remembers its key range and merges the
12
+ threads' partial results with a WebAssembly kernel instead of a JavaScript
13
+ loop. This also removes the 31-thread limit for queries with many groups.
14
+ - Measured on 2M orders (`SELECT product_id, sum(amount) ... GROUP BY 1`,
15
+ `compare/bench-2m-groupby.mjs`, numbers in `compare/results.json`): with
16
+ 1,000 products, 3.0 ms on 1 thread (DuckDB 2.0: 6.8 ms) and 2.3 ms on 8
17
+ threads (DuckDB 2.0: 2.4 ms). Before this release Vectro was 1.9x slower
18
+ than DuckDB on 8 threads in this case; it is now level or faster at every
19
+ size from 100 to 100,000 products.
20
+
21
+ ## 0.1.0 (first release)
22
+
23
+ The first public release. Everything below is new.
24
+
25
+ **Engine**
26
+ - Columnar tables in engine memory; expressions compiled into fused SIMD
27
+ WebAssembly loops and run on every CPU core (Node worker threads, Web
28
+ Workers on cross-origin-isolated pages), one thread elsewhere, and a
29
+ vectorized interpreter where code generation isn't allowed (Cloudflare Workers).
30
+ - Filters, computed columns, aggregates, group by any keys (millions of
31
+ groups: partitioned by key range on every thread, sorted by key), exact and
32
+ approximate distinct counts, joins (inner, left, right, full), sort and
33
+ top-k, zone maps, compressed columns. Top-k over a file reads only the
34
+ blocks that can still hold a winning row.
35
+ - A query planner: `table.lazy()` chains are optimized as a whole.
36
+ - CSV (parallel parser), JSON lines, Apache Arrow (read and write).
37
+ - Datasets bigger than memory (`.vectro` files): chunked, bit-packed, read in
38
+ parallel; group-by, joins and sorts spill to disk; in browsers too.
39
+ - Streams (CSV, JSON lines, WebSocket feeds) with running windows.
40
+ - Vector search (cosine / dot / L2, exact top-k).
41
+
42
+ **SQL**
43
+ - `sql(text, tables)`: joins, subqueries (IN, EXISTS, correlated), CTEs,
44
+ UNION / INTERSECT / EXCEPT, window functions, percentiles, text functions,
45
+ dates and intervals. 40 queries checked against DuckDB give the same answers.
46
+ - Shortcuts for common shapes: only the rows that can rank in the first k for
47
+ `ROW_NUMBER() / RANK() ... <= k`; distinct counts of IDs with a byte map;
48
+ medians from bucket counts; CASE with quoted labels as label codes.
49
+
50
+ **Serving** (beta)
51
+ - `vectro serve`: SQL over HTTP (JSON, CSV, Arrow) and an OData v4 feed;
52
+ the PostgreSQL wire protocol (Power BI, Tableau, Metabase, Grafana, psql);
53
+ Arrow Flight SQL (pandas, Polars, DuckDB through ADBC). Checked with
54
+ pgJDBC, Npgsql, Microsoft's OData libraries and the ADBC driver.
55
+ - An MCP server for AI assistants (`vectro-mcp`).
56
+
57
+ **Connectors** (experimental)
58
+ - `connectors/dist/Vectro.mez` for Power BI and `vectro.taco` for Tableau.
59
+ Not signed, not yet tried in the applications.
60
+
61
+ **Missing values**
62
+ - SQL uses three-valued logic for missing values: `NOT (x > 5)`, `x <> 5`,
63
+ `NOT IN`, `NOT BETWEEN`, `NOT LIKE` and `LIKE` drop rows where the value
64
+ is missing, as other databases do. Table expressions keep JavaScript's rules
65
+ (`x != 5` is true where x is missing).
66
+ - Blank text (`''`, the missing value of a text column) is not counted by
67
+ `count(x)`, `countDistinct(x)`, `approxDistinct(x)` or SQL's `COUNT`, on
68
+ tables, datasets and split tables.
69
+ - `null` in arrays and rows loads as missing (it used to load as 0); a `Date`
70
+ in `tableFromRows` makes a date column.
71
+ - Clear errors for a text param, for date columns in a `Float32Array` table
72
+ (times don't fit in float32) and for SQL on a split table.
73
+ - `readCSV(path, { compress: true })` packs the columns, as `parseCSV` does.
74
+
75
+ **Testing**
76
+ - `VECTRO_POISON=1` overwrites memory as it is freed, so code that reads an
77
+ array after freeing it gives wrong answers in tests (part of `test:all`).
78
+
79
+ **Known gaps**
80
+ - Slower than DuckDB on one shape measured: a join over a file on disk with
81
+ a GROUP BY on the joined table's columns (1.2-1.3x at 100M and 1B rows).
82
+ Faster on all 20 SQL queries measured, on every group-by, join and
83
+ distinct count measured in memory, and on 7 of 8 queries over a billion
84
+ rows on disk (see the README's numbers).
85
+ - Free-text columns (text that rarely repeats) can be shown but not grouped
86
+ or filtered, except when served (`vectro serve` loads them as categories).
87
+ - Window functions and percentiles keep the rows they read in memory.
88
+ - An engine holds at most 4 GB in memory; tables are freed with `dispose()`.
89
+ - Integers are exact up to 2^53; times are UTC.