sqlmath 2024.3.25 → 2024.6.25
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/CHANGELOG.md +39 -2
- package/README.md +21 -15
- package/jslint.mjs +25 -12
- package/package.json +4 -4
- package/sqlmath.mjs +218 -78
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,46 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
# Todo
|
|
4
|
-
- sqlmath - Add sqlite-extension for lightgbm.
|
|
5
4
|
- none
|
|
6
5
|
|
|
6
|
+
# v2024.6.25
|
|
7
|
+
- jslint - Remove unnecessary shell-function shCurlExe().
|
|
8
|
+
- lgbm - Upgrade to lightgbm-v4.4.0.
|
|
9
|
+
- jslint - Upgrade to jslint-v2024.6.1-beta.
|
|
10
|
+
- lgbm - Include lib_lightgbm.xxx in npm/python package.
|
|
11
|
+
- lgbm - Add sqlite-extension for lightgbm.
|
|
12
|
+
- lgbm - Add sql-functions:
|
|
13
|
+
lgbm_datasetcreatefromfile()
|
|
14
|
+
lgbm_datasetcreatefrommat()
|
|
15
|
+
lgbm_datasetcreatefromtable()
|
|
16
|
+
lgbm_datasetdumptext()
|
|
17
|
+
lgbm_datasetfree()
|
|
18
|
+
lgbm_datasetgetnumdata()
|
|
19
|
+
lgbm_datasetgetnumfeature()
|
|
20
|
+
lgbm_datasetsavebinary()
|
|
21
|
+
lgbm_dlopen()
|
|
22
|
+
lgbm_predictforfile()
|
|
23
|
+
lgbm_predictfortable()
|
|
24
|
+
lgbm_trainfromdataset()
|
|
25
|
+
lgbm_trainfromtable()
|
|
26
|
+
- sqlmath - Remove little-used sql-function fill_forward().
|
|
27
|
+
- zlib - Update to zlib v1.3.1.
|
|
28
|
+
- sqlmath - Add function dbExecAndReturnLastValue().
|
|
29
|
+
- sqlmath - Replace functions:
|
|
30
|
+
dbExecAndReturnFirstRow() with dbExecAndReturnLastRow()
|
|
31
|
+
dbExecAndReturnFirstTable() with dbExecAndReturnLastTable()
|
|
32
|
+
|
|
33
|
+
# v2024.5.26
|
|
34
|
+
- webdemo - Replace market-indices .spx/.ndx/.dji with futures .es/.nq/.ym.
|
|
35
|
+
- sqlite - Decouple c-function str99JsonAppendText() from builtin-function jsonAppendString().
|
|
36
|
+
- sqlite - Update to sqlite v3.44.2.
|
|
37
|
+
- sqlmath - Remove little-used sqlean-regexp-extension and file sqlmath_external_pcre2.c.
|
|
38
|
+
- sqlmath - bugfix - Fix off-by-2 root-mean-square-deviation calculation of parameter lee in sql-function win_sinefit2().
|
|
39
|
+
- sqlmath - bugfix - Fix null-case handling-behavior for function dbExecAndReturnLastBlobAsync().
|
|
40
|
+
- sqlmath - Add functions dbExecAndReturnFirstRow(), dbExecAndReturnFirstTable(), listOrEmptyList().
|
|
41
|
+
- jslint - Update jslint to v2024.4.1-beta.
|
|
42
|
+
- ci - bugfix - Fix package.json config-regression breaking ci.
|
|
43
|
+
|
|
7
44
|
# v2024.3.25
|
|
8
45
|
- jslint-ci - Add shell-functions shGitPullrequestCleanup(), shGitPullrequest() to automatically cleanup or create-and-push github-pull-commit to origin/alpha.
|
|
9
46
|
- ci - Fix tmpdir in shell-function shBrowserScreenshot().
|
|
@@ -33,7 +70,7 @@
|
|
|
33
70
|
- sqlean - Add sqlean-extension regexp with regexp-replacement and pcre2 - increases wasm size to 1.1mb.
|
|
34
71
|
- zlib - Update to zlib v1.3.
|
|
35
72
|
- sqlmath - Fix SIGSEGV error when binding external-buffer during db_exec.
|
|
36
|
-
- sqlite - Update to sqlite v3.
|
|
73
|
+
- sqlite - Update to sqlite v3.42.0.
|
|
37
74
|
- python - Add python-functions db_file_load(), db_file_save().
|
|
38
75
|
- sqlmath - Revamp how js-arraybuffers are passed to c-api without copying.
|
|
39
76
|
- python - Revamp python-c-extension to support cp312.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
# Status
|
|
5
|
-
| Branch | [master<br>(v2024.
|
|
5
|
+
| Branch | [master<br>(v2024.6.25)](https://github.com/sqlmath/sqlmath/tree/master) | [beta<br>(Web Demo)](https://github.com/sqlmath/sqlmath/tree/beta) | [alpha<br>(Development)](https://github.com/sqlmath/sqlmath/tree/alpha) |
|
|
6
6
|
|--:|:--:|:--:|:--:|
|
|
7
7
|
| CI | [](https://github.com/sqlmath/sqlmath/actions?query=branch%3Amaster) | [](https://github.com/sqlmath/sqlmath/actions?query=branch%3Abeta) | [](https://github.com/sqlmath/sqlmath/actions?query=branch%3Aalpha) |
|
|
8
8
|
| Coverage | [](https://sqlmath.github.io/sqlmath/branch-master/.artifact/coverage/index.html) | [](https://sqlmath.github.io/sqlmath/branch-beta/.artifact/coverage/index.html) | [](https://sqlmath.github.io/sqlmath/branch-alpha/.artifact/coverage/index.html) |
|
|
@@ -106,7 +106,6 @@ PORT=8080 sh jslint_ci.sh shHttpFileServer
|
|
|
106
106
|
# License
|
|
107
107
|
- [sqlite](https://github.com/sqlite/sqlite) is under [public domain](https://www.sqlite.org/copyright.html).
|
|
108
108
|
- [jslint](https://github.com/jslint-org/jslint) is under [Unlicense License](https://github.com/jslint-org/jslint/blob/master/LICENSE).
|
|
109
|
-
- [pcre2](https://github.com/PCRE2Project/pcre2) is under [3-Clause BSD License](https://github.com/PCRE2Project/pcre2/blob/pcre2-10.42/LICENCE)
|
|
110
109
|
- [zlib](https://github.com/madler/zlib) is under [zlib License](https://github.com/madler/zlib/blob/v1.2.13/LICENSE).
|
|
111
110
|
- [cpplint.py](cpplint.py) is under [3-Clause BSD License](https://github.com/cpplint/cpplint/blob/1.5.5/LICENSE).
|
|
112
111
|
- [indent.exe](indent.exe) is under [GPLv3 License](https://www.gnu.org/licenses/gpl-3.0.txt).
|
|
@@ -122,11 +121,11 @@ PORT=8080 sh jslint_ci.sh shHttpFileServer
|
|
|
122
121
|
```shell
|
|
123
122
|
python -m build
|
|
124
123
|
#
|
|
125
|
-
twine upload --repository testpypi dist/sqlmath-2024.
|
|
126
|
-
py -m pip install --index-url https://test.pypi.org/simple/ sqlmath==2024.
|
|
124
|
+
twine upload --repository testpypi dist/sqlmath-2024.6.25*
|
|
125
|
+
py -m pip install --index-url https://test.pypi.org/simple/ sqlmath==2024.6.25
|
|
127
126
|
#
|
|
128
|
-
twine upload dist/sqlmath-2024.
|
|
129
|
-
pip install sqlmath==2024.
|
|
127
|
+
twine upload dist/sqlmath-2024.6.25*
|
|
128
|
+
pip install sqlmath==2024.6.25
|
|
130
129
|
```
|
|
131
130
|
|
|
132
131
|
|
|
@@ -134,13 +133,20 @@ pip install sqlmath==2024.3.25
|
|
|
134
133
|
### sqlite upgrade
|
|
135
134
|
- goto https://www.sqlite.org/changes.html
|
|
136
135
|
```shell
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
136
|
+
(set -e
|
|
137
|
+
#
|
|
138
|
+
# lgbm
|
|
139
|
+
sh jslint_ci.sh shRollupUpgrade "v4.3.0" "v4.4.0" ".ci.sh sqlmath_base.h"
|
|
140
|
+
#
|
|
141
|
+
# sqlite
|
|
142
|
+
sh jslint_ci.sh shRollupUpgrade "3.42.0" "3.44.2" ".ci.sh sqlmath_external_sqlite.c"
|
|
143
|
+
sh jslint_ci.sh shRollupUpgrade "3420000" "3440200" ".ci.sh sqlmath_external_sqlite.c"
|
|
144
|
+
#
|
|
145
|
+
# zlib
|
|
146
|
+
sh jslint_ci.sh shRollupUpgrade "1.3" "1.3.1" ".ci.sh sqlmath_external_zlib.c"
|
|
147
|
+
#
|
|
148
|
+
# shSqlmathUpdate
|
|
149
|
+
read -p "Press Enter to shSqlmathUpdate:"
|
|
150
|
+
sh jslint_ci.sh shSqlmathUpdate
|
|
151
|
+
)
|
|
146
152
|
```
|
package/jslint.mjs
CHANGED
|
@@ -125,8 +125,8 @@
|
|
|
125
125
|
process_env, process_exit, promises, property, property_dict, push, quote,
|
|
126
126
|
ranges, readFile, readdir, readonly, recursive, reduce, repeat, replace,
|
|
127
127
|
resolve, result, reverse, role, round, scriptId, search, set, shebang,
|
|
128
|
-
shift, signature, single, slice, some, sort, source, spawn, splice,
|
|
129
|
-
stack, stack_trace, start, startOffset, startsWith, statement,
|
|
128
|
+
shell, shift, signature, single, slice, some, sort, source, spawn, splice,
|
|
129
|
+
split, stack, stack_trace, start, startOffset, startsWith, statement,
|
|
130
130
|
statement_prv, stdio, stop, stop_at, stringify, subscript, switch,
|
|
131
131
|
syntax_dict, tenure, test, test_cause, test_internal_error, this, thru,
|
|
132
132
|
toLocaleString, toString, token, token_global, token_list, token_nxt,
|
|
@@ -163,7 +163,7 @@ let jslint_charset_ascii = (
|
|
|
163
163
|
+ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
|
164
164
|
+ "`abcdefghijklmnopqrstuvwxyz{|}~\u007f"
|
|
165
165
|
);
|
|
166
|
-
let jslint_edition = "v2024.
|
|
166
|
+
let jslint_edition = "v2024.6.1-beta";
|
|
167
167
|
let jslint_export; // The jslint object to be exported.
|
|
168
168
|
let jslint_fudge = 1; // Fudge starting line and starting
|
|
169
169
|
// ... column to 1.
|
|
@@ -11285,24 +11285,37 @@ function sentinel() {}
|
|
|
11285
11285
|
}
|
|
11286
11286
|
}));
|
|
11287
11287
|
exitCode = await new Promise(function (resolve) {
|
|
11288
|
-
|
|
11289
|
-
(
|
|
11290
|
-
processArgv[0] === "npm"
|
|
11288
|
+
let processArgv0 = processArgv[0];
|
|
11291
11289
|
|
|
11292
11290
|
// If win32 environment, then replace program npm with npm.cmd.
|
|
11293
11291
|
// Coverage-hack - Ugly-hack to get test-coverage under both win32 and linux.
|
|
11294
11292
|
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
11300
|
-
|
|
11293
|
+
if (processArgv0 === "npm") {
|
|
11294
|
+
processArgv0 = process.platform.replace(
|
|
11295
|
+
"win32",
|
|
11296
|
+
"npm.cmd"
|
|
11297
|
+
).replace(
|
|
11298
|
+
process.platform,
|
|
11299
|
+
"npm"
|
|
11300
|
+
);
|
|
11301
|
+
}
|
|
11302
|
+
moduleChildProcess.spawn(
|
|
11303
|
+
processArgv0,
|
|
11301
11304
|
processArgv.slice(1),
|
|
11302
11305
|
{
|
|
11303
11306
|
env: Object.assign({}, process.env, {
|
|
11304
11307
|
NODE_V8_COVERAGE: coverageDir
|
|
11305
11308
|
}),
|
|
11309
|
+
|
|
11310
|
+
// PR-465
|
|
11311
|
+
// https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2
|
|
11312
|
+
// Node.js will now error with EINVAL if a .bat or .cmd file is passed to
|
|
11313
|
+
// child_process.spawn and child_process.spawnSync without the shell option set.
|
|
11314
|
+
|
|
11315
|
+
shell: (
|
|
11316
|
+
processArgv0.endsWith(".bat")
|
|
11317
|
+
|| processArgv0.endsWith(".cmd")
|
|
11318
|
+
),
|
|
11306
11319
|
stdio: ["ignore", 1, 2]
|
|
11307
11320
|
}
|
|
11308
11321
|
).on("exit", resolve);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"email": "kaizhu256@gmail.com",
|
|
4
4
|
"name": "kai zhu"
|
|
5
5
|
},
|
|
6
|
-
"counter":
|
|
6
|
+
"counter": 1,
|
|
7
7
|
"cpu": [
|
|
8
8
|
"x64"
|
|
9
9
|
],
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=14"
|
|
13
13
|
},
|
|
14
|
-
"fileCount":
|
|
14
|
+
"fileCount": 46,
|
|
15
15
|
"homepage": "https://github.com/sqlmath/sqlmath",
|
|
16
16
|
"keywords": [
|
|
17
17
|
"data-science",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
|
-
"url": "https://github.com/sqlmath/sqlmath.git"
|
|
32
|
+
"url": "git+https://github.com/sqlmath/sqlmath.git"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "sh jslint_ci.sh shCiBuildNodejs",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
},
|
|
39
39
|
"shCiArtifactUpload": 1,
|
|
40
40
|
"shCiPublishNpm": 1,
|
|
41
|
-
"version": "2024.
|
|
41
|
+
"version": "2024.6.25"
|
|
42
42
|
}
|
package/sqlmath.mjs
CHANGED
|
@@ -25,49 +25,66 @@
|
|
|
25
25
|
/*global FinalizationRegistry*/
|
|
26
26
|
"use strict";
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
const JSBATON_ARGC = 8;
|
|
29
|
+
const JSBATON_OFFSET_ALL = 256;
|
|
30
|
+
const JSBATON_OFFSET_ARGV = 128;
|
|
31
|
+
const JSBATON_OFFSET_BUFV = 192;
|
|
32
|
+
// const JSBATON_OFFSET_ERRMSG = 48;
|
|
33
|
+
const JSBATON_OFFSET_FUNCNAME = 8;
|
|
34
|
+
const JS_MAX_SAFE_INTEGER = 0x1f_ffff_ffff_ffff;
|
|
35
|
+
const JS_MIN_SAFE_INTEGER = -0x1f_ffff_ffff_ffff;
|
|
36
|
+
const SIZEOF_BLOB_MAX = 1_000_000_000;
|
|
37
|
+
// const SIZEOF_ERRMSG = 80;
|
|
38
|
+
const SIZEOF_FUNCNAME = 16;
|
|
39
|
+
const SQLITE_DATATYPE_BLOB = 0x04;
|
|
40
|
+
const SQLITE_DATATYPE_EXTERNALBUFFER = 0x71;
|
|
41
|
+
const SQLITE_DATATYPE_FLOAT = 0x02;
|
|
42
|
+
const SQLITE_DATATYPE_INTEGER = 0x01;
|
|
43
|
+
const SQLITE_DATATYPE_INTEGER_0 = 0x00;
|
|
44
|
+
const SQLITE_DATATYPE_INTEGER_1 = 0x21;
|
|
45
|
+
const SQLITE_DATATYPE_NULL = 0x05;
|
|
46
|
+
const SQLITE_DATATYPE_TEXT = 0x03;
|
|
47
|
+
const SQLITE_DATATYPE_TEXT_0 = 0x13;
|
|
48
|
+
const SQLITE_RESPONSETYPE_LASTBLOB = 1;
|
|
49
|
+
const SQLITE_RESPONSETYPE_LASTVALUE = 2;
|
|
50
|
+
|
|
51
|
+
const FILENAME_DBTMP = "/tmp/__dbtmp1"; //jslint-ignore-line
|
|
52
|
+
|
|
53
|
+
const LGBM_DTYPE_FLOAT32 = 0; /* float32 (single precision float)*/
|
|
54
|
+
const LGBM_DTYPE_FLOAT64 = 1; /* float64 (double precision float)*/
|
|
55
|
+
const LGBM_DTYPE_INT32 = 2; /* int32*/
|
|
56
|
+
const LGBM_DTYPE_INT64 = 3; /* int64*/
|
|
57
|
+
const LGBM_FEATURE_IMPORTANCE_GAIN = 1; /* Gain type of feature importance*/
|
|
58
|
+
const LGBM_FEATURE_IMPORTANCE_SPLIT = 0;/* Split type of feature importance*/
|
|
59
|
+
const LGBM_MATRIX_TYPE_CSC = 1; /* CSC sparse matrix type*/
|
|
60
|
+
const LGBM_MATRIX_TYPE_CSR = 0; /* CSR sparse matrix type*/
|
|
61
|
+
const LGBM_PREDICT_CONTRIB = 3; /* Predict feature contributions (SHAP values)*/
|
|
62
|
+
const LGBM_PREDICT_LEAF_INDEX = 2; /* Predict leaf index*/
|
|
63
|
+
const LGBM_PREDICT_NORMAL = 0; /* Normal prediction w/ transform (if needed)*/
|
|
64
|
+
const LGBM_PREDICT_RAW_SCORE = 1; /* Predict raw score*/
|
|
65
|
+
const SQLITE_OPEN_AUTOPROXY = 0x00000020; /* VFS only */
|
|
66
|
+
const SQLITE_OPEN_CREATE = 0x00000004; /* Ok for sqlite3_open_v2() */
|
|
67
|
+
const SQLITE_OPEN_DELETEONCLOSE = 0x00000008; /* VFS only */
|
|
68
|
+
const SQLITE_OPEN_EXCLUSIVE = 0x00000010; /* VFS only */
|
|
69
|
+
const SQLITE_OPEN_FULLMUTEX = 0x00010000; /* Ok for sqlite3_open_v2() */
|
|
70
|
+
const SQLITE_OPEN_MAIN_DB = 0x00000100; /* VFS only */
|
|
71
|
+
const SQLITE_OPEN_MAIN_JOURNAL = 0x00000800; /* VFS only */
|
|
72
|
+
const SQLITE_OPEN_MEMORY = 0x00000080; /* Ok for sqlite3_open_v2() */
|
|
73
|
+
const SQLITE_OPEN_NOFOLLOW = 0x01000000; /* Ok for sqlite3_open_v2() */
|
|
74
|
+
const SQLITE_OPEN_NOMUTEX = 0x00008000; /* Ok for sqlite3_open_v2() */
|
|
75
|
+
const SQLITE_OPEN_PRIVATECACHE = 0x00040000; /* Ok for sqlite3_open_v2() */
|
|
76
|
+
const SQLITE_OPEN_READONLY = 0x00000001; /* Ok for sqlite3_open_v2() */
|
|
77
|
+
const SQLITE_OPEN_READWRITE = 0x00000002; /* Ok for sqlite3_open_v2() */
|
|
78
|
+
const SQLITE_OPEN_SHAREDCACHE = 0x00020000; /* Ok for sqlite3_open_v2() */
|
|
79
|
+
const SQLITE_OPEN_SUBJOURNAL = 0x00002000; /* VFS only */
|
|
80
|
+
const SQLITE_OPEN_SUPER_JOURNAL = 0x00004000; /* VFS only */
|
|
81
|
+
const SQLITE_OPEN_TEMP_DB = 0x00000200; /* VFS only */
|
|
82
|
+
const SQLITE_OPEN_TEMP_JOURNAL = 0x00001000; /* VFS only */
|
|
83
|
+
const SQLITE_OPEN_TRANSIENT_DB = 0x00000400; /* VFS only */
|
|
84
|
+
const SQLITE_OPEN_URI = 0x00000040; /* Ok for sqlite3_open_v2() */
|
|
85
|
+
const SQLITE_OPEN_WAL = 0x00080000; /* VFS only */
|
|
86
|
+
|
|
49
87
|
let IS_BROWSER;
|
|
50
|
-
let SQLITE_OPEN_AUTOPROXY = 0x00000020; /* VFS only */
|
|
51
|
-
let SQLITE_OPEN_CREATE = 0x00000004; /* Ok for sqlite3_open_v2() */
|
|
52
|
-
let SQLITE_OPEN_DELETEONCLOSE = 0x00000008; /* VFS only */
|
|
53
|
-
let SQLITE_OPEN_EXCLUSIVE = 0x00000010; /* VFS only */
|
|
54
|
-
let SQLITE_OPEN_FULLMUTEX = 0x00010000; /* Ok for sqlite3_open_v2() */
|
|
55
|
-
let SQLITE_OPEN_MAIN_DB = 0x00000100; /* VFS only */
|
|
56
|
-
let SQLITE_OPEN_MAIN_JOURNAL = 0x00000800; /* VFS only */
|
|
57
|
-
let SQLITE_OPEN_MEMORY = 0x00000080; /* Ok for sqlite3_open_v2() */
|
|
58
|
-
let SQLITE_OPEN_NOFOLLOW = 0x01000000; /* Ok for sqlite3_open_v2() */
|
|
59
|
-
let SQLITE_OPEN_NOMUTEX = 0x00008000; /* Ok for sqlite3_open_v2() */
|
|
60
|
-
let SQLITE_OPEN_PRIVATECACHE = 0x00040000; /* Ok for sqlite3_open_v2() */
|
|
61
|
-
let SQLITE_OPEN_READONLY = 0x00000001; /* Ok for sqlite3_open_v2() */
|
|
62
|
-
let SQLITE_OPEN_READWRITE = 0x00000002; /* Ok for sqlite3_open_v2() */
|
|
63
|
-
let SQLITE_OPEN_SHAREDCACHE = 0x00020000; /* Ok for sqlite3_open_v2() */
|
|
64
|
-
let SQLITE_OPEN_SUBJOURNAL = 0x00002000; /* VFS only */
|
|
65
|
-
let SQLITE_OPEN_SUPER_JOURNAL = 0x00004000; /* VFS only */
|
|
66
|
-
let SQLITE_OPEN_TEMP_DB = 0x00000200; /* VFS only */
|
|
67
|
-
let SQLITE_OPEN_TEMP_JOURNAL = 0x00001000; /* VFS only */
|
|
68
|
-
let SQLITE_OPEN_TRANSIENT_DB = 0x00000400; /* VFS only */
|
|
69
|
-
let SQLITE_OPEN_URI = 0x00000040; /* Ok for sqlite3_open_v2() */
|
|
70
|
-
let SQLITE_OPEN_WAL = 0x00080000; /* VFS only */
|
|
71
88
|
let cModule;
|
|
72
89
|
let cModulePath;
|
|
73
90
|
let consoleError = console.error;
|
|
@@ -92,6 +109,7 @@ let debugInline = (function () {
|
|
|
92
109
|
}());
|
|
93
110
|
let moduleChildProcess;
|
|
94
111
|
let moduleChildProcessSpawn;
|
|
112
|
+
let moduleCrypto;
|
|
95
113
|
let moduleFs;
|
|
96
114
|
let moduleFsInitResolveList;
|
|
97
115
|
let modulePath;
|
|
@@ -104,7 +122,7 @@ let {
|
|
|
104
122
|
let sqlMessageDict = {}; // dict of web-worker-callbacks
|
|
105
123
|
let sqlMessageId = 0;
|
|
106
124
|
let sqlWorker;
|
|
107
|
-
let version = "v2024.
|
|
125
|
+
let version = "v2024.6.25";
|
|
108
126
|
|
|
109
127
|
async function assertErrorThrownAsync(asyncFunc, regexp) {
|
|
110
128
|
|
|
@@ -300,7 +318,10 @@ async function ciBuildExt1NodejsConfigure({
|
|
|
300
318
|
"-Wno-all",
|
|
301
319
|
"-Wno-extra",
|
|
302
320
|
"-Wno-implicit-fallthrough",
|
|
321
|
+
"-Wno-incompatible-pointer-types",
|
|
303
322
|
"-Wno-int-conversion",
|
|
323
|
+
"-Wno-unreachable-code",
|
|
324
|
+
"-Wno-unused-function",
|
|
304
325
|
"-Wno-unused-parameter"
|
|
305
326
|
];
|
|
306
327
|
consoleError(`ciBuildExt1Nodejs - configure binding.gyp`);
|
|
@@ -310,16 +331,6 @@ async function ciBuildExt1NodejsConfigure({
|
|
|
310
331
|
"-Wextra",
|
|
311
332
|
"-std=c11"
|
|
312
333
|
],
|
|
313
|
-
"conditions": [
|
|
314
|
-
[
|
|
315
|
-
"OS == 'win'",
|
|
316
|
-
{
|
|
317
|
-
"defines": [
|
|
318
|
-
"WIN32"
|
|
319
|
-
]
|
|
320
|
-
}
|
|
321
|
-
]
|
|
322
|
-
],
|
|
323
334
|
// https://github.com/nodejs/node-gyp/blob/v9.3.1/gyp/pylib/gyp/MSVSSettings.py
|
|
324
335
|
"msvs_settings": {
|
|
325
336
|
"VCCLCompilerTool": {
|
|
@@ -341,7 +352,6 @@ async function ciBuildExt1NodejsConfigure({
|
|
|
341
352
|
],
|
|
342
353
|
"sources": [
|
|
343
354
|
"sqlmath_base.c",
|
|
344
|
-
"sqlmath_external_pcre2.c",
|
|
345
355
|
"sqlmath_external_sqlite.c",
|
|
346
356
|
"sqlmath_external_zlib.c"
|
|
347
357
|
],
|
|
@@ -626,14 +636,14 @@ async function dbCloseAsync(db) {
|
|
|
626
636
|
}));
|
|
627
637
|
}
|
|
628
638
|
|
|
629
|
-
function
|
|
639
|
+
function dbExecAndReturnLastBlob({
|
|
630
640
|
bindList = [],
|
|
631
641
|
db,
|
|
632
642
|
sql
|
|
633
643
|
}) {
|
|
634
644
|
|
|
635
|
-
// This function will exec <sql> in <db
|
|
636
|
-
// from execution as raw blob/buffer.
|
|
645
|
+
// This function will exec <sql> in <db>,
|
|
646
|
+
// and return last-value retrieved from execution as raw blob/buffer.
|
|
637
647
|
|
|
638
648
|
return dbExecAsync({
|
|
639
649
|
bindList,
|
|
@@ -643,6 +653,52 @@ function dbExecAndReturnLastBlobAsync({
|
|
|
643
653
|
});
|
|
644
654
|
}
|
|
645
655
|
|
|
656
|
+
async function dbExecAndReturnLastRow({
|
|
657
|
+
bindList = [],
|
|
658
|
+
db,
|
|
659
|
+
sql
|
|
660
|
+
}) {
|
|
661
|
+
|
|
662
|
+
// This function will exec <sql> in <db>,
|
|
663
|
+
// and return last-row or empty-object.
|
|
664
|
+
|
|
665
|
+
let result = await dbExecAsync({bindList, db, sql});
|
|
666
|
+
result = result[result.length - 1] || [];
|
|
667
|
+
result = result[result.length - 1] || {};
|
|
668
|
+
return result;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
async function dbExecAndReturnLastTable({
|
|
672
|
+
bindList = [],
|
|
673
|
+
db,
|
|
674
|
+
sql
|
|
675
|
+
}) {
|
|
676
|
+
|
|
677
|
+
// This function will exec <sql> in <db>,
|
|
678
|
+
// and return last-table or empty-list.
|
|
679
|
+
|
|
680
|
+
let result = await dbExecAsync({bindList, db, sql});
|
|
681
|
+
result = result[result.length - 1] || [];
|
|
682
|
+
return result;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function dbExecAndReturnLastValue({
|
|
686
|
+
bindList = [],
|
|
687
|
+
db,
|
|
688
|
+
sql
|
|
689
|
+
}) {
|
|
690
|
+
|
|
691
|
+
// This function will exec <sql> in <db>,
|
|
692
|
+
// and return last-json-value.
|
|
693
|
+
|
|
694
|
+
return dbExecAsync({
|
|
695
|
+
bindList,
|
|
696
|
+
db,
|
|
697
|
+
responseType: "lastvalue",
|
|
698
|
+
sql
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
|
|
646
702
|
async function dbExecAsync({
|
|
647
703
|
bindList = [],
|
|
648
704
|
db,
|
|
@@ -698,6 +754,8 @@ async function dbExecAsync({
|
|
|
698
754
|
(
|
|
699
755
|
responseType === "lastblob"
|
|
700
756
|
? SQLITE_RESPONSETYPE_LASTBLOB
|
|
757
|
+
: responseType === "lastvalue"
|
|
758
|
+
? SQLITE_RESPONSETYPE_LASTVALUE
|
|
701
759
|
: 0
|
|
702
760
|
)
|
|
703
761
|
],
|
|
@@ -717,6 +775,7 @@ async function dbExecAsync({
|
|
|
717
775
|
case "arraybuffer":
|
|
718
776
|
case "lastblob":
|
|
719
777
|
return result;
|
|
778
|
+
case "lastvalue":
|
|
720
779
|
case "list":
|
|
721
780
|
return jsonParseArraybuffer(result);
|
|
722
781
|
default:
|
|
@@ -743,6 +802,25 @@ async function dbFileLoadAsync({
|
|
|
743
802
|
|
|
744
803
|
// This function will load <filename> to <db>.
|
|
745
804
|
|
|
805
|
+
let filename2;
|
|
806
|
+
async function _dbFileLoad() {
|
|
807
|
+
dbData = await dbCallAsync(
|
|
808
|
+
jsbatonCreate("_dbFileLoad"),
|
|
809
|
+
[
|
|
810
|
+
// 0. sqlite3 * pInMemory
|
|
811
|
+
db,
|
|
812
|
+
// 1. char *zFilename
|
|
813
|
+
filename,
|
|
814
|
+
// 2. const int isSave
|
|
815
|
+
modeSave,
|
|
816
|
+
// 3. undefined
|
|
817
|
+
undefined,
|
|
818
|
+
// 4. dbData - same position as dbOpenAsync
|
|
819
|
+
dbData
|
|
820
|
+
],
|
|
821
|
+
"modeDb"
|
|
822
|
+
);
|
|
823
|
+
}
|
|
746
824
|
if (modeNoop) {
|
|
747
825
|
return;
|
|
748
826
|
}
|
|
@@ -753,22 +831,22 @@ async function dbFileLoadAsync({
|
|
|
753
831
|
typeof filename === "string" && filename,
|
|
754
832
|
`invalid filename ${filename}`
|
|
755
833
|
);
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
834
|
+
// Save to tmpfile and then atomically-rename to actual-filename.
|
|
835
|
+
if (moduleFs && modeSave) {
|
|
836
|
+
filename2 = filename;
|
|
837
|
+
filename = modulePath.join(
|
|
838
|
+
modulePath.dirname(filename),
|
|
839
|
+
`.dbFileSaveAsync.${moduleCrypto.randomUUID()}`
|
|
840
|
+
);
|
|
841
|
+
try {
|
|
842
|
+
await _dbFileLoad();
|
|
843
|
+
await moduleFs.promises.rename(filename, filename2);
|
|
844
|
+
} finally {
|
|
845
|
+
await moduleFs.promises.unlink(filename).catch(noop);
|
|
846
|
+
}
|
|
847
|
+
} else {
|
|
848
|
+
await _dbFileLoad();
|
|
849
|
+
}
|
|
772
850
|
return dbData[1 + 0];
|
|
773
851
|
}
|
|
774
852
|
|
|
@@ -815,6 +893,7 @@ async function dbOpenAsync({
|
|
|
815
893
|
// );
|
|
816
894
|
let connPool;
|
|
817
895
|
let db = {busy: 0, filename, ii: 0};
|
|
896
|
+
let fileLgbm;
|
|
818
897
|
assertOrThrow(typeof filename === "string", `invalid filename ${filename}`);
|
|
819
898
|
assertOrThrow(
|
|
820
899
|
!dbData || isExternalBuffer(dbData),
|
|
@@ -845,11 +924,25 @@ async function dbOpenAsync({
|
|
|
845
924
|
return ptr;
|
|
846
925
|
}));
|
|
847
926
|
db.connPool = connPool;
|
|
927
|
+
// init lightgbm
|
|
928
|
+
if (!IS_BROWSER) {
|
|
929
|
+
fileLgbm = process.platform;
|
|
930
|
+
fileLgbm = fileLgbm.replace("darwin", "lib_lightgbm.dylib");
|
|
931
|
+
fileLgbm = fileLgbm.replace("win32", "lib_lightgbm.dll");
|
|
932
|
+
fileLgbm = fileLgbm.replace(process.platform, "lib_lightgbm.so");
|
|
933
|
+
fileLgbm = `${import.meta.dirname}/sqlmath/${fileLgbm}`;
|
|
934
|
+
await dbExecAsync({
|
|
935
|
+
db,
|
|
936
|
+
sql: `SELECT lgbm_dlopen('${fileLgbm}');`
|
|
937
|
+
});
|
|
938
|
+
}
|
|
848
939
|
return db;
|
|
849
940
|
}
|
|
850
941
|
|
|
851
942
|
async function dbTableImportAsync({
|
|
852
943
|
db,
|
|
944
|
+
filename,
|
|
945
|
+
headerMissing,
|
|
853
946
|
mode,
|
|
854
947
|
tableName,
|
|
855
948
|
textData
|
|
@@ -859,6 +952,9 @@ async function dbTableImportAsync({
|
|
|
859
952
|
let rowList;
|
|
860
953
|
let rowidList;
|
|
861
954
|
let tmp;
|
|
955
|
+
if (filename) {
|
|
956
|
+
textData = await moduleFs.promises.readFile(filename, "utf8");
|
|
957
|
+
}
|
|
862
958
|
switch (mode) {
|
|
863
959
|
case "csv":
|
|
864
960
|
rowList = jsonRowListFromCsv({
|
|
@@ -888,6 +984,12 @@ async function dbTableImportAsync({
|
|
|
888
984
|
return val;
|
|
889
985
|
});
|
|
890
986
|
}
|
|
987
|
+
// headerMissing
|
|
988
|
+
if (headerMissing && (rowList.length > 0 && Array.isArray(rowList[0]))) {
|
|
989
|
+
rowList.unshift(Array.from(rowList[0]).map(function (ignore, ii) {
|
|
990
|
+
return String(ii + 1);
|
|
991
|
+
}));
|
|
992
|
+
}
|
|
891
993
|
// normalize rowList[ii] to list
|
|
892
994
|
if (rowList.length === 0) {
|
|
893
995
|
rowList.push([
|
|
@@ -1274,9 +1376,12 @@ function jsonParseArraybuffer(buf) {
|
|
|
1274
1376
|
// This function will JSON.parse arraybuffer <buf>.
|
|
1275
1377
|
|
|
1276
1378
|
return JSON.parse(
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1379
|
+
(
|
|
1380
|
+
IS_BROWSER
|
|
1381
|
+
? new TextDecoder().decode(buf)
|
|
1382
|
+
: buf
|
|
1383
|
+
)
|
|
1384
|
+
|| "null"
|
|
1280
1385
|
);
|
|
1281
1386
|
}
|
|
1282
1387
|
|
|
@@ -1431,6 +1536,13 @@ function jsonRowListFromCsv({
|
|
|
1431
1536
|
return rowList;
|
|
1432
1537
|
}
|
|
1433
1538
|
|
|
1539
|
+
function listOrEmptyList(list) {
|
|
1540
|
+
|
|
1541
|
+
// This function will return <list> or empty-list if falsy.
|
|
1542
|
+
|
|
1543
|
+
return list || [];
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1434
1546
|
async function moduleFsInit() {
|
|
1435
1547
|
|
|
1436
1548
|
// This function will import nodejs builtin-modules if they have not yet been
|
|
@@ -1455,11 +1567,13 @@ async function moduleFsInit() {
|
|
|
1455
1567
|
moduleFsInitResolveList = [];
|
|
1456
1568
|
[
|
|
1457
1569
|
moduleChildProcess,
|
|
1570
|
+
moduleCrypto,
|
|
1458
1571
|
moduleFs,
|
|
1459
1572
|
modulePath,
|
|
1460
1573
|
moduleUrl
|
|
1461
1574
|
] = await Promise.all([
|
|
1462
1575
|
import("child_process"),
|
|
1576
|
+
import("crypto"),
|
|
1463
1577
|
import("fs"),
|
|
1464
1578
|
import("path"),
|
|
1465
1579
|
import("url")
|
|
@@ -1623,11 +1737,32 @@ function sqlmathWebworkerInit({
|
|
|
1623
1737
|
}
|
|
1624
1738
|
}
|
|
1625
1739
|
|
|
1740
|
+
function waitAsync(timeout) {
|
|
1741
|
+
|
|
1742
|
+
// This function will wait <timeout> ms.
|
|
1743
|
+
|
|
1744
|
+
return new Promise(function (resolve) {
|
|
1745
|
+
setTimeout(resolve, timeout * !npm_config_mode_test);
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1626
1749
|
sqlmathInit(); // coverage-hack
|
|
1627
1750
|
await sqlmathInit();
|
|
1628
1751
|
sqlmathInit(); // coverage-hack
|
|
1629
1752
|
|
|
1630
1753
|
export {
|
|
1754
|
+
LGBM_DTYPE_FLOAT32,
|
|
1755
|
+
LGBM_DTYPE_FLOAT64,
|
|
1756
|
+
LGBM_DTYPE_INT32,
|
|
1757
|
+
LGBM_DTYPE_INT64,
|
|
1758
|
+
LGBM_FEATURE_IMPORTANCE_GAIN,
|
|
1759
|
+
LGBM_FEATURE_IMPORTANCE_SPLIT,
|
|
1760
|
+
LGBM_MATRIX_TYPE_CSC,
|
|
1761
|
+
LGBM_MATRIX_TYPE_CSR,
|
|
1762
|
+
LGBM_PREDICT_CONTRIB,
|
|
1763
|
+
LGBM_PREDICT_LEAF_INDEX,
|
|
1764
|
+
LGBM_PREDICT_NORMAL,
|
|
1765
|
+
LGBM_PREDICT_RAW_SCORE,
|
|
1631
1766
|
SQLITE_OPEN_AUTOPROXY,
|
|
1632
1767
|
SQLITE_OPEN_CREATE,
|
|
1633
1768
|
SQLITE_OPEN_DELETEONCLOSE,
|
|
@@ -1657,7 +1792,10 @@ export {
|
|
|
1657
1792
|
childProcessSpawn2,
|
|
1658
1793
|
ciBuildExt,
|
|
1659
1794
|
dbCloseAsync,
|
|
1660
|
-
|
|
1795
|
+
dbExecAndReturnLastBlob,
|
|
1796
|
+
dbExecAndReturnLastRow,
|
|
1797
|
+
dbExecAndReturnLastTable,
|
|
1798
|
+
dbExecAndReturnLastValue,
|
|
1661
1799
|
dbExecAsync,
|
|
1662
1800
|
dbFileLoadAsync,
|
|
1663
1801
|
dbFileSaveAsync,
|
|
@@ -1671,8 +1809,10 @@ export {
|
|
|
1671
1809
|
fsWriteFileUnlessTest,
|
|
1672
1810
|
jsbatonGetInt64,
|
|
1673
1811
|
jsbatonGetString,
|
|
1812
|
+
listOrEmptyList,
|
|
1674
1813
|
noop,
|
|
1675
1814
|
objectDeepCopyWithKeysSorted,
|
|
1676
1815
|
sqlmathWebworkerInit,
|
|
1677
|
-
version
|
|
1816
|
+
version,
|
|
1817
|
+
waitAsync
|
|
1678
1818
|
};
|