@ladybugdb/core-darwin-x64 0.23.0-dev.20261105 → 0.23.0-dev.20261123

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
@@ -47,6 +47,8 @@ The database was formerly known as [Kuzu](https://github.com/kuzudb/kuzu).
47
47
  | Go | `go get github.com/LadybugDB/go-ladybug` |
48
48
  | Swift | [lbug-swift](https://github.com/LadybugDB/swift-ladybug) |
49
49
  | Java | [Maven Central](https://central.sonatype.com/artifact/com.ladybugdb/lbug) |
50
+ | .NET | [NuGet](https://www.nuget.org/packages/LadybugDB) |
51
+ | Lean4 | [Reservoir](https://reservoir.lean-lang.org/@Volland/ladybug) |
50
52
  | C/C++ | [precompiled binaries](https://github.com/LadybugDB/ladybug/releases/latest) |
51
53
  | CLI | [precompiled binaries](https://github.com/LadybugDB/ladybug/releases/latest) |
52
54
 
package/connection.js CHANGED
@@ -27,6 +27,7 @@ class Connection {
27
27
  this._isInitialized = false;
28
28
  this._initPromise = null;
29
29
  this._isClosed = false;
30
+ this._trackingRef = database._trackConnection(this);
30
31
  numThreads = parseInt(numThreads);
31
32
  if (numThreads && numThreads > 0) {
32
33
  this._numThreads = numThreads;
@@ -611,6 +612,7 @@ class Connection {
611
612
  this._isInitialized = true;
612
613
  this._isClosed = true;
613
614
  delete this._connection;
615
+ this._database._untrackConnection(this._trackingRef);
614
616
  return;
615
617
  }
616
618
  }
@@ -618,6 +620,7 @@ class Connection {
618
620
  this._connection.close();
619
621
  delete this._connection;
620
622
  this._isClosed = true;
623
+ this._database._untrackConnection(this._trackingRef);
621
624
  }
622
625
 
623
626
  /**
@@ -635,11 +638,13 @@ class Connection {
635
638
  this._isInitialized = true;
636
639
  this._isClosed = true;
637
640
  delete this._connection;
641
+ this._database._untrackConnection(this._trackingRef);
638
642
  return;
639
643
  }
640
644
  this._connection.close();
641
645
  delete this._connection;
642
646
  this._isClosed = true;
647
+ this._database._untrackConnection(this._trackingRef);
643
648
  }
644
649
  }
645
650
 
package/database.js CHANGED
@@ -11,34 +11,39 @@ class Database {
11
11
  *
12
12
  * @param {String} databasePath path to the database file. If the path is not specified, or empty, or equal to
13
13
  `:memory:`, the database will be created in memory.
14
- * @param {Number} bufferManagerSize size of the buffer manager in bytes.
15
- * @param {Boolean} enableCompression whether to enable compression.
16
- * @param {Boolean} readOnly if true, database will be opened in read-only mode.
17
- * @param {Number} maxDBSize maximum size of the database file in bytes. Note that
14
+ * @param {Number|null} bufferManagerSize size of the buffer manager in bytes. Null (default) uses the engine default.
15
+ * @param {Boolean|null} enableCompression whether to enable compression. Null (default) uses the engine default.
16
+ * @param {Boolean|null} readOnly if true, database will be opened in read-only mode. Null (default) uses the engine default.
17
+ * @param {Number|null} maxDBSize maximum size of the database file in bytes. Note that
18
18
  * this is introduced temporarily for now to get around with the default 8TB mmap
19
- * address space limit some environment.
20
- * @param {Boolean} autoCheckpoint If true, the database will automatically checkpoint when the size of
21
- * the WAL file exceeds the checkpoint threshold.
22
- * @param {Number} checkpointThreshold The threshold of the WAL file size in bytes. When the size of the
19
+ * address space limit some environment. Null (default) uses the engine default.
20
+ * @param {Boolean|null} autoCheckpoint If true, the database will automatically checkpoint when the size of
21
+ * the WAL file exceeds the checkpoint threshold. Null (default) uses the engine default.
22
+ * @param {Number|null} checkpointThreshold The threshold of the WAL file size in bytes. When the size of the
23
23
  * WAL file exceeds this threshold, the database will checkpoint if autoCheckpoint is true.
24
- * @param {Boolean} throwOnWalReplayFailure If true, any WAL replaying failure when loading the database
24
+ * Null (default) uses the engine default.
25
+ * @param {Boolean|null} throwOnWalReplayFailure If true, any WAL replaying failure when loading the database
25
26
  * will throw an error. Otherwise, Lbug will silently ignore the failure and replay up to where
26
- * the error occured.
27
- * @param {Boolean} enableChecksums If true, the database will use checksums to detect corruption in the
28
- * WAL file.
29
- * @param {Boolean} enableDefaultHashIndex If true, node tables create the default primary-key hash index.
27
+ * the error occured. Null (default) uses the engine default.
28
+ * @param {Boolean|null} enableChecksums If true, the database will use checksums to detect corruption in the
29
+ * WAL file. Null (default) uses the engine default.
30
+ * @param {Boolean|null} enableDefaultHashIndex If true, node tables create the default primary-key hash index.
31
+ * Null (default) uses the engine default.
32
+ *
33
+ * Any setting left as null/undefined is not forwarded, so the engine default applies and
34
+ * engine-side default changes propagate automatically.
30
35
  */
31
36
  constructor(
32
37
  databasePath,
33
- bufferManagerSize = 0,
34
- enableCompression = true,
35
- readOnly = false,
36
- maxDBSize = 0,
37
- autoCheckpoint = true,
38
- checkpointThreshold = -1,
39
- throwOnWalReplayFailure = true,
40
- enableChecksums = true,
41
- enableDefaultHashIndex = true,
38
+ bufferManagerSize = null,
39
+ enableCompression = null,
40
+ readOnly = null,
41
+ maxDBSize = null,
42
+ autoCheckpoint = null,
43
+ checkpointThreshold = null,
44
+ throwOnWalReplayFailure = null,
45
+ enableChecksums = null,
46
+ enableDefaultHashIndex = null,
42
47
  ) {
43
48
  if (!databasePath) {
44
49
  databasePath = ":memory:";
@@ -46,18 +51,26 @@ class Database {
46
51
  else if (typeof databasePath !== "string") {
47
52
  throw new Error("Database path must be a string.");
48
53
  }
49
- if (typeof bufferManagerSize !== "number" || bufferManagerSize < 0) {
54
+ if (bufferManagerSize != null && (typeof bufferManagerSize !== "number" || bufferManagerSize < 0)) {
50
55
  throw new Error("Buffer manager size must be a positive integer.");
51
56
  }
52
- if (typeof maxDBSize !== "number" || maxDBSize < 0) {
57
+ if (maxDBSize != null && (typeof maxDBSize !== "number" || maxDBSize < 0)) {
53
58
  throw new Error("Max DB size must be a positive integer.");
54
59
  }
55
- if (typeof checkpointThreshold !== "number" || maxDBSize < -1) {
60
+ // Note: negative explicit values (e.g. the historical -1 default) are accepted here and
61
+ // ignored by the native layer, which keeps the engine default for them.
62
+ if (checkpointThreshold != null && typeof checkpointThreshold !== "number") {
56
63
  throw new Error("Checkpoint threshold must be a positive integer.");
57
64
  }
58
- bufferManagerSize = Math.floor(bufferManagerSize);
59
- maxDBSize = Math.floor(maxDBSize);
60
- checkpointThreshold = Math.floor(checkpointThreshold);
65
+ if (bufferManagerSize != null) {
66
+ bufferManagerSize = Math.floor(bufferManagerSize);
67
+ }
68
+ if (maxDBSize != null) {
69
+ maxDBSize = Math.floor(maxDBSize);
70
+ }
71
+ if (checkpointThreshold != null) {
72
+ checkpointThreshold = Math.floor(checkpointThreshold);
73
+ }
61
74
  this._database = new LbugNative.NodeDatabase(
62
75
  databasePath,
63
76
  bufferManagerSize,
@@ -73,6 +86,34 @@ class Database {
73
86
  this._isInitialized = false;
74
87
  this._initPromise = null;
75
88
  this._isClosed = false;
89
+ // Connections opened on this database, so that close() can close them.
90
+ // They are held weakly: a connection that goes out of scope must still be
91
+ // garbage-collected.
92
+ this._openConnections = new Set();
93
+ this._connectionFinalizer = new FinalizationRegistry((ref) => {
94
+ this._openConnections.delete(ref);
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Internal function to track an open connection.
100
+ * @param {lbug.Connection} connection the connection.
101
+ * @returns {WeakRef} the handle to pass to `_untrackConnection`.
102
+ */
103
+ _trackConnection(connection) {
104
+ const ref = new WeakRef(connection);
105
+ this._openConnections.add(ref);
106
+ this._connectionFinalizer.register(connection, ref, ref);
107
+ return ref;
108
+ }
109
+
110
+ /**
111
+ * Internal function to stop tracking a closed connection.
112
+ * @param {WeakRef} ref the handle returned by `_trackConnection`.
113
+ */
114
+ _untrackConnection(ref) {
115
+ this._openConnections.delete(ref);
116
+ this._connectionFinalizer.unregister(ref);
76
117
  }
77
118
 
78
119
  /**
@@ -163,7 +204,8 @@ class Database {
163
204
  }
164
205
 
165
206
  /**
166
- * Close the database.
207
+ * Close the database. Connections and query results that are still open
208
+ * are closed with it, so the database is released when this returns.
167
209
  */
168
210
  async close() {
169
211
  if (this._isClosed) {
@@ -182,13 +224,17 @@ class Database {
182
224
  }
183
225
  }
184
226
  // Database is initialized, close it.
227
+ for (const ref of [...this._openConnections]) {
228
+ await ref.deref()?.close();
229
+ }
185
230
  this._database.close();
186
231
  delete this._database;
187
232
  this._isClosed = true;
188
233
  }
189
234
 
190
235
  /**
191
- * Close the database synchronously.
236
+ * Close the database synchronously. Connections and query results that are
237
+ * still open are closed with it.
192
238
  * @throws {Error} if there is an ongoing asynchronous initialization.
193
239
  */
194
240
  closeSync() {
@@ -205,6 +251,9 @@ class Database {
205
251
  return;
206
252
  }
207
253
  }
254
+ for (const ref of [...this._openConnections]) {
255
+ ref.deref()?.closeSync();
256
+ }
208
257
  this._database.close();
209
258
  delete this._database;
210
259
  this._isClosed = true;
package/lbug.d.ts CHANGED
@@ -104,21 +104,24 @@ export type LbugValue =
104
104
 
105
105
  /**
106
106
  * Configuration options for the database system.
107
+ *
108
+ * Any option left undefined uses the engine default; explicitly set options
109
+ * override the engine configuration.
107
110
  */
108
111
  export interface SystemConfig {
109
- /** Size of the buffer pool in bytes */
112
+ /** Size of the buffer pool in bytes (engine default if omitted) */
110
113
  bufferPoolSize?: number;
111
- /** Whether to enable compression */
114
+ /** Whether to enable compression (engine default if omitted) */
112
115
  enableCompression?: boolean;
113
- /** Whether to open the database in read-only mode */
116
+ /** Whether to open the database in read-only mode (engine default if omitted) */
114
117
  readOnly?: boolean;
115
- /** Maximum size of the database in bytes */
118
+ /** Maximum size of the database in bytes (engine default if omitted) */
116
119
  maxDBSize?: number;
117
- /** Whether to enable automatic checkpoints */
120
+ /** Whether to enable automatic checkpoints (engine default if omitted) */
118
121
  autoCheckpoint?: boolean;
119
- /** Threshold for automatic checkpoints */
122
+ /** Threshold for automatic checkpoints (engine default if omitted) */
120
123
  checkpointThreshold?: number;
121
- /** Whether node tables create the default primary-key hash index */
124
+ /** Whether node tables create the default primary-key hash index (engine default if omitted) */
122
125
  enableDefaultHashIndex?: boolean;
123
126
  }
124
127
 
@@ -132,17 +135,18 @@ export function json(value: string | LbugValue): LbugValue;
132
135
  */
133
136
  export class Database {
134
137
  /**
135
- * Constructs a new Database instance.
138
+ * Constructs a new Database instance. Any setting left undefined/null uses
139
+ * the engine default; explicitly set settings override it.
136
140
  * @param databasePath Path to the database directory (defaults to ":memory:")
137
- * @param bufferManagerSize Size of the buffer manager in bytes
138
- * @param enableCompression Whether to enable compression
139
- * @param readOnly Whether to open in read-only mode
140
- * @param maxDBSize Maximum size of the database in bytes
141
- * @param autoCheckpoint Whether to enable automatic checkpoints
142
- * @param checkpointThreshold Threshold for automatic checkpoints
143
- * @param throwOnWalReplayFailure Whether WAL replay failures should throw
144
- * @param enableChecksums Whether checksum validation is enabled
145
- * @param enableDefaultHashIndex Whether node tables create the default primary-key hash index
141
+ * @param bufferManagerSize Size of the buffer manager in bytes (engine default if omitted)
142
+ * @param enableCompression Whether to enable compression (engine default if omitted)
143
+ * @param readOnly Whether to open in read-only mode (engine default if omitted)
144
+ * @param maxDBSize Maximum size of the database in bytes (engine default if omitted)
145
+ * @param autoCheckpoint Whether to enable automatic checkpoints (engine default if omitted)
146
+ * @param checkpointThreshold Threshold for automatic checkpoints (engine default if omitted)
147
+ * @param throwOnWalReplayFailure Whether WAL replay failures should throw (engine default if omitted)
148
+ * @param enableChecksums Whether checksum validation is enabled (engine default if omitted)
149
+ * @param enableDefaultHashIndex Whether node tables create the default primary-key hash index (engine default if omitted)
146
150
  */
147
151
  constructor(
148
152
  databasePath?: string,
package/lbugjs.node CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ladybugdb/core-darwin-x64",
3
- "version": "0.23.0-dev.20261105",
3
+ "version": "0.23.0-dev.20261123",
4
4
  "description": "An in-process property graph database management system built for query speed and scalability.",
5
5
  "os": [
6
6
  "darwin"