@harperfast/rocksdb-js 2.5.0 → 2.6.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 +102 -1
- package/dist/index.cjs +89 -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 +89 -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,50 @@ 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, returns an empty object and
|
|
1217
|
+
* lets the native layer apply the default (LZ4 when the build supports it, else
|
|
1218
|
+
* RocksDB's own default). Throws a `TypeError` for a malformed option and an
|
|
1219
|
+
* `Error` for an algorithm that isn't supported by this build.
|
|
1220
|
+
*/
|
|
1221
|
+
function normalizeCompression(option) {
|
|
1222
|
+
if (option === void 0 || option === null) return {};
|
|
1223
|
+
let algorithm;
|
|
1224
|
+
let level;
|
|
1225
|
+
if (typeof option === "string") algorithm = option;
|
|
1226
|
+
else if (typeof option === "object" && option.algorithm !== void 0) {
|
|
1227
|
+
algorithm = option.algorithm;
|
|
1228
|
+
if (option.level !== void 0 && option.level !== null) {
|
|
1229
|
+
const raw = option.level;
|
|
1230
|
+
const coerced = typeof raw === "number" ? raw : typeof raw === "string" && raw.trim() !== "" ? Number(raw) : NaN;
|
|
1231
|
+
if (!Number.isInteger(coerced) || coerced < -2147483648 || coerced > 2147483647) throw new TypeError(`compression level must be a 32-bit integer, got ${JSON.stringify(option.level)}`);
|
|
1232
|
+
level = coerced;
|
|
1233
|
+
}
|
|
1234
|
+
} else throw new TypeError("compression must be an algorithm name or an { algorithm, level } object");
|
|
1235
|
+
if (!supportedCompression.includes(algorithm)) throw new Error(`Unsupported compression algorithm "${algorithm}". This build supports: ${supportedCompression.join(", ")}`);
|
|
1236
|
+
return {
|
|
1237
|
+
compression: algorithm,
|
|
1238
|
+
compressionLevel: level
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1206
1242
|
* A store wraps the `NativeDatabase` binding and database settings so that a
|
|
1207
1243
|
* single database instance can be shared between the main `RocksDatabase`
|
|
1208
1244
|
* instance and the `Transaction` instance.
|
|
1209
1245
|
*
|
|
1210
|
-
*
|
|
1246
|
+
* A store is bound to a single `RocksDatabase` instance and must not be shared
|
|
1247
|
+
* between `RocksDatabase` instances. Each `RocksDatabase` claims its store on
|
|
1248
|
+
* construction (see `claim()`); passing a store that another `RocksDatabase`
|
|
1249
|
+
* already owns throws. (Sharing with the owning database's `Transaction`
|
|
1250
|
+
* instances is expected and allowed.)
|
|
1211
1251
|
*/
|
|
1212
1252
|
var Store = class {
|
|
1253
|
+
/**
|
|
1254
|
+
* Whether a `RocksDatabase` has claimed this store. Durable across
|
|
1255
|
+
* close/reopen (unlike the handle's open state), so a store reused after its
|
|
1256
|
+
* owner temporarily closed is still recognized as in-use. See `claim()`.
|
|
1257
|
+
*/
|
|
1258
|
+
#claimed = false;
|
|
1213
1259
|
/**
|
|
1214
1260
|
* The database instance.
|
|
1215
1261
|
*/
|
|
@@ -1224,6 +1270,11 @@ var Store = class {
|
|
|
1224
1270
|
*/
|
|
1225
1271
|
decoderCopies = false;
|
|
1226
1272
|
/**
|
|
1273
|
+
* The compression algorithm (or `{ algorithm, level }`) requested for this
|
|
1274
|
+
* store's column family. Normalized and applied when the database opens.
|
|
1275
|
+
*/
|
|
1276
|
+
compression;
|
|
1277
|
+
/**
|
|
1227
1278
|
* Whether to disable the write ahead log.
|
|
1228
1279
|
*/
|
|
1229
1280
|
disableWAL;
|
|
@@ -1381,6 +1432,7 @@ var Store = class {
|
|
|
1381
1432
|
if (options !== void 0 && options !== null && typeof options !== "object") throw new TypeError("Database options must be an object");
|
|
1382
1433
|
const { keyEncoding, readKey, writeKey } = initKeyEncoder(options?.keyEncoding, options?.keyEncoder);
|
|
1383
1434
|
this.db = new NativeDatabase();
|
|
1435
|
+
this.compression = options?.compression;
|
|
1384
1436
|
this.dbWriteBufferSize = options?.dbWriteBufferSize;
|
|
1385
1437
|
this.decoder = options?.decoder ?? null;
|
|
1386
1438
|
this.disableWAL = options?.disableWAL ?? false;
|
|
@@ -1420,6 +1472,16 @@ var Store = class {
|
|
|
1420
1472
|
this.db.close();
|
|
1421
1473
|
}
|
|
1422
1474
|
/**
|
|
1475
|
+
* Claims this store for a `RocksDatabase`. A store is bound to a single
|
|
1476
|
+
* database instance, so claiming a store that another `RocksDatabase` has
|
|
1477
|
+
* already claimed throws. The claim is durable across close/reopen, so a
|
|
1478
|
+
* store reused after its owner temporarily closed still throws.
|
|
1479
|
+
*/
|
|
1480
|
+
claim() {
|
|
1481
|
+
if (this.#claimed) throw new Error("Store is already in use by another RocksDatabase instance");
|
|
1482
|
+
this.#claimed = true;
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1423
1485
|
* Compacts the entire key range of the database asynchronously.
|
|
1424
1486
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
1425
1487
|
*
|
|
@@ -1681,7 +1743,10 @@ var Store = class {
|
|
|
1681
1743
|
*/
|
|
1682
1744
|
open() {
|
|
1683
1745
|
if (this.db.opened) return true;
|
|
1746
|
+
const { compression, compressionLevel } = normalizeCompression(this.compression);
|
|
1684
1747
|
this.db.open(this.path, {
|
|
1748
|
+
compression,
|
|
1749
|
+
compressionLevel,
|
|
1685
1750
|
dbWriteBufferSize: this.dbWriteBufferSize,
|
|
1686
1751
|
disableWAL: this.disableWAL,
|
|
1687
1752
|
enableStats: this.enableStats,
|
|
@@ -1983,9 +2048,12 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1983
2048
|
*/
|
|
1984
2049
|
#name;
|
|
1985
2050
|
constructor(pathOrStore, options) {
|
|
1986
|
-
|
|
1987
|
-
|
|
2051
|
+
let store;
|
|
2052
|
+
if (typeof pathOrStore === "string") store = new Store(pathOrStore, options);
|
|
2053
|
+
else if (pathOrStore instanceof Store) store = pathOrStore;
|
|
1988
2054
|
else throw new TypeError("Invalid database path or store");
|
|
2055
|
+
store.claim();
|
|
2056
|
+
super(store);
|
|
1989
2057
|
this.#name = options?.name ?? "default";
|
|
1990
2058
|
}
|
|
1991
2059
|
/**
|
|
@@ -2099,6 +2167,22 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
2099
2167
|
return this.store.db.columns;
|
|
2100
2168
|
}
|
|
2101
2169
|
/**
|
|
2170
|
+
* The compression currently in effect for this database's column family, read
|
|
2171
|
+
* live from RocksDB, as `{ algorithm, level? }`. `algorithm` is a friendly
|
|
2172
|
+
* name (e.g. `'lz4'`, `'zstd'`, `'none'`); `level` is present only when a
|
|
2173
|
+
* non-default compression level is set. The database must be open. Defaults to
|
|
2174
|
+
* LZ4 when the native build supports it.
|
|
2175
|
+
*
|
|
2176
|
+
* @example
|
|
2177
|
+
* ```typescript
|
|
2178
|
+
* const db = RocksDatabase.open('/path/to/db', { compression: { algorithm: 'zstd', level: 3 } });
|
|
2179
|
+
* db.compression; // { algorithm: 'zstd', level: 3 }
|
|
2180
|
+
* ```
|
|
2181
|
+
*/
|
|
2182
|
+
get compression() {
|
|
2183
|
+
return this.store.db.getCompression();
|
|
2184
|
+
}
|
|
2185
|
+
/**
|
|
2102
2186
|
* Set global database settings.
|
|
2103
2187
|
*
|
|
2104
2188
|
* @param options - The options for the database.
|
|
@@ -2928,9 +3012,9 @@ function loadLastPosition(transactionLog, readUncommitted) {
|
|
|
2928
3012
|
//#region src/index.ts
|
|
2929
3013
|
const versions = {
|
|
2930
3014
|
rocksdb: version,
|
|
2931
|
-
"rocksdb-js": "2.
|
|
3015
|
+
"rocksdb-js": "2.6.0"
|
|
2932
3016
|
};
|
|
2933
3017
|
|
|
2934
3018
|
//#endregion
|
|
2935
|
-
export { DBI, DBIterator, RocksDatabase, Store, Transaction, TransactionLog, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, tryFileLock, validateTransactionLogStore, versions };
|
|
3019
|
+
export { DBI, DBIterator, RocksDatabase, Store, Transaction, TransactionLog, backups, constants, coolTransactionLogs, currentThreadId, fileLockRelease, parseTransactionLog, registryStatus, shutdown, stats, supportedCompression, tryFileLock, validateTransactionLogStore, versions };
|
|
2936
3020
|
//# sourceMappingURL=index.mjs.map
|