@harperfast/rocksdb-js 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +299 -14
- package/dist/index.cjs +513 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +524 -15
- package/dist/index.d.mts +524 -15
- package/dist/index.mjs +511 -16
- package/dist/index.mjs.map +1 -1
- package/docs/stats.md +309 -268
- package/package.json +19 -20
package/dist/index.d.cts
CHANGED
|
@@ -293,6 +293,23 @@ type CompressionInfo = {
|
|
|
293
293
|
algorithm: CompressionAlgorithm;
|
|
294
294
|
level?: number;
|
|
295
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* The informational-log settings currently in effect for a database, as
|
|
298
|
+
* returned by the `logOptions` getter. These are database-wide (`DBOptions`)
|
|
299
|
+
* settings, not per-column-family.
|
|
300
|
+
*/
|
|
301
|
+
type LogOptions = {
|
|
302
|
+
/**
|
|
303
|
+
* Per-file size cap (bytes) for informational log files (`LOG` /
|
|
304
|
+
* `LOG.old.*`).
|
|
305
|
+
*/
|
|
306
|
+
maxLogFileSize: number;
|
|
307
|
+
/**
|
|
308
|
+
* Verbosity of informational logging: `0` (debug), `1` (info), `2` (warn),
|
|
309
|
+
* `3` (error), `4` (fatal), or `5` (header-only).
|
|
310
|
+
*/
|
|
311
|
+
infoLogLevel: number;
|
|
312
|
+
};
|
|
296
313
|
/**
|
|
297
314
|
* Options for the `Store` class.
|
|
298
315
|
*/
|
|
@@ -352,7 +369,9 @@ interface StoreOptions extends Omit<NativeDatabaseOptions, "compression" | "comp
|
|
|
352
369
|
randomAccessStructure?: boolean;
|
|
353
370
|
/**
|
|
354
371
|
* When `true`, the database is opened in read-only mode. Write operations
|
|
355
|
-
* will throw an error with code `ERR_DATABASE_READONLY
|
|
372
|
+
* will throw an error with code `ERR_DATABASE_READONLY`, except for
|
|
373
|
+
* `flush()`/`flushSync()`/`compact()`/`compactSync()`, which succeed as
|
|
374
|
+
* no-ops.
|
|
356
375
|
*/
|
|
357
376
|
readOnly?: boolean;
|
|
358
377
|
sharedStructuresKey?: symbol;
|
|
@@ -439,6 +458,11 @@ declare class Store {
|
|
|
439
458
|
* Encoder specific option used to signal that the data should be frozen.
|
|
440
459
|
*/
|
|
441
460
|
freezeData: boolean;
|
|
461
|
+
/**
|
|
462
|
+
* Verbosity of RocksDB's informational logging (`info_log_level`). Omit to
|
|
463
|
+
* leave RocksDB's own default.
|
|
464
|
+
*/
|
|
465
|
+
infoLogLevel?: number;
|
|
442
466
|
/**
|
|
443
467
|
* Reusable buffer for encoding keys.
|
|
444
468
|
*/
|
|
@@ -451,6 +475,16 @@ declare class Store {
|
|
|
451
475
|
* The maximum key size.
|
|
452
476
|
*/
|
|
453
477
|
maxKeySize: number;
|
|
478
|
+
/**
|
|
479
|
+
* Per-file size cap (bytes) for informational log files (`LOG` /
|
|
480
|
+
* `LOG.old.*`). Bounds total informational-log footprint to roughly `5 *
|
|
481
|
+
* maxLogFileSize` (RocksDB retains up to 5 of these files). A value of `0`
|
|
482
|
+
* is RocksDB's "single unbounded log file" mode: it disables size-based
|
|
483
|
+
* rotation, so the log can grow without limit — set it only if you want that.
|
|
484
|
+
*
|
|
485
|
+
* @default 16777216 (16MB)
|
|
486
|
+
*/
|
|
487
|
+
maxLogFileSize?: number;
|
|
454
488
|
/**
|
|
455
489
|
* The maximum number of table files RocksDB keeps open. `0` (the default)
|
|
456
490
|
* derives a budget from the effective per-process open-file limit (an
|
|
@@ -470,13 +504,26 @@ declare class Store {
|
|
|
470
504
|
/**
|
|
471
505
|
* The bytes of recent memtable history to retain in memory for transaction
|
|
472
506
|
* conflict checking. `-1` derives the value from
|
|
473
|
-
* `maxWriteBufferNumber * writeBufferSize
|
|
507
|
+
* `maxWriteBufferNumber * writeBufferSize`, except under a stalling
|
|
508
|
+
* `writeBufferManager`, where it derives `0`: retained history is charged to
|
|
509
|
+
* that manager and is only trimmable down to this target, so a target the
|
|
510
|
+
* budget cannot hold stalls writes permanently. Set a number to size it
|
|
511
|
+
* yourself against the budget and the column-family count.
|
|
474
512
|
*/
|
|
475
513
|
maxWriteBufferSizeToMaintain?: number;
|
|
476
514
|
/**
|
|
477
515
|
* The total memtable budget in bytes across all column families. When the
|
|
478
|
-
* sum of memtables reaches this size, RocksDB flushes the largest one.
|
|
479
|
-
* disables the global trigger so per-CF
|
|
516
|
+
* sum of memtables reaches this size, RocksDB flushes the largest one.
|
|
517
|
+
* Defaults to `0`, which disables the global trigger so per-CF
|
|
518
|
+
* `writeBufferSize` drives flushing.
|
|
519
|
+
*
|
|
520
|
+
* Set this only if you know your column-family count: it is one budget split
|
|
521
|
+
* across all of them, so a value that suits a few families starves many. To
|
|
522
|
+
* bound total memtable memory instead, configure a WriteBufferManager.
|
|
523
|
+
*
|
|
524
|
+
* Database-wide, so it binds when the path is first opened in this process:
|
|
525
|
+
* a later open of the same path — including from another worker thread —
|
|
526
|
+
* keeps the first opener's value rather than overriding or rejecting it.
|
|
480
527
|
*/
|
|
481
528
|
dbWriteBufferSize?: number;
|
|
482
529
|
/**
|
|
@@ -505,7 +552,9 @@ declare class Store {
|
|
|
505
552
|
pessimistic: boolean;
|
|
506
553
|
/**
|
|
507
554
|
* Whether the database is open in readonly mode. When `true`, write
|
|
508
|
-
* operations will throw an error with code `ERR_DATABASE_READONLY
|
|
555
|
+
* operations will throw an error with code `ERR_DATABASE_READONLY`, except
|
|
556
|
+
* for `flush()`/`flushSync()`/`compact()`/`compactSync()`, which succeed as
|
|
557
|
+
* no-ops.
|
|
509
558
|
*/
|
|
510
559
|
readOnly: boolean;
|
|
511
560
|
/**
|
|
@@ -532,8 +581,8 @@ declare class Store {
|
|
|
532
581
|
*/
|
|
533
582
|
transactionLogMaxAgeThreshold?: number;
|
|
534
583
|
/**
|
|
535
|
-
* The maximum size of a transaction log before
|
|
536
|
-
*
|
|
584
|
+
* The target maximum size of a transaction log before rotation. Transactions
|
|
585
|
+
* are never split across files, so one transaction may exceed this target.
|
|
537
586
|
*/
|
|
538
587
|
transactionLogMaxSize?: number;
|
|
539
588
|
/**
|
|
@@ -641,6 +690,13 @@ declare class Store {
|
|
|
641
690
|
*/
|
|
642
691
|
encodeValue(value: any): BufferWithDataView | Uint8Array;
|
|
643
692
|
get(context: StoreContext, key: Key, alwaysCreateNewBuffer?: boolean, options?: StoreGetOptions): any | undefined;
|
|
693
|
+
/**
|
|
694
|
+
* Estimates the number of keys in a range from RocksDB statistics
|
|
695
|
+
* (memtable stats + approximate SST sizes with range-local entry density)
|
|
696
|
+
* without iterating. Estimates always reflect committed state, so there is
|
|
697
|
+
* no transactional variant.
|
|
698
|
+
*/
|
|
699
|
+
estimateCount(options?: CountEstimateOptions): CountEstimate;
|
|
644
700
|
getCount(context: StoreContext, options?: StoreRangeOptions): number;
|
|
645
701
|
getKeys(context: StoreContext, options?: StoreIteratorOptions): any | undefined;
|
|
646
702
|
getKeysCount(context: StoreContext, options?: StoreRangeOptions): number;
|
|
@@ -885,6 +941,21 @@ interface RocksDBOptions {
|
|
|
885
941
|
*/
|
|
886
942
|
tailing?: boolean;
|
|
887
943
|
}
|
|
944
|
+
interface CountEstimate {
|
|
945
|
+
/**
|
|
946
|
+
* The estimated number of keys.
|
|
947
|
+
*/
|
|
948
|
+
count: number;
|
|
949
|
+
/**
|
|
950
|
+
* Heuristic 0–1 indicator of how trustworthy `count` is; exactly 1 only
|
|
951
|
+
* when the count is exact. Derived from the estimate's resolution
|
|
952
|
+
* (SST data-block / memtable sampling granularity relative to the count),
|
|
953
|
+
* the tombstone fraction of the overlapping SSTs, and — for open-ended
|
|
954
|
+
* starts — the error compounded by complement subtraction. A heuristic
|
|
955
|
+
* ordering signal, not a statistical bound.
|
|
956
|
+
*/
|
|
957
|
+
confidence: number;
|
|
958
|
+
}
|
|
888
959
|
interface RangeOptions extends RocksDBOptions {
|
|
889
960
|
/**
|
|
890
961
|
* The range end key, otherwise known as the "upper bound". Defaults to
|
|
@@ -907,6 +978,13 @@ interface RangeOptions extends RocksDBOptions {
|
|
|
907
978
|
*/
|
|
908
979
|
start?: Key | Uint8Array;
|
|
909
980
|
}
|
|
981
|
+
interface CountEstimateOptions extends RangeOptions {
|
|
982
|
+
/**
|
|
983
|
+
* Interpret `start` as the upper bound and `end` as the lower bound, as
|
|
984
|
+
* `getRange()` does for reverse iteration. Defaults to `false`.
|
|
985
|
+
*/
|
|
986
|
+
reverse?: boolean;
|
|
987
|
+
}
|
|
910
988
|
interface IteratorOptions extends RangeOptions {
|
|
911
989
|
/**
|
|
912
990
|
* The maximum number of entries to yield. When set, iteration stops after
|
|
@@ -1187,6 +1265,7 @@ type StatsBasics = {
|
|
|
1187
1265
|
"rocksdb.num-live-versions": number;
|
|
1188
1266
|
"rocksdb.current-super-version-number": number;
|
|
1189
1267
|
"rocksdb.oldest-snapshot-time": number;
|
|
1268
|
+
"rocksdb.num-snapshots": number;
|
|
1190
1269
|
"rocksdb.num-blob-files": number;
|
|
1191
1270
|
"rocksdb.total-blob-file-size": number;
|
|
1192
1271
|
"rocksdb.live-blob-file-size": number;
|
|
@@ -1450,6 +1529,34 @@ type StatsAllExtras = {
|
|
|
1450
1529
|
"rocksdb.prefetch.memory.bytes.granted": number;
|
|
1451
1530
|
"rocksdb.prefetch.memory.bytes.released": number;
|
|
1452
1531
|
"rocksdb.prefetch.memory.requests.blocked": number;
|
|
1532
|
+
"rocksdb.wal.precreate.hit": number;
|
|
1533
|
+
"rocksdb.wal.precreate.miss": number;
|
|
1534
|
+
"rocksdb.wal.precreate.waited": number;
|
|
1535
|
+
"rocksdb.wal.precreate.wait.micros": number;
|
|
1536
|
+
"rocksdb.wal.precreate.failed": number;
|
|
1537
|
+
"rocksdb.rate.limiter.bytes.read": number;
|
|
1538
|
+
"rocksdb.rate.limiter.bytes.write": number;
|
|
1539
|
+
"rocksdb.rate.limiter.requests.read": number;
|
|
1540
|
+
"rocksdb.rate.limiter.requests.write": number;
|
|
1541
|
+
"rocksdb.rate.limiter.delayed.requests.read": number;
|
|
1542
|
+
"rocksdb.rate.limiter.delayed.requests.write": number;
|
|
1543
|
+
"rocksdb.rate.limiter.total.wait.micros.read": number;
|
|
1544
|
+
"rocksdb.rate.limiter.total.wait.micros.write": number;
|
|
1545
|
+
"rocksdb.read.path.range.tombstones.inserted": number;
|
|
1546
|
+
"rocksdb.read.path.range.tombstones.discarded": number;
|
|
1547
|
+
"rocksdb.file.open.metadata.retrieved": number;
|
|
1548
|
+
"rocksdb.file.open.metadata.passed": number;
|
|
1549
|
+
"rocksdb.manifest.validation.failure.count": number;
|
|
1550
|
+
"rocksdb.flush.reason.write_buffer_full": number;
|
|
1551
|
+
"rocksdb.flush.reason.write_buffer_manager": number;
|
|
1552
|
+
"rocksdb.flush.reason.memtable_max_range_deletions": number;
|
|
1553
|
+
"rocksdb.atomic_flush.request.reason.write_buffer_full": number;
|
|
1554
|
+
"rocksdb.atomic_flush.request.reason.write_buffer_manager": number;
|
|
1555
|
+
"rocksdb.atomic_flush.request.reason.memtable_max_range_deletions": number;
|
|
1556
|
+
"rocksdb.atomic_flush.request.reason.other": number;
|
|
1557
|
+
"rocksdb.checkpoint.read.bytes": number;
|
|
1558
|
+
"rocksdb.checkpoint.write.bytes": number;
|
|
1559
|
+
"rocksdb.file.submit.async.read.fallback": number;
|
|
1453
1560
|
"rocksdb.compaction.times.cpu_micros": StatsHistogramData;
|
|
1454
1561
|
"rocksdb.subcompaction.setup.times.micros": StatsHistogramData;
|
|
1455
1562
|
"rocksdb.table.sync.micros": StatsHistogramData;
|
|
@@ -1510,6 +1617,18 @@ type StatsAllExtras = {
|
|
|
1510
1617
|
"rocksdb.multiscan.prepare.micros": StatsHistogramData;
|
|
1511
1618
|
"rocksdb.multiscan.blocks.per.prepare": StatsHistogramData;
|
|
1512
1619
|
"rocksdb.block.key.distribution.cv": StatsHistogramData;
|
|
1620
|
+
"rocksdb.ingest.external.file.prepare.micros": StatsHistogramData;
|
|
1621
|
+
"rocksdb.ingest.external.file.run.micros": StatsHistogramData;
|
|
1622
|
+
"rocksdb.iodispatcher.async.read.observed.completion.micros": StatsHistogramData;
|
|
1623
|
+
"rocksdb.iodispatcher.async.read.poll.wait.micros": StatsHistogramData;
|
|
1624
|
+
"rocksdb.iodispatcher.async.read.prefetch.lead.micros": StatsHistogramData;
|
|
1625
|
+
"rocksdb.rate.limiter.wait.micros.read": StatsHistogramData;
|
|
1626
|
+
"rocksdb.rate.limiter.wait.micros.write": StatsHistogramData;
|
|
1627
|
+
"rocksdb.flush.memtable.memory.bytes": StatsHistogramData;
|
|
1628
|
+
"rocksdb.flush.memtable.total.data.size.bytes": StatsHistogramData;
|
|
1629
|
+
"rocksdb.flush.write_buffer_full.memtable.memory.bytes": StatsHistogramData;
|
|
1630
|
+
"rocksdb.flush.write_buffer_manager.memtable.memory.bytes": StatsHistogramData;
|
|
1631
|
+
"rocksdb.open.and.compact.db.open.micros": StatsHistogramData;
|
|
1513
1632
|
};
|
|
1514
1633
|
type StatsCurated = StatsBasics & StatsCuratedExtras;
|
|
1515
1634
|
type StatsAll = StatsCurated & StatsAllExtras;
|
|
@@ -1630,6 +1749,69 @@ interface ValidateTransactionLogStoreOptions {
|
|
|
1630
1749
|
declare function validateTransactionLogStore(path: string, options?: ValidateTransactionLogStoreOptions): Promise<TransactionLogStoreValidation>;
|
|
1631
1750
|
//#endregion
|
|
1632
1751
|
//#region src/load-binding.d.ts
|
|
1752
|
+
/**
|
|
1753
|
+
* The `Error` subclass passed to `'error'` event listeners and returned by
|
|
1754
|
+
* `db.getLastError()` when RocksDB reports a background error (e.g. a write
|
|
1755
|
+
* failing at the filesystem level). A real `Error` instance (`instanceof Error`
|
|
1756
|
+
* and `instanceof BackgroundError` both hold) with the fields below. Only a
|
|
1757
|
+
* hard-or-worse error (`writesDisabled`) stops writes; a soft error is
|
|
1758
|
+
* auto-recoverable. When `writesDisabled` is `true` and the underlying condition
|
|
1759
|
+
* has cleared, call {@link RocksDatabase.resume}. See HarperFast/rocksdb-js#730.
|
|
1760
|
+
*
|
|
1761
|
+
* The runtime constructor is defined natively and exported as
|
|
1762
|
+
* {@link BackgroundError}; the same name is both a value (for `instanceof`) and
|
|
1763
|
+
* this instance type.
|
|
1764
|
+
*
|
|
1765
|
+
* @example
|
|
1766
|
+
* ```typescript
|
|
1767
|
+
* db.on('error', (err: BackgroundError) => {
|
|
1768
|
+
* if (err.writesDisabled) console.error(`writes disabled: ${err.message}`);
|
|
1769
|
+
* });
|
|
1770
|
+
* ```
|
|
1771
|
+
*/
|
|
1772
|
+
interface BackgroundError extends Error {
|
|
1773
|
+
/** Always `'BackgroundError'`. */
|
|
1774
|
+
name: string;
|
|
1775
|
+
/** Discriminator for the error class; always `'background'` here. */
|
|
1776
|
+
type: string;
|
|
1777
|
+
/**
|
|
1778
|
+
* The RocksDB `Status::Severity` as a number: 1 soft, 2 hard, 3 fatal,
|
|
1779
|
+
* 4 unrecoverable.
|
|
1780
|
+
*/
|
|
1781
|
+
severity: number;
|
|
1782
|
+
/** Human-readable severity: `'soft'`, `'hard'`, `'fatal'`, or `'unrecoverable'`. */
|
|
1783
|
+
severityName: string;
|
|
1784
|
+
/**
|
|
1785
|
+
* Whether RocksDB has disabled writes on the database in response to this
|
|
1786
|
+
* error (severity hard or worse, i.e. `severity >= 2`). Only when `true` is
|
|
1787
|
+
* {@link RocksDatabase.resume} warranted; a soft error auto-recovers and
|
|
1788
|
+
* leaves writes enabled. Distinct from opening the database in read-only
|
|
1789
|
+
* mode — this is RocksDB halting writes after a background failure.
|
|
1790
|
+
*/
|
|
1791
|
+
writesDisabled: boolean;
|
|
1792
|
+
/**
|
|
1793
|
+
* The RocksDB `BackgroundErrorReason` as a number, present when the error
|
|
1794
|
+
* originated from a reason-bearing callback (flush, compaction, etc.).
|
|
1795
|
+
*/
|
|
1796
|
+
reason?: number;
|
|
1797
|
+
/** Human-readable reason, e.g. `'flush'` or `'compaction'`. */
|
|
1798
|
+
reasonName?: string;
|
|
1799
|
+
}
|
|
1800
|
+
/**
|
|
1801
|
+
* The shape accepted by `db.setLastError(...)` to inject or reset a background
|
|
1802
|
+
* error. `message` is required; the rest default/omit as with a real error.
|
|
1803
|
+
* `type` defaults to `'background'`. Pass `null`/nothing to `setLastError` to
|
|
1804
|
+
* clear instead of an object of this shape.
|
|
1805
|
+
*/
|
|
1806
|
+
type BackgroundErrorOptions = {
|
|
1807
|
+
message: string;
|
|
1808
|
+
severity?: number;
|
|
1809
|
+
severityName?: string;
|
|
1810
|
+
writesDisabled?: boolean;
|
|
1811
|
+
reason?: number;
|
|
1812
|
+
reasonName?: string;
|
|
1813
|
+
type?: string;
|
|
1814
|
+
};
|
|
1633
1815
|
type NativeTransactionOptions = {
|
|
1634
1816
|
/**
|
|
1635
1817
|
* Whether to disable snapshots.
|
|
@@ -1663,7 +1845,7 @@ type NativeTransaction = {
|
|
|
1663
1845
|
putSync(key: Key, value: Buffer | Uint8Array, txnId?: number): void;
|
|
1664
1846
|
removeSync(key: Key): void;
|
|
1665
1847
|
setTimestamp(timestamp?: number): void;
|
|
1666
|
-
useLog(name: string | number): TransactionLog;
|
|
1848
|
+
useLog(name: string | number, jsDatabase: NativeDatabase): TransactionLog;
|
|
1667
1849
|
};
|
|
1668
1850
|
type LogBuffer = Buffer & {
|
|
1669
1851
|
dataView: DataView;
|
|
@@ -1811,6 +1993,22 @@ type NativeDatabaseOptions = {
|
|
|
1811
1993
|
dbWriteBufferSize?: number;
|
|
1812
1994
|
disableWAL?: boolean;
|
|
1813
1995
|
enableStats?: boolean;
|
|
1996
|
+
/**
|
|
1997
|
+
* Verbosity of RocksDB's informational logging (`info_log_level`): `0`
|
|
1998
|
+
* (debug), `1` (info), `2` (warn), `3` (error), `4` (fatal), or `5`
|
|
1999
|
+
* (header-only). Omit to leave RocksDB's own default (`INFO_LEVEL` in a
|
|
2000
|
+
* release build of the linked RocksDB library).
|
|
2001
|
+
*/
|
|
2002
|
+
infoLogLevel?: number;
|
|
2003
|
+
/**
|
|
2004
|
+
* Per-file size cap (bytes) for informational log files (`LOG` /
|
|
2005
|
+
* `LOG.old.*`, `max_log_file_size`). RocksDB retains up to 5 of these files
|
|
2006
|
+
* (`keep_log_file_num`, not currently exposed as an option), so total
|
|
2007
|
+
* informational-log footprint is bounded at roughly `5 * maxLogFileSize`.
|
|
2008
|
+
*
|
|
2009
|
+
* @default 16777216 (16MB)
|
|
2010
|
+
*/
|
|
2011
|
+
maxLogFileSize?: number;
|
|
1814
2012
|
maxOpenFiles?: number;
|
|
1815
2013
|
maxWriteBufferNumber?: number;
|
|
1816
2014
|
maxWriteBufferSizeToMaintain?: number;
|
|
@@ -1854,6 +2052,47 @@ type PurgedLog = {
|
|
|
1854
2052
|
path: string;
|
|
1855
2053
|
entries: number;
|
|
1856
2054
|
};
|
|
2055
|
+
type FlushOptions = {
|
|
2056
|
+
/**
|
|
2057
|
+
* Whether the flush may proceed even though it will stall writes for its duration.
|
|
2058
|
+
*
|
|
2059
|
+
* Maps to `rocksdb::FlushOptions::allow_write_stall`. RocksDB's default is `false`, which
|
|
2060
|
+
* means the opposite of what the name suggests on first read: the flush **waits** until it
|
|
2061
|
+
* can run without causing a stall. That wait has no timeout, so a database sitting in a stall
|
|
2062
|
+
* condition — immutable-memtable backlog, L0 stop trigger, pending-compaction-bytes limit, an
|
|
2063
|
+
* exhausted WriteBufferManager budget — blocks the caller for as long as the condition lasts.
|
|
2064
|
+
* `flush()` runs on the libuv threadpool, so there the wait shows up as a promise that simply
|
|
2065
|
+
* never settles while the event loop stays alive — and it parks that whole worker, not just
|
|
2066
|
+
* the caller's promise: `UV_THREADPOOL_SIZE` defaults to 4, so a handful of concurrently
|
|
2067
|
+
* stalled flushes can exhaust the pool and stall every unrelated `fs`/`dns`/`crypto` call and
|
|
2068
|
+
* cold-cache `get()` in the process, not only this database's own operations. `flushSync()`
|
|
2069
|
+
* takes the same wait on the JS thread, so it is the worse of the two here rather than the
|
|
2070
|
+
* safer one: it freezes the event loop outright instead of parking a pool worker, and it holds
|
|
2071
|
+
* the in-flight operation claim that `close()` waits on for the duration.
|
|
2072
|
+
*
|
|
2073
|
+
* Pass `true` when the flush is a durability gate the caller is blocked on and stalling
|
|
2074
|
+
* writers is the acceptable cost of it completing — decide that up front, before issuing the
|
|
2075
|
+
* call, since there is no way to cancel an in-flight `flush()` and turn `true` into an escape
|
|
2076
|
+
* hatch after the fact. It is also not a free way out of an existing stall: forcing the
|
|
2077
|
+
* memtable switch adds another L0 file to the level whose file count may be *causing* the
|
|
2078
|
+
* stop trigger, so it can prolong the condition it is meant to clear. Weigh the cost
|
|
2079
|
+
* database-wide, not per-caller: a flush covers **every column family** on the database, and
|
|
2080
|
+
* the descriptor is process-global and shared across `worker_threads`, so the stall lands on
|
|
2081
|
+
* every other column family and every other handle that opened the same path — not just the
|
|
2082
|
+
* one you called. It also relocates the hang rather than removing it: a stalled `db->Write()`
|
|
2083
|
+
* blocks the database's single `CommitWorker` thread, which dispatches every
|
|
2084
|
+
* `Transaction.commit()` in order, so the stall queues up every commit behind it — including
|
|
2085
|
+
* ones from callers that never touched flush — until the stall clears.
|
|
2086
|
+
*
|
|
2087
|
+
* Note this is a *different* knob from the `writeBufferManagerAllowStall` config, and their
|
|
2088
|
+
* polarity is nearly opposite: that one decides whether the WriteBufferManager may stall
|
|
2089
|
+
* writers at all, this one decides whether a manual flush is willing to cause a stall rather
|
|
2090
|
+
* than wait one out.
|
|
2091
|
+
*
|
|
2092
|
+
* @default false
|
|
2093
|
+
*/
|
|
2094
|
+
allowWriteStall?: boolean;
|
|
2095
|
+
};
|
|
1857
2096
|
type NativeDatabase = {
|
|
1858
2097
|
new (): NativeDatabase;
|
|
1859
2098
|
addListener(event: string, callback: (...args: any[]) => void): void;
|
|
@@ -1872,17 +2111,27 @@ type NativeDatabase = {
|
|
|
1872
2111
|
destroy(): void;
|
|
1873
2112
|
drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
1874
2113
|
dropSync(): void;
|
|
1875
|
-
flush(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
1876
|
-
flushSync(): void;
|
|
2114
|
+
flush(resolve: ResolveCallback<void>, reject: RejectCallback, options?: FlushOptions): void;
|
|
2115
|
+
flushSync(options?: FlushOptions): void;
|
|
1877
2116
|
notify(event: string | BufferWithDataView, args?: any[]): boolean;
|
|
1878
2117
|
get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
|
|
2118
|
+
estimateCount(startKey?: Buffer, endKey?: Buffer): {
|
|
2119
|
+
count: number;
|
|
2120
|
+
confidence: number;
|
|
2121
|
+
};
|
|
1879
2122
|
getCompression(): {
|
|
1880
2123
|
algorithm: string;
|
|
1881
2124
|
level?: number;
|
|
1882
2125
|
};
|
|
1883
2126
|
getCount(options?: RangeOptions, txnId?: number): number;
|
|
2127
|
+
getLastError(): BackgroundError | null;
|
|
2128
|
+
setLastError(error?: BackgroundErrorOptions | null): void;
|
|
1884
2129
|
getDBIntProperty(propertyName: string): number | undefined;
|
|
1885
2130
|
getDBProperty(propertyName: string): string | undefined;
|
|
2131
|
+
getLogOptions(): {
|
|
2132
|
+
maxLogFileSize: number;
|
|
2133
|
+
infoLogLevel: number;
|
|
2134
|
+
};
|
|
1886
2135
|
getMonotonicTimestamp(): number;
|
|
1887
2136
|
getOldestSnapshotTimestamp(): number;
|
|
1888
2137
|
getStat(statName: string): number | StatsHistogramData;
|
|
@@ -1906,12 +2155,13 @@ type NativeDatabase = {
|
|
|
1906
2155
|
putSync(key: BufferWithDataView, value: any, txnId?: number): void;
|
|
1907
2156
|
removeListener(event: string | BufferWithDataView, callback: () => void): boolean;
|
|
1908
2157
|
removeSync(key: BufferWithDataView, txnId?: number): void;
|
|
2158
|
+
resume(): void;
|
|
1909
2159
|
setDefaultKeyBuffer(buffer: Buffer | Uint8Array | null): void;
|
|
1910
2160
|
setDefaultValueBuffer(buffer: Buffer | Uint8Array | null): void;
|
|
1911
2161
|
setIteratorState(buffer: Buffer | Uint8Array): void;
|
|
1912
2162
|
tryLock(key: BufferWithDataView, callback?: () => void): boolean;
|
|
1913
2163
|
unlock(key: BufferWithDataView): void;
|
|
1914
|
-
useLog(name: string): TransactionLog;
|
|
2164
|
+
useLog(name: string, jsDatabase?: NativeDatabase): TransactionLog;
|
|
1915
2165
|
verifyVersion(keyLengthOrKeyBuffer: number | Buffer, version: number): boolean;
|
|
1916
2166
|
withLock(key: BufferWithDataView, callback: () => void | Promise<void>): Promise<void>;
|
|
1917
2167
|
};
|
|
@@ -1961,23 +2211,62 @@ type RocksDatabaseConfig = {
|
|
|
1961
2211
|
*/
|
|
1962
2212
|
writeBufferManagerAllowStall?: boolean;
|
|
1963
2213
|
};
|
|
2214
|
+
type RegistryStatusTransaction = {
|
|
2215
|
+
/** The transaction id assigned by the database descriptor. */
|
|
2216
|
+
id: number;
|
|
2217
|
+
/** Milliseconds since the transaction handle was created. */
|
|
2218
|
+
ageMs: number;
|
|
2219
|
+
};
|
|
1964
2220
|
type RegistryStatusDB = {
|
|
1965
2221
|
path: string;
|
|
1966
2222
|
refCount: number;
|
|
1967
2223
|
columnFamilies: string[];
|
|
1968
2224
|
transactions: number;
|
|
2225
|
+
/**
|
|
2226
|
+
* One entry per live transaction handle. An `ageMs` beyond any plausible request lifetime,
|
|
2227
|
+
* against a nonzero `rocksdb.num-snapshots`, identifies a handle holding back reclamation for
|
|
2228
|
+
* its whole database.
|
|
2229
|
+
*/
|
|
2230
|
+
transactionDetails: RegistryStatusTransaction[];
|
|
1969
2231
|
closables: number;
|
|
1970
2232
|
locks: number;
|
|
1971
2233
|
userSharedBuffers: number;
|
|
1972
2234
|
listenerCallbacks: number;
|
|
1973
2235
|
};
|
|
1974
2236
|
type RegistryStatus = RegistryStatusDB[];
|
|
2237
|
+
/**
|
|
2238
|
+
* The native `BackgroundError` constructor (a real `Error` subclass). Exported
|
|
2239
|
+
* as both a value — for `err instanceof BackgroundError` — and, via declaration
|
|
2240
|
+
* merging with the interface above, a type. Instances are produced by the
|
|
2241
|
+
* `'error'` event and `db.getLastError()`; consumers rarely construct their own.
|
|
2242
|
+
* The `details` param is required and typed to the instance fields so a bare
|
|
2243
|
+
* `new BackgroundError()` (which would omit `severity` / `writesDisabled` / …)
|
|
2244
|
+
* is a type error.
|
|
2245
|
+
*/
|
|
2246
|
+
declare const BackgroundError: new (details: Pick<BackgroundError, "message" | "severity" | "severityName" | "writesDisabled" | "reason" | "reasonName"> & {
|
|
2247
|
+
type?: string;
|
|
2248
|
+
}) => BackgroundError;
|
|
1975
2249
|
declare const constants: {
|
|
1976
2250
|
ALWAYS_CREATE_NEW_BUFFER_FLAG: number;
|
|
1977
2251
|
NOT_IN_MEMORY_CACHE_FLAG: number;
|
|
1978
2252
|
ONLY_IF_IN_MEMORY_CACHE_FLAG: number;
|
|
1979
2253
|
POPULATE_VERSION_FLAG: number;
|
|
1980
2254
|
FRESH_VERSION_FLAG: number;
|
|
2255
|
+
/**
|
|
2256
|
+
* Producer flag in a value's metadata word (4 big-endian bytes at offset 8, top byte `0x0E`,
|
|
2257
|
+
* low 24 bits flags), declaring that this version does NOT uniquely identify the value —
|
|
2258
|
+
* the producer has stored more than one distinct value under it.
|
|
2259
|
+
*
|
|
2260
|
+
* Set it and the VerificationTable stops treating version equality as evidence for this value:
|
|
2261
|
+
* a read never answers `FRESH_VERSION_FLAG` for it and never publishes its version to a slot,
|
|
2262
|
+
* so a consumer holding a differing cached copy at that version cannot have it confirmed.
|
|
2263
|
+
* Clear it again on the next write that gives the value a version of its own.
|
|
2264
|
+
*
|
|
2265
|
+
* Read only from values in a column family that opted into the verification table. Do not call
|
|
2266
|
+
* `populateVersion()` for a marked version: that explicit primitive never sees the value and
|
|
2267
|
+
* cannot enforce this flag.
|
|
2268
|
+
*/
|
|
2269
|
+
VERSION_NOT_UNIQUE_FLAG: number;
|
|
1981
2270
|
/**
|
|
1982
2271
|
* Sentinel value resolved (not rejected) by `commit()` when
|
|
1983
2272
|
* `coordinatedRetry: true` and the transaction encountered an IsBusy
|
|
@@ -2088,6 +2377,57 @@ interface BackupStreamOptions {
|
|
|
2088
2377
|
transactionLogs?: boolean;
|
|
2089
2378
|
}
|
|
2090
2379
|
//#endregion
|
|
2380
|
+
//#region src/count-estimator.d.ts
|
|
2381
|
+
interface CountEstimatorOptions extends CountEstimateOptions {}
|
|
2382
|
+
/**
|
|
2383
|
+
* Progressively refines a range key-count estimate as an iterator traverses
|
|
2384
|
+
* the range. The estimate starts as the pure statistical estimate
|
|
2385
|
+
* (`estimateCount`) and converges toward the exact count: the traversed
|
|
2386
|
+
* portion is exact, and the statistical estimate of the untraversed remainder
|
|
2387
|
+
* is calibrated by the observed ratio of actual-to-estimated entries over the
|
|
2388
|
+
* portion already traversed.
|
|
2389
|
+
*
|
|
2390
|
+
* The estimator never touches the iterator itself — the caller reports
|
|
2391
|
+
* progress with `advance(lastKey, count)` whenever it wants a checkpoint
|
|
2392
|
+
* (e.g. once per page), then reads `estimate()`. The caller owns the
|
|
2393
|
+
* progress contract: cursors must move monotonically through the range and
|
|
2394
|
+
* each entry must be reported once (a re-reported page inflates the count
|
|
2395
|
+
* undetectably). When traversal completes, call `finish()` so `estimate()`
|
|
2396
|
+
* returns the exact total instead of adding a block-granular remainder.
|
|
2397
|
+
*
|
|
2398
|
+
* Each `estimate()` checkpoint queries RocksDB statistics for the two range
|
|
2399
|
+
* segments (cost scales with the SSTs overlapping them, not with key count);
|
|
2400
|
+
* results are memoized per checkpoint, so repeated reads between `advance()`
|
|
2401
|
+
* calls are free.
|
|
2402
|
+
*/
|
|
2403
|
+
declare class CountEstimator {
|
|
2404
|
+
#private;
|
|
2405
|
+
constructor(store: Store, options?: CountEstimatorOptions);
|
|
2406
|
+
/**
|
|
2407
|
+
* The number of entries reported traversed so far.
|
|
2408
|
+
*/
|
|
2409
|
+
get traversed(): number;
|
|
2410
|
+
/**
|
|
2411
|
+
* Records that iteration has advanced through `count` more entries, ending
|
|
2412
|
+
* at `lastKey`. Pass `count: 0` when an empty page has no last key.
|
|
2413
|
+
*/
|
|
2414
|
+
advance(lastKey: Key | Uint8Array | undefined, count?: number): void;
|
|
2415
|
+
/**
|
|
2416
|
+
* Marks traversal of the range as complete: `estimate()` becomes the exact
|
|
2417
|
+
* traversed count.
|
|
2418
|
+
*/
|
|
2419
|
+
finish(): void;
|
|
2420
|
+
/**
|
|
2421
|
+
* Estimates the total number of entries in the full range: the exact
|
|
2422
|
+
* traversed count plus a calibrated statistical estimate of the remainder.
|
|
2423
|
+
* `confidence` is the exactness-weighted blend of the traversed portion
|
|
2424
|
+
* (exact) and the remainder's statistical confidence, so it approaches 1
|
|
2425
|
+
* as the exact portion grows (though a checkpoint can decrease when
|
|
2426
|
+
* calibration makes a large correction), and is exactly 1 after `finish()`.
|
|
2427
|
+
*/
|
|
2428
|
+
estimate(): CountEstimate;
|
|
2429
|
+
}
|
|
2430
|
+
//#endregion
|
|
2091
2431
|
//#region src/database.d.ts
|
|
2092
2432
|
type TransactionCallback<T> = (txn: Transaction, attempt: number) => T | PromiseLike<T>;
|
|
2093
2433
|
interface RocksDatabaseOptions extends StoreOptions {
|
|
@@ -2164,6 +2504,9 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
2164
2504
|
* Compacts the entire key range of the database asynchronously.
|
|
2165
2505
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
2166
2506
|
*
|
|
2507
|
+
* On a read-only database this is a no-op: arguments are still validated, but
|
|
2508
|
+
* the returned promise resolves without compacting rather than rejecting.
|
|
2509
|
+
*
|
|
2167
2510
|
* @example
|
|
2168
2511
|
* ```typescript
|
|
2169
2512
|
* const db = RocksDatabase.open('/path/to/database');
|
|
@@ -2234,6 +2577,9 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
2234
2577
|
* Compacts the entire key range of the database synchronously.
|
|
2235
2578
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
2236
2579
|
*
|
|
2580
|
+
* On a read-only database this validates its arguments and then returns
|
|
2581
|
+
* without compacting, rather than throwing.
|
|
2582
|
+
*
|
|
2237
2583
|
* @example
|
|
2238
2584
|
* ```typescript
|
|
2239
2585
|
* const db = RocksDatabase.open('/path/to/database');
|
|
@@ -2259,6 +2605,22 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
2259
2605
|
* ```
|
|
2260
2606
|
*/
|
|
2261
2607
|
get compression(): CompressionInfo;
|
|
2608
|
+
/**
|
|
2609
|
+
* The informational-log settings currently in effect for this database,
|
|
2610
|
+
* read live from RocksDB, as `{ maxLogFileSize, infoLogLevel }`. These are
|
|
2611
|
+
* database-wide settings (not per-column-family): `maxLogFileSize` bounds
|
|
2612
|
+
* each retained `LOG` / `LOG.old.*` file's size (defaults to 16MB, so with
|
|
2613
|
+
* RocksDB's `keep_log_file_num = 5` the total footprint is bounded at
|
|
2614
|
+
* roughly 80MB); `infoLogLevel` is the logging verbosity. The database must
|
|
2615
|
+
* be open.
|
|
2616
|
+
*
|
|
2617
|
+
* @example
|
|
2618
|
+
* ```typescript
|
|
2619
|
+
* const db = RocksDatabase.open('/path/to/db', { maxLogFileSize: 4 * 1024 * 1024 });
|
|
2620
|
+
* db.logOptions; // { maxLogFileSize: 4194304, infoLogLevel: 1 }
|
|
2621
|
+
* ```
|
|
2622
|
+
*/
|
|
2623
|
+
get logOptions(): LogOptions;
|
|
2262
2624
|
/**
|
|
2263
2625
|
* Set global database settings.
|
|
2264
2626
|
*
|
|
@@ -2319,15 +2681,90 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
2319
2681
|
/**
|
|
2320
2682
|
* Flushes the underlying database by performing a commit or clearing any buffered operations.
|
|
2321
2683
|
*
|
|
2684
|
+
* On a read-only database this is a no-op: the options bag is still validated, but the
|
|
2685
|
+
* returned promise resolves without flushing rather than rejecting.
|
|
2686
|
+
*
|
|
2687
|
+
* @param options - Flush options; see {@link FlushOptions.allowWriteStall} before relying on
|
|
2688
|
+
* this resolving promptly under write pressure.
|
|
2322
2689
|
* @return {void} Does not return a value.
|
|
2323
2690
|
*/
|
|
2324
|
-
flush(): Promise<void>;
|
|
2691
|
+
flush(options?: FlushOptions): Promise<void>;
|
|
2325
2692
|
/**
|
|
2326
2693
|
* Synchronously flushes the underlying database by performing a commit or clearing any buffered operations.
|
|
2327
2694
|
*
|
|
2695
|
+
* The default `allowWriteStall: false` wait is taken on the JS thread here, so it freezes the
|
|
2696
|
+
* event loop rather than parking a libuv worker — a larger blast radius than {@link flush}, not
|
|
2697
|
+
* a smaller one.
|
|
2698
|
+
*
|
|
2699
|
+
* On a read-only database this validates its options and then returns without flushing, rather
|
|
2700
|
+
* than throwing.
|
|
2701
|
+
*
|
|
2702
|
+
* @param options - Flush options; see {@link FlushOptions.allowWriteStall}.
|
|
2328
2703
|
* @return {void} Does not return a value.
|
|
2329
2704
|
*/
|
|
2330
|
-
flushSync(): void;
|
|
2705
|
+
flushSync(options?: FlushOptions): void;
|
|
2706
|
+
/**
|
|
2707
|
+
* Returns the most recent {@link BackgroundError} observed on this database, or
|
|
2708
|
+
* `null` when none has occurred. The `'error'` event is the push counterpart;
|
|
2709
|
+
* this is the pull equivalent for on-demand checks (e.g. a health probe) and
|
|
2710
|
+
* for catching an error that fired after open but before a listener was
|
|
2711
|
+
* attached. (A background error that occurs *during* the initial open is a
|
|
2712
|
+
* narrow startup window not yet captured, addressed separately.)
|
|
2713
|
+
*
|
|
2714
|
+
* Purely historical — it is not cleared by a successful {@link RocksDatabase.resume}.
|
|
2715
|
+
* When the returned error's `writesDisabled` is `true`, writes are stopped
|
|
2716
|
+
* until recovery.
|
|
2717
|
+
*
|
|
2718
|
+
* @example
|
|
2719
|
+
* ```typescript
|
|
2720
|
+
* const err = db.getLastError();
|
|
2721
|
+
* if (err?.writesDisabled) {
|
|
2722
|
+
* // ...free disk space...
|
|
2723
|
+
* db.resume();
|
|
2724
|
+
* }
|
|
2725
|
+
* ```
|
|
2726
|
+
*/
|
|
2727
|
+
getLastError(): BackgroundError | null;
|
|
2728
|
+
/**
|
|
2729
|
+
* Sets or clears the last background error, mirroring the Win32
|
|
2730
|
+
* `SetLastError`/`GetLastError` pair. Pass `null` (or no argument) to **reset**
|
|
2731
|
+
* it — {@link RocksDatabase.getLastError} then returns `null` and no event
|
|
2732
|
+
* fires; this is the intended way to clear the error after handling or
|
|
2733
|
+
* recovering it (e.g. after {@link RocksDatabase.resume}). Pass an object to
|
|
2734
|
+
* set it: it is stored and the `'error'` event fires with the reconstructed
|
|
2735
|
+
* {@link BackgroundError}. `type` defaults to `'background'`.
|
|
2736
|
+
*
|
|
2737
|
+
* @example
|
|
2738
|
+
* ```typescript
|
|
2739
|
+
* db.resume();
|
|
2740
|
+
* db.setLastError(null); // recovered — clear the historical error
|
|
2741
|
+
* ```
|
|
2742
|
+
*/
|
|
2743
|
+
setLastError(error?: BackgroundErrorOptions | null): void;
|
|
2744
|
+
/**
|
|
2745
|
+
* Attempts to recover the database from a background error by calling
|
|
2746
|
+
* RocksDB's `DB::Resume()`. When a write fails at the filesystem level (e.g. a
|
|
2747
|
+
* full disk), RocksDB stops accepting writes and this database emits an
|
|
2748
|
+
* {@link BackgroundError} via the `'error'` event. Call `resume()` after the
|
|
2749
|
+
* underlying condition has cleared — e.g. once disk space has been freed. On
|
|
2750
|
+
* success writes are accepted again; on failure (the condition has not
|
|
2751
|
+
* actually cleared) it throws and the database stays read-only. A no-op on a
|
|
2752
|
+
* healthy database.
|
|
2753
|
+
*
|
|
2754
|
+
* Runs synchronously and may briefly block, since recovery can re-flush
|
|
2755
|
+
* memtables.
|
|
2756
|
+
*
|
|
2757
|
+
* @example
|
|
2758
|
+
* ```typescript
|
|
2759
|
+
* db.on('error', (err) => {
|
|
2760
|
+
* if (err.writesDisabled) {
|
|
2761
|
+
* // ...free disk space...
|
|
2762
|
+
* db.resume();
|
|
2763
|
+
* }
|
|
2764
|
+
* });
|
|
2765
|
+
* ```
|
|
2766
|
+
*/
|
|
2767
|
+
resume(): void;
|
|
2331
2768
|
/**
|
|
2332
2769
|
* Gets a RocksDB database property as an integer.
|
|
2333
2770
|
*
|
|
@@ -2357,7 +2794,9 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
2357
2794
|
*/
|
|
2358
2795
|
getDBProperty(propertyName: string): string | undefined;
|
|
2359
2796
|
/**
|
|
2360
|
-
* Retrieves the estimated number of keys in the database.
|
|
2797
|
+
* Retrieves the estimated number of keys in the database. This is an alias
|
|
2798
|
+
* for `db.estimateCount().count`; use `estimateCount()` for range support
|
|
2799
|
+
* and a confidence indicator.
|
|
2361
2800
|
*
|
|
2362
2801
|
* @example
|
|
2363
2802
|
* ```typescript
|
|
@@ -2367,6 +2806,54 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
2367
2806
|
* ```
|
|
2368
2807
|
*/
|
|
2369
2808
|
getEstimatedKeyCount(): number;
|
|
2809
|
+
/**
|
|
2810
|
+
* Estimates the number of keys in the database, or within a key range,
|
|
2811
|
+
* returning `{ count, confidence }`. Unlike `getKeysCount()`, this never
|
|
2812
|
+
* iterates: the estimate is derived from RocksDB statistics (memtable
|
|
2813
|
+
* stats plus approximate SST sizes converted through the entry density of
|
|
2814
|
+
* the SSTs overlapping the range), so its cost scales with the number of
|
|
2815
|
+
* SSTs overlapping the range rather than the number of keys — though
|
|
2816
|
+
* reading table properties for cold files can do I/O through the table
|
|
2817
|
+
* cache, and a start-only range does the work of its complement below
|
|
2818
|
+
* `start`. Accuracy improves with range size. Resolution is bounded by SST
|
|
2819
|
+
* data-block granularity, so tiny ranges may over-report or report zero for
|
|
2820
|
+
* present keys; low `confidence` is the signal. Recently deleted or
|
|
2821
|
+
* overwritten entries may be counted until compaction. An inverted range
|
|
2822
|
+
* (`start` >= `end`) returns `{ count: 0, confidence: 1 }`.
|
|
2823
|
+
*
|
|
2824
|
+
* `confidence` is a heuristic 0–1 trust indicator (1 only when exact) —
|
|
2825
|
+
* see `CountEstimate`. Estimates always reflect committed state; writes
|
|
2826
|
+
* pending in a transaction are not included.
|
|
2827
|
+
*
|
|
2828
|
+
* @example
|
|
2829
|
+
* ```typescript
|
|
2830
|
+
* const db = RocksDatabase.open('/path/to/database');
|
|
2831
|
+
* const { count, confidence } = db.estimateCount({ start: 'a', end: 'z' });
|
|
2832
|
+
* ```
|
|
2833
|
+
*/
|
|
2834
|
+
estimateCount(options?: CountEstimateOptions): CountEstimate;
|
|
2835
|
+
/**
|
|
2836
|
+
* Creates a `CountEstimator` for progressively refining a range count
|
|
2837
|
+
* estimate while iterating the range: report progress with
|
|
2838
|
+
* `advance(lastKey, count)` (e.g. once per page of results) and
|
|
2839
|
+
* `estimate()` returns the exact traversed count plus a calibrated
|
|
2840
|
+
* estimate of the remainder, converging toward the exact total. Call
|
|
2841
|
+
* `finish()` when traversal completes to make `estimate()` exact.
|
|
2842
|
+
*
|
|
2843
|
+
* @example
|
|
2844
|
+
* ```typescript
|
|
2845
|
+
* const estimator = db.createCountEstimator({ start: 'a', end: 'z' });
|
|
2846
|
+
* let lastKey;
|
|
2847
|
+
* let pageSize = 0;
|
|
2848
|
+
* for (const { key } of db.getRange({ start: 'a', end: 'z', limit: 25 })) {
|
|
2849
|
+
* lastKey = key;
|
|
2850
|
+
* pageSize++;
|
|
2851
|
+
* }
|
|
2852
|
+
* estimator.advance(lastKey, pageSize);
|
|
2853
|
+
* const { count, confidence } = estimator.estimate();
|
|
2854
|
+
* ```
|
|
2855
|
+
*/
|
|
2856
|
+
createCountEstimator(options?: CountEstimatorOptions): CountEstimator;
|
|
2370
2857
|
/**
|
|
2371
2858
|
* Returns the current timestamp as a monotonically increasing timestamp in
|
|
2372
2859
|
* milliseconds represented as a decimal number.
|
|
@@ -2641,11 +3128,33 @@ declare function parseTransactionLog(path: string, options?: {
|
|
|
2641
3128
|
skipData?: boolean;
|
|
2642
3129
|
}): TransactionLog$1;
|
|
2643
3130
|
//#endregion
|
|
3131
|
+
//#region src/transaction-log-reader.d.ts
|
|
3132
|
+
/**
|
|
3133
|
+
* Thrown when an entry's framing is broken. `resyncPosition` is the offset where valid framing
|
|
3134
|
+
* resumes, when one was found: the frames after a mid-log break are intact and reachable, and
|
|
3135
|
+
* only the broken span between `position` and `resyncPosition` is unreadable. It is `undefined`
|
|
3136
|
+
* for a torn tail, where nothing follows the break.
|
|
3137
|
+
*
|
|
3138
|
+
* The iterator is left positioned at `resyncPosition` (or at end-of-log when there is none), so a
|
|
3139
|
+
* caller that chooses to recover the entries past the break calls `next()` again.
|
|
3140
|
+
*/
|
|
3141
|
+
declare class CorruptFrameError extends RangeError {
|
|
3142
|
+
/** Sequence number of the log file the break is in. */
|
|
3143
|
+
logId: number;
|
|
3144
|
+
/** Offset of the broken frame. */
|
|
3145
|
+
position: number;
|
|
3146
|
+
/** Offset where valid framing resumes, or `undefined` when nothing valid follows. */
|
|
3147
|
+
resyncPosition?: number;
|
|
3148
|
+
/** Bytes between the break and the resume point that cannot be read. */
|
|
3149
|
+
unreadableBytes: number;
|
|
3150
|
+
constructor(message: string, logId: number, position: number, resyncPosition: number | undefined);
|
|
3151
|
+
}
|
|
3152
|
+
//#endregion
|
|
2644
3153
|
//#region src/index.d.ts
|
|
2645
3154
|
declare const versions: {
|
|
2646
3155
|
rocksdb: string;
|
|
2647
3156
|
"rocksdb-js": string;
|
|
2648
3157
|
};
|
|
2649
3158
|
//#endregion
|
|
2650
|
-
export { type BackupInfo, type BackupOptions, type BackupStreamOptions, type CompressionAlgorithm, type CompressionInfo, type CompressionOption, 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 TransactionLogFileValidation, type TransactionLogPosition, type TransactionLogStats, type TransactionLogStoreValidation, type ValidateTransactionLogStoreOptions, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, supportedCompression, tryFileLock, validateTransactionLogStore, versions };
|
|
3159
|
+
export { BackgroundError, type BackgroundErrorOptions, type BackupInfo, type BackupOptions, type BackupStreamOptions, type CompressionAlgorithm, type CompressionInfo, type CompressionOption, CorruptFrameError, type CountEstimate, type CountEstimateOptions, CountEstimator, type CountEstimatorOptions, DBI, DBIterator, type FlushOptions, type GetStatsMethod, type IteratorOptions, type Key, type LogOptions, 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 TransactionLogFileValidation, type TransactionLogPosition, type TransactionLogStats, type TransactionLogStoreValidation, type ValidateTransactionLogStoreOptions, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, supportedCompression, tryFileLock, validateTransactionLogStore, versions };
|
|
2651
3160
|
//# sourceMappingURL=index.d.cts.map
|