@harperfast/rocksdb-js 2.3.0 → 2.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/dist/index.d.mts CHANGED
@@ -9,6 +9,10 @@ import { ExtendedIterable } from "@harperfast/extended-iterable";
9
9
  * not scoped to an individual `Store`.
10
10
  */
11
11
  interface BackupOptions {
12
+ /**
13
+ * Include write-ahead log files in the backup. Defaults to `true`.
14
+ */
15
+ backupLogFiles?: boolean;
12
16
  /**
13
17
  * Flush the memtable before backing up. Defaults to `true` when the database
14
18
  * was opened with `disableWAL` (otherwise unflushed data would be lost from
@@ -16,32 +20,47 @@ interface BackupOptions {
16
20
  */
17
21
  flushBeforeBackup?: boolean;
18
22
  /**
23
+ * Number of background threads used to copy files. Defaults to `1`.
24
+ */
25
+ maxBackgroundOperations?: number;
26
+ /**
19
27
  * Arbitrary application metadata stored with the backup and returned by
20
28
  * `backups.list()`.
21
29
  */
22
30
  metadata?: string;
23
31
  /**
24
- * Share table/blob files between backups in the same directory to enable
25
- * incremental backups. Defaults to `true`.
26
- */
27
- shareTableFiles?: boolean;
28
- /**
29
32
  * Distinguish shared files by checksum to avoid collisions across databases.
30
33
  * Defaults to `true`. Only relevant when `shareTableFiles` is enabled.
31
34
  */
32
35
  shareFilesWithChecksum?: boolean;
33
36
  /**
34
- * Include write-ahead log files in the backup. Defaults to `true`.
37
+ * Share table/blob files between backups in the same directory to enable
38
+ * incremental backups. Defaults to `true`.
35
39
  */
36
- backupLogFiles?: boolean;
40
+ shareTableFiles?: boolean;
37
41
  /**
38
- * `fsync` backup files for crash consistency. Defaults to `true`.
42
+ * `fsync` backup files — including the transaction log snapshot when
43
+ * `transactionLogs` is enabled — for crash consistency. Defaults to `true`.
39
44
  */
40
45
  sync?: boolean;
41
46
  /**
42
- * Number of background threads used to copy files. Defaults to `1`.
47
+ * Snapshot the transaction log store into
48
+ * `<backupDir>/transaction_logs/<backupId>/`. Defaults to `false`. This is an
49
+ * all-or-nothing snapshot per backup (not incremental); `backups.delete()` and
50
+ * `backups.purge()` remove the corresponding log snapshots, and
51
+ * `backups.restore()` restores them into the database directory.
52
+ *
53
+ * The snapshot is staged and atomically renamed into place after every file
54
+ * is copied (and fsynced, per `sync`), so a crash mid-backup can never leave
55
+ * a partial snapshot: a backup id either has its complete log snapshot or
56
+ * none at all.
57
+ *
58
+ * The log snapshot is captured just after the RocksDB engine snapshot, so it
59
+ * may include entries committed between the two — the restored logs can run
60
+ * slightly ahead of the restored key-value data, never behind it. That bias
61
+ * is safe for redo-style logs that are replayed against the restored data.
43
62
  */
44
- maxBackgroundOperations?: number;
63
+ transactionLogs?: boolean;
45
64
  }
46
65
  /**
47
66
  * The level of incremental restore to perform.
@@ -165,462 +184,94 @@ type KeyEncoding = "binary" | "ordered-binary" | "uint32";
165
184
  type ReadKeyFunction<T> = (source: BufferWithDataView, start: number, end?: number) => T;
166
185
  type WriteKeyFunction = (key: Key, target: BufferWithDataView, start: number) => number;
167
186
  //#endregion
168
- //#region src/stats.d.ts
169
- /** Database-level RocksDB statistics types for `db.getStats()` / `db.getStat()`. */
170
- type StatsHistogramData = {
171
- average: number;
172
- count: number;
173
- max: number;
174
- median: number;
175
- min: number;
176
- percentile95: number;
177
- percentile99: number;
178
- standardDeviation: number;
179
- sum: number;
187
+ //#region src/dbi-iterator.d.ts
188
+ interface DBIteratorValue<T> {
189
+ key: Key;
190
+ value: T;
191
+ }
192
+ /**
193
+ * Wraps the `NativeIterator` C++ binding, decoding keys and values from the
194
+ * shared key/value buffers (fast path) or from per-iteration buffers (slow
195
+ * fallback path used for oversized data or stable-buffer decoders).
196
+ *
197
+ * The native `next()` returns a primitive signal (and writes lengths to the
198
+ * shared `ITERATOR_STATE` buffer) instead of constructing a JS result object,
199
+ * so this class is responsible for building the `IteratorResult`.
200
+ */
201
+ declare class DBIterator<T> implements Iterator<DBIteratorValue<T>> {
202
+ #private;
203
+ iterator: InstanceType<typeof NativeIteratorCls>;
204
+ store: Store;
205
+ constructor(iterator: InstanceType<typeof NativeIteratorCls>, store: Store, includeValues: boolean, limit?: number);
206
+ [Symbol.iterator](): Iterator<DBIteratorValue<T>>;
207
+ next(): IteratorResult<DBIteratorValue<T>>;
208
+ return(value?: any): IteratorResult<DBIteratorValue<T>, any>;
209
+ throw(err: unknown): IteratorResult<DBIteratorValue<T>, any>;
210
+ }
211
+ //#endregion
212
+ //#region src/store.d.ts
213
+ type StoreContext = NativeDatabase | NativeTransaction;
214
+ type StoreGetOptions = GetOptions & DBITransactional;
215
+ type StoreIteratorOptions = IteratorOptions & DBITransactional;
216
+ type StorePutOptions = PutOptions & DBITransactional;
217
+ type StoreRangeOptions = RangeOptions & DBITransactional;
218
+ type StoreRemoveOptions = DBITransactional | unknown;
219
+ type CompactOptions = {
220
+ start?: Key;
221
+ end?: Key;
180
222
  };
181
- type StatsBasics = {
182
- "rocksdb.num-immutable-mem-table": number;
183
- "rocksdb.num-immutable-mem-table-flushed": number;
184
- "rocksdb.mem-table-flush-pending": number;
185
- "rocksdb.cur-size-active-mem-table": number;
186
- "rocksdb.cur-size-all-mem-tables": number;
187
- "rocksdb.size-all-mem-tables": number;
188
- "rocksdb.num-entries-active-mem-table": number;
189
- "rocksdb.num-deletes-active-mem-table": number;
190
- "rocksdb.compaction-pending": number;
191
- "rocksdb.estimate-pending-compaction-bytes": number;
192
- "rocksdb.num-running-compactions": number;
193
- "rocksdb.num-running-flushes": number;
194
- "rocksdb.total-sst-files-size": number;
195
- "rocksdb.live-sst-files-size": number;
196
- "rocksdb.estimate-live-data-size": number;
197
- "rocksdb.estimate-num-keys": number;
198
- "rocksdb.block-cache-capacity": number;
199
- "rocksdb.block-cache-usage": number;
200
- "rocksdb.block-cache-pinned-usage": number;
201
- "rocksdb.num-live-versions": number;
202
- "rocksdb.current-super-version-number": number;
203
- "rocksdb.oldest-snapshot-time": number;
204
- "rocksdb.num-blob-files": number;
205
- "rocksdb.total-blob-file-size": number;
206
- "rocksdb.live-blob-file-size": number;
207
- "txnlog.logCount": number;
208
- "txnlog.fileCount": number;
209
- "txnlog.totalSizeBytes": number;
210
- "txnlog.mappedBytes": number;
211
- "txnlog.overlayBytes": number;
212
- "txnlog.activeMaps": number;
213
- "txnlog.pendingTransactions": number;
214
- "txnlog.uncommittedTransactions": number;
215
- "txnlog.transactionsWritten": number;
216
- "txnlog.bytesWritten": number;
217
- "txnlog.replayGapBytes": number;
223
+ /**
224
+ * Options for the `Store` class.
225
+ */
226
+ interface StoreOptions extends Omit<NativeDatabaseOptions, "mode" | "transactionLogRetentionMs"> {
227
+ decoder?: Encoder | null;
228
+ encoder?: Encoder | null;
229
+ encoding?: Encoding;
230
+ freezeData?: boolean;
231
+ keyEncoder?: {
232
+ readKey?: ReadKeyFunction<Key>;
233
+ writeKey?: WriteKeyFunction;
234
+ };
235
+ keyEncoding?: KeyEncoding;
236
+ maxKeySize?: number;
237
+ pessimistic?: boolean;
238
+ /**
239
+ * If `true`, the encoder will use a random access structure.
240
+ */
241
+ randomAccessStructure?: boolean;
242
+ /**
243
+ * When `true`, the database is opened in read-only mode. Write operations
244
+ * will throw an error with code `ERR_DATABASE_READONLY`.
245
+ */
246
+ readOnly?: boolean;
247
+ sharedStructuresKey?: symbol;
248
+ /**
249
+ * A string containing the amount of time or the number of milliseconds to
250
+ * retain transaction logs before purging.
251
+ *
252
+ * @default '3d' (3 days)
253
+ */
254
+ transactionLogRetention?: number | string;
255
+ }
256
+ /**
257
+ * Options for the `getUserSharedBuffer()` method.
258
+ */
259
+ type UserSharedBufferOptions = {
260
+ callback?: UserSharedBufferCallback;
218
261
  };
219
- type StatsCuratedExtras = {
220
- "rocksdb.block.cache.hit": number;
221
- "rocksdb.block.cache.miss": number;
222
- "rocksdb.block.cache.data.hit": number;
223
- "rocksdb.block.cache.data.miss": number;
224
- "rocksdb.block.cache.index.hit": number;
225
- "rocksdb.block.cache.index.miss": number;
226
- "rocksdb.block.cache.filter.hit": number;
227
- "rocksdb.block.cache.filter.miss": number;
228
- "rocksdb.bloom.filter.useful": number;
229
- "rocksdb.bloom.filter.full.positive": number;
230
- "rocksdb.bloom.filter.full.true.positive": number;
231
- "rocksdb.db.iter.bytes.read": number;
232
- "rocksdb.number.reseeks.iteration": number;
233
- "rocksdb.number.keys.read": number;
234
- "rocksdb.number.keys.written": number;
235
- "rocksdb.bytes.read": number;
236
- "rocksdb.bytes.written": number;
237
- "rocksdb.memtable.hit": number;
238
- "rocksdb.memtable.miss": number;
239
- "rocksdb.txn.overhead.mutex.prepare": number;
240
- "rocksdb.txn.overhead.mutex.old.commit.map": number;
241
- "rocksdb.txn.overhead.mutex.snapshot": number;
242
- "rocksdb.compact.read.bytes": number;
243
- "rocksdb.compact.write.bytes": number;
244
- "rocksdb.compaction.cancelled": number;
245
- "rocksdb.stall.micros": number;
246
- "rocksdb.no.file.errors": number;
247
- "rocksdb.read.amp.estimate.useful.bytes": number;
248
- "rocksdb.read.amp.total.read.bytes": number;
249
- "rocksdb.db.get.micros": StatsHistogramData;
250
- "rocksdb.db.write.micros": StatsHistogramData;
251
- "rocksdb.db.seek.micros": StatsHistogramData;
252
- "rocksdb.db.flush.micros": StatsHistogramData;
253
- "rocksdb.db.write.stall": StatsHistogramData;
254
- "rocksdb.blobdb.value.size": StatsHistogramData;
255
- "rocksdb.sst.read.micros": StatsHistogramData;
256
- "rocksdb.compaction.times.micros": StatsHistogramData;
262
+ /**
263
+ * The return type of `getUserSharedBuffer()`.
264
+ */
265
+ type ArrayBufferWithNotify = ArrayBuffer & {
266
+ cancel: () => void;
267
+ notify: () => void;
257
268
  };
258
- type StatsAllExtras = {
259
- "rocksdb.block.cache.add": number;
260
- "rocksdb.block.cache.add.failures": number;
261
- "rocksdb.block.cache.index.add": number;
262
- "rocksdb.block.cache.index.bytes.insert": number;
263
- "rocksdb.block.cache.filter.add": number;
264
- "rocksdb.block.cache.filter.bytes.insert": number;
265
- "rocksdb.block.cache.data.add": number;
266
- "rocksdb.block.cache.data.bytes.insert": number;
267
- "rocksdb.block.cache.bytes.read": number;
268
- "rocksdb.block.cache.bytes.write": number;
269
- "rocksdb.block.cache.compression.dict.miss": number;
270
- "rocksdb.block.cache.compression.dict.hit": number;
271
- "rocksdb.block.cache.compression.dict.add": number;
272
- "rocksdb.block.cache.compression.dict.bytes.insert": number;
273
- "rocksdb.block.cache.add.redundant": number;
274
- "rocksdb.block.cache.index.add.redundant": number;
275
- "rocksdb.block.cache.filter.add.redundant": number;
276
- "rocksdb.block.cache.data.add.redundant": number;
277
- "rocksdb.block.cache.compression.dict.add.redundant": number;
278
- "rocksdb.secondary.cache.hits": number;
279
- "rocksdb.secondary.cache.filter.hits": number;
280
- "rocksdb.secondary.cache.index.hits": number;
281
- "rocksdb.secondary.cache.data.hits": number;
282
- "rocksdb.compressed.secondary.cache.dummy.hits": number;
283
- "rocksdb.compressed.secondary.cache.hits": number;
284
- "rocksdb.compressed.secondary.cache.promotions": number;
285
- "rocksdb.compressed.secondary.cache.promotion.skips": number;
286
- "rocksdb.bloom.filter.prefix.checked": number;
287
- "rocksdb.bloom.filter.prefix.useful": number;
288
- "rocksdb.bloom.filter.prefix.true.positive": number;
289
- "rocksdb.persistent.cache.hit": number;
290
- "rocksdb.persistent.cache.miss": number;
291
- "rocksdb.sim.block.cache.hit": number;
292
- "rocksdb.sim.block.cache.miss": number;
293
- "rocksdb.l0.hit": number;
294
- "rocksdb.l1.hit": number;
295
- "rocksdb.l2andup.hit": number;
296
- "rocksdb.compaction.key.drop.new": number;
297
- "rocksdb.compaction.key.drop.obsolete": number;
298
- "rocksdb.compaction.key.drop.range_del": number;
299
- "rocksdb.compaction.key.drop.user": number;
300
- "rocksdb.compaction.range_del.drop.obsolete": number;
301
- "rocksdb.compaction.optimized.del.drop.obsolete": number;
302
- "rocksdb.compaction.aborted": number;
303
- "rocksdb.number.keys.updated": number;
304
- "rocksdb.number.db.seek": number;
305
- "rocksdb.number.db.next": number;
306
- "rocksdb.number.db.prev": number;
307
- "rocksdb.number.db.seek.found": number;
308
- "rocksdb.number.db.next.found": number;
309
- "rocksdb.number.db.prev.found": number;
310
- "rocksdb.number.iter.skip": number;
311
- "rocksdb.num.iterator.created": number;
312
- "rocksdb.num.iterator.deleted": number;
313
- "rocksdb.no.file.opens": number;
314
- "rocksdb.db.mutex.wait.micros": number;
315
- "rocksdb.number.multiget.get": number;
316
- "rocksdb.number.multiget.keys.read": number;
317
- "rocksdb.number.multiget.bytes.read": number;
318
- "rocksdb.number.multiget.keys.found": number;
319
- "rocksdb.number.merge.failures": number;
320
- "rocksdb.getupdatessince.calls": number;
321
- "rocksdb.wal.synced": number;
322
- "rocksdb.wal.bytes": number;
323
- "rocksdb.write.self": number;
324
- "rocksdb.write.other": number;
325
- "rocksdb.write.wal": number;
326
- "rocksdb.flush.write.bytes": number;
327
- "rocksdb.compact.read.marked.bytes": number;
328
- "rocksdb.compact.read.periodic.bytes": number;
329
- "rocksdb.compact.read.ttl.bytes": number;
330
- "rocksdb.compact.write.marked.bytes": number;
331
- "rocksdb.compact.write.periodic.bytes": number;
332
- "rocksdb.compact.write.ttl.bytes": number;
333
- "rocksdb.number.direct.load.table.properties": number;
334
- "rocksdb.number.superversion_acquires": number;
335
- "rocksdb.number.superversion_releases": number;
336
- "rocksdb.number.superversion_cleanups": number;
337
- "rocksdb.number.block.compressed": number;
338
- "rocksdb.number.block.decompressed": number;
339
- "rocksdb.bytes.compressed.from": number;
340
- "rocksdb.bytes.compressed.to": number;
341
- "rocksdb.bytes.compression_bypassed": number;
342
- "rocksdb.bytes.compression.rejected": number;
343
- "rocksdb.number.block_compression_bypassed": number;
344
- "rocksdb.number.block_compression_rejected": number;
345
- "rocksdb.bytes.decompressed.from": number;
346
- "rocksdb.bytes.decompressed.to": number;
347
- "rocksdb.merge.operation.time.nanos": number;
348
- "rocksdb.filter.operation.time.nanos": number;
349
- "rocksdb.compaction.total.time.cpu_micros": number;
350
- "rocksdb.row.cache.hit": number;
351
- "rocksdb.row.cache.miss": number;
352
- "rocksdb.number.rate_limiter.drains": number;
353
- "rocksdb.blobdb.num.put": number;
354
- "rocksdb.blobdb.num.write": number;
355
- "rocksdb.blobdb.num.get": number;
356
- "rocksdb.blobdb.num.multiget": number;
357
- "rocksdb.blobdb.num.seek": number;
358
- "rocksdb.blobdb.num.next": number;
359
- "rocksdb.blobdb.num.prev": number;
360
- "rocksdb.blobdb.num.keys.written": number;
361
- "rocksdb.blobdb.num.keys.read": number;
362
- "rocksdb.blobdb.bytes.written": number;
363
- "rocksdb.blobdb.bytes.read": number;
364
- "rocksdb.blobdb.write.inlined": number;
365
- "rocksdb.blobdb.write.inlined.ttl": number;
366
- "rocksdb.blobdb.write.blob": number;
367
- "rocksdb.blobdb.write.blob.ttl": number;
368
- "rocksdb.blobdb.blob.file.bytes.written": number;
369
- "rocksdb.blobdb.blob.file.bytes.read": number;
370
- "rocksdb.blobdb.blob.file.synced": number;
371
- "rocksdb.blobdb.blob.index.expired.count": number;
372
- "rocksdb.blobdb.blob.index.expired.size": number;
373
- "rocksdb.blobdb.blob.index.evicted.count": number;
374
- "rocksdb.blobdb.blob.index.evicted.size": number;
375
- "rocksdb.blobdb.gc.num.files": number;
376
- "rocksdb.blobdb.gc.num.new.files": number;
377
- "rocksdb.blobdb.gc.failures": number;
378
- "rocksdb.blobdb.gc.num.keys.relocated": number;
379
- "rocksdb.blobdb.gc.bytes.relocated": number;
380
- "rocksdb.blobdb.fifo.num.files.evicted": number;
381
- "rocksdb.blobdb.fifo.num.keys.evicted": number;
382
- "rocksdb.blobdb.fifo.bytes.evicted": number;
383
- "rocksdb.blobdb.cache.miss": number;
384
- "rocksdb.blobdb.cache.hit": number;
385
- "rocksdb.blobdb.cache.add": number;
386
- "rocksdb.blobdb.cache.add.failures": number;
387
- "rocksdb.blobdb.cache.bytes.read": number;
388
- "rocksdb.blobdb.cache.bytes.write": number;
389
- "rocksdb.txn.overhead.duplicate.key": number;
390
- "rocksdb.txn.get.tryagain": number;
391
- "rocksdb.files.marked.trash": number;
392
- "rocksdb.files.marked.trash.deleted": number;
393
- "rocksdb.files.deleted.immediately": number;
394
- "rocksdb.error.handler.bg.error.count": number;
395
- "rocksdb.error.handler.bg.io.error.count": number;
396
- "rocksdb.error.handler.bg.retryable.io.error.count": number;
397
- "rocksdb.error.handler.autoresume.count": number;
398
- "rocksdb.error.handler.autoresume.retry.total.count": number;
399
- "rocksdb.error.handler.autoresume.success.count": number;
400
- "rocksdb.memtable.payload.bytes.at.flush": number;
401
- "rocksdb.memtable.garbage.bytes.at.flush": number;
402
- "rocksdb.verify_checksum.read.bytes": number;
403
- "rocksdb.backup.read.bytes": number;
404
- "rocksdb.backup.write.bytes": number;
405
- "rocksdb.remote.compact.read.bytes": number;
406
- "rocksdb.remote.compact.write.bytes": number;
407
- "rocksdb.remote.compact.resumed.bytes": number;
408
- "rocksdb.hot.file.read.bytes": number;
409
- "rocksdb.warm.file.read.bytes": number;
410
- "rocksdb.cool.file.read.bytes": number;
411
- "rocksdb.cold.file.read.bytes": number;
412
- "rocksdb.ice.file.read.bytes": number;
413
- "rocksdb.hot.file.read.count": number;
414
- "rocksdb.warm.file.read.count": number;
415
- "rocksdb.cool.file.read.count": number;
416
- "rocksdb.cold.file.read.count": number;
417
- "rocksdb.ice.file.read.count": number;
418
- "rocksdb.last.level.read.bytes": number;
419
- "rocksdb.last.level.read.count": number;
420
- "rocksdb.non.last.level.read.bytes": number;
421
- "rocksdb.non.last.level.read.count": number;
422
- "rocksdb.last.level.seek.filtered": number;
423
- "rocksdb.last.level.seek.filter.match": number;
424
- "rocksdb.last.level.seek.data": number;
425
- "rocksdb.last.level.seek.data.useful.no.filter": number;
426
- "rocksdb.last.level.seek.data.useful.filter.match": number;
427
- "rocksdb.non.last.level.seek.filtered": number;
428
- "rocksdb.non.last.level.seek.filter.match": number;
429
- "rocksdb.non.last.level.seek.data": number;
430
- "rocksdb.non.last.level.seek.data.useful.no.filter": number;
431
- "rocksdb.non.last.level.seek.data.useful.filter.match": number;
432
- "rocksdb.block.checksum.compute.count": number;
433
- "rocksdb.block.checksum.mismatch.count": number;
434
- "rocksdb.multiget.coroutine.count": number;
435
- "rocksdb.read.async.micros": number;
436
- "rocksdb.async.read.error.count": number;
437
- "rocksdb.table.open.prefetch.tail.miss": number;
438
- "rocksdb.table.open.prefetch.tail.hit": number;
439
- "rocksdb.timestamp.filter.table.checked": number;
440
- "rocksdb.timestamp.filter.table.filtered": number;
441
- "rocksdb.readahead.trimmed": number;
442
- "rocksdb.fifo.max.size.compactions": number;
443
- "rocksdb.fifo.ttl.compactions": number;
444
- "rocksdb.fifo.change_temperature.compactions": number;
445
- "rocksdb.prefetch.bytes": number;
446
- "rocksdb.prefetch.bytes.useful": number;
447
- "rocksdb.prefetch.hits": number;
448
- "rocksdb.footer.corruption.count": number;
449
- "rocksdb.file.read.corruption.retry.count": number;
450
- "rocksdb.file.read.corruption.retry.success.count": number;
451
- "rocksdb.number.wbwi.ingest": number;
452
- "rocksdb.sst.user.defined.index.load.fail.count": number;
453
- "rocksdb.multiscan.prepare.calls": number;
454
- "rocksdb.multiscan.prepare.errors": number;
455
- "rocksdb.multiscan.blocks.prefetched": number;
456
- "rocksdb.multiscan.blocks.from.cache": number;
457
- "rocksdb.multiscan.prefetch.bytes": number;
458
- "rocksdb.multiscan.prefetch.blocks.wasted": number;
459
- "rocksdb.multiscan.io.requests": number;
460
- "rocksdb.multiscan.io.coalesced.nonadjacent": number;
461
- "rocksdb.multiscan.seek.errors": number;
462
- "rocksdb.prefetch.memory.bytes.granted": number;
463
- "rocksdb.prefetch.memory.bytes.released": number;
464
- "rocksdb.prefetch.memory.requests.blocked": number;
465
- "rocksdb.compaction.times.cpu_micros": StatsHistogramData;
466
- "rocksdb.subcompaction.setup.times.micros": StatsHistogramData;
467
- "rocksdb.table.sync.micros": StatsHistogramData;
468
- "rocksdb.compaction.outfile.sync.micros": StatsHistogramData;
469
- "rocksdb.wal.file.sync.micros": StatsHistogramData;
470
- "rocksdb.manifest.file.sync.micros": StatsHistogramData;
471
- "rocksdb.table.open.io.micros": StatsHistogramData;
472
- "rocksdb.db.multiget.micros": StatsHistogramData;
473
- "rocksdb.read.block.compaction.micros": StatsHistogramData;
474
- "rocksdb.read.block.get.micros": StatsHistogramData;
475
- "rocksdb.write.raw.block.micros": StatsHistogramData;
476
- "rocksdb.numfiles.in.singlecompaction": StatsHistogramData;
477
- "rocksdb.file.read.flush.micros": StatsHistogramData;
478
- "rocksdb.file.read.compaction.micros": StatsHistogramData;
479
- "rocksdb.file.read.db.open.micros": StatsHistogramData;
480
- "rocksdb.file.read.get.micros": StatsHistogramData;
481
- "rocksdb.file.read.multiget.micros": StatsHistogramData;
482
- "rocksdb.file.read.db.iterator.micros": StatsHistogramData;
483
- "rocksdb.file.read.verify.db.checksum.micros": StatsHistogramData;
484
- "rocksdb.file.read.verify.file.checksums.micros": StatsHistogramData;
485
- "rocksdb.sst.write.micros": StatsHistogramData;
486
- "rocksdb.file.write.flush.micros": StatsHistogramData;
487
- "rocksdb.file.write.compaction.micros": StatsHistogramData;
488
- "rocksdb.file.write.db.open.micros": StatsHistogramData;
489
- "rocksdb.num.subcompactions.scheduled": StatsHistogramData;
490
- "rocksdb.bytes.per.read": StatsHistogramData;
491
- "rocksdb.bytes.per.write": StatsHistogramData;
492
- "rocksdb.bytes.per.multiget": StatsHistogramData;
493
- "rocksdb.compression.times.nanos": StatsHistogramData;
494
- "rocksdb.decompression.times.nanos": StatsHistogramData;
495
- "rocksdb.read.num.merge_operands": StatsHistogramData;
496
- "rocksdb.blobdb.key.size": StatsHistogramData;
497
- "rocksdb.blobdb.write.micros": StatsHistogramData;
498
- "rocksdb.blobdb.get.micros": StatsHistogramData;
499
- "rocksdb.blobdb.multiget.micros": StatsHistogramData;
500
- "rocksdb.blobdb.seek.micros": StatsHistogramData;
501
- "rocksdb.blobdb.next.micros": StatsHistogramData;
502
- "rocksdb.blobdb.prev.micros": StatsHistogramData;
503
- "rocksdb.blobdb.blob.file.write.micros": StatsHistogramData;
504
- "rocksdb.blobdb.blob.file.read.micros": StatsHistogramData;
505
- "rocksdb.blobdb.blob.file.sync.micros": StatsHistogramData;
506
- "rocksdb.blobdb.compression.micros": StatsHistogramData;
507
- "rocksdb.blobdb.decompression.micros": StatsHistogramData;
508
- "rocksdb.sst.batch.size": StatsHistogramData;
509
- "rocksdb.multiget.io.batch.size": StatsHistogramData;
510
- "rocksdb.num.index.and.filter.blocks.read.per.level": StatsHistogramData;
511
- "rocksdb.num.sst.read.per.level": StatsHistogramData;
512
- "rocksdb.num.level.read.per.multiget": StatsHistogramData;
513
- "rocksdb.error.handler.autoresume.retry.count": StatsHistogramData;
514
- "rocksdb.async.read.bytes": StatsHistogramData;
515
- "rocksdb.poll.wait.micros": StatsHistogramData;
516
- "rocksdb.compaction.prefetch.bytes": StatsHistogramData;
517
- "rocksdb.prefetched.bytes.discarded": StatsHistogramData;
518
- "rocksdb.async.prefetch.abort.micros": StatsHistogramData;
519
- "rocksdb.table.open.prefetch.tail.read.bytes": StatsHistogramData;
520
- "rocksdb.num.op.per.transaction": StatsHistogramData;
521
- "rocksdb.multiscan.op.prepare.iterators.micros": StatsHistogramData;
522
- "rocksdb.multiscan.prepare.micros": StatsHistogramData;
523
- "rocksdb.multiscan.blocks.per.prepare": StatsHistogramData;
524
- "rocksdb.block.key.distribution.cv": StatsHistogramData;
525
- };
526
- type StatsCurated = StatsBasics & StatsCuratedExtras;
527
- type StatsAll = StatsCurated & StatsAllExtras;
528
- type StatsValue = number | StatsHistogramData;
529
- /** Returned by `getStats()` when `all` is omitted or `false`. Curated keys require `enableStats: true`. */
530
- type StatsDefault = StatsBasics | StatsCurated;
531
- interface GetStatsMethod {
532
- getStats(all?: false): StatsDefault;
533
- getStats(all: true): StatsAll;
534
- }
535
- //#endregion
536
- //#region src/dbi-iterator.d.ts
537
- interface DBIteratorValue<T> {
538
- key: Key;
539
- value: T;
540
- }
541
269
  /**
542
- * Wraps the `NativeIterator` C++ binding, decoding keys and values from the
543
- * shared key/value buffers (fast path) or from per-iteration buffers (slow
544
- * fallback path used for oversized data or stable-buffer decoders).
270
+ * A store wraps the `NativeDatabase` binding and database settings so that a
271
+ * single database instance can be shared between the main `RocksDatabase`
272
+ * instance and the `Transaction` instance.
545
273
  *
546
- * The native `next()` returns a primitive signal (and writes lengths to the
547
- * shared `ITERATOR_STATE` buffer) instead of constructing a JS result object,
548
- * so this class is responsible for building the `IteratorResult`.
549
- */
550
- declare class DBIterator<T> implements Iterator<DBIteratorValue<T>> {
551
- #private;
552
- iterator: InstanceType<typeof NativeIteratorCls>;
553
- store: Store;
554
- constructor(iterator: InstanceType<typeof NativeIteratorCls>, store: Store, includeValues: boolean, limit?: number);
555
- [Symbol.iterator](): Iterator<DBIteratorValue<T>>;
556
- next(): IteratorResult<DBIteratorValue<T>>;
557
- return(value?: any): IteratorResult<DBIteratorValue<T>, any>;
558
- throw(err: unknown): IteratorResult<DBIteratorValue<T>, any>;
559
- }
560
- //#endregion
561
- //#region src/store.d.ts
562
- type StoreContext = NativeDatabase | NativeTransaction;
563
- type StoreGetOptions = GetOptions & DBITransactional;
564
- type StoreIteratorOptions = IteratorOptions & DBITransactional;
565
- type StorePutOptions = PutOptions & DBITransactional;
566
- type StoreRangeOptions = RangeOptions & DBITransactional;
567
- type StoreRemoveOptions = DBITransactional | unknown;
568
- type CompactOptions = {
569
- start?: Key;
570
- end?: Key;
571
- };
572
- /**
573
- * Options for the `Store` class.
574
- */
575
- interface StoreOptions extends Omit<NativeDatabaseOptions, "mode" | "transactionLogRetentionMs"> {
576
- decoder?: Encoder | null;
577
- encoder?: Encoder | null;
578
- encoding?: Encoding;
579
- freezeData?: boolean;
580
- keyEncoder?: {
581
- readKey?: ReadKeyFunction<Key>;
582
- writeKey?: WriteKeyFunction;
583
- };
584
- keyEncoding?: KeyEncoding;
585
- maxKeySize?: number;
586
- pessimistic?: boolean;
587
- /**
588
- * If `true`, the encoder will use a random access structure.
589
- */
590
- randomAccessStructure?: boolean;
591
- /**
592
- * When `true`, the database is opened in read-only mode. Write operations
593
- * will throw an error with code `ERR_DATABASE_READONLY`.
594
- */
595
- readOnly?: boolean;
596
- sharedStructuresKey?: symbol;
597
- /**
598
- * A string containing the amount of time or the number of milliseconds to
599
- * retain transaction logs before purging.
600
- *
601
- * @default '3d' (3 days)
602
- */
603
- transactionLogRetention?: number | string;
604
- }
605
- /**
606
- * Options for the `getUserSharedBuffer()` method.
607
- */
608
- type UserSharedBufferOptions = {
609
- callback?: UserSharedBufferCallback;
610
- };
611
- /**
612
- * The return type of `getUserSharedBuffer()`.
613
- */
614
- type ArrayBufferWithNotify = ArrayBuffer & {
615
- cancel: () => void;
616
- notify: () => void;
617
- };
618
- /**
619
- * A store wraps the `NativeDatabase` binding and database settings so that a
620
- * single database instance can be shared between the main `RocksDatabase`
621
- * instance and the `Transaction` instance.
622
- *
623
- * This store should not be shared between `RocksDatabase` instances.
274
+ * This store should not be shared between `RocksDatabase` instances.
624
275
  */
625
276
  declare class Store {
626
277
  /**
@@ -806,6 +457,7 @@ declare class Store {
806
457
  * ```
807
458
  */
808
459
  backup(backupDir: string, options?: BackupOptions): Promise<number>;
460
+ backup(stream: WritableStream<Uint8Array>, options?: BackupStreamOptions): Promise<void>;
809
461
  /**
810
462
  * Compacts the entire key range of the database synchronously.
811
463
  * This triggers manual compaction which removes tombstones and reclaims space.
@@ -973,753 +625,1171 @@ interface PutOptions {
973
625
  noOverwrite?: boolean;
974
626
  }
975
627
  //#endregion
976
- //#region src/load-binding.d.ts
977
- type NativeTransactionOptions = {
628
+ //#region src/transaction.d.ts
629
+ /**
630
+ * Sentinel value returned by `commit()` when `coordinatedRetry: true` and the
631
+ * transaction encountered an IsBusy conflict. The native layer parks on VT
632
+ * slots and resolves only after the conflicting transaction releases its write
633
+ * intent, so callers should retry immediately without any backoff delay.
634
+ */
635
+ declare const RETRY_NOW: number;
636
+ /**
637
+ * Provides transaction level operations to a transaction callback.
638
+ */
639
+ declare class Transaction extends DBI {
640
+ #private;
978
641
  /**
979
- * Whether to disable snapshots.
642
+ * Create a new transaction.
980
643
  *
981
- * @default false
644
+ * @param store - The base store interface for this transaction.
645
+ * @param options - The options for the transaction.
982
646
  */
983
- disableSnapshot?: boolean;
647
+ constructor(store: Store, options?: NativeTransactionOptions);
984
648
  /**
985
- * When `true`, an `IsBusy` conflict at commit time is resolved with the
986
- * `RETRY_NOW` sentinel value instead of being rejected. The native layer
987
- * may park on a VT slot before resolving, so the JS retry fires only after
988
- * the conflicting transaction has committed and released its write intent.
989
- *
990
- * Use together with `verificationTable: true` on the database.
991
- *
992
- * @default false
649
+ * Abort the transaction.
993
650
  */
994
- coordinatedRetry?: boolean;
995
- };
996
- type NativeTransaction = {
997
- id: number;
998
- new (context: NativeDatabase, options?: NativeTransactionOptions): NativeTransaction;
999
651
  abort(): void;
1000
- commit(resolve: (retrySignal?: number) => void, reject: (err: Error) => void): void;
652
+ /**
653
+ * Commit the transaction.
654
+ *
655
+ * Returns `RETRY_NOW` when `coordinatedRetry: true` and an IsBusy conflict
656
+ * was detected. The caller should retry the transaction body immediately.
657
+ */
658
+ commit(): Promise<typeof RETRY_NOW | void>;
659
+ /**
660
+ * Commit the transaction synchronously.
661
+ */
1001
662
  commitSync(): void;
1002
- get(keyLengthOrKeyBuffer: number | Buffer, resolve: (value: Buffer | number) => void, reject: (err: Error) => void, txnIdIgnored?: number, expectedVersion?: number): number;
1003
- getCount(options?: RangeOptions): number;
1004
- getSync(keyLengthOrKeyBuffer: number | Buffer): Buffer | number | undefined;
663
+ /**
664
+ * Returns the transaction start timestamp in seconds. Defaults to the time at which
665
+ * the transaction was created.
666
+ *
667
+ * @returns The transaction start timestamp in seconds.
668
+ */
1005
669
  getTimestamp(): number;
1006
- putSync(key: Key, value: Buffer | Uint8Array, txnId?: number): void;
1007
- removeSync(key: Key): void;
670
+ /**
671
+ * Get the transaction id.
672
+ */
673
+ get id(): number;
674
+ /**
675
+ * Set the transaction start timestamp in seconds.
676
+ *
677
+ * @param timestamp - The timestamp to set in seconds.
678
+ */
1008
679
  setTimestamp(timestamp?: number): void;
1009
- useLog(name: string | number): TransactionLog;
1010
- };
1011
- type LogBuffer = Buffer & {
1012
- dataView: DataView;
1013
- logId: number;
1014
- size: number;
1015
- };
1016
- type TransactionLogQueryOptions = {
1017
- start?: number;
1018
- end?: number;
1019
- exactStart?: boolean;
1020
- startFromLastFlushed?: boolean;
1021
- readUncommitted?: boolean;
1022
- exclusiveStart?: boolean;
1023
- };
1024
- type TransactionEntry = {
1025
- timestamp: number;
1026
- data: Buffer;
1027
- endTxn: boolean;
1028
- };
1029
- /**
1030
- * A position within a transaction log, identifying a log file by its sequence
1031
- * number and a byte `offset` within that file.
1032
- */
1033
- type TransactionLogPosition = {
1034
- sequence: number;
1035
- offset: number;
1036
- };
1037
- /**
1038
- * A detailed statistics snapshot for a single transaction log store, returned
1039
- * by {@link TransactionLog.getStats}. All sizes are in bytes; timestamps are
1040
- * milliseconds since the Unix epoch.
1041
- *
1042
- * Memory note: `memory.mappedBytes` is virtual address space — the active write
1043
- * file is mapped at the full configured `maxFileSize` on POSIX, so it does not
1044
- * reflect resident memory. `memory.overlayBytes` (POSIX only; 0 on Windows) is
1045
- * the file-backed portion and is the closer proxy for real consumption.
1046
- */
1047
- type TransactionLogStats = {
1048
- name: string;
1049
- path: string;
1050
- fileCount: number;
1051
- currentSequenceNumber: number;
1052
- oldestSequenceNumber: number;
1053
- totalSizeBytes: number;
1054
- currentFileSize: number;
1055
- pendingTransactions: number;
1056
- uncommittedTransactions: number;
1057
- replayGapBytes: number;
1058
- memory: {
1059
- mappedBytes: number;
1060
- overlayBytes: number;
1061
- activeMaps: number;
1062
- };
1063
- nextLogPosition: TransactionLogPosition;
1064
- lastFlushedPosition: TransactionLogPosition;
1065
- lastCommittedPosition: TransactionLogPosition | null;
1066
- purge: {
1067
- oldestFileAgeMs: number;
1068
- purgeableFiles: number;
1069
- retainedUnflushedFiles: number;
1070
- lastPurgeMs: number;
1071
- };
1072
- totals: {
1073
- transactionsWritten: number;
1074
- entriesWritten: number;
1075
- bytesWritten: number;
1076
- rotations: number;
1077
- filesPurged: number;
1078
- bytesPurged: number;
1079
- purgeRuns: number;
1080
- databaseFlushes: number;
1081
- writeFailures: number;
1082
- };
1083
- config: {
1084
- maxFileSize: number;
1085
- retentionMs: number;
1086
- maxAgeThreshold: number;
1087
- };
1088
- };
1089
- type TransactionLog = {
1090
- new (db: NativeDatabase, name: string): TransactionLog;
1091
- addEntry(data: Buffer | Uint8Array, txnId?: number): void;
1092
- getLogFileSize(sequenceId?: number): number;
1093
- getStats(): TransactionLogStats;
1094
- name: string;
1095
- path: string;
1096
- query(options?: TransactionLogQueryOptions): IterableIterator<TransactionEntry>;
1097
- _currentLogBuffer: LogBuffer;
1098
- _findPosition(timestamp: number): number;
1099
- _getLastCommittedPosition(): Buffer;
1100
- _getLastFlushed(): number;
1101
- _getMemoryMapOfFile(sequenceId: number): LogBuffer | undefined;
1102
- _lastCommittedPosition: Float64Array;
1103
- _logBuffers: Map<number, WeakRef<LogBuffer>>;
1104
- };
1105
- /**
1106
- * Shape of options that can be passed to the native iterator constructor for
1107
- * the rare case of advanced RocksDB ReadOptions overrides. Common iterator
1108
- * options are passed via the bitmask `flags` argument instead.
1109
- */
1110
- type NativeIteratorAdvancedOptions = {
680
+ }
681
+ //#endregion
682
+ //#region src/util.d.ts
683
+ type MaybePromise<T> = T | Promise<T>;
684
+ //#endregion
685
+ //#region src/dbi.d.ts
686
+ interface RocksDBOptions {
687
+ /**
688
+ * When `true`, RocksDB will do some enhancements for prefetching the data.
689
+ * Defaults to `true`. Note that RocksDB defaults this to `false`.
690
+ */
1111
691
  adaptiveReadahead?: boolean;
692
+ /**
693
+ * When `true`, RocksDB will prefetch some data async and apply it if reads
694
+ * are sequential and its internal automatic prefetching. Defaults to
695
+ * `true`. Note that RocksDB defaults this to `false`.
696
+ */
1112
697
  asyncIO?: boolean;
698
+ /**
699
+ * When `true`, RocksDB will auto-tune the readahead size during scans
700
+ * internally based on the block cache data when block caching is enabled,
701
+ * an end key (e.g. upper bound) is set, and prefix is the same as the start
702
+ * key. Defaults to `true`.
703
+ */
1113
704
  autoReadaheadSize?: boolean;
705
+ /**
706
+ * When `true`, after the iterator is closed, a background job is scheduled
707
+ * to flush the job queue and delete obsolete files. Defaults to `true`.
708
+ * Note that RocksDB defaults this to `false`.
709
+ */
1114
710
  backgroundPurgeOnIteratorCleanup?: boolean;
711
+ /**
712
+ * When `true`, the iterator will fill the block cache. Filling the block
713
+ * cache is not desirable for bulk scans and could impact eviction order.
714
+ * Defaults to `false`. Note that RocksDB defaults this to `true`.
715
+ */
1115
716
  fillCache?: boolean;
717
+ /**
718
+ * The RocksDB readahead size. RocksDB does auto-readahead for iterators
719
+ * when there is more than two reads for a table file. The readahead
720
+ * starts at 8KB and doubles on every additional read up to 256KB. This
721
+ * option can help if most of the range scans are large and if a larger
722
+ * readahead than that enabled by auto-readahead is needed. Using a large
723
+ * readahead size (> 2MB) can typically improve the performance of forward
724
+ * iteration on spinning disks. Defaults to `0`.
725
+ */
1116
726
  readaheadSize?: number;
1117
- tailing?: boolean;
1118
- };
1119
- /**
1120
- * The result of a single native iterator step. A number value matches one of
1121
- * the `ITERATOR_RESULT_*` constants. The slow-path object is returned when
1122
- * the data does not fit in the shared key/value buffers, or when the decoder
1123
- * needs a stable value buffer.
1124
- */
1125
- type NativeIteratorResult = number | {
1126
- key: Buffer;
1127
- value?: Buffer;
1128
- };
1129
- declare class NativeIteratorCls {
1130
- constructor(context: StoreContext, flags: number, startKeyEnd: number, endKeyStart: number, endKeyEnd: number, options?: NativeIteratorAdvancedOptions);
1131
- next(): NativeIteratorResult;
1132
- return(): void;
1133
- throw(err?: unknown): void;
727
+ /**
728
+ * When `true`, creates a "tailing iterator" which is a special iterator
729
+ * that has a view of the complete database including newly added data and
730
+ * is optimized for sequential reads. This will return records that were
731
+ * inserted into the database after the creation of the iterator. Defaults
732
+ * to `false`.
733
+ */
734
+ tailing?: boolean;
1134
735
  }
1135
- type NativeDatabaseMode = "optimistic" | "pessimistic";
1136
- type NativeDatabaseOptions = {
1137
- dbWriteBufferSize?: number;
1138
- disableWAL?: boolean;
1139
- enableStats?: boolean;
1140
- maxWriteBufferNumber?: number;
1141
- maxWriteBufferSizeToMaintain?: number;
1142
- mode?: NativeDatabaseMode;
1143
- name?: string;
1144
- noBlockCache?: boolean;
1145
- parallelismThreads?: number;
1146
- readOnly?: boolean;
1147
- statsLevel?: (typeof stats.StatsLevel)[keyof typeof stats.StatsLevel];
1148
- transactionLogMaxAgeThreshold?: number;
1149
- transactionLogMaxSize?: number;
1150
- transactionLogRetentionMs?: number;
1151
- transactionLogsPath?: string;
736
+ interface RangeOptions extends RocksDBOptions {
1152
737
  /**
1153
- * When true, transaction writes to this column family invalidate the
1154
- * VerificationTable slot for each written key at write time (not at
1155
- * commit time). Enable only for column families whose records are
1156
- * cached (e.g. the primary CF of a table). Default: false.
738
+ * The range end key, otherwise known as the "upper bound". Defaults to
739
+ * the last key in the database.
1157
740
  */
1158
- verificationTable?: boolean;
1159
- writeBufferSize?: number;
1160
- };
1161
- type ResolveCallback<T> = (value: T) => void;
1162
- type RejectCallback = (err: Error) => void;
1163
- type UserSharedBufferCallback = () => void;
1164
- type PurgeLogsOptions = {
1165
- before?: number;
1166
- destroy?: boolean;
741
+ end?: Key | Uint8Array;
1167
742
  /**
1168
- * When `true`, count the entries in each purged log file (extra work) and
1169
- * return `PurgedLog[]` instead of the default `string[]` of file paths.
743
+ * When `true`, the iterator will exclude the first key if it matches the start key.
744
+ * Defaults to `false`.
1170
745
  */
1171
- includeEntryCounts?: boolean;
1172
- name?: string;
1173
- };
746
+ exclusiveStart?: boolean;
747
+ /**
748
+ * When `true`, the iterator will include the last key if it matches the end
749
+ * key. Defaults to `false`.
750
+ */
751
+ inclusiveEnd?: boolean;
752
+ /**
753
+ * The range start key, otherwise known as the "lower bound". Defaults to
754
+ * the first key in the database.
755
+ */
756
+ start?: Key | Uint8Array;
757
+ }
758
+ interface IteratorOptions extends RangeOptions {
759
+ /**
760
+ * The maximum number of entries to yield. When set, iteration stops after
761
+ * `limit` entries regardless of the range bounds. Values <= 0 yield nothing.
762
+ * Unset means no limit.
763
+ */
764
+ limit?: number;
765
+ /**
766
+ * A specific key to match which may result in zero, one, or many values.
767
+ */
768
+ key?: Key;
769
+ /**
770
+ * When `true`, only returns the number of values for the given query.
771
+ */
772
+ onlyCount?: boolean;
773
+ /**
774
+ * When `true`, the iterator will iterate in reverse order. Defaults to
775
+ * `false`.
776
+ */
777
+ reverse?: boolean;
778
+ /**
779
+ * When `true`, decodes and returns the value. When `false`, the value is
780
+ * omitted. Defaults to `true`.
781
+ */
782
+ values?: boolean;
783
+ /**
784
+ * When `true`, the iterator will only return the values.
785
+ */
786
+ valuesOnly?: boolean;
787
+ }
788
+ interface DBITransactional {
789
+ transaction?: Transaction;
790
+ }
1174
791
  /**
1175
- * A purged transaction log file and the number of entries it held, returned by
1176
- * `purgeLogs()` when `includeEntryCounts` is `true`.
792
+ * The base class for all database operations. This base class is shared by
793
+ * `RocksDatabase` and `Transaction`.
794
+ *
795
+ * This class is not meant to be used directly.
1177
796
  */
1178
- type PurgedLog = {
1179
- path: string;
1180
- entries: number;
1181
- };
1182
- type NativeDatabase = {
1183
- new (): NativeDatabase;
1184
- addListener(event: string, callback: (...args: any[]) => void): void;
1185
- backup(resolve: ResolveCallback<number>, reject: RejectCallback, backupDir: string, options?: BackupOptions): void;
1186
- clear(resolve: ResolveCallback<void>, reject: RejectCallback): void;
1187
- clearSync(): void;
1188
- close(): void;
1189
- compact(resolve: ResolveCallback<void>, reject: RejectCallback, start?: Key, end?: Key): void;
1190
- compactSync(start?: Key, end?: Key): void;
1191
- columns: string[];
1192
- createCheckpoint(resolve: ResolveCallback<void>, reject: RejectCallback, targetPath: string): void;
1193
- destroy(): void;
1194
- drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
1195
- dropSync(): void;
1196
- flush(resolve: ResolveCallback<void>, reject: RejectCallback): void;
1197
- flushSync(): void;
1198
- notify(event: string | BufferWithDataView, args?: any[]): boolean;
1199
- get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
1200
- getCount(options?: RangeOptions, txnId?: number): number;
1201
- getDBIntProperty(propertyName: string): number | undefined;
1202
- getDBProperty(propertyName: string): string | undefined;
1203
- getMonotonicTimestamp(): number;
1204
- getOldestSnapshotTimestamp(): number;
1205
- getStat(statName: string): number | StatsHistogramData;
1206
- getStats(all?: false): StatsDefault;
1207
- getStats(all: true): StatsAll;
1208
- getSync(keyLengthOrKeyBuffer: number | Buffer, flags: number, txnId?: number, expectedVersion?: number): Buffer;
1209
- getUserSharedBuffer(key: BufferWithDataView, defaultBuffer: ArrayBuffer, callback?: UserSharedBufferCallback): ArrayBuffer;
1210
- hasLock(key: BufferWithDataView): boolean;
1211
- listeners(event: string | BufferWithDataView): number;
1212
- listLogs(): string[];
1213
- opened: boolean;
1214
- open(path: string, options?: NativeDatabaseOptions): void;
1215
- populateVersion(keyLengthOrKeyBuffer: number | Buffer, version: number): void;
1216
- purgeLogs(options: PurgeLogsOptions & {
1217
- includeEntryCounts: true;
1218
- }): PurgedLog[];
1219
- purgeLogs(options?: PurgeLogsOptions & {
1220
- includeEntryCounts?: false;
1221
- }): string[];
1222
- purgeLogs(options?: PurgeLogsOptions): string[] | PurgedLog[];
1223
- putSync(key: BufferWithDataView, value: any, txnId?: number): void;
1224
- removeListener(event: string | BufferWithDataView, callback: () => void): boolean;
1225
- removeSync(key: BufferWithDataView, txnId?: number): void;
1226
- setDefaultKeyBuffer(buffer: Buffer | Uint8Array | null): void;
1227
- setDefaultValueBuffer(buffer: Buffer | Uint8Array | null): void;
1228
- setIteratorState(buffer: Buffer | Uint8Array): void;
1229
- tryLock(key: BufferWithDataView, callback?: () => void): boolean;
1230
- unlock(key: BufferWithDataView): void;
1231
- useLog(name: string): TransactionLog;
1232
- verifyVersion(keyLengthOrKeyBuffer: number | Buffer, version: number): boolean;
1233
- withLock(key: BufferWithDataView, callback: () => void | Promise<void>): Promise<void>;
1234
- };
1235
- type RocksDatabaseConfig = {
1236
- blockCacheSize?: number;
797
+ declare class DBI<T extends DBITransactional | unknown = unknown> {
1237
798
  /**
1238
- * Number of slots in the process-global verification table. Each slot is
1239
- * 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
799
+ * The RocksDB context for `get()`, `put()`, and `remove()`.
800
+ */
801
+ _context: StoreContext;
802
+ /**
803
+ * The database store instance. The store instance is tied to the database
804
+ * instance and shared with transaction instances.
805
+ */
806
+ store: Store;
807
+ /**
808
+ * Initializes the DBI context.
1240
809
  *
1241
- * Must be configured before the first database is opened. Once the table
1242
- * is materialized, attempts to change this value will throw.
810
+ * @param store - The store instance.
811
+ * @param transaction - The transaction instance.
1243
812
  */
1244
- verificationTableEntries?: number;
1245
- compactOnClose?: boolean;
813
+ constructor(store: Store, transaction?: NativeTransaction);
1246
814
  /**
1247
- * Total memtable memory limit (bytes) shared across every database opened
1248
- * in this process. When set, RocksDB uses a single `WriteBufferManager` so
1249
- * write buffers are bounded process-wide rather than per database. 0 (the
1250
- * default) disables the manager.
815
+ * Adds a listener for the given key.
1251
816
  *
1252
- * Can be updated at runtime; the new size takes effect on the existing
1253
- * manager via `SetBufferSize`.
817
+ * @param event - The event name to add the listener for.
818
+ * @param callback - The callback to add.
1254
819
  */
1255
- writeBufferManagerSize?: number;
820
+ addListener(event: string, callback: (...args: any[]) => void): this;
821
+ /**
822
+ * Retrieves the value for the given key, then returns the decoded value.
823
+ */
824
+ get(key: Key, options?: GetOptions & T): MaybePromise<any | undefined>;
825
+ /**
826
+ * Retrieves the binary data for the given key. This is just like `get()`,
827
+ * but bypasses the decoder.
828
+ *
829
+ * Note: Used by HDBreplication.
830
+ */
831
+ getBinary(key: Key, options?: GetOptions & T): MaybePromise<Buffer | number | undefined>;
832
+ /**
833
+ * Synchronously retrieves the binary data for the given key.
834
+ */
835
+ getBinarySync(key: Key, options?: GetOptions & T): Buffer | number | undefined;
836
+ /**
837
+ * Retrieves the binary data for the given key using a preallocated,
838
+ * reusable buffer. Data in the buffer is only valid until the next get
839
+ * operation (including cursor operations).
840
+ *
841
+ * Note: The reusable buffer slightly differs from a typical buffer:
842
+ * - `.length` is set to the size of the value
843
+ * - `.byteLength` is set to the size of the full allocated memory area for
844
+ * the buffer (usually much larger).
845
+ */
846
+ getBinaryFast(key: Key, options?: GetOptions & T): MaybePromise<Buffer | number | undefined>;
847
+ /**
848
+ * Synchronously retrieves the binary data for the given key using a
849
+ * preallocated, reusable buffer. Data in the buffer is only valid until the
850
+ * next get operation (including cursor operations).
851
+ */
852
+ getBinaryFastSync(key: Key, options?: GetOptions & T): Buffer | number | undefined;
853
+ /**
854
+ * Retrieves all keys within a range.
855
+ */
856
+ getKeys(options?: IteratorOptions & T): any | undefined;
857
+ /**
858
+ * Retrieves the number of keys within a range.
859
+ *
860
+ * @param options - The range options.
861
+ * @returns The number of keys within the range.
862
+ *
863
+ * @example
864
+ * ```typescript
865
+ * const total = db.getKeysCount();
866
+ * const range = db.getKeysCount({ start: 'a', end: 'z' });
867
+ * ```
868
+ */
869
+ getKeysCount(options?: RangeOptions & T): number;
870
+ /**
871
+ * Retrieves a range of keys and their values.
872
+ *
873
+ * @param options - The iterator options.
874
+ * @returns A range iterable.
875
+ *
876
+ * @example
877
+ * ```typescript
878
+ * for (const { key, value } of db.getRange()) {
879
+ * console.log({ key, value });
880
+ * }
881
+ *
882
+ * for (const { key, value } of db.getRange({ start: 'a', end: 'z' })) {
883
+ * console.log({ key, value });
884
+ * }
885
+ * ```
886
+ */
887
+ getRange(options?: IteratorOptions & T): any | undefined;
888
+ /**
889
+ * Synchronously retrieves the value for the given key, then returns the
890
+ * decoded value.
891
+ */
892
+ getSync(key: Key, options?: GetOptions & T): any | undefined;
893
+ /**
894
+ * Gets the number of listeners for the given key.
895
+ *
896
+ * @param event - The event name to get the listeners for.
897
+ * @returns The number of listeners for the given key.
898
+ */
899
+ listeners(event: string | BufferWithDataView): number;
900
+ /**
901
+ * Notifies an event for the given key.
902
+ *
903
+ * @param event - The event name to emit the event for.
904
+ * @param args - The arguments to emit.
905
+ * @returns `true` if there were listeners, `false` otherwise.
906
+ */
907
+ notify(event: string, ...args: any[]): boolean;
908
+ /**
909
+ * Alias for `removeListener()`.
910
+ *
911
+ * @param event - The event name to remove the listener for.
912
+ * @param callback - The callback to remove.
913
+ */
914
+ off(event: string, callback: (...args: any[]) => void): this;
915
+ /**
916
+ * Alias for `addListener()`.
917
+ *
918
+ * @param event - The event name to add the listener for.
919
+ * @param callback - The callback to add.
920
+ */
921
+ on(event: string, callback: (...args: any[]) => void): this;
922
+ /**
923
+ * Adds a one-time listener, then automatically removes it.
924
+ *
925
+ * @param event - The event name to add the listener for.
926
+ * @param callback - The callback to add.
927
+ */
928
+ once(event: string, callback: (...args: any[]) => void): this;
929
+ /**
930
+ * Stores a value for the given key.
931
+ *
932
+ * @param key - The key to store the value for.
933
+ * @param value - The value to store.
934
+ * @param options - The put options.
935
+ * @returns The key and value.
936
+ *
937
+ * @example
938
+ * ```typescript
939
+ * await db.put('a', 'b');
940
+ * ```
941
+ */
942
+ put(key: Key, value: any, options?: PutOptions & T): Promise<void>;
943
+ /**
944
+ * Synchronously stores a value for the given key.
945
+ *
946
+ * @param key - The key to store the value for.
947
+ * @param value - The value to store.
948
+ * @param options - The put options.
949
+ * @returns The key and value.
950
+ *
951
+ * @example
952
+ * ```typescript
953
+ * db.putSync('a', 'b');
954
+ * ```
955
+ */
956
+ putSync(key: Key, value: any, options?: PutOptions & T): void;
957
+ /**
958
+ * Removes a value for the given key. If the key does not exist, it will
959
+ * not error.
960
+ *
961
+ * @param key - The key to remove the value for.
962
+ * @param options - The remove options.
963
+ * @returns The key and value.
964
+ *
965
+ * @example
966
+ * ```typescript
967
+ * await db.remove('a');
968
+ * ```
969
+ */
970
+ remove(key: Key, options?: T): Promise<void>;
971
+ /**
972
+ * Removes a value for the given key. If the key does not exist, it will
973
+ * not error.
974
+ *
975
+ * @param key - The key to remove the value for.
976
+ * @param options - The remove options.
977
+ * @returns The key and value.
978
+ *
979
+ * @example
980
+ * ```typescript
981
+ * db.removeSync('a');
982
+ * ```
983
+ */
984
+ removeSync(key: Key, options?: T): void;
985
+ /**
986
+ * Removes an event listener. You must specify the exact same callback that was
987
+ * used in `addListener()`.
988
+ *
989
+ * @param event - The event name to remove the listener for.
990
+ * @param callback - The callback to remove.
991
+ */
992
+ removeListener(event: string, callback: (value?: any) => void): boolean;
993
+ /**
994
+ * Get or create a transaction log instance.
995
+ *
996
+ * @param name - The name of the transaction log.
997
+ * @returns The transaction log.
998
+ */
999
+ useLog(name: string | number): TransactionLog;
1000
+ }
1001
+ //#endregion
1002
+ //#region src/stats.d.ts
1003
+ /** Database-level RocksDB statistics types for `db.getStats()` / `db.getStat()`. */
1004
+ type StatsHistogramData = {
1005
+ average: number;
1006
+ count: number;
1007
+ max: number;
1008
+ median: number;
1009
+ min: number;
1010
+ percentile95: number;
1011
+ percentile99: number;
1012
+ standardDeviation: number;
1013
+ sum: number;
1014
+ };
1015
+ type StatsBasics = {
1016
+ "rocksdb.num-immutable-mem-table": number;
1017
+ "rocksdb.num-immutable-mem-table-flushed": number;
1018
+ "rocksdb.mem-table-flush-pending": number;
1019
+ "rocksdb.cur-size-active-mem-table": number;
1020
+ "rocksdb.cur-size-all-mem-tables": number;
1021
+ "rocksdb.size-all-mem-tables": number;
1022
+ "rocksdb.num-entries-active-mem-table": number;
1023
+ "rocksdb.num-deletes-active-mem-table": number;
1024
+ "rocksdb.compaction-pending": number;
1025
+ "rocksdb.estimate-pending-compaction-bytes": number;
1026
+ "rocksdb.num-running-compactions": number;
1027
+ "rocksdb.num-running-flushes": number;
1028
+ "rocksdb.total-sst-files-size": number;
1029
+ "rocksdb.live-sst-files-size": number;
1030
+ "rocksdb.estimate-live-data-size": number;
1031
+ "rocksdb.estimate-num-keys": number;
1032
+ "rocksdb.block-cache-capacity": number;
1033
+ "rocksdb.block-cache-usage": number;
1034
+ "rocksdb.block-cache-pinned-usage": number;
1035
+ "rocksdb.num-live-versions": number;
1036
+ "rocksdb.current-super-version-number": number;
1037
+ "rocksdb.oldest-snapshot-time": number;
1038
+ "rocksdb.num-blob-files": number;
1039
+ "rocksdb.total-blob-file-size": number;
1040
+ "rocksdb.live-blob-file-size": number;
1041
+ "txnlog.logCount": number;
1042
+ "txnlog.fileCount": number;
1043
+ "txnlog.totalSizeBytes": number;
1044
+ "txnlog.mappedBytes": number;
1045
+ "txnlog.overlayBytes": number;
1046
+ "txnlog.activeMaps": number;
1047
+ "txnlog.pendingTransactions": number;
1048
+ "txnlog.uncommittedTransactions": number;
1049
+ "txnlog.transactionsWritten": number;
1050
+ "txnlog.bytesWritten": number;
1051
+ "txnlog.replayGapBytes": number;
1052
+ };
1053
+ type StatsCuratedExtras = {
1054
+ "rocksdb.block.cache.hit": number;
1055
+ "rocksdb.block.cache.miss": number;
1056
+ "rocksdb.block.cache.data.hit": number;
1057
+ "rocksdb.block.cache.data.miss": number;
1058
+ "rocksdb.block.cache.index.hit": number;
1059
+ "rocksdb.block.cache.index.miss": number;
1060
+ "rocksdb.block.cache.filter.hit": number;
1061
+ "rocksdb.block.cache.filter.miss": number;
1062
+ "rocksdb.bloom.filter.useful": number;
1063
+ "rocksdb.bloom.filter.full.positive": number;
1064
+ "rocksdb.bloom.filter.full.true.positive": number;
1065
+ "rocksdb.db.iter.bytes.read": number;
1066
+ "rocksdb.number.reseeks.iteration": number;
1067
+ "rocksdb.number.keys.read": number;
1068
+ "rocksdb.number.keys.written": number;
1069
+ "rocksdb.bytes.read": number;
1070
+ "rocksdb.bytes.written": number;
1071
+ "rocksdb.memtable.hit": number;
1072
+ "rocksdb.memtable.miss": number;
1073
+ "rocksdb.txn.overhead.mutex.prepare": number;
1074
+ "rocksdb.txn.overhead.mutex.old.commit.map": number;
1075
+ "rocksdb.txn.overhead.mutex.snapshot": number;
1076
+ "rocksdb.compact.read.bytes": number;
1077
+ "rocksdb.compact.write.bytes": number;
1078
+ "rocksdb.compaction.cancelled": number;
1079
+ "rocksdb.stall.micros": number;
1080
+ "rocksdb.no.file.errors": number;
1081
+ "rocksdb.read.amp.estimate.useful.bytes": number;
1082
+ "rocksdb.read.amp.total.read.bytes": number;
1083
+ "rocksdb.db.get.micros": StatsHistogramData;
1084
+ "rocksdb.db.write.micros": StatsHistogramData;
1085
+ "rocksdb.db.seek.micros": StatsHistogramData;
1086
+ "rocksdb.db.flush.micros": StatsHistogramData;
1087
+ "rocksdb.db.write.stall": StatsHistogramData;
1088
+ "rocksdb.blobdb.value.size": StatsHistogramData;
1089
+ "rocksdb.sst.read.micros": StatsHistogramData;
1090
+ "rocksdb.compaction.times.micros": StatsHistogramData;
1091
+ };
1092
+ type StatsAllExtras = {
1093
+ "rocksdb.block.cache.add": number;
1094
+ "rocksdb.block.cache.add.failures": number;
1095
+ "rocksdb.block.cache.index.add": number;
1096
+ "rocksdb.block.cache.index.bytes.insert": number;
1097
+ "rocksdb.block.cache.filter.add": number;
1098
+ "rocksdb.block.cache.filter.bytes.insert": number;
1099
+ "rocksdb.block.cache.data.add": number;
1100
+ "rocksdb.block.cache.data.bytes.insert": number;
1101
+ "rocksdb.block.cache.bytes.read": number;
1102
+ "rocksdb.block.cache.bytes.write": number;
1103
+ "rocksdb.block.cache.compression.dict.miss": number;
1104
+ "rocksdb.block.cache.compression.dict.hit": number;
1105
+ "rocksdb.block.cache.compression.dict.add": number;
1106
+ "rocksdb.block.cache.compression.dict.bytes.insert": number;
1107
+ "rocksdb.block.cache.add.redundant": number;
1108
+ "rocksdb.block.cache.index.add.redundant": number;
1109
+ "rocksdb.block.cache.filter.add.redundant": number;
1110
+ "rocksdb.block.cache.data.add.redundant": number;
1111
+ "rocksdb.block.cache.compression.dict.add.redundant": number;
1112
+ "rocksdb.secondary.cache.hits": number;
1113
+ "rocksdb.secondary.cache.filter.hits": number;
1114
+ "rocksdb.secondary.cache.index.hits": number;
1115
+ "rocksdb.secondary.cache.data.hits": number;
1116
+ "rocksdb.compressed.secondary.cache.dummy.hits": number;
1117
+ "rocksdb.compressed.secondary.cache.hits": number;
1118
+ "rocksdb.compressed.secondary.cache.promotions": number;
1119
+ "rocksdb.compressed.secondary.cache.promotion.skips": number;
1120
+ "rocksdb.bloom.filter.prefix.checked": number;
1121
+ "rocksdb.bloom.filter.prefix.useful": number;
1122
+ "rocksdb.bloom.filter.prefix.true.positive": number;
1123
+ "rocksdb.persistent.cache.hit": number;
1124
+ "rocksdb.persistent.cache.miss": number;
1125
+ "rocksdb.sim.block.cache.hit": number;
1126
+ "rocksdb.sim.block.cache.miss": number;
1127
+ "rocksdb.l0.hit": number;
1128
+ "rocksdb.l1.hit": number;
1129
+ "rocksdb.l2andup.hit": number;
1130
+ "rocksdb.compaction.key.drop.new": number;
1131
+ "rocksdb.compaction.key.drop.obsolete": number;
1132
+ "rocksdb.compaction.key.drop.range_del": number;
1133
+ "rocksdb.compaction.key.drop.user": number;
1134
+ "rocksdb.compaction.range_del.drop.obsolete": number;
1135
+ "rocksdb.compaction.optimized.del.drop.obsolete": number;
1136
+ "rocksdb.compaction.aborted": number;
1137
+ "rocksdb.number.keys.updated": number;
1138
+ "rocksdb.number.db.seek": number;
1139
+ "rocksdb.number.db.next": number;
1140
+ "rocksdb.number.db.prev": number;
1141
+ "rocksdb.number.db.seek.found": number;
1142
+ "rocksdb.number.db.next.found": number;
1143
+ "rocksdb.number.db.prev.found": number;
1144
+ "rocksdb.number.iter.skip": number;
1145
+ "rocksdb.num.iterator.created": number;
1146
+ "rocksdb.num.iterator.deleted": number;
1147
+ "rocksdb.no.file.opens": number;
1148
+ "rocksdb.db.mutex.wait.micros": number;
1149
+ "rocksdb.number.multiget.get": number;
1150
+ "rocksdb.number.multiget.keys.read": number;
1151
+ "rocksdb.number.multiget.bytes.read": number;
1152
+ "rocksdb.number.multiget.keys.found": number;
1153
+ "rocksdb.number.merge.failures": number;
1154
+ "rocksdb.getupdatessince.calls": number;
1155
+ "rocksdb.wal.synced": number;
1156
+ "rocksdb.wal.bytes": number;
1157
+ "rocksdb.write.self": number;
1158
+ "rocksdb.write.other": number;
1159
+ "rocksdb.write.wal": number;
1160
+ "rocksdb.flush.write.bytes": number;
1161
+ "rocksdb.compact.read.marked.bytes": number;
1162
+ "rocksdb.compact.read.periodic.bytes": number;
1163
+ "rocksdb.compact.read.ttl.bytes": number;
1164
+ "rocksdb.compact.write.marked.bytes": number;
1165
+ "rocksdb.compact.write.periodic.bytes": number;
1166
+ "rocksdb.compact.write.ttl.bytes": number;
1167
+ "rocksdb.number.direct.load.table.properties": number;
1168
+ "rocksdb.number.superversion_acquires": number;
1169
+ "rocksdb.number.superversion_releases": number;
1170
+ "rocksdb.number.superversion_cleanups": number;
1171
+ "rocksdb.number.block.compressed": number;
1172
+ "rocksdb.number.block.decompressed": number;
1173
+ "rocksdb.bytes.compressed.from": number;
1174
+ "rocksdb.bytes.compressed.to": number;
1175
+ "rocksdb.bytes.compression_bypassed": number;
1176
+ "rocksdb.bytes.compression.rejected": number;
1177
+ "rocksdb.number.block_compression_bypassed": number;
1178
+ "rocksdb.number.block_compression_rejected": number;
1179
+ "rocksdb.bytes.decompressed.from": number;
1180
+ "rocksdb.bytes.decompressed.to": number;
1181
+ "rocksdb.merge.operation.time.nanos": number;
1182
+ "rocksdb.filter.operation.time.nanos": number;
1183
+ "rocksdb.compaction.total.time.cpu_micros": number;
1184
+ "rocksdb.row.cache.hit": number;
1185
+ "rocksdb.row.cache.miss": number;
1186
+ "rocksdb.number.rate_limiter.drains": number;
1187
+ "rocksdb.blobdb.num.put": number;
1188
+ "rocksdb.blobdb.num.write": number;
1189
+ "rocksdb.blobdb.num.get": number;
1190
+ "rocksdb.blobdb.num.multiget": number;
1191
+ "rocksdb.blobdb.num.seek": number;
1192
+ "rocksdb.blobdb.num.next": number;
1193
+ "rocksdb.blobdb.num.prev": number;
1194
+ "rocksdb.blobdb.num.keys.written": number;
1195
+ "rocksdb.blobdb.num.keys.read": number;
1196
+ "rocksdb.blobdb.bytes.written": number;
1197
+ "rocksdb.blobdb.bytes.read": number;
1198
+ "rocksdb.blobdb.write.inlined": number;
1199
+ "rocksdb.blobdb.write.inlined.ttl": number;
1200
+ "rocksdb.blobdb.write.blob": number;
1201
+ "rocksdb.blobdb.write.blob.ttl": number;
1202
+ "rocksdb.blobdb.blob.file.bytes.written": number;
1203
+ "rocksdb.blobdb.blob.file.bytes.read": number;
1204
+ "rocksdb.blobdb.blob.file.synced": number;
1205
+ "rocksdb.blobdb.blob.index.expired.count": number;
1206
+ "rocksdb.blobdb.blob.index.expired.size": number;
1207
+ "rocksdb.blobdb.blob.index.evicted.count": number;
1208
+ "rocksdb.blobdb.blob.index.evicted.size": number;
1209
+ "rocksdb.blobdb.gc.num.files": number;
1210
+ "rocksdb.blobdb.gc.num.new.files": number;
1211
+ "rocksdb.blobdb.gc.failures": number;
1212
+ "rocksdb.blobdb.gc.num.keys.relocated": number;
1213
+ "rocksdb.blobdb.gc.bytes.relocated": number;
1214
+ "rocksdb.blobdb.fifo.num.files.evicted": number;
1215
+ "rocksdb.blobdb.fifo.num.keys.evicted": number;
1216
+ "rocksdb.blobdb.fifo.bytes.evicted": number;
1217
+ "rocksdb.blobdb.cache.miss": number;
1218
+ "rocksdb.blobdb.cache.hit": number;
1219
+ "rocksdb.blobdb.cache.add": number;
1220
+ "rocksdb.blobdb.cache.add.failures": number;
1221
+ "rocksdb.blobdb.cache.bytes.read": number;
1222
+ "rocksdb.blobdb.cache.bytes.write": number;
1223
+ "rocksdb.txn.overhead.duplicate.key": number;
1224
+ "rocksdb.txn.get.tryagain": number;
1225
+ "rocksdb.files.marked.trash": number;
1226
+ "rocksdb.files.marked.trash.deleted": number;
1227
+ "rocksdb.files.deleted.immediately": number;
1228
+ "rocksdb.error.handler.bg.error.count": number;
1229
+ "rocksdb.error.handler.bg.io.error.count": number;
1230
+ "rocksdb.error.handler.bg.retryable.io.error.count": number;
1231
+ "rocksdb.error.handler.autoresume.count": number;
1232
+ "rocksdb.error.handler.autoresume.retry.total.count": number;
1233
+ "rocksdb.error.handler.autoresume.success.count": number;
1234
+ "rocksdb.memtable.payload.bytes.at.flush": number;
1235
+ "rocksdb.memtable.garbage.bytes.at.flush": number;
1236
+ "rocksdb.verify_checksum.read.bytes": number;
1237
+ "rocksdb.backup.read.bytes": number;
1238
+ "rocksdb.backup.write.bytes": number;
1239
+ "rocksdb.remote.compact.read.bytes": number;
1240
+ "rocksdb.remote.compact.write.bytes": number;
1241
+ "rocksdb.remote.compact.resumed.bytes": number;
1242
+ "rocksdb.hot.file.read.bytes": number;
1243
+ "rocksdb.warm.file.read.bytes": number;
1244
+ "rocksdb.cool.file.read.bytes": number;
1245
+ "rocksdb.cold.file.read.bytes": number;
1246
+ "rocksdb.ice.file.read.bytes": number;
1247
+ "rocksdb.hot.file.read.count": number;
1248
+ "rocksdb.warm.file.read.count": number;
1249
+ "rocksdb.cool.file.read.count": number;
1250
+ "rocksdb.cold.file.read.count": number;
1251
+ "rocksdb.ice.file.read.count": number;
1252
+ "rocksdb.last.level.read.bytes": number;
1253
+ "rocksdb.last.level.read.count": number;
1254
+ "rocksdb.non.last.level.read.bytes": number;
1255
+ "rocksdb.non.last.level.read.count": number;
1256
+ "rocksdb.last.level.seek.filtered": number;
1257
+ "rocksdb.last.level.seek.filter.match": number;
1258
+ "rocksdb.last.level.seek.data": number;
1259
+ "rocksdb.last.level.seek.data.useful.no.filter": number;
1260
+ "rocksdb.last.level.seek.data.useful.filter.match": number;
1261
+ "rocksdb.non.last.level.seek.filtered": number;
1262
+ "rocksdb.non.last.level.seek.filter.match": number;
1263
+ "rocksdb.non.last.level.seek.data": number;
1264
+ "rocksdb.non.last.level.seek.data.useful.no.filter": number;
1265
+ "rocksdb.non.last.level.seek.data.useful.filter.match": number;
1266
+ "rocksdb.block.checksum.compute.count": number;
1267
+ "rocksdb.block.checksum.mismatch.count": number;
1268
+ "rocksdb.multiget.coroutine.count": number;
1269
+ "rocksdb.read.async.micros": number;
1270
+ "rocksdb.async.read.error.count": number;
1271
+ "rocksdb.table.open.prefetch.tail.miss": number;
1272
+ "rocksdb.table.open.prefetch.tail.hit": number;
1273
+ "rocksdb.timestamp.filter.table.checked": number;
1274
+ "rocksdb.timestamp.filter.table.filtered": number;
1275
+ "rocksdb.readahead.trimmed": number;
1276
+ "rocksdb.fifo.max.size.compactions": number;
1277
+ "rocksdb.fifo.ttl.compactions": number;
1278
+ "rocksdb.fifo.change_temperature.compactions": number;
1279
+ "rocksdb.prefetch.bytes": number;
1280
+ "rocksdb.prefetch.bytes.useful": number;
1281
+ "rocksdb.prefetch.hits": number;
1282
+ "rocksdb.footer.corruption.count": number;
1283
+ "rocksdb.file.read.corruption.retry.count": number;
1284
+ "rocksdb.file.read.corruption.retry.success.count": number;
1285
+ "rocksdb.number.wbwi.ingest": number;
1286
+ "rocksdb.sst.user.defined.index.load.fail.count": number;
1287
+ "rocksdb.multiscan.prepare.calls": number;
1288
+ "rocksdb.multiscan.prepare.errors": number;
1289
+ "rocksdb.multiscan.blocks.prefetched": number;
1290
+ "rocksdb.multiscan.blocks.from.cache": number;
1291
+ "rocksdb.multiscan.prefetch.bytes": number;
1292
+ "rocksdb.multiscan.prefetch.blocks.wasted": number;
1293
+ "rocksdb.multiscan.io.requests": number;
1294
+ "rocksdb.multiscan.io.coalesced.nonadjacent": number;
1295
+ "rocksdb.multiscan.seek.errors": number;
1296
+ "rocksdb.prefetch.memory.bytes.granted": number;
1297
+ "rocksdb.prefetch.memory.bytes.released": number;
1298
+ "rocksdb.prefetch.memory.requests.blocked": number;
1299
+ "rocksdb.compaction.times.cpu_micros": StatsHistogramData;
1300
+ "rocksdb.subcompaction.setup.times.micros": StatsHistogramData;
1301
+ "rocksdb.table.sync.micros": StatsHistogramData;
1302
+ "rocksdb.compaction.outfile.sync.micros": StatsHistogramData;
1303
+ "rocksdb.wal.file.sync.micros": StatsHistogramData;
1304
+ "rocksdb.manifest.file.sync.micros": StatsHistogramData;
1305
+ "rocksdb.table.open.io.micros": StatsHistogramData;
1306
+ "rocksdb.db.multiget.micros": StatsHistogramData;
1307
+ "rocksdb.read.block.compaction.micros": StatsHistogramData;
1308
+ "rocksdb.read.block.get.micros": StatsHistogramData;
1309
+ "rocksdb.write.raw.block.micros": StatsHistogramData;
1310
+ "rocksdb.numfiles.in.singlecompaction": StatsHistogramData;
1311
+ "rocksdb.file.read.flush.micros": StatsHistogramData;
1312
+ "rocksdb.file.read.compaction.micros": StatsHistogramData;
1313
+ "rocksdb.file.read.db.open.micros": StatsHistogramData;
1314
+ "rocksdb.file.read.get.micros": StatsHistogramData;
1315
+ "rocksdb.file.read.multiget.micros": StatsHistogramData;
1316
+ "rocksdb.file.read.db.iterator.micros": StatsHistogramData;
1317
+ "rocksdb.file.read.verify.db.checksum.micros": StatsHistogramData;
1318
+ "rocksdb.file.read.verify.file.checksums.micros": StatsHistogramData;
1319
+ "rocksdb.sst.write.micros": StatsHistogramData;
1320
+ "rocksdb.file.write.flush.micros": StatsHistogramData;
1321
+ "rocksdb.file.write.compaction.micros": StatsHistogramData;
1322
+ "rocksdb.file.write.db.open.micros": StatsHistogramData;
1323
+ "rocksdb.num.subcompactions.scheduled": StatsHistogramData;
1324
+ "rocksdb.bytes.per.read": StatsHistogramData;
1325
+ "rocksdb.bytes.per.write": StatsHistogramData;
1326
+ "rocksdb.bytes.per.multiget": StatsHistogramData;
1327
+ "rocksdb.compression.times.nanos": StatsHistogramData;
1328
+ "rocksdb.decompression.times.nanos": StatsHistogramData;
1329
+ "rocksdb.read.num.merge_operands": StatsHistogramData;
1330
+ "rocksdb.blobdb.key.size": StatsHistogramData;
1331
+ "rocksdb.blobdb.write.micros": StatsHistogramData;
1332
+ "rocksdb.blobdb.get.micros": StatsHistogramData;
1333
+ "rocksdb.blobdb.multiget.micros": StatsHistogramData;
1334
+ "rocksdb.blobdb.seek.micros": StatsHistogramData;
1335
+ "rocksdb.blobdb.next.micros": StatsHistogramData;
1336
+ "rocksdb.blobdb.prev.micros": StatsHistogramData;
1337
+ "rocksdb.blobdb.blob.file.write.micros": StatsHistogramData;
1338
+ "rocksdb.blobdb.blob.file.read.micros": StatsHistogramData;
1339
+ "rocksdb.blobdb.blob.file.sync.micros": StatsHistogramData;
1340
+ "rocksdb.blobdb.compression.micros": StatsHistogramData;
1341
+ "rocksdb.blobdb.decompression.micros": StatsHistogramData;
1342
+ "rocksdb.sst.batch.size": StatsHistogramData;
1343
+ "rocksdb.multiget.io.batch.size": StatsHistogramData;
1344
+ "rocksdb.num.index.and.filter.blocks.read.per.level": StatsHistogramData;
1345
+ "rocksdb.num.sst.read.per.level": StatsHistogramData;
1346
+ "rocksdb.num.level.read.per.multiget": StatsHistogramData;
1347
+ "rocksdb.error.handler.autoresume.retry.count": StatsHistogramData;
1348
+ "rocksdb.async.read.bytes": StatsHistogramData;
1349
+ "rocksdb.poll.wait.micros": StatsHistogramData;
1350
+ "rocksdb.compaction.prefetch.bytes": StatsHistogramData;
1351
+ "rocksdb.prefetched.bytes.discarded": StatsHistogramData;
1352
+ "rocksdb.async.prefetch.abort.micros": StatsHistogramData;
1353
+ "rocksdb.table.open.prefetch.tail.read.bytes": StatsHistogramData;
1354
+ "rocksdb.num.op.per.transaction": StatsHistogramData;
1355
+ "rocksdb.multiscan.op.prepare.iterators.micros": StatsHistogramData;
1356
+ "rocksdb.multiscan.prepare.micros": StatsHistogramData;
1357
+ "rocksdb.multiscan.blocks.per.prepare": StatsHistogramData;
1358
+ "rocksdb.block.key.distribution.cv": StatsHistogramData;
1359
+ };
1360
+ type StatsCurated = StatsBasics & StatsCuratedExtras;
1361
+ type StatsAll = StatsCurated & StatsAllExtras;
1362
+ type StatsValue = number | StatsHistogramData;
1363
+ /** Returned by `getStats()` when `all` is omitted or `false`. Curated keys require `enableStats: true`. */
1364
+ type StatsDefault = StatsBasics | StatsCurated;
1365
+ interface GetStatsMethod {
1366
+ getStats(all?: false): StatsDefault;
1367
+ getStats(all: true): StatsAll;
1368
+ }
1369
+ //#endregion
1370
+ //#region src/load-binding.d.ts
1371
+ type NativeTransactionOptions = {
1256
1372
  /**
1257
- * When `true`, memtable memory is "charged" against the shared block cache
1258
- * so the block cache and write buffers draw from a single pool. During
1259
- * write bursts the cache shrinks to make room for memtables; once
1260
- * memtables flush, the cache can grow back into the reclaimed space.
1261
- *
1262
- * Has no effect when the block cache is disabled (size 0) or
1263
- * `writeBufferManagerSize` is 0. Must be set on the same `config()` call
1264
- * that first enables the manager — changing it after the manager has been
1265
- * created has no effect on the running instance.
1373
+ * Whether to disable snapshots.
1266
1374
  *
1267
1375
  * @default false
1268
1376
  */
1269
- writeBufferManagerCostToCache?: boolean;
1377
+ disableSnapshot?: boolean;
1270
1378
  /**
1271
- * When `true`, writes are stalled once the manager's `buffer_size` is
1272
- * exceeded, providing a hard cap on memtable memory. When `false`,
1273
- * memtables are allowed to grow past the limit and flushes are simply
1274
- * scheduled more aggressively. Off by default to favor write throughput
1275
- * over hard memory bounding.
1379
+ * When `true`, an `IsBusy` conflict at commit time is resolved with the
1380
+ * `RETRY_NOW` sentinel value instead of being rejected. The native layer
1381
+ * may park on a VT slot before resolving, so the JS retry fires only after
1382
+ * the conflicting transaction has committed and released its write intent.
1383
+ *
1384
+ * Use together with `verificationTable: true` on the database.
1276
1385
  *
1277
1386
  * @default false
1278
1387
  */
1279
- writeBufferManagerAllowStall?: boolean;
1388
+ coordinatedRetry?: boolean;
1280
1389
  };
1281
- type RegistryStatusDB = {
1282
- path: string;
1283
- refCount: number;
1284
- columnFamilies: string[];
1285
- transactions: number;
1286
- closables: number;
1287
- locks: number;
1288
- userSharedBuffers: number;
1289
- listenerCallbacks: number;
1390
+ type NativeTransaction = {
1391
+ id: number;
1392
+ new (context: NativeDatabase, options?: NativeTransactionOptions): NativeTransaction;
1393
+ abort(): void;
1394
+ commit(resolve: (retrySignal?: number) => void, reject: (err: Error) => void): void;
1395
+ commitSync(): void;
1396
+ get(keyLengthOrKeyBuffer: number | Buffer, resolve: (value: Buffer | number) => void, reject: (err: Error) => void, txnIdIgnored?: number, expectedVersion?: number): number;
1397
+ getCount(options?: RangeOptions): number;
1398
+ getSync(keyLengthOrKeyBuffer: number | Buffer): Buffer | number | undefined;
1399
+ getTimestamp(): number;
1400
+ putSync(key: Key, value: Buffer | Uint8Array, txnId?: number): void;
1401
+ removeSync(key: Key): void;
1402
+ setTimestamp(timestamp?: number): void;
1403
+ useLog(name: string | number): TransactionLog;
1290
1404
  };
1291
- type RegistryStatus = RegistryStatusDB[];
1292
- declare const constants: {
1293
- ALWAYS_CREATE_NEW_BUFFER_FLAG: number;
1294
- NOT_IN_MEMORY_CACHE_FLAG: number;
1295
- ONLY_IF_IN_MEMORY_CACHE_FLAG: number;
1296
- POPULATE_VERSION_FLAG: number;
1297
- FRESH_VERSION_FLAG: number;
1298
- /**
1299
- * Sentinel value resolved (not rejected) by `commit()` when
1300
- * `coordinatedRetry: true` and the transaction encountered an IsBusy
1301
- * conflict. JS should retry the transaction body immediately.
1302
- */
1303
- RETRY_NOW_VALUE: number;
1304
- TRANSACTION_LOG_TOKEN: number;
1305
- TRANSACTION_LOG_ENTRY_HEADER_SIZE: number;
1306
- TRANSACTION_LOG_FILE_HEADER_SIZE: number;
1307
- ITERATOR_REVERSE_FLAG: number;
1308
- ITERATOR_INCLUSIVE_END_FLAG: number;
1309
- ITERATOR_EXCLUSIVE_START_FLAG: number;
1310
- ITERATOR_INCLUDE_VALUES_FLAG: number;
1311
- ITERATOR_NEEDS_STABLE_VALUE_BUFFER_FLAG: number;
1312
- ITERATOR_CONTEXT_IS_TRANSACTION_FLAG: number;
1313
- ITERATOR_RESULT_DONE: number;
1314
- ITERATOR_RESULT_FAST: number;
1405
+ type LogBuffer = Buffer & {
1406
+ dataView: DataView;
1407
+ logId: number;
1408
+ size: number;
1315
1409
  };
1316
- declare const NativeDatabase: NativeDatabase;
1317
- declare const NativeTransaction: NativeTransaction;
1318
- declare const TransactionLog: TransactionLog;
1319
- declare const registryStatus: () => RegistryStatus;
1320
- declare const shutdown: () => void;
1321
- declare const currentThreadId: () => number;
1322
- /**
1323
- * Advises the kernel that the file-backed pages of every mapped transaction log
1324
- * are cold (Linux MADV_COLD), so they are reclaimed first under memory pressure
1325
- * without being freed — useful during replication catch-up, where a full read of
1326
- * the logs would otherwise inflate the container's reclaimable cache toward its
1327
- * cgroup limit. No-op on kernels < 5.4, macOS, and Windows.
1328
- *
1329
- * The transaction log registry is a process-global singleton shared across all
1330
- * worker threads, so a single call cools every worker's maps. Call it on an
1331
- * interval from one thread (e.g. an `unref()`ed timer on the main thread).
1332
- *
1333
- * @returns the number of maps cooled and total file-backed bytes advised.
1334
- */
1335
- declare const coolTransactionLogs: () => {
1336
- maps: number;
1337
- bytes: number;
1410
+ type TransactionLogQueryOptions = {
1411
+ start?: number;
1412
+ end?: number;
1413
+ exactStart?: boolean;
1414
+ startFromLastFlushed?: boolean;
1415
+ readUncommitted?: boolean;
1416
+ exclusiveStart?: boolean;
1338
1417
  };
1339
- declare const stats: {
1340
- StatsLevel: {
1341
- DisableAll: number;
1342
- ExceptTickers: number;
1343
- ExceptHistogramOrTimers: number;
1344
- ExceptTimers: number;
1345
- ExceptDetailedTimers: number;
1346
- ExceptTimeForMutex: number;
1347
- All: number;
1348
- };
1418
+ type TransactionEntry = {
1419
+ timestamp: number;
1420
+ data: Buffer;
1421
+ endTxn: boolean;
1349
1422
  };
1350
- //#endregion
1351
- //#region src/transaction.d.ts
1352
1423
  /**
1353
- * Sentinel value returned by `commit()` when `coordinatedRetry: true` and the
1354
- * transaction encountered an IsBusy conflict. The native layer parks on VT
1355
- * slots and resolves only after the conflicting transaction releases its write
1356
- * intent, so callers should retry immediately without any backoff delay.
1424
+ * A position within a transaction log, identifying a log file by its sequence
1425
+ * number and a byte `offset` within that file.
1357
1426
  */
1358
- declare const RETRY_NOW: number;
1427
+ type TransactionLogPosition = {
1428
+ sequence: number;
1429
+ offset: number;
1430
+ };
1359
1431
  /**
1360
- * Provides transaction level operations to a transaction callback.
1432
+ * A detailed statistics snapshot for a single transaction log store, returned
1433
+ * by {@link TransactionLog.getStats}. All sizes are in bytes; timestamps are
1434
+ * milliseconds since the Unix epoch.
1435
+ *
1436
+ * Memory note: `memory.mappedBytes` is virtual address space — the active write
1437
+ * file is mapped at the full configured `maxFileSize` on POSIX, so it does not
1438
+ * reflect resident memory. `memory.overlayBytes` (POSIX only; 0 on Windows) is
1439
+ * the file-backed portion and is the closer proxy for real consumption.
1361
1440
  */
1362
- declare class Transaction extends DBI {
1363
- #private;
1364
- /**
1365
- * Create a new transaction.
1366
- *
1367
- * @param store - The base store interface for this transaction.
1368
- * @param options - The options for the transaction.
1369
- */
1370
- constructor(store: Store, options?: NativeTransactionOptions);
1371
- /**
1372
- * Abort the transaction.
1373
- */
1374
- abort(): void;
1375
- /**
1376
- * Commit the transaction.
1377
- *
1378
- * Returns `RETRY_NOW` when `coordinatedRetry: true` and an IsBusy conflict
1379
- * was detected. The caller should retry the transaction body immediately.
1380
- */
1381
- commit(): Promise<typeof RETRY_NOW | void>;
1382
- /**
1383
- * Commit the transaction synchronously.
1384
- */
1385
- commitSync(): void;
1386
- /**
1387
- * Returns the transaction start timestamp in seconds. Defaults to the time at which
1388
- * the transaction was created.
1389
- *
1390
- * @returns The transaction start timestamp in seconds.
1391
- */
1392
- getTimestamp(): number;
1393
- /**
1394
- * Get the transaction id.
1395
- */
1396
- get id(): number;
1397
- /**
1398
- * Set the transaction start timestamp in seconds.
1399
- *
1400
- * @param timestamp - The timestamp to set in seconds.
1401
- */
1402
- setTimestamp(timestamp?: number): void;
1403
- }
1404
- //#endregion
1405
- //#region src/util.d.ts
1406
- type MaybePromise<T> = T | Promise<T>;
1407
- //#endregion
1408
- //#region src/dbi.d.ts
1409
- interface RocksDBOptions {
1410
- /**
1411
- * When `true`, RocksDB will do some enhancements for prefetching the data.
1412
- * Defaults to `true`. Note that RocksDB defaults this to `false`.
1413
- */
1441
+ type TransactionLogStats = {
1442
+ name: string;
1443
+ path: string;
1444
+ fileCount: number;
1445
+ currentSequenceNumber: number;
1446
+ oldestSequenceNumber: number;
1447
+ totalSizeBytes: number;
1448
+ currentFileSize: number;
1449
+ pendingTransactions: number;
1450
+ uncommittedTransactions: number;
1451
+ replayGapBytes: number;
1452
+ memory: {
1453
+ mappedBytes: number;
1454
+ overlayBytes: number;
1455
+ activeMaps: number;
1456
+ };
1457
+ nextLogPosition: TransactionLogPosition;
1458
+ lastFlushedPosition: TransactionLogPosition;
1459
+ lastCommittedPosition: TransactionLogPosition | null;
1460
+ purge: {
1461
+ oldestFileAgeMs: number;
1462
+ purgeableFiles: number;
1463
+ retainedUnflushedFiles: number;
1464
+ lastPurgeMs: number;
1465
+ };
1466
+ totals: {
1467
+ transactionsWritten: number;
1468
+ entriesWritten: number;
1469
+ bytesWritten: number;
1470
+ rotations: number;
1471
+ filesPurged: number;
1472
+ bytesPurged: number;
1473
+ purgeRuns: number;
1474
+ databaseFlushes: number;
1475
+ writeFailures: number;
1476
+ };
1477
+ config: {
1478
+ maxFileSize: number;
1479
+ retentionMs: number;
1480
+ maxAgeThreshold: number;
1481
+ };
1482
+ };
1483
+ type TransactionLog = {
1484
+ new (db: NativeDatabase, name: string): TransactionLog;
1485
+ addEntry(data: Buffer | Uint8Array, txnId?: number): void;
1486
+ getLogFileSize(sequenceId?: number): number;
1487
+ getStats(): TransactionLogStats;
1488
+ name: string;
1489
+ path: string;
1490
+ query(options?: TransactionLogQueryOptions): IterableIterator<TransactionEntry>;
1491
+ _currentLogBuffer: LogBuffer;
1492
+ _findPosition(timestamp: number): number;
1493
+ _getLastCommittedPosition(): Buffer;
1494
+ _getLastFlushed(): number;
1495
+ _getMemoryMapOfFile(sequenceId: number): LogBuffer | undefined;
1496
+ _lastCommittedPosition: Float64Array;
1497
+ _logBuffers: Map<number, WeakRef<LogBuffer>>;
1498
+ };
1499
+ /**
1500
+ * Shape of options that can be passed to the native iterator constructor for
1501
+ * the rare case of advanced RocksDB ReadOptions overrides. Common iterator
1502
+ * options are passed via the bitmask `flags` argument instead.
1503
+ */
1504
+ type NativeIteratorAdvancedOptions = {
1414
1505
  adaptiveReadahead?: boolean;
1415
- /**
1416
- * When `true`, RocksDB will prefetch some data async and apply it if reads
1417
- * are sequential and its internal automatic prefetching. Defaults to
1418
- * `true`. Note that RocksDB defaults this to `false`.
1419
- */
1420
1506
  asyncIO?: boolean;
1421
- /**
1422
- * When `true`, RocksDB will auto-tune the readahead size during scans
1423
- * internally based on the block cache data when block caching is enabled,
1424
- * an end key (e.g. upper bound) is set, and prefix is the same as the start
1425
- * key. Defaults to `true`.
1426
- */
1427
1507
  autoReadaheadSize?: boolean;
1428
- /**
1429
- * When `true`, after the iterator is closed, a background job is scheduled
1430
- * to flush the job queue and delete obsolete files. Defaults to `true`.
1431
- * Note that RocksDB defaults this to `false`.
1432
- */
1433
1508
  backgroundPurgeOnIteratorCleanup?: boolean;
1434
- /**
1435
- * When `true`, the iterator will fill the block cache. Filling the block
1436
- * cache is not desirable for bulk scans and could impact eviction order.
1437
- * Defaults to `false`. Note that RocksDB defaults this to `true`.
1438
- */
1439
1509
  fillCache?: boolean;
1440
- /**
1441
- * The RocksDB readahead size. RocksDB does auto-readahead for iterators
1442
- * when there is more than two reads for a table file. The readahead
1443
- * starts at 8KB and doubles on every additional read up to 256KB. This
1444
- * option can help if most of the range scans are large and if a larger
1445
- * readahead than that enabled by auto-readahead is needed. Using a large
1446
- * readahead size (> 2MB) can typically improve the performance of forward
1447
- * iteration on spinning disks. Defaults to `0`.
1448
- */
1449
1510
  readaheadSize?: number;
1450
- /**
1451
- * When `true`, creates a "tailing iterator" which is a special iterator
1452
- * that has a view of the complete database including newly added data and
1453
- * is optimized for sequential reads. This will return records that were
1454
- * inserted into the database after the creation of the iterator. Defaults
1455
- * to `false`.
1456
- */
1457
1511
  tailing?: boolean;
1458
- }
1459
- interface RangeOptions extends RocksDBOptions {
1460
- /**
1461
- * The range end key, otherwise known as the "upper bound". Defaults to
1462
- * the last key in the database.
1463
- */
1464
- end?: Key | Uint8Array;
1465
- /**
1466
- * When `true`, the iterator will exclude the first key if it matches the start key.
1467
- * Defaults to `false`.
1468
- */
1469
- exclusiveStart?: boolean;
1470
- /**
1471
- * When `true`, the iterator will include the last key if it matches the end
1472
- * key. Defaults to `false`.
1473
- */
1474
- inclusiveEnd?: boolean;
1475
- /**
1476
- * The range start key, otherwise known as the "lower bound". Defaults to
1477
- * the first key in the database.
1478
- */
1479
- start?: Key | Uint8Array;
1480
- }
1481
- interface IteratorOptions extends RangeOptions {
1482
- /**
1483
- * The maximum number of entries to yield. When set, iteration stops after
1484
- * `limit` entries regardless of the range bounds. Values <= 0 yield nothing.
1485
- * Unset means no limit.
1486
- */
1487
- limit?: number;
1488
- /**
1489
- * A specific key to match which may result in zero, one, or many values.
1490
- */
1491
- key?: Key;
1492
- /**
1493
- * When `true`, only returns the number of values for the given query.
1494
- */
1495
- onlyCount?: boolean;
1496
- /**
1497
- * When `true`, the iterator will iterate in reverse order. Defaults to
1498
- * `false`.
1499
- */
1500
- reverse?: boolean;
1501
- /**
1502
- * When `true`, decodes and returns the value. When `false`, the value is
1503
- * omitted. Defaults to `true`.
1504
- */
1505
- values?: boolean;
1506
- /**
1507
- * When `true`, the iterator will only return the values.
1508
- */
1509
- valuesOnly?: boolean;
1510
- }
1511
- interface DBITransactional {
1512
- transaction?: Transaction;
1513
- }
1512
+ };
1514
1513
  /**
1515
- * The base class for all database operations. This base class is shared by
1516
- * `RocksDatabase` and `Transaction`.
1517
- *
1518
- * This class is not meant to be used directly.
1514
+ * The result of a single native iterator step. A number value matches one of
1515
+ * the `ITERATOR_RESULT_*` constants. The slow-path object is returned when
1516
+ * the data does not fit in the shared key/value buffers, or when the decoder
1517
+ * needs a stable value buffer.
1519
1518
  */
1520
- declare class DBI<T extends DBITransactional | unknown = unknown> {
1521
- /**
1522
- * The RocksDB context for `get()`, `put()`, and `remove()`.
1523
- */
1524
- _context: StoreContext;
1525
- /**
1526
- * The database store instance. The store instance is tied to the database
1527
- * instance and shared with transaction instances.
1528
- */
1529
- store: Store;
1530
- /**
1531
- * Initializes the DBI context.
1532
- *
1533
- * @param store - The store instance.
1534
- * @param transaction - The transaction instance.
1535
- */
1536
- constructor(store: Store, transaction?: NativeTransaction);
1537
- /**
1538
- * Adds a listener for the given key.
1539
- *
1540
- * @param event - The event name to add the listener for.
1541
- * @param callback - The callback to add.
1542
- */
1543
- addListener(event: string, callback: (...args: any[]) => void): this;
1544
- /**
1545
- * Retrieves the value for the given key, then returns the decoded value.
1546
- */
1547
- get(key: Key, options?: GetOptions & T): MaybePromise<any | undefined>;
1548
- /**
1549
- * Retrieves the binary data for the given key. This is just like `get()`,
1550
- * but bypasses the decoder.
1551
- *
1552
- * Note: Used by HDBreplication.
1553
- */
1554
- getBinary(key: Key, options?: GetOptions & T): MaybePromise<Buffer | number | undefined>;
1555
- /**
1556
- * Synchronously retrieves the binary data for the given key.
1557
- */
1558
- getBinarySync(key: Key, options?: GetOptions & T): Buffer | number | undefined;
1559
- /**
1560
- * Retrieves the binary data for the given key using a preallocated,
1561
- * reusable buffer. Data in the buffer is only valid until the next get
1562
- * operation (including cursor operations).
1563
- *
1564
- * Note: The reusable buffer slightly differs from a typical buffer:
1565
- * - `.length` is set to the size of the value
1566
- * - `.byteLength` is set to the size of the full allocated memory area for
1567
- * the buffer (usually much larger).
1568
- */
1569
- getBinaryFast(key: Key, options?: GetOptions & T): MaybePromise<Buffer | number | undefined>;
1570
- /**
1571
- * Synchronously retrieves the binary data for the given key using a
1572
- * preallocated, reusable buffer. Data in the buffer is only valid until the
1573
- * next get operation (including cursor operations).
1574
- */
1575
- getBinaryFastSync(key: Key, options?: GetOptions & T): Buffer | number | undefined;
1576
- /**
1577
- * Retrieves all keys within a range.
1578
- */
1579
- getKeys(options?: IteratorOptions & T): any | undefined;
1580
- /**
1581
- * Retrieves the number of keys within a range.
1582
- *
1583
- * @param options - The range options.
1584
- * @returns The number of keys within the range.
1585
- *
1586
- * @example
1587
- * ```typescript
1588
- * const total = db.getKeysCount();
1589
- * const range = db.getKeysCount({ start: 'a', end: 'z' });
1590
- * ```
1591
- */
1592
- getKeysCount(options?: RangeOptions & T): number;
1593
- /**
1594
- * Retrieves a range of keys and their values.
1595
- *
1596
- * @param options - The iterator options.
1597
- * @returns A range iterable.
1598
- *
1599
- * @example
1600
- * ```typescript
1601
- * for (const { key, value } of db.getRange()) {
1602
- * console.log({ key, value });
1603
- * }
1604
- *
1605
- * for (const { key, value } of db.getRange({ start: 'a', end: 'z' })) {
1606
- * console.log({ key, value });
1607
- * }
1608
- * ```
1609
- */
1610
- getRange(options?: IteratorOptions & T): any | undefined;
1611
- /**
1612
- * Synchronously retrieves the value for the given key, then returns the
1613
- * decoded value.
1614
- */
1615
- getSync(key: Key, options?: GetOptions & T): any | undefined;
1616
- /**
1617
- * Gets the number of listeners for the given key.
1618
- *
1619
- * @param event - The event name to get the listeners for.
1620
- * @returns The number of listeners for the given key.
1621
- */
1622
- listeners(event: string | BufferWithDataView): number;
1519
+ type NativeIteratorResult = number | {
1520
+ key: Buffer;
1521
+ value?: Buffer;
1522
+ };
1523
+ declare class NativeIteratorCls {
1524
+ constructor(context: StoreContext, flags: number, startKeyEnd: number, endKeyStart: number, endKeyEnd: number, options?: NativeIteratorAdvancedOptions);
1525
+ next(): NativeIteratorResult;
1526
+ return(): void;
1527
+ throw(err?: unknown): void;
1528
+ }
1529
+ type NativeDatabaseMode = "optimistic" | "pessimistic";
1530
+ type NativeDatabaseOptions = {
1531
+ dbWriteBufferSize?: number;
1532
+ disableWAL?: boolean;
1533
+ enableStats?: boolean;
1534
+ maxWriteBufferNumber?: number;
1535
+ maxWriteBufferSizeToMaintain?: number;
1536
+ mode?: NativeDatabaseMode;
1537
+ name?: string;
1538
+ noBlockCache?: boolean;
1539
+ parallelismThreads?: number;
1540
+ readOnly?: boolean;
1541
+ statsLevel?: (typeof stats.StatsLevel)[keyof typeof stats.StatsLevel];
1542
+ transactionLogMaxAgeThreshold?: number;
1543
+ transactionLogMaxSize?: number;
1544
+ transactionLogRetentionMs?: number;
1545
+ transactionLogsPath?: string;
1623
1546
  /**
1624
- * Notifies an event for the given key.
1625
- *
1626
- * @param event - The event name to emit the event for.
1627
- * @param args - The arguments to emit.
1628
- * @returns `true` if there were listeners, `false` otherwise.
1547
+ * When true, transaction writes to this column family invalidate the
1548
+ * VerificationTable slot for each written key at write time (not at
1549
+ * commit time). Enable only for column families whose records are
1550
+ * cached (e.g. the primary CF of a table). Default: false.
1629
1551
  */
1630
- notify(event: string, ...args: any[]): boolean;
1552
+ verificationTable?: boolean;
1553
+ writeBufferSize?: number;
1554
+ };
1555
+ type ResolveCallback<T> = (value: T) => void;
1556
+ type RejectCallback = (err: Error) => void;
1557
+ type UserSharedBufferCallback = () => void;
1558
+ type PurgeLogsOptions = {
1559
+ before?: number;
1560
+ destroy?: boolean;
1631
1561
  /**
1632
- * Alias for `removeListener()`.
1633
- *
1634
- * @param event - The event name to remove the listener for.
1635
- * @param callback - The callback to remove.
1562
+ * When `true`, count the entries in each purged log file (extra work) and
1563
+ * return `PurgedLog[]` instead of the default `string[]` of file paths.
1636
1564
  */
1637
- off(event: string, callback: (...args: any[]) => void): this;
1565
+ includeEntryCounts?: boolean;
1566
+ name?: string;
1567
+ };
1568
+ /**
1569
+ * A purged transaction log file and the number of entries it held, returned by
1570
+ * `purgeLogs()` when `includeEntryCounts` is `true`.
1571
+ */
1572
+ type PurgedLog = {
1573
+ path: string;
1574
+ entries: number;
1575
+ };
1576
+ type NativeDatabase = {
1577
+ new (): NativeDatabase;
1578
+ addListener(event: string, callback: (...args: any[]) => void): void;
1579
+ backup(resolve: ResolveCallback<number>, reject: RejectCallback, backupDir: string, options?: BackupOptions): void;
1580
+ backupStream(resolve: ResolveCallback<void>, reject: RejectCallback, emit: (kind: number, data: string | Uint8Array, size: number, mtime: number) => Promise<void>, options?: {
1581
+ flushBeforeBackup?: boolean;
1582
+ transactionLogs?: boolean;
1583
+ }): void;
1584
+ clear(resolve: ResolveCallback<void>, reject: RejectCallback): void;
1585
+ clearSync(): void;
1586
+ close(): void;
1587
+ compact(resolve: ResolveCallback<void>, reject: RejectCallback, start?: Key, end?: Key): void;
1588
+ compactSync(start?: Key, end?: Key): void;
1589
+ columns: string[];
1590
+ createCheckpoint(resolve: ResolveCallback<void>, reject: RejectCallback, targetPath: string): void;
1591
+ destroy(): void;
1592
+ drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
1593
+ dropSync(): void;
1594
+ flush(resolve: ResolveCallback<void>, reject: RejectCallback): void;
1595
+ flushSync(): void;
1596
+ notify(event: string | BufferWithDataView, args?: any[]): boolean;
1597
+ get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
1598
+ getCount(options?: RangeOptions, txnId?: number): number;
1599
+ getDBIntProperty(propertyName: string): number | undefined;
1600
+ getDBProperty(propertyName: string): string | undefined;
1601
+ getMonotonicTimestamp(): number;
1602
+ getOldestSnapshotTimestamp(): number;
1603
+ getStat(statName: string): number | StatsHistogramData;
1604
+ getStats(all?: false): StatsDefault;
1605
+ getStats(all: true): StatsAll;
1606
+ getSync(keyLengthOrKeyBuffer: number | Buffer, flags: number, txnId?: number, expectedVersion?: number): Buffer;
1607
+ getUserSharedBuffer(key: BufferWithDataView, defaultBuffer: ArrayBuffer, callback?: UserSharedBufferCallback): ArrayBuffer;
1608
+ hasLock(key: BufferWithDataView): boolean;
1609
+ listeners(event: string | BufferWithDataView): number;
1610
+ listLogs(): string[];
1611
+ opened: boolean;
1612
+ open(path: string, options?: NativeDatabaseOptions): void;
1613
+ populateVersion(keyLengthOrKeyBuffer: number | Buffer, version: number): void;
1614
+ purgeLogs(options: PurgeLogsOptions & {
1615
+ includeEntryCounts: true;
1616
+ }): PurgedLog[];
1617
+ purgeLogs(options?: PurgeLogsOptions & {
1618
+ includeEntryCounts?: false;
1619
+ }): string[];
1620
+ purgeLogs(options?: PurgeLogsOptions): string[] | PurgedLog[];
1621
+ putSync(key: BufferWithDataView, value: any, txnId?: number): void;
1622
+ removeListener(event: string | BufferWithDataView, callback: () => void): boolean;
1623
+ removeSync(key: BufferWithDataView, txnId?: number): void;
1624
+ setDefaultKeyBuffer(buffer: Buffer | Uint8Array | null): void;
1625
+ setDefaultValueBuffer(buffer: Buffer | Uint8Array | null): void;
1626
+ setIteratorState(buffer: Buffer | Uint8Array): void;
1627
+ tryLock(key: BufferWithDataView, callback?: () => void): boolean;
1628
+ unlock(key: BufferWithDataView): void;
1629
+ useLog(name: string): TransactionLog;
1630
+ verifyVersion(keyLengthOrKeyBuffer: number | Buffer, version: number): boolean;
1631
+ withLock(key: BufferWithDataView, callback: () => void | Promise<void>): Promise<void>;
1632
+ };
1633
+ type RocksDatabaseConfig = {
1634
+ blockCacheSize?: number;
1638
1635
  /**
1639
- * Alias for `addListener()`.
1636
+ * Number of slots in the process-global verification table. Each slot is
1637
+ * 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
1640
1638
  *
1641
- * @param event - The event name to add the listener for.
1642
- * @param callback - The callback to add.
1639
+ * Must be configured before the first database is opened. Once the table
1640
+ * is materialized, attempts to change this value will throw.
1643
1641
  */
1644
- on(event: string, callback: (...args: any[]) => void): this;
1642
+ verificationTableEntries?: number;
1643
+ compactOnClose?: boolean;
1645
1644
  /**
1646
- * Adds a one-time listener, then automatically removes it.
1645
+ * Total memtable memory limit (bytes) shared across every database opened
1646
+ * in this process. When set, RocksDB uses a single `WriteBufferManager` so
1647
+ * write buffers are bounded process-wide rather than per database. 0 (the
1648
+ * default) disables the manager.
1647
1649
  *
1648
- * @param event - The event name to add the listener for.
1649
- * @param callback - The callback to add.
1650
+ * Can be updated at runtime; the new size takes effect on the existing
1651
+ * manager via `SetBufferSize`.
1650
1652
  */
1651
- once(event: string, callback: (...args: any[]) => void): this;
1653
+ writeBufferManagerSize?: number;
1652
1654
  /**
1653
- * Stores a value for the given key.
1655
+ * When `true`, memtable memory is "charged" against the shared block cache
1656
+ * so the block cache and write buffers draw from a single pool. During
1657
+ * write bursts the cache shrinks to make room for memtables; once
1658
+ * memtables flush, the cache can grow back into the reclaimed space.
1654
1659
  *
1655
- * @param key - The key to store the value for.
1656
- * @param value - The value to store.
1657
- * @param options - The put options.
1658
- * @returns The key and value.
1660
+ * Has no effect when the block cache is disabled (size 0) or
1661
+ * `writeBufferManagerSize` is 0. Must be set on the same `config()` call
1662
+ * that first enables the manager — changing it after the manager has been
1663
+ * created has no effect on the running instance.
1659
1664
  *
1660
- * @example
1661
- * ```typescript
1662
- * await db.put('a', 'b');
1663
- * ```
1665
+ * @default false
1664
1666
  */
1665
- put(key: Key, value: any, options?: PutOptions & T): Promise<void>;
1667
+ writeBufferManagerCostToCache?: boolean;
1666
1668
  /**
1667
- * Synchronously stores a value for the given key.
1668
- *
1669
- * @param key - The key to store the value for.
1670
- * @param value - The value to store.
1671
- * @param options - The put options.
1672
- * @returns The key and value.
1669
+ * When `true`, writes are stalled once the manager's `buffer_size` is
1670
+ * exceeded, providing a hard cap on memtable memory. When `false`,
1671
+ * memtables are allowed to grow past the limit and flushes are simply
1672
+ * scheduled more aggressively. Off by default to favor write throughput
1673
+ * over hard memory bounding.
1673
1674
  *
1674
- * @example
1675
- * ```typescript
1676
- * db.putSync('a', 'b');
1677
- * ```
1675
+ * @default false
1678
1676
  */
1679
- putSync(key: Key, value: any, options?: PutOptions & T): void;
1677
+ writeBufferManagerAllowStall?: boolean;
1678
+ };
1679
+ type RegistryStatusDB = {
1680
+ path: string;
1681
+ refCount: number;
1682
+ columnFamilies: string[];
1683
+ transactions: number;
1684
+ closables: number;
1685
+ locks: number;
1686
+ userSharedBuffers: number;
1687
+ listenerCallbacks: number;
1688
+ };
1689
+ type RegistryStatus = RegistryStatusDB[];
1690
+ declare const constants: {
1691
+ ALWAYS_CREATE_NEW_BUFFER_FLAG: number;
1692
+ NOT_IN_MEMORY_CACHE_FLAG: number;
1693
+ ONLY_IF_IN_MEMORY_CACHE_FLAG: number;
1694
+ POPULATE_VERSION_FLAG: number;
1695
+ FRESH_VERSION_FLAG: number;
1680
1696
  /**
1681
- * Removes a value for the given key. If the key does not exist, it will
1682
- * not error.
1683
- *
1684
- * @param key - The key to remove the value for.
1685
- * @param options - The remove options.
1686
- * @returns The key and value.
1687
- *
1688
- * @example
1689
- * ```typescript
1690
- * await db.remove('a');
1691
- * ```
1697
+ * Sentinel value resolved (not rejected) by `commit()` when
1698
+ * `coordinatedRetry: true` and the transaction encountered an IsBusy
1699
+ * conflict. JS should retry the transaction body immediately.
1692
1700
  */
1693
- remove(key: Key, options?: T): Promise<void>;
1701
+ RETRY_NOW_VALUE: number;
1702
+ TRANSACTION_LOG_TOKEN: number;
1703
+ TRANSACTION_LOG_ENTRY_HEADER_SIZE: number;
1704
+ TRANSACTION_LOG_FILE_HEADER_SIZE: number;
1705
+ ITERATOR_REVERSE_FLAG: number;
1706
+ ITERATOR_INCLUSIVE_END_FLAG: number;
1707
+ ITERATOR_EXCLUSIVE_START_FLAG: number;
1708
+ ITERATOR_INCLUDE_VALUES_FLAG: number;
1709
+ ITERATOR_NEEDS_STABLE_VALUE_BUFFER_FLAG: number;
1710
+ ITERATOR_CONTEXT_IS_TRANSACTION_FLAG: number;
1711
+ ITERATOR_RESULT_DONE: number;
1712
+ ITERATOR_RESULT_FAST: number;
1713
+ };
1714
+ declare const NativeDatabase: NativeDatabase;
1715
+ declare const NativeTransaction: NativeTransaction;
1716
+ declare const TransactionLog: TransactionLog;
1717
+ declare const registryStatus: () => RegistryStatus;
1718
+ declare const shutdown: () => void;
1719
+ declare const currentThreadId: () => number;
1720
+ /**
1721
+ * Advises the kernel that the file-backed pages of every mapped transaction log
1722
+ * are cold (Linux MADV_COLD), so they are reclaimed first under memory pressure
1723
+ * without being freed — useful during replication catch-up, where a full read of
1724
+ * the logs would otherwise inflate the container's reclaimable cache toward its
1725
+ * cgroup limit. No-op on kernels < 5.4, macOS, and Windows.
1726
+ *
1727
+ * The transaction log registry is a process-global singleton shared across all
1728
+ * worker threads, so a single call cools every worker's maps. Call it on an
1729
+ * interval from one thread (e.g. an `unref()`ed timer on the main thread).
1730
+ *
1731
+ * @returns the number of maps cooled and total file-backed bytes advised.
1732
+ */
1733
+ declare const coolTransactionLogs: () => {
1734
+ maps: number;
1735
+ bytes: number;
1736
+ };
1737
+ /**
1738
+ * Creates a native file lock using the specified file path (`flock` on POSIX,
1739
+ * `LockFileEx` on Windows). Returns an opaque non-zero token to pass to
1740
+ * `fileLockRelease`, or `0` if another holder — in any process, container, or
1741
+ * worker thread — currently has it. Throws if `file` is missing or on a hard
1742
+ * error. The OS handle is owned entirely in native code (no fd crosses into
1743
+ * JS), and the kernel releases the lock when the handle closes, including on
1744
+ * process death.
1745
+ */
1746
+ declare const tryFileLock: (file: string) => number;
1747
+ /**
1748
+ * Releases a file lock acquired via `tryFileLock`. A no-op for
1749
+ * token `0` or an unknown token.
1750
+ */
1751
+ declare const fileLockRelease: (token: number) => void;
1752
+ declare const stats: {
1753
+ StatsLevel: {
1754
+ DisableAll: number;
1755
+ ExceptTickers: number;
1756
+ ExceptHistogramOrTimers: number;
1757
+ ExceptTimers: number;
1758
+ ExceptDetailedTimers: number;
1759
+ ExceptTimeForMutex: number;
1760
+ All: number;
1761
+ };
1762
+ };
1763
+ //#endregion
1764
+ //#region src/backup-stream.d.ts
1765
+ /**
1766
+ * Options for streaming a backup via `db.backup(stream)`.
1767
+ */
1768
+ interface BackupStreamOptions {
1694
1769
  /**
1695
- * Removes a value for the given key. If the key does not exist, it will
1696
- * not error.
1697
- *
1698
- * @param key - The key to remove the value for.
1699
- * @param options - The remove options.
1700
- * @returns The key and value.
1701
- *
1702
- * @example
1703
- * ```typescript
1704
- * db.removeSync('a');
1705
- * ```
1770
+ * Flush the memtable before streaming. Defaults to `true` when the database
1771
+ * was opened with `disableWAL` (otherwise unflushed data would be missing
1772
+ * from the stream), and `false` otherwise — matching `db.backup(dir)`.
1706
1773
  */
1707
- removeSync(key: Key, options?: T): void;
1774
+ flushBeforeBackup?: boolean;
1708
1775
  /**
1709
- * Removes an event listener. You must specify the exact same callback that was
1710
- * used in `addListener()`.
1776
+ * Gzip-compress the archive before writing it to the stream, producing a
1777
+ * `.tar.gz` stream instead of a plain `.tar`. Defaults to `false`.
1711
1778
  *
1712
- * @param event - The event name to remove the listener for.
1713
- * @param callback - The callback to remove.
1779
+ * Compression runs in the runtime's `CompressionStream`, downstream of the tar
1780
+ * encoder, so end-to-end backpressure is preserved. RocksDB SST files are
1781
+ * usually already block-compressed, so the additional savings vary with the
1782
+ * data and the configured compression.
1714
1783
  */
1715
- removeListener(event: string, callback: (value?: any) => void): boolean;
1784
+ gzip?: boolean;
1716
1785
  /**
1717
- * Get or create a transaction log instance.
1718
- *
1719
- * @param name - The name of the transaction log.
1720
- * @returns The transaction log.
1786
+ * Also stream the transaction log store as `transaction_logs/<store>/…`
1787
+ * entries (each `*.txnlog` and `txn.state` file) after the database files.
1788
+ * Defaults to `false`. Extraction reconstructs them next to the database, and
1789
+ * their mtimes are preserved so the store's age-based rotation/retention stays
1790
+ * correct.
1721
1791
  */
1722
- useLog(name: string | number): TransactionLog;
1792
+ transactionLogs?: boolean;
1723
1793
  }
1724
1794
  //#endregion
1725
1795
  //#region src/database.d.ts
@@ -1824,6 +1894,22 @@ declare class RocksDatabase extends DBI<DBITransactional> {
1824
1894
  */
1825
1895
  backup(backupDir: string, options?: BackupOptions): Promise<number>;
1826
1896
  /**
1897
+ * Streams a consistent snapshot of the entire database to a `WritableStream`
1898
+ * as a tar archive, with no intermediate copy written to disk. Resolves once
1899
+ * the stream has been fully written and closed.
1900
+ *
1901
+ * Backpressure is honored end to end, so a slow consumer (e.g. a network or
1902
+ * S3 upload) paces the backup rather than buffering it in memory. The archive
1903
+ * unpacks with any tar tool into a directory that opens as a RocksDB database.
1904
+ *
1905
+ * @example
1906
+ * ```typescript
1907
+ * const file = await fetch(uploadUrl, { method: 'PUT', body: stream });
1908
+ * await db.backup(stream); // `stream` is the request's WritableStream
1909
+ * ```
1910
+ */
1911
+ backup(stream: WritableStream<Uint8Array>, options?: BackupStreamOptions): Promise<void>;
1912
+ /**
1827
1913
  * Creates a hardlinked, point-in-time, fully independent copy of the entire
1828
1914
  * database (all column families) at `targetPath` and resolves once written.
1829
1915
  *
@@ -2251,5 +2337,5 @@ declare const versions: {
2251
2337
  "rocksdb-js": string;
2252
2338
  };
2253
2339
  //#endregion
2254
- export { type BackupInfo, type BackupOptions, DBI, DBIterator, type GetStatsMethod, type IteratorOptions, type Key, type RestoreMode, type RestoreOptions, type RocksDBStat, type RocksDBStats, RocksDatabase, type RocksDatabaseOptions, type StatsAll, type StatsAllExtras, type StatsBasics, type StatsCurated, type StatsCuratedExtras, type StatsDefault, type StatsHistogramData, type StatsValue, Store, type StoreContext, type StoreGetOptions, type StoreIteratorOptions, type StorePutOptions, type StoreRangeOptions, type StoreRemoveOptions, Transaction, type TransactionEntry, TransactionLog, type TransactionLogPosition, type TransactionLogStats, backups, constants, coolTransactionLogs, currentThreadId, parseTransactionLog, registryStatus, shutdown, stats, versions };
2340
+ export { type BackupInfo, type BackupOptions, type BackupStreamOptions, DBI, DBIterator, type GetStatsMethod, type IteratorOptions, type Key, type RestoreMode, type RestoreOptions, type RocksDBStat, type RocksDBStats, RocksDatabase, type RocksDatabaseOptions, type StatsAll, type StatsAllExtras, type StatsBasics, type StatsCurated, type StatsCuratedExtras, type StatsDefault, type StatsHistogramData, type StatsValue, Store, type StoreContext, type StoreGetOptions, type StoreIteratorOptions, type StorePutOptions, type StoreRangeOptions, type StoreRemoveOptions, Transaction, type TransactionEntry, TransactionLog, type TransactionLogPosition, type TransactionLogStats, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, tryFileLock, versions };
2255
2341
  //# sourceMappingURL=index.d.mts.map