vastgrid-js 0.0.0-stage → 0.2.0

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 (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +211 -2
  3. package/dist/aggregate.d.ts +45 -0
  4. package/dist/aggregate.d.ts.map +1 -0
  5. package/dist/aggregate.js +305 -0
  6. package/dist/aggregate.js.map +1 -0
  7. package/dist/arrow.d.ts +7 -0
  8. package/dist/arrow.d.ts.map +1 -0
  9. package/dist/arrow.js +25 -0
  10. package/dist/arrow.js.map +1 -0
  11. package/dist/engine.d.ts +40 -0
  12. package/dist/engine.d.ts.map +1 -0
  13. package/dist/engine.js +1022 -0
  14. package/dist/engine.js.map +1 -0
  15. package/dist/evaluate.d.ts +37 -0
  16. package/dist/evaluate.d.ts.map +1 -0
  17. package/dist/evaluate.js +774 -0
  18. package/dist/evaluate.js.map +1 -0
  19. package/dist/export.d.ts +23 -0
  20. package/dist/export.d.ts.map +1 -0
  21. package/dist/export.js +48 -0
  22. package/dist/export.js.map +1 -0
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +2 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/lazy.d.ts +65 -0
  28. package/dist/lazy.d.ts.map +1 -0
  29. package/dist/lazy.js +177 -0
  30. package/dist/lazy.js.map +1 -0
  31. package/dist/numbers.d.ts +20 -0
  32. package/dist/numbers.d.ts.map +1 -0
  33. package/dist/numbers.js +129 -0
  34. package/dist/numbers.js.map +1 -0
  35. package/dist/order.d.ts +67 -0
  36. package/dist/order.d.ts.map +1 -0
  37. package/dist/order.js +561 -0
  38. package/dist/order.js.map +1 -0
  39. package/dist/parquet.d.ts +38 -0
  40. package/dist/parquet.d.ts.map +1 -0
  41. package/dist/parquet.js +673 -0
  42. package/dist/parquet.js.map +1 -0
  43. package/dist/plan.d.ts +37 -0
  44. package/dist/plan.d.ts.map +1 -0
  45. package/dist/plan.js +51 -0
  46. package/dist/plan.js.map +1 -0
  47. package/dist/summary.d.ts +37 -0
  48. package/dist/summary.d.ts.map +1 -0
  49. package/dist/summary.js +175 -0
  50. package/dist/summary.js.map +1 -0
  51. package/dist/table.d.ts +172 -0
  52. package/dist/table.d.ts.map +1 -0
  53. package/dist/table.js +154 -0
  54. package/dist/table.js.map +1 -0
  55. package/dist/text.d.ts +18 -0
  56. package/dist/text.d.ts.map +1 -0
  57. package/dist/text.js +1204 -0
  58. package/dist/text.js.map +1 -0
  59. package/dist/workbook.d.ts +6 -0
  60. package/dist/workbook.d.ts.map +1 -0
  61. package/dist/workbook.js +35 -0
  62. package/dist/workbook.js.map +1 -0
  63. package/package.json +46 -4
  64. package/src/aggregate.ts +358 -0
  65. package/src/arrow.ts +24 -0
  66. package/src/engine.ts +1163 -0
  67. package/src/evaluate.ts +764 -0
  68. package/src/export.ts +73 -0
  69. package/src/index.ts +2 -0
  70. package/src/lazy.ts +185 -0
  71. package/src/numbers.ts +128 -0
  72. package/src/order.ts +594 -0
  73. package/src/parquet.ts +801 -0
  74. package/src/plan.ts +99 -0
  75. package/src/summary.ts +180 -0
  76. package/src/table.ts +297 -0
  77. package/src/text.ts +1285 -0
  78. package/src/workbook.ts +48 -0
package/dist/table.js ADDED
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Tables in memory: what a host gives the engine, and the checks that make them tables of docs/spec.md
3
+ * §2: columns of §2.1 with unique names, and rows of typed JSON values (§2.2).
4
+ */
5
+ import { isValueOf, LOGICAL_TYPES, typeName } from "vastgrid-spec";
6
+ /** An array of typed JSON as a vector, which arrays are: they have `length` and `at`. */
7
+ export function vectorOf(values) {
8
+ return values;
9
+ }
10
+ /**
11
+ * A table that does not follow §2, or a file that cannot be read, which the engine answers with `load_failed`
12
+ * (§8.7); a file that changed while it was open with `file_changed`.
13
+ */
14
+ export class TableProblem extends Error {
15
+ path;
16
+ code;
17
+ constructor(path, message, code = "load_failed") {
18
+ super(message);
19
+ this.path = path;
20
+ this.code = code;
21
+ this.name = "TableProblem";
22
+ }
23
+ }
24
+ const COLUMN_MEMBERS = ["name", "type", "precision", "scale", "bits", "unit", "sourceType", "readOnly"];
25
+ const UNITS = ["s", "ms", "us", "ns"];
26
+ export function isObject(value) {
27
+ return value !== null && typeof value === "object" && !Array.isArray(value);
28
+ }
29
+ function isInteger(value, min, max) {
30
+ return typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
31
+ }
32
+ /** A value as a problem shows it: its JSON, cut to a length that reads. */
33
+ export function shown(value) {
34
+ const text = value === undefined ? "undefined" : (JSON.stringify(value) ?? String(value));
35
+ return text.length > 60 ? `${text.slice(0, 57)}...` : text;
36
+ }
37
+ /** Checks a column of a table (§2.1), and gives a copy of it. */
38
+ function checkColumn(value, path) {
39
+ if (!isObject(value))
40
+ throw new TableProblem(path, "A column is an object: { name, type, … } (§2.1).");
41
+ for (const key of Object.keys(value)) {
42
+ if (!COLUMN_MEMBERS.includes(key))
43
+ throw new TableProblem(`${path}/${key}`, `"${key}" is not a member of a column (§2.1).`);
44
+ }
45
+ const { name, type } = value;
46
+ if (typeof name !== "string")
47
+ throw new TableProblem(`${path}/name`, "A column's name is a string.");
48
+ if (typeof type !== "string" || !LOGICAL_TYPES.includes(type)) {
49
+ throw new TableProblem(`${path}/type`, `${shown(type)} is not a type of §2.1.`);
50
+ }
51
+ if (type === "decimal") {
52
+ if (!isInteger(value.precision, 1, 38))
53
+ throw new TableProblem(`${path}/precision`, "A decimal's precision is from 1 to 38.");
54
+ if (!isInteger(value.scale, 0, value.precision))
55
+ throw new TableProblem(`${path}/scale`, "A decimal's scale is from 0 to its precision.");
56
+ }
57
+ else {
58
+ for (const member of ["precision", "scale"]) {
59
+ if (value[member] !== undefined)
60
+ throw new TableProblem(`${path}/${member}`, "Only decimals have a precision and a scale.");
61
+ }
62
+ }
63
+ if (value.bits !== undefined && (type !== "float" || (value.bits !== 32 && value.bits !== 64))) {
64
+ throw new TableProblem(`${path}/bits`, "bits is 32 or 64, for floats.");
65
+ }
66
+ if (value.unit !== undefined && (type !== "timestamp" || !UNITS.includes(value.unit))) {
67
+ throw new TableProblem(`${path}/unit`, "unit is s, ms, us or ns, for timestamps.");
68
+ }
69
+ if (value.sourceType !== undefined && typeof value.sourceType !== "string") {
70
+ throw new TableProblem(`${path}/sourceType`, "sourceType is a string.");
71
+ }
72
+ if (value.readOnly !== undefined && typeof value.readOnly !== "boolean") {
73
+ throw new TableProblem(`${path}/readOnly`, "readOnly is a boolean.");
74
+ }
75
+ return { ...value };
76
+ }
77
+ /** Throws a `TableProblem` at `path(index)` for the first column whose name an earlier column has. */
78
+ export function checkNames(columns, path) {
79
+ const names = new Set();
80
+ columns.forEach((column, index) => {
81
+ if (names.has(column.name))
82
+ throw new TableProblem(path(index), `"${column.name}" names two columns.`);
83
+ names.add(column.name);
84
+ });
85
+ }
86
+ /** Whether a host's table is given as Arrow (`ArrowTable`), which `checkArrow` of arrow.ts checks. */
87
+ export function isArrowTable(table) {
88
+ return isObject(table) && "arrow" in table;
89
+ }
90
+ /** Whether a host's table is given as a Parquet file (`ParquetTable`), which parquet.ts reads. */
91
+ export function isParquetTable(table) {
92
+ return isObject(table) && "parquet" in table;
93
+ }
94
+ /** Whether a host's table is given as a text file (`FileTable`), which `readFile` of text.ts reads. */
95
+ export function isFileTable(table) {
96
+ return isObject(table) && "file" in table;
97
+ }
98
+ /** Whether a table given as a file is an Excel workbook, which workbook.ts reads. */
99
+ export function isWorkbook(table) {
100
+ if (table.format !== undefined)
101
+ return table.format === "xlsx";
102
+ const name = isObject(table.file) ? table.file.name : undefined;
103
+ return typeof name === "string" && /\.xls[xm]$/i.test(name);
104
+ }
105
+ /**
106
+ * Checks the form of a table given as rows against §2: its columns, with unique names, and rows of one value per
107
+ * column. Gives copies of the columns. Throws a `TableProblem` with the JSON Pointer of the first member at fault.
108
+ * The values are checked as they are read (`valueChecker`), so that opening a table of millions of rows costs
109
+ * nothing per value.
110
+ */
111
+ export function checkTable(table) {
112
+ if (!isObject(table))
113
+ throw new TableProblem("", "A table is an object: { columns, rows }, { arrow }, { file } or { parquet }.");
114
+ if (!Array.isArray(table.columns))
115
+ throw new TableProblem("/columns", "columns is a list of columns (§2.1).");
116
+ const columns = table.columns.map((column, index) => checkColumn(column, `/columns/${index}`));
117
+ checkNames(columns, (index) => `/columns/${index}/name`);
118
+ const rows = table.rows;
119
+ if (!Array.isArray(rows))
120
+ throw new TableProblem("/rows", "rows is a list of rows.");
121
+ for (let row = 0; row < rows.length; row++) {
122
+ const values = rows[row];
123
+ if (!Array.isArray(values) || values.length !== columns.length) {
124
+ throw new TableProblem(`/rows/${row}`, `A row is a list of ${columns.length} values, one per column.`);
125
+ }
126
+ }
127
+ return { columns, rows, vectors: null, rowCount: rows.length };
128
+ }
129
+ /**
130
+ * Checks the values of a column of a table (§2.2): a function of a value and its row that throws a
131
+ * `TableProblem` at `/rows/{row}/{index}` for a value that is not of the column's type.
132
+ */
133
+ export function valueChecker(column, index) {
134
+ return (value, row) => {
135
+ if (value !== null &&
136
+ !((typeof value === "string" || typeof value === "number" || typeof value === "boolean") &&
137
+ isValueOf(value, column))) {
138
+ throw new TableProblem(`/rows/${row}/${index}`, `${shown(value)} is not a ${typeName(column)} value of column "${column.name}" (§2.2).`);
139
+ }
140
+ };
141
+ }
142
+ /**
143
+ * The value of a column of an Arrow table at a row. A value that has no typed JSON, such as text that is not
144
+ * UTF-8 or a time beyond a day, throws a `TableProblem` at `/rows/{row}/{index}`.
145
+ */
146
+ export function vectorValue(vector, column, index, row) {
147
+ try {
148
+ return vector.at(row);
149
+ }
150
+ catch (error) {
151
+ throw new TableProblem(`/rows/${row}/${index}`, `the value is not a ${typeName(column)} value of column "${column.name}" (§2.2): ${error.message}`);
152
+ }
153
+ }
154
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.js","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAe,S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,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,KAAa;IACxD,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACpB,IACE,KAAK,KAAK,IAAI;YACd,CAAC,CACC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,CAAC;gBACtF,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CACzB,EACD,CAAC;YACD,MAAM,IAAI,YAAY,CACpB,SAAS,GAAG,IAAI,KAAK,EAAE,EACvB,GAAG,KAAK,CAAC,KAAK,CAAC,aAAa,QAAQ,CAAC,MAAM,CAAC,qBAAqB,MAAM,CAAC,IAAI,WAAW,CACxF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,MAAc,EAAE,KAAa,EAAE,GAAW;IACpF,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,YAAY,CACpB,SAAS,GAAG,IAAI,KAAK,EAAE,EACvB,sBAAsB,QAAQ,CAAC,MAAM,CAAC,qBAAqB,MAAM,CAAC,IAAI,aAAc,KAAe,CAAC,OAAO,EAAE,CAC9G,CAAC;IACJ,CAAC;AACH,CAAC"}
package/dist/text.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Tables given as text files (CSV, TSV and JSON Lines in UTF-8), read by a module of their own that the engine
3
+ * loads with the first such table, so that pages whose tables are rows do not load it. A file is read in slices,
4
+ * first to find its columns, the types that all their values fit, the memory they take and where every 1,024th row
5
+ * starts. When its columns fit `maxBytes`, it is read again to keep its values in typed columns, numbers in typed
6
+ * arrays and text as UTF-8, without making rows of JSON; otherwise its rows are read by blocks of 1,024 rows as
7
+ * requests need them, and columns whole only when a request goes through every row of them (lazy.ts).
8
+ */
9
+ import { type Column } from "vastgrid-spec";
10
+ import { type CheckedTable, type FileTable } from "./table.js";
11
+ /**
12
+ * Reads a table given as a text file into typed columns. Throws a `TableProblem` at the member of the table at
13
+ * fault, or at `/rows/{row}/{column}` (`/rows/{row}` for a line of JSON Lines) for text that is not UTF-8 or a
14
+ * line that is not JSON. `fields` gives the column of each field of a CSV file, whose values fit its type, or null
15
+ * for a field that is left out (workbook.ts); by default each field is a column of the type its values fit.
16
+ */
17
+ export declare function readFile(table: FileTable, chunkBytes?: number, fields?: readonly (Column | null)[]): Promise<CheckedTable>;
18
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,KAAK,MAAM,EAOZ,MAAM,eAAe,CAAC;AAIvB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EAMf,MAAM,YAAY,CAAC;AAsGpB;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,SAAS,EAChB,UAAU,SAAc,EACxB,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAClC,OAAO,CAAC,YAAY,CAAC,CAsDvB"}