@stoolap/node 0.3.7 → 0.4.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.
package/README.md CHANGED
@@ -127,7 +127,7 @@ import { Database, RunResult } from '@stoolap/node';
127
127
 
128
128
  #### Persistence
129
129
 
130
- File-based databases persist data to disk using WAL (Write-Ahead Logging) and periodic snapshots. Data survives process restarts.
130
+ File-based databases persist data to disk using WAL (Write-Ahead Logging) and an immutable volume-based storage engine. Hot data lives in memory, cold data is sealed into columnar `.vol` files with zone maps, bloom filters, and LZ4 compression. Data survives process restarts.
131
131
 
132
132
  ```js
133
133
  const db = await Database.open('./mydata');
@@ -148,18 +148,18 @@ await db2.close();
148
148
  Pass configuration as query parameters in the path:
149
149
 
150
150
  ```js
151
- // Maximum durability: fsync on every WAL write
152
- const db = await Database.open('./mydata?sync=full');
151
+ // Maximum durability: fsync on every write
152
+ const db = await Database.open('./mydata?sync_mode=full');
153
153
 
154
- // High throughput: no fsync, larger buffers
155
- const db = await Database.open('./mydata?sync=none&wal_buffer_size=131072');
154
+ // High throughput: no fsync, data durable at checkpoint
155
+ const db = await Database.open('./mydata?sync_mode=none');
156
156
 
157
- // Custom snapshot interval with compression
158
- const db = await Database.open('./mydata?snapshot_interval=60&compression=on');
157
+ // Custom checkpoint interval with compression
158
+ const db = await Database.open('./mydata?checkpoint_interval=60&compression=on');
159
159
 
160
160
  // Multiple options
161
161
  const db = await Database.open(
162
- './mydata?sync=full&snapshot_interval=120&keep_snapshots=10&wal_max_size=134217728'
162
+ './mydata?sync_mode=normal&checkpoint_interval=120&compact_threshold=4'
163
163
  );
164
164
  ```
165
165
 
@@ -169,26 +169,22 @@ Controls the durability vs. performance trade-off:
169
169
 
170
170
  | Mode | Value | Description |
171
171
  |------|-------|-------------|
172
- | `none` | `sync=none` | No fsync. Fastest, data may be lost on crash |
173
- | `normal` | `sync=normal` | Fsync on commit batches. Good balance (default) |
174
- | `full` | `sync=full` | Fsync on every WAL write. Slowest, maximum durability |
172
+ | `none` | `sync_mode=none` | No fsync. Data durable only after checkpoint |
173
+ | `normal` | `sync_mode=normal` | Fsync every 1 second (batched). DDL fsyncs immediately (default) |
174
+ | `full` | `sync_mode=full` | Fsync on every write. Maximum durability |
175
175
 
176
176
  ##### All Configuration Parameters
177
177
 
178
178
  | Parameter | Default | Description |
179
179
  |-----------|---------|-------------|
180
- | `sync` | `normal` | Sync mode: `none`, `normal`, or `full` |
181
- | `snapshot_interval` | `300` | Seconds between automatic snapshots (5 min) |
182
- | `keep_snapshots` | `5` | Number of snapshot files to retain |
183
- | `wal_flush_trigger` | `32768` | WAL flush trigger size in bytes (32 KB) |
184
- | `wal_buffer_size` | `65536` | WAL buffer size in bytes (64 KB) |
185
- | `wal_max_size` | `67108864` | Max WAL file size before rotation (64 MB) |
186
- | `commit_batch_size` | `100` | Commits to batch before syncing (normal mode) |
187
- | `sync_interval_ms` | `10` | Minimum ms between syncs (normal mode) |
180
+ | `sync_mode` | `normal` | Sync mode: `none`, `normal`, or `full` |
181
+ | `checkpoint_interval` | `60` | Seconds between checkpoint cycles (seal + compact + WAL truncate) |
182
+ | `compact_threshold` | `4` | Number of cold volumes before compaction merges them |
183
+ | `checkpoint_on_close` | `on` | Seal all hot rows on clean shutdown for fast startup |
188
184
  | `wal_compression` | `on` | LZ4 compression for WAL entries |
189
- | `snapshot_compression` | `on` | LZ4 compression for snapshots |
190
- | `compression` | | Set both `wal_compression` and `snapshot_compression` |
191
- | `compression_threshold` | `64` | Minimum bytes before compressing an entry |
185
+ | `volume_compression` | `on` | LZ4 compression for cold volume files |
186
+ | `compression` | `on` | Shorthand: set both `wal_compression` and `volume_compression` |
187
+ | `keep_snapshots` | `5` | Number of backup snapshot files to retain |
192
188
 
193
189
  #### Cloning
194
190
 
@@ -179,7 +179,12 @@ class Transaction {
179
179
  executeBatchSync(sql, paramsArray) {
180
180
  this.#checkSyncReady();
181
181
  if (paramsArray.length > 0 && Array.isArray(paramsArray[0])) {
182
- return this.#stoolap.txExecBatch(this.#dbPtr, this.#ptr, sql, paramsArray);
182
+ return this.#stoolap.txExecBatch(
183
+ this.#dbPtr,
184
+ this.#ptr,
185
+ sql,
186
+ paramsArray,
187
+ );
183
188
  }
184
189
  let totalChanges = 0;
185
190
  for (const params of paramsArray) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoolap/node",
3
- "version": "0.3.7",
3
+ "version": "0.4.0",
4
4
  "description": "High-performance Node.js driver for Stoolap embedded SQL database",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,11 +18,11 @@
18
18
  "bench": "node benchmark.mjs"
19
19
  },
20
20
  "optionalDependencies": {
21
- "@stoolap/lib-darwin-arm64": "0.3.7",
22
- "@stoolap/lib-darwin-x64": "0.3.7",
23
- "@stoolap/lib-linux-arm64-gnu": "0.3.7",
24
- "@stoolap/lib-linux-x64-gnu": "0.3.7",
25
- "@stoolap/lib-win32-x64-msvc": "0.3.7"
21
+ "@stoolap/lib-darwin-arm64": "0.4.0",
22
+ "@stoolap/lib-darwin-x64": "0.4.0",
23
+ "@stoolap/lib-linux-arm64-gnu": "0.4.0",
24
+ "@stoolap/lib-linux-x64-gnu": "0.4.0",
25
+ "@stoolap/lib-win32-x64-msvc": "0.4.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "better-sqlite3": "^12.6.2",
package/src/stoolap.c CHANGED
@@ -24,6 +24,7 @@
24
24
  typedef HMODULE LibHandle;
25
25
  #else
26
26
  #include <dlfcn.h>
27
+ #include <alloca.h>
27
28
  #define DLOPEN(path) dlopen(path, RTLD_NOW | RTLD_LOCAL)
28
29
  #define DLSYM(lib, name) dlsym(lib, name)
29
30
  #define DLERROR() dlerror()