sqlmath 2024.5.26 → 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 CHANGED
@@ -1,13 +1,39 @@
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
+
7
33
  # v2024.5.26
8
34
  - webdemo - Replace market-indices .spx/.ndx/.dji with futures .es/.nq/.ym.
9
35
  - sqlite - Decouple c-function str99JsonAppendText() from builtin-function jsonAppendString().
10
- - sqlite - Update to sqlite v3.42.0.
36
+ - sqlite - Update to sqlite v3.44.2.
11
37
  - sqlmath - Remove little-used sqlean-regexp-extension and file sqlmath_external_pcre2.c.
12
38
  - sqlmath - bugfix - Fix off-by-2 root-mean-square-deviation calculation of parameter lee in sql-function win_sinefit2().
13
39
  - sqlmath - bugfix - Fix null-case handling-behavior for function dbExecAndReturnLastBlobAsync().
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  # Status
5
- | Branch | [master<br>(v2024.5.26)](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) |
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 | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Amaster) | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=beta)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Abeta) | [![ci](https://github.com/sqlmath/sqlmath/actions/workflows/ci.yml/badge.svg?branch=alpha)](https://github.com/sqlmath/sqlmath/actions?query=branch%3Aalpha) |
8
8
  | Coverage | [![coverage](https://sqlmath.github.io/sqlmath/branch-master/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-master/.artifact/coverage/index.html) | [![coverage](https://sqlmath.github.io/sqlmath/branch-beta/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-beta/.artifact/coverage/index.html) | [![coverage](https://sqlmath.github.io/sqlmath/branch-alpha/.artifact/coverage/coverage_badge.svg)](https://sqlmath.github.io/sqlmath/branch-alpha/.artifact/coverage/index.html) |
@@ -121,11 +121,11 @@ PORT=8080 sh jslint_ci.sh shHttpFileServer
121
121
  ```shell
122
122
  python -m build
123
123
  #
124
- twine upload --repository testpypi dist/sqlmath-2024.5.26*
125
- py -m pip install --index-url https://test.pypi.org/simple/ sqlmath==2024.5.26
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
126
126
  #
127
- twine upload dist/sqlmath-2024.5.26*
128
- pip install sqlmath==2024.5.26
127
+ twine upload dist/sqlmath-2024.6.25*
128
+ pip install sqlmath==2024.6.25
129
129
  ```
130
130
 
131
131
 
@@ -133,16 +133,20 @@ pip install sqlmath==2024.5.26
133
133
  ### sqlite upgrade
134
134
  - goto https://www.sqlite.org/changes.html
135
135
  ```shell
136
- curl -L https://www.sqlite.org/2023/sqlite-autoconf-3440200.tar.gz | tar -xz
137
- mv sqlite-autoconf-3440200 .sqlite-autoconf-3440200
138
- git grep "3\.42\.0\|3420000"
139
- for FILE in .ci.sh sqlmath_external_sqlite.c sqlmath_external_zlib.c
140
- do
141
- sed -i -e "s|\<3\.42\.0\>|3.44.2|g" "$FILE"
142
- sed -i -e "s|\<3420000\>|3440200|g" "$FILE"
143
- done
144
- git grep "3\.42\.0\|3420000"
145
- shRollupFetch sqlmath_external_sqlite.c
146
- shRollupFetch sqlmath_external_zlib.c
147
- sh jslint_ci.sh shSqlmathUpdate
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
+ )
148
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, split,
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.4.1-beta";
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
- moduleChildProcess.spawn(
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
- ? process.platform.replace("win32", "npm.cmd").replace(
11296
- process.platform,
11297
- "npm"
11298
- )
11299
- : processArgv[0]
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": 0,
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": 41,
14
+ "fileCount": 46,
15
15
  "homepage": "https://github.com/sqlmath/sqlmath",
16
16
  "keywords": [
17
17
  "data-science",
@@ -38,5 +38,5 @@
38
38
  },
39
39
  "shCiArtifactUpload": 1,
40
40
  "shCiPublishNpm": 1,
41
- "version": "2024.5.26"
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
- let JSBATON_ARGC = 8;
29
- let JSBATON_OFFSET_ALL = 256;
30
- let JSBATON_OFFSET_ARGV = 128;
31
- let JSBATON_OFFSET_BUFV = 192;
32
- let JSBATON_OFFSET_FUNCNAME = 8;
33
- let JS_MAX_SAFE_INTEGER = 0x1f_ffff_ffff_ffff;
34
- let JS_MIN_SAFE_INTEGER = -0x1f_ffff_ffff_ffff;
35
- let SIZEOF_BLOB_MAX = 1_000_000_000;
36
- let SIZEOF_FUNCNAME = 16;
37
- let SQLITE_DATATYPE_BLOB = 0x04;
38
- let SQLITE_DATATYPE_EXTERNALBUFFER = 0x71;
39
- let SQLITE_DATATYPE_FLOAT = 0x02;
40
- let SQLITE_DATATYPE_INTEGER = 0x01;
41
- let SQLITE_DATATYPE_INTEGER_0 = 0x00;
42
- let SQLITE_DATATYPE_INTEGER_1 = 0x21;
43
- let SQLITE_DATATYPE_NULL = 0x05;
44
- let SQLITE_DATATYPE_TEXT = 0x03;
45
- let SQLITE_DATATYPE_TEXT_0 = 0x13;
46
- let SQLITE_RESPONSETYPE_LASTBLOB = 1;
47
-
48
- let FILENAME_DBTMP = "/tmp/__dbtmp1"; //jslint-ignore-line
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;
@@ -105,7 +122,7 @@ let {
105
122
  let sqlMessageDict = {}; // dict of web-worker-callbacks
106
123
  let sqlMessageId = 0;
107
124
  let sqlWorker;
108
- let version = "v2024.5.26";
125
+ let version = "v2024.6.25";
109
126
 
110
127
  async function assertErrorThrownAsync(asyncFunc, regexp) {
111
128
 
@@ -301,7 +318,10 @@ async function ciBuildExt1NodejsConfigure({
301
318
  "-Wno-all",
302
319
  "-Wno-extra",
303
320
  "-Wno-implicit-fallthrough",
321
+ "-Wno-incompatible-pointer-types",
304
322
  "-Wno-int-conversion",
323
+ "-Wno-unreachable-code",
324
+ "-Wno-unused-function",
305
325
  "-Wno-unused-parameter"
306
326
  ];
307
327
  consoleError(`ciBuildExt1Nodejs - configure binding.gyp`);
@@ -311,16 +331,6 @@ async function ciBuildExt1NodejsConfigure({
311
331
  "-Wextra",
312
332
  "-std=c11"
313
333
  ],
314
- "conditions": [
315
- [
316
- "OS == 'win'",
317
- {
318
- "defines": [
319
- "WIN32"
320
- ]
321
- }
322
- ]
323
- ],
324
334
  // https://github.com/nodejs/node-gyp/blob/v9.3.1/gyp/pylib/gyp/MSVSSettings.py
325
335
  "msvs_settings": {
326
336
  "VCCLCompilerTool": {
@@ -626,64 +636,65 @@ async function dbCloseAsync(db) {
626
636
  }));
627
637
  }
628
638
 
629
- async function dbExecAndReturnFirstRow({
639
+ function dbExecAndReturnLastBlob({
630
640
  bindList = [],
631
641
  db,
632
642
  sql
633
643
  }) {
634
644
 
635
645
  // This function will exec <sql> in <db>,
636
- // and return first-row or empty-object.
637
-
638
- return (
639
- noop(
640
- noop(
641
- await dbExecAsync({
642
- bindList,
643
- db,
644
- sql
645
- })
646
- )[0]
647
- || []
648
- )[0]
649
- || {}
650
- );
646
+ // and return last-value retrieved from execution as raw blob/buffer.
647
+
648
+ return dbExecAsync({
649
+ bindList,
650
+ db,
651
+ responseType: "lastblob",
652
+ sql
653
+ });
651
654
  }
652
655
 
653
- async function dbExecAndReturnFirstTable({
656
+ async function dbExecAndReturnLastRow({
654
657
  bindList = [],
655
658
  db,
656
659
  sql
657
660
  }) {
658
661
 
659
662
  // This function will exec <sql> in <db>,
660
- // and return first-table or empty-list.
663
+ // and return last-row or empty-object.
661
664
 
662
- return (
663
- noop(
664
- await dbExecAsync({
665
- bindList,
666
- db,
667
- sql
668
- })
669
- )[0]
670
- || []
671
- );
665
+ let result = await dbExecAsync({bindList, db, sql});
666
+ result = result[result.length - 1] || [];
667
+ result = result[result.length - 1] || {};
668
+ return result;
672
669
  }
673
670
 
674
- function dbExecAndReturnLastBlobAsync({
671
+ async function dbExecAndReturnLastTable({
675
672
  bindList = [],
676
673
  db,
677
674
  sql
678
675
  }) {
679
676
 
680
677
  // This function will exec <sql> in <db>,
681
- // and return last-value retrieved from execution as raw blob/buffer.
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.
682
693
 
683
694
  return dbExecAsync({
684
695
  bindList,
685
696
  db,
686
- responseType: "lastblob",
697
+ responseType: "lastvalue",
687
698
  sql
688
699
  });
689
700
  }
@@ -743,6 +754,8 @@ async function dbExecAsync({
743
754
  (
744
755
  responseType === "lastblob"
745
756
  ? SQLITE_RESPONSETYPE_LASTBLOB
757
+ : responseType === "lastvalue"
758
+ ? SQLITE_RESPONSETYPE_LASTVALUE
746
759
  : 0
747
760
  )
748
761
  ],
@@ -762,6 +775,7 @@ async function dbExecAsync({
762
775
  case "arraybuffer":
763
776
  case "lastblob":
764
777
  return result;
778
+ case "lastvalue":
765
779
  case "list":
766
780
  return jsonParseArraybuffer(result);
767
781
  default:
@@ -879,6 +893,7 @@ async function dbOpenAsync({
879
893
  // );
880
894
  let connPool;
881
895
  let db = {busy: 0, filename, ii: 0};
896
+ let fileLgbm;
882
897
  assertOrThrow(typeof filename === "string", `invalid filename ${filename}`);
883
898
  assertOrThrow(
884
899
  !dbData || isExternalBuffer(dbData),
@@ -909,11 +924,25 @@ async function dbOpenAsync({
909
924
  return ptr;
910
925
  }));
911
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
+ }
912
939
  return db;
913
940
  }
914
941
 
915
942
  async function dbTableImportAsync({
916
943
  db,
944
+ filename,
945
+ headerMissing,
917
946
  mode,
918
947
  tableName,
919
948
  textData
@@ -923,6 +952,9 @@ async function dbTableImportAsync({
923
952
  let rowList;
924
953
  let rowidList;
925
954
  let tmp;
955
+ if (filename) {
956
+ textData = await moduleFs.promises.readFile(filename, "utf8");
957
+ }
926
958
  switch (mode) {
927
959
  case "csv":
928
960
  rowList = jsonRowListFromCsv({
@@ -952,6 +984,12 @@ async function dbTableImportAsync({
952
984
  return val;
953
985
  });
954
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
+ }
955
993
  // normalize rowList[ii] to list
956
994
  if (rowList.length === 0) {
957
995
  rowList.push([
@@ -1338,9 +1376,12 @@ function jsonParseArraybuffer(buf) {
1338
1376
  // This function will JSON.parse arraybuffer <buf>.
1339
1377
 
1340
1378
  return JSON.parse(
1341
- IS_BROWSER
1342
- ? new TextDecoder().decode(buf)
1343
- : buf
1379
+ (
1380
+ IS_BROWSER
1381
+ ? new TextDecoder().decode(buf)
1382
+ : buf
1383
+ )
1384
+ || "null"
1344
1385
  );
1345
1386
  }
1346
1387
 
@@ -1710,6 +1751,18 @@ await sqlmathInit();
1710
1751
  sqlmathInit(); // coverage-hack
1711
1752
 
1712
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,
1713
1766
  SQLITE_OPEN_AUTOPROXY,
1714
1767
  SQLITE_OPEN_CREATE,
1715
1768
  SQLITE_OPEN_DELETEONCLOSE,
@@ -1739,9 +1792,10 @@ export {
1739
1792
  childProcessSpawn2,
1740
1793
  ciBuildExt,
1741
1794
  dbCloseAsync,
1742
- dbExecAndReturnFirstRow,
1743
- dbExecAndReturnFirstTable,
1744
- dbExecAndReturnLastBlobAsync,
1795
+ dbExecAndReturnLastBlob,
1796
+ dbExecAndReturnLastRow,
1797
+ dbExecAndReturnLastTable,
1798
+ dbExecAndReturnLastValue,
1745
1799
  dbExecAsync,
1746
1800
  dbFileLoadAsync,
1747
1801
  dbFileSaveAsync,