@harperfast/rocksdb-js 2.5.0 → 2.6.1
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 +102 -1
- package/dist/index.cjs +94 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -3
- package/dist/index.d.mts +101 -3
- package/dist/index.mjs +94 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
package/dist/index.d.cts
CHANGED
|
@@ -256,10 +256,52 @@ type CompactOptions = {
|
|
|
256
256
|
start?: Key;
|
|
257
257
|
end?: Key;
|
|
258
258
|
};
|
|
259
|
+
/**
|
|
260
|
+
* A RocksDB block/blob compression algorithm. Which algorithms are actually
|
|
261
|
+
* available depends on the libraries the native binding was compiled with —
|
|
262
|
+
* check `supportedCompression` at runtime. `'none'` disables compression and
|
|
263
|
+
* is always available.
|
|
264
|
+
*/
|
|
265
|
+
type CompressionAlgorithm = "none" | "snappy" | "zlib" | "bzip2" | "lz4" | "lz4hc" | "xpress" | "zstd";
|
|
266
|
+
/**
|
|
267
|
+
* The `compression` open option: either an algorithm name, or an object with
|
|
268
|
+
* an algorithm and an optional level (forwarded to RocksDB's
|
|
269
|
+
* `compression_opts.level`; meaning is algorithm-specific).
|
|
270
|
+
*/
|
|
271
|
+
type CompressionOption = CompressionAlgorithm | {
|
|
272
|
+
algorithm: CompressionAlgorithm;
|
|
273
|
+
level?: number;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* The compression currently in effect for a column family, as returned by the
|
|
277
|
+
* `compression` getter. `level` is present only when a non-default compression
|
|
278
|
+
* level is configured.
|
|
279
|
+
*/
|
|
280
|
+
type CompressionInfo = {
|
|
281
|
+
algorithm: CompressionAlgorithm;
|
|
282
|
+
level?: number;
|
|
283
|
+
};
|
|
259
284
|
/**
|
|
260
285
|
* Options for the `Store` class.
|
|
261
286
|
*/
|
|
262
|
-
interface StoreOptions extends Omit<NativeDatabaseOptions, "mode" | "transactionLogRetentionMs"> {
|
|
287
|
+
interface StoreOptions extends Omit<NativeDatabaseOptions, "compression" | "compressionLevel" | "mode" | "transactionLogRetentionMs"> {
|
|
288
|
+
/**
|
|
289
|
+
* The block/blob compression algorithm for this column family. Accepts an
|
|
290
|
+
* algorithm name (`'lz4'`, `'zstd'`, `'none'`, ...) or an object with an
|
|
291
|
+
* `algorithm` and optional `level`. Applies to both SST blocks and blob
|
|
292
|
+
* files (large values). Which algorithms are available depends on the native
|
|
293
|
+
* build — see `supportedCompression`.
|
|
294
|
+
*
|
|
295
|
+
* When omitted, defaults to `lz4` if the build supports it, otherwise
|
|
296
|
+
* RocksDB's own default (Snappy when linked, else no compression).
|
|
297
|
+
* Compression is a dynamically-changeable option: reopening with a
|
|
298
|
+
* different algorithm governs subsequently written files; existing files
|
|
299
|
+
* keep their compression until rewritten by compaction. Use the
|
|
300
|
+
* `compression` getter to read the value currently in effect.
|
|
301
|
+
*
|
|
302
|
+
* @default 'lz4'
|
|
303
|
+
*/
|
|
304
|
+
compression?: CompressionOption;
|
|
263
305
|
decoder?: Encoder | null;
|
|
264
306
|
encoder?: Encoder | null;
|
|
265
307
|
encoding?: Encoding;
|
|
@@ -307,9 +349,14 @@ type ArrayBufferWithNotify = ArrayBuffer & {
|
|
|
307
349
|
* single database instance can be shared between the main `RocksDatabase`
|
|
308
350
|
* instance and the `Transaction` instance.
|
|
309
351
|
*
|
|
310
|
-
*
|
|
352
|
+
* A store is bound to a single `RocksDatabase` instance and must not be shared
|
|
353
|
+
* between `RocksDatabase` instances. Each `RocksDatabase` claims its store on
|
|
354
|
+
* construction (see `claim()`); passing a store that another `RocksDatabase`
|
|
355
|
+
* already owns throws. (Sharing with the owning database's `Transaction`
|
|
356
|
+
* instances is expected and allowed.)
|
|
311
357
|
*/
|
|
312
358
|
declare class Store {
|
|
359
|
+
#private;
|
|
313
360
|
/**
|
|
314
361
|
* The database instance.
|
|
315
362
|
*/
|
|
@@ -323,6 +370,11 @@ declare class Store {
|
|
|
323
370
|
* Whether the decoder copies the buffer when encoding values.
|
|
324
371
|
*/
|
|
325
372
|
decoderCopies: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* The compression algorithm (or `{ algorithm, level }`) requested for this
|
|
375
|
+
* store's column family. Normalized and applied when the database opens.
|
|
376
|
+
*/
|
|
377
|
+
compression?: CompressionOption;
|
|
326
378
|
/**
|
|
327
379
|
* Whether to disable the write ahead log.
|
|
328
380
|
*/
|
|
@@ -481,6 +533,13 @@ declare class Store {
|
|
|
481
533
|
* Closes the database.
|
|
482
534
|
*/
|
|
483
535
|
close(): void;
|
|
536
|
+
/**
|
|
537
|
+
* Claims this store for a `RocksDatabase`. A store is bound to a single
|
|
538
|
+
* database instance, so claiming a store that another `RocksDatabase` has
|
|
539
|
+
* already claimed throws. The claim is durable across close/reopen, so a
|
|
540
|
+
* store reused after its owner temporarily closed still throws.
|
|
541
|
+
*/
|
|
542
|
+
claim(): void;
|
|
484
543
|
/**
|
|
485
544
|
* Compacts the entire key range of the database asynchronously.
|
|
486
545
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
@@ -1684,6 +1743,18 @@ declare class NativeIteratorCls {
|
|
|
1684
1743
|
}
|
|
1685
1744
|
type NativeDatabaseMode = "optimistic" | "pessimistic";
|
|
1686
1745
|
type NativeDatabaseOptions = {
|
|
1746
|
+
/**
|
|
1747
|
+
* The friendly name of a compression algorithm compiled into this RocksDB
|
|
1748
|
+
* build (see `supportedCompression`), e.g. `'lz4'`, `'zstd'`, `'none'`. The
|
|
1749
|
+
* higher-level `StoreOptions.compression` (which also accepts an object with
|
|
1750
|
+
* a level) is normalized down to this string plus `compressionLevel`.
|
|
1751
|
+
*/
|
|
1752
|
+
compression?: string;
|
|
1753
|
+
/**
|
|
1754
|
+
* Compression level forwarded to RocksDB's `compression_opts.level`. Meaning
|
|
1755
|
+
* is algorithm-specific; omit to use the algorithm's default.
|
|
1756
|
+
*/
|
|
1757
|
+
compressionLevel?: number;
|
|
1687
1758
|
dbWriteBufferSize?: number;
|
|
1688
1759
|
disableWAL?: boolean;
|
|
1689
1760
|
enableStats?: boolean;
|
|
@@ -1752,6 +1823,10 @@ type NativeDatabase = {
|
|
|
1752
1823
|
flushSync(): void;
|
|
1753
1824
|
notify(event: string | BufferWithDataView, args?: any[]): boolean;
|
|
1754
1825
|
get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
|
|
1826
|
+
getCompression(): {
|
|
1827
|
+
algorithm: string;
|
|
1828
|
+
level?: number;
|
|
1829
|
+
};
|
|
1755
1830
|
getCount(options?: RangeOptions, txnId?: number): number;
|
|
1756
1831
|
getDBIntProperty(propertyName: string): number | undefined;
|
|
1757
1832
|
getDBProperty(propertyName: string): string | undefined;
|
|
@@ -1868,6 +1943,15 @@ declare const constants: {
|
|
|
1868
1943
|
ITERATOR_RESULT_DONE: number;
|
|
1869
1944
|
ITERATOR_RESULT_FAST: number;
|
|
1870
1945
|
};
|
|
1946
|
+
/**
|
|
1947
|
+
* The friendly names of every compression algorithm compiled into the loaded
|
|
1948
|
+
* RocksDB native binding, e.g. `['none', 'snappy', 'lz4', 'zstd']`. The set is
|
|
1949
|
+
* fixed for a given binary (it depends on which compression libraries RocksDB
|
|
1950
|
+
* was linked against), so this is a static list. `'none'` (no compression) is
|
|
1951
|
+
* always present. Use it to validate a `compression` option or to pick an
|
|
1952
|
+
* algorithm that is actually available at runtime.
|
|
1953
|
+
*/
|
|
1954
|
+
declare const supportedCompression: readonly string[];
|
|
1871
1955
|
declare const NativeDatabase: NativeDatabase;
|
|
1872
1956
|
declare const NativeTransaction: NativeTransaction;
|
|
1873
1957
|
declare const TransactionLog: TransactionLog;
|
|
@@ -2108,6 +2192,20 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
2108
2192
|
* Returns the list of column families in the RocksDB database.
|
|
2109
2193
|
*/
|
|
2110
2194
|
get columns(): string[];
|
|
2195
|
+
/**
|
|
2196
|
+
* The compression currently in effect for this database's column family, read
|
|
2197
|
+
* live from RocksDB, as `{ algorithm, level? }`. `algorithm` is a friendly
|
|
2198
|
+
* name (e.g. `'lz4'`, `'zstd'`, `'none'`); `level` is present only when a
|
|
2199
|
+
* non-default compression level is set. The database must be open. Defaults to
|
|
2200
|
+
* LZ4 when the native build supports it.
|
|
2201
|
+
*
|
|
2202
|
+
* @example
|
|
2203
|
+
* ```typescript
|
|
2204
|
+
* const db = RocksDatabase.open('/path/to/db', { compression: { algorithm: 'zstd', level: 3 } });
|
|
2205
|
+
* db.compression; // { algorithm: 'zstd', level: 3 }
|
|
2206
|
+
* ```
|
|
2207
|
+
*/
|
|
2208
|
+
get compression(): CompressionInfo;
|
|
2111
2209
|
/**
|
|
2112
2210
|
* Set global database settings.
|
|
2113
2211
|
*
|
|
@@ -2496,5 +2594,5 @@ declare const versions: {
|
|
|
2496
2594
|
"rocksdb-js": string;
|
|
2497
2595
|
};
|
|
2498
2596
|
//#endregion
|
|
2499
|
-
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 TransactionLogFileValidation, type TransactionLogPosition, type TransactionLogStats, type TransactionLogStoreValidation, type ValidateTransactionLogStoreOptions, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, tryFileLock, validateTransactionLogStore, versions };
|
|
2597
|
+
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 };
|
|
2500
2598
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -256,10 +256,52 @@ type CompactOptions = {
|
|
|
256
256
|
start?: Key;
|
|
257
257
|
end?: Key;
|
|
258
258
|
};
|
|
259
|
+
/**
|
|
260
|
+
* A RocksDB block/blob compression algorithm. Which algorithms are actually
|
|
261
|
+
* available depends on the libraries the native binding was compiled with —
|
|
262
|
+
* check `supportedCompression` at runtime. `'none'` disables compression and
|
|
263
|
+
* is always available.
|
|
264
|
+
*/
|
|
265
|
+
type CompressionAlgorithm = "none" | "snappy" | "zlib" | "bzip2" | "lz4" | "lz4hc" | "xpress" | "zstd";
|
|
266
|
+
/**
|
|
267
|
+
* The `compression` open option: either an algorithm name, or an object with
|
|
268
|
+
* an algorithm and an optional level (forwarded to RocksDB's
|
|
269
|
+
* `compression_opts.level`; meaning is algorithm-specific).
|
|
270
|
+
*/
|
|
271
|
+
type CompressionOption = CompressionAlgorithm | {
|
|
272
|
+
algorithm: CompressionAlgorithm;
|
|
273
|
+
level?: number;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* The compression currently in effect for a column family, as returned by the
|
|
277
|
+
* `compression` getter. `level` is present only when a non-default compression
|
|
278
|
+
* level is configured.
|
|
279
|
+
*/
|
|
280
|
+
type CompressionInfo = {
|
|
281
|
+
algorithm: CompressionAlgorithm;
|
|
282
|
+
level?: number;
|
|
283
|
+
};
|
|
259
284
|
/**
|
|
260
285
|
* Options for the `Store` class.
|
|
261
286
|
*/
|
|
262
|
-
interface StoreOptions extends Omit<NativeDatabaseOptions, "mode" | "transactionLogRetentionMs"> {
|
|
287
|
+
interface StoreOptions extends Omit<NativeDatabaseOptions, "compression" | "compressionLevel" | "mode" | "transactionLogRetentionMs"> {
|
|
288
|
+
/**
|
|
289
|
+
* The block/blob compression algorithm for this column family. Accepts an
|
|
290
|
+
* algorithm name (`'lz4'`, `'zstd'`, `'none'`, ...) or an object with an
|
|
291
|
+
* `algorithm` and optional `level`. Applies to both SST blocks and blob
|
|
292
|
+
* files (large values). Which algorithms are available depends on the native
|
|
293
|
+
* build — see `supportedCompression`.
|
|
294
|
+
*
|
|
295
|
+
* When omitted, defaults to `lz4` if the build supports it, otherwise
|
|
296
|
+
* RocksDB's own default (Snappy when linked, else no compression).
|
|
297
|
+
* Compression is a dynamically-changeable option: reopening with a
|
|
298
|
+
* different algorithm governs subsequently written files; existing files
|
|
299
|
+
* keep their compression until rewritten by compaction. Use the
|
|
300
|
+
* `compression` getter to read the value currently in effect.
|
|
301
|
+
*
|
|
302
|
+
* @default 'lz4'
|
|
303
|
+
*/
|
|
304
|
+
compression?: CompressionOption;
|
|
263
305
|
decoder?: Encoder | null;
|
|
264
306
|
encoder?: Encoder | null;
|
|
265
307
|
encoding?: Encoding;
|
|
@@ -307,9 +349,14 @@ type ArrayBufferWithNotify = ArrayBuffer & {
|
|
|
307
349
|
* single database instance can be shared between the main `RocksDatabase`
|
|
308
350
|
* instance and the `Transaction` instance.
|
|
309
351
|
*
|
|
310
|
-
*
|
|
352
|
+
* A store is bound to a single `RocksDatabase` instance and must not be shared
|
|
353
|
+
* between `RocksDatabase` instances. Each `RocksDatabase` claims its store on
|
|
354
|
+
* construction (see `claim()`); passing a store that another `RocksDatabase`
|
|
355
|
+
* already owns throws. (Sharing with the owning database's `Transaction`
|
|
356
|
+
* instances is expected and allowed.)
|
|
311
357
|
*/
|
|
312
358
|
declare class Store {
|
|
359
|
+
#private;
|
|
313
360
|
/**
|
|
314
361
|
* The database instance.
|
|
315
362
|
*/
|
|
@@ -323,6 +370,11 @@ declare class Store {
|
|
|
323
370
|
* Whether the decoder copies the buffer when encoding values.
|
|
324
371
|
*/
|
|
325
372
|
decoderCopies: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* The compression algorithm (or `{ algorithm, level }`) requested for this
|
|
375
|
+
* store's column family. Normalized and applied when the database opens.
|
|
376
|
+
*/
|
|
377
|
+
compression?: CompressionOption;
|
|
326
378
|
/**
|
|
327
379
|
* Whether to disable the write ahead log.
|
|
328
380
|
*/
|
|
@@ -481,6 +533,13 @@ declare class Store {
|
|
|
481
533
|
* Closes the database.
|
|
482
534
|
*/
|
|
483
535
|
close(): void;
|
|
536
|
+
/**
|
|
537
|
+
* Claims this store for a `RocksDatabase`. A store is bound to a single
|
|
538
|
+
* database instance, so claiming a store that another `RocksDatabase` has
|
|
539
|
+
* already claimed throws. The claim is durable across close/reopen, so a
|
|
540
|
+
* store reused after its owner temporarily closed still throws.
|
|
541
|
+
*/
|
|
542
|
+
claim(): void;
|
|
484
543
|
/**
|
|
485
544
|
* Compacts the entire key range of the database asynchronously.
|
|
486
545
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
@@ -1684,6 +1743,18 @@ declare class NativeIteratorCls {
|
|
|
1684
1743
|
}
|
|
1685
1744
|
type NativeDatabaseMode = "optimistic" | "pessimistic";
|
|
1686
1745
|
type NativeDatabaseOptions = {
|
|
1746
|
+
/**
|
|
1747
|
+
* The friendly name of a compression algorithm compiled into this RocksDB
|
|
1748
|
+
* build (see `supportedCompression`), e.g. `'lz4'`, `'zstd'`, `'none'`. The
|
|
1749
|
+
* higher-level `StoreOptions.compression` (which also accepts an object with
|
|
1750
|
+
* a level) is normalized down to this string plus `compressionLevel`.
|
|
1751
|
+
*/
|
|
1752
|
+
compression?: string;
|
|
1753
|
+
/**
|
|
1754
|
+
* Compression level forwarded to RocksDB's `compression_opts.level`. Meaning
|
|
1755
|
+
* is algorithm-specific; omit to use the algorithm's default.
|
|
1756
|
+
*/
|
|
1757
|
+
compressionLevel?: number;
|
|
1687
1758
|
dbWriteBufferSize?: number;
|
|
1688
1759
|
disableWAL?: boolean;
|
|
1689
1760
|
enableStats?: boolean;
|
|
@@ -1752,6 +1823,10 @@ type NativeDatabase = {
|
|
|
1752
1823
|
flushSync(): void;
|
|
1753
1824
|
notify(event: string | BufferWithDataView, args?: any[]): boolean;
|
|
1754
1825
|
get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
|
|
1826
|
+
getCompression(): {
|
|
1827
|
+
algorithm: string;
|
|
1828
|
+
level?: number;
|
|
1829
|
+
};
|
|
1755
1830
|
getCount(options?: RangeOptions, txnId?: number): number;
|
|
1756
1831
|
getDBIntProperty(propertyName: string): number | undefined;
|
|
1757
1832
|
getDBProperty(propertyName: string): string | undefined;
|
|
@@ -1868,6 +1943,15 @@ declare const constants: {
|
|
|
1868
1943
|
ITERATOR_RESULT_DONE: number;
|
|
1869
1944
|
ITERATOR_RESULT_FAST: number;
|
|
1870
1945
|
};
|
|
1946
|
+
/**
|
|
1947
|
+
* The friendly names of every compression algorithm compiled into the loaded
|
|
1948
|
+
* RocksDB native binding, e.g. `['none', 'snappy', 'lz4', 'zstd']`. The set is
|
|
1949
|
+
* fixed for a given binary (it depends on which compression libraries RocksDB
|
|
1950
|
+
* was linked against), so this is a static list. `'none'` (no compression) is
|
|
1951
|
+
* always present. Use it to validate a `compression` option or to pick an
|
|
1952
|
+
* algorithm that is actually available at runtime.
|
|
1953
|
+
*/
|
|
1954
|
+
declare const supportedCompression: readonly string[];
|
|
1871
1955
|
declare const NativeDatabase: NativeDatabase;
|
|
1872
1956
|
declare const NativeTransaction: NativeTransaction;
|
|
1873
1957
|
declare const TransactionLog: TransactionLog;
|
|
@@ -2108,6 +2192,20 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
2108
2192
|
* Returns the list of column families in the RocksDB database.
|
|
2109
2193
|
*/
|
|
2110
2194
|
get columns(): string[];
|
|
2195
|
+
/**
|
|
2196
|
+
* The compression currently in effect for this database's column family, read
|
|
2197
|
+
* live from RocksDB, as `{ algorithm, level? }`. `algorithm` is a friendly
|
|
2198
|
+
* name (e.g. `'lz4'`, `'zstd'`, `'none'`); `level` is present only when a
|
|
2199
|
+
* non-default compression level is set. The database must be open. Defaults to
|
|
2200
|
+
* LZ4 when the native build supports it.
|
|
2201
|
+
*
|
|
2202
|
+
* @example
|
|
2203
|
+
* ```typescript
|
|
2204
|
+
* const db = RocksDatabase.open('/path/to/db', { compression: { algorithm: 'zstd', level: 3 } });
|
|
2205
|
+
* db.compression; // { algorithm: 'zstd', level: 3 }
|
|
2206
|
+
* ```
|
|
2207
|
+
*/
|
|
2208
|
+
get compression(): CompressionInfo;
|
|
2111
2209
|
/**
|
|
2112
2210
|
* Set global database settings.
|
|
2113
2211
|
*
|
|
@@ -2496,5 +2594,5 @@ declare const versions: {
|
|
|
2496
2594
|
"rocksdb-js": string;
|
|
2497
2595
|
};
|
|
2498
2596
|
//#endregion
|
|
2499
|
-
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 TransactionLogFileValidation, type TransactionLogPosition, type TransactionLogStats, type TransactionLogStoreValidation, type ValidateTransactionLogStoreOptions, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, tryFileLock, validateTransactionLogStore, versions };
|
|
2597
|
+
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 };
|
|
2500
2598
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -62,6 +62,15 @@ const removeGlobalListener = binding.removeListener;
|
|
|
62
62
|
const globalListenerCount = binding.listenerCount;
|
|
63
63
|
const globalNotify = binding.notify;
|
|
64
64
|
const constants = binding.constants;
|
|
65
|
+
/**
|
|
66
|
+
* The friendly names of every compression algorithm compiled into the loaded
|
|
67
|
+
* RocksDB native binding, e.g. `['none', 'snappy', 'lz4', 'zstd']`. The set is
|
|
68
|
+
* fixed for a given binary (it depends on which compression libraries RocksDB
|
|
69
|
+
* was linked against), so this is a static list. `'none'` (no compression) is
|
|
70
|
+
* always present. Use it to validate a `compression` option or to pick an
|
|
71
|
+
* algorithm that is actually available at runtime.
|
|
72
|
+
*/
|
|
73
|
+
const supportedCompression = Object.freeze(binding.supportedCompression);
|
|
65
74
|
const NativeDatabase = binding.Database;
|
|
66
75
|
const NativeIterator = binding.Iterator;
|
|
67
76
|
const NativeTransaction = binding.Transaction;
|
|
@@ -1203,13 +1212,55 @@ const ITERATOR_STATE = new Uint32Array(ITERATOR_STATE_BUFFER.buffer, ITERATOR_ST
|
|
|
1203
1212
|
const MAX_KEY_SIZE = 1024 * 1024;
|
|
1204
1213
|
const SAVE_BUFFER_SIZE = 8192;
|
|
1205
1214
|
/**
|
|
1215
|
+
* Normalizes the public `compression` option into the primitive fields the
|
|
1216
|
+
* native layer expects. When `option` is omitted, or is an object without an
|
|
1217
|
+
* `algorithm`, returns an empty object and lets the native layer apply the
|
|
1218
|
+
* default (LZ4 when the build supports it, else RocksDB's own default).
|
|
1219
|
+
* Throws a `TypeError` for a malformed option and an
|
|
1220
|
+
* `Error` for an algorithm that isn't supported by this build.
|
|
1221
|
+
*/
|
|
1222
|
+
function normalizeCompression(option) {
|
|
1223
|
+
if (option === void 0 || option === null) return {};
|
|
1224
|
+
let algorithm;
|
|
1225
|
+
let level;
|
|
1226
|
+
if (typeof option === "string") algorithm = option;
|
|
1227
|
+
else if (typeof option === "object" && !Array.isArray(option)) {
|
|
1228
|
+
if (option.algorithm === void 0 || option.algorithm === null) {
|
|
1229
|
+
if (option.level !== void 0 && option.level !== null) throw new TypeError("Compression level cannot be specified without an algorithm");
|
|
1230
|
+
return {};
|
|
1231
|
+
}
|
|
1232
|
+
algorithm = option.algorithm;
|
|
1233
|
+
if (option.level !== void 0 && option.level !== null) {
|
|
1234
|
+
const raw = option.level;
|
|
1235
|
+
const coerced = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
|
|
1236
|
+
if (!Number.isInteger(coerced) || coerced < -2147483648 || coerced > 2147483647) throw new TypeError(`compression level must be a 32-bit integer, got ${JSON.stringify(option.level)}`);
|
|
1237
|
+
level = coerced;
|
|
1238
|
+
}
|
|
1239
|
+
} else throw new TypeError("compression must be an algorithm name or an { algorithm, level } object");
|
|
1240
|
+
if (!supportedCompression.includes(algorithm)) throw new Error(`Unsupported compression algorithm "${algorithm}". This build supports: ${supportedCompression.join(", ")}`);
|
|
1241
|
+
return {
|
|
1242
|
+
compression: algorithm,
|
|
1243
|
+
compressionLevel: level
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1206
1247
|
* A store wraps the `NativeDatabase` binding and database settings so that a
|
|
1207
1248
|
* single database instance can be shared between the main `RocksDatabase`
|
|
1208
1249
|
* instance and the `Transaction` instance.
|
|
1209
1250
|
*
|
|
1210
|
-
*
|
|
1251
|
+
* A store is bound to a single `RocksDatabase` instance and must not be shared
|
|
1252
|
+
* between `RocksDatabase` instances. Each `RocksDatabase` claims its store on
|
|
1253
|
+
* construction (see `claim()`); passing a store that another `RocksDatabase`
|
|
1254
|
+
* already owns throws. (Sharing with the owning database's `Transaction`
|
|
1255
|
+
* instances is expected and allowed.)
|
|
1211
1256
|
*/
|
|
1212
1257
|
var Store = class {
|
|
1258
|
+
/**
|
|
1259
|
+
* Whether a `RocksDatabase` has claimed this store. Durable across
|
|
1260
|
+
* close/reopen (unlike the handle's open state), so a store reused after its
|
|
1261
|
+
* owner temporarily closed is still recognized as in-use. See `claim()`.
|
|
1262
|
+
*/
|
|
1263
|
+
#claimed = false;
|
|
1213
1264
|
/**
|
|
1214
1265
|
* The database instance.
|
|
1215
1266
|
*/
|
|
@@ -1224,6 +1275,11 @@ var Store = class {
|
|
|
1224
1275
|
*/
|
|
1225
1276
|
decoderCopies = false;
|
|
1226
1277
|
/**
|
|
1278
|
+
* The compression algorithm (or `{ algorithm, level }`) requested for this
|
|
1279
|
+
* store's column family. Normalized and applied when the database opens.
|
|
1280
|
+
*/
|
|
1281
|
+
compression;
|
|
1282
|
+
/**
|
|
1227
1283
|
* Whether to disable the write ahead log.
|
|
1228
1284
|
*/
|
|
1229
1285
|
disableWAL;
|
|
@@ -1381,6 +1437,7 @@ var Store = class {
|
|
|
1381
1437
|
if (options !== void 0 && options !== null && typeof options !== "object") throw new TypeError("Database options must be an object");
|
|
1382
1438
|
const { keyEncoding, readKey, writeKey } = initKeyEncoder(options?.keyEncoding, options?.keyEncoder);
|
|
1383
1439
|
this.db = new NativeDatabase();
|
|
1440
|
+
this.compression = options?.compression;
|
|
1384
1441
|
this.dbWriteBufferSize = options?.dbWriteBufferSize;
|
|
1385
1442
|
this.decoder = options?.decoder ?? null;
|
|
1386
1443
|
this.disableWAL = options?.disableWAL ?? false;
|
|
@@ -1420,6 +1477,16 @@ var Store = class {
|
|
|
1420
1477
|
this.db.close();
|
|
1421
1478
|
}
|
|
1422
1479
|
/**
|
|
1480
|
+
* Claims this store for a `RocksDatabase`. A store is bound to a single
|
|
1481
|
+
* database instance, so claiming a store that another `RocksDatabase` has
|
|
1482
|
+
* already claimed throws. The claim is durable across close/reopen, so a
|
|
1483
|
+
* store reused after its owner temporarily closed still throws.
|
|
1484
|
+
*/
|
|
1485
|
+
claim() {
|
|
1486
|
+
if (this.#claimed) throw new Error("Store is already in use by another RocksDatabase instance");
|
|
1487
|
+
this.#claimed = true;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1423
1490
|
* Compacts the entire key range of the database asynchronously.
|
|
1424
1491
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
1425
1492
|
*
|
|
@@ -1681,7 +1748,10 @@ var Store = class {
|
|
|
1681
1748
|
*/
|
|
1682
1749
|
open() {
|
|
1683
1750
|
if (this.db.opened) return true;
|
|
1751
|
+
const { compression, compressionLevel } = normalizeCompression(this.compression);
|
|
1684
1752
|
this.db.open(this.path, {
|
|
1753
|
+
compression,
|
|
1754
|
+
compressionLevel,
|
|
1685
1755
|
dbWriteBufferSize: this.dbWriteBufferSize,
|
|
1686
1756
|
disableWAL: this.disableWAL,
|
|
1687
1757
|
enableStats: this.enableStats,
|
|
@@ -1983,9 +2053,12 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1983
2053
|
*/
|
|
1984
2054
|
#name;
|
|
1985
2055
|
constructor(pathOrStore, options) {
|
|
1986
|
-
|
|
1987
|
-
|
|
2056
|
+
let store;
|
|
2057
|
+
if (typeof pathOrStore === "string") store = new Store(pathOrStore, options);
|
|
2058
|
+
else if (pathOrStore instanceof Store) store = pathOrStore;
|
|
1988
2059
|
else throw new TypeError("Invalid database path or store");
|
|
2060
|
+
store.claim();
|
|
2061
|
+
super(store);
|
|
1989
2062
|
this.#name = options?.name ?? "default";
|
|
1990
2063
|
}
|
|
1991
2064
|
/**
|
|
@@ -2099,6 +2172,22 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
2099
2172
|
return this.store.db.columns;
|
|
2100
2173
|
}
|
|
2101
2174
|
/**
|
|
2175
|
+
* The compression currently in effect for this database's column family, read
|
|
2176
|
+
* live from RocksDB, as `{ algorithm, level? }`. `algorithm` is a friendly
|
|
2177
|
+
* name (e.g. `'lz4'`, `'zstd'`, `'none'`); `level` is present only when a
|
|
2178
|
+
* non-default compression level is set. The database must be open. Defaults to
|
|
2179
|
+
* LZ4 when the native build supports it.
|
|
2180
|
+
*
|
|
2181
|
+
* @example
|
|
2182
|
+
* ```typescript
|
|
2183
|
+
* const db = RocksDatabase.open('/path/to/db', { compression: { algorithm: 'zstd', level: 3 } });
|
|
2184
|
+
* db.compression; // { algorithm: 'zstd', level: 3 }
|
|
2185
|
+
* ```
|
|
2186
|
+
*/
|
|
2187
|
+
get compression() {
|
|
2188
|
+
return this.store.db.getCompression();
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2102
2191
|
* Set global database settings.
|
|
2103
2192
|
*
|
|
2104
2193
|
* @param options - The options for the database.
|
|
@@ -2928,9 +3017,9 @@ function loadLastPosition(transactionLog, readUncommitted) {
|
|
|
2928
3017
|
//#region src/index.ts
|
|
2929
3018
|
const versions = {
|
|
2930
3019
|
rocksdb: version,
|
|
2931
|
-
"rocksdb-js": "2.
|
|
3020
|
+
"rocksdb-js": "2.6.1"
|
|
2932
3021
|
};
|
|
2933
3022
|
|
|
2934
3023
|
//#endregion
|
|
2935
|
-
export { DBI, DBIterator, RocksDatabase, Store, Transaction, TransactionLog, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, tryFileLock, validateTransactionLogStore, versions };
|
|
3024
|
+
export { DBI, DBIterator, RocksDatabase, Store, Transaction, TransactionLog, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, supportedCompression, tryFileLock, validateTransactionLogStore, versions };
|
|
2936
3025
|
//# sourceMappingURL=index.mjs.map
|