@harperfast/rocksdb-js 2.6.1 → 2.7.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 +73 -4
- package/dist/index.cjs +22 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -2
- package/dist/index.d.mts +55 -2
- package/dist/index.mjs +22 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/dist/index.d.cts
CHANGED
|
@@ -255,6 +255,18 @@ type StoreRemoveOptions = DBITransactional | unknown;
|
|
|
255
255
|
type CompactOptions = {
|
|
256
256
|
start?: Key;
|
|
257
257
|
end?: Key;
|
|
258
|
+
/**
|
|
259
|
+
* Compact the bottommost level as well, rewriting every file in range.
|
|
260
|
+
*
|
|
261
|
+
* RocksDB skips the bottommost level by default when no compaction filter is installed, and
|
|
262
|
+
* that is where most of the data sits — so an ordinary `compact()` leaves it untouched. Since a
|
|
263
|
+
* changed `compression` algorithm only governs newly written files, rewriting that level is the
|
|
264
|
+
* only way to re-encode data that already exists.
|
|
265
|
+
*
|
|
266
|
+
* This rewrites the whole range regardless of whether RocksDB considers it worth doing, so it
|
|
267
|
+
* is as expensive as the data is large. Defaults to `false`.
|
|
268
|
+
*/
|
|
269
|
+
bottommost?: boolean;
|
|
258
270
|
};
|
|
259
271
|
/**
|
|
260
272
|
* A RocksDB block/blob compression algorithm. Which algorithms are actually
|
|
@@ -302,6 +314,27 @@ interface StoreOptions extends Omit<NativeDatabaseOptions, "compression" | "comp
|
|
|
302
314
|
* @default 'lz4'
|
|
303
315
|
*/
|
|
304
316
|
compression?: CompressionOption;
|
|
317
|
+
/**
|
|
318
|
+
* Apply `compression` to every column family in the database, not only the one being opened.
|
|
319
|
+
*
|
|
320
|
+
* RocksDB opens all of a database's column families in a single native call, and by default
|
|
321
|
+
* each of the ones you did not name keeps its persisted algorithm. That is right when codecs
|
|
322
|
+
* are chosen per table, but it leaves a caller that wants one codec for the whole database
|
|
323
|
+
* unable to say so: those families are already open at their old algorithm before it gets a
|
|
324
|
+
* chance to ask, and a column family's compression cannot be changed while it is open.
|
|
325
|
+
*
|
|
326
|
+
* Setting this applies the requested algorithm to all of them instead — including families
|
|
327
|
+
* that were persisted with a different one, which is the point when adopting a codec on a
|
|
328
|
+
* database that predates it.
|
|
329
|
+
*
|
|
330
|
+
* Only meaningful with an explicit `compression` (it throws otherwise), and only on the open
|
|
331
|
+
* that actually creates the database handle; later opens of the same path reuse that handle
|
|
332
|
+
* and cannot revisit the decision. As always, the algorithm governs newly written files —
|
|
333
|
+
* existing SST/blob files keep theirs until rewritten (see `compact({ bottommost: true })`).
|
|
334
|
+
*
|
|
335
|
+
* @default false
|
|
336
|
+
*/
|
|
337
|
+
compressionForAllColumnFamilies?: boolean;
|
|
305
338
|
decoder?: Encoder | null;
|
|
306
339
|
encoder?: Encoder | null;
|
|
307
340
|
encoding?: Encoding;
|
|
@@ -375,6 +408,11 @@ declare class Store {
|
|
|
375
408
|
* store's column family. Normalized and applied when the database opens.
|
|
376
409
|
*/
|
|
377
410
|
compression?: CompressionOption;
|
|
411
|
+
/**
|
|
412
|
+
* Whether `compression` applies to every column family in the database rather than just this
|
|
413
|
+
* store's. See `RocksDatabaseOptions.compressionForAllColumnFamilies`.
|
|
414
|
+
*/
|
|
415
|
+
compressionForAllColumnFamilies: boolean;
|
|
378
416
|
/**
|
|
379
417
|
* Whether to disable the write ahead log.
|
|
380
418
|
*/
|
|
@@ -750,6 +788,15 @@ declare class Transaction extends DBI {
|
|
|
750
788
|
* @param options - The options for the transaction.
|
|
751
789
|
*/
|
|
752
790
|
constructor(store: Store, options?: NativeTransactionOptions);
|
|
791
|
+
/**
|
|
792
|
+
* Release the staged writes' verification-table write intents without
|
|
793
|
+
* closing the transaction, barring any later commit or write. For a
|
|
794
|
+
* transaction kept open only for its outstanding read iterators after the
|
|
795
|
+
* writes were replayed onto another transaction: otherwise other writers'
|
|
796
|
+
* coordinated-retry commits park on those intents until it is aborted.
|
|
797
|
+
* Reads keep working, including read-your-own-writes.
|
|
798
|
+
*/
|
|
799
|
+
abandonWrites(): void;
|
|
753
800
|
/**
|
|
754
801
|
* Abort the transaction.
|
|
755
802
|
*/
|
|
@@ -1605,6 +1652,7 @@ type NativeTransactionOptions = {
|
|
|
1605
1652
|
type NativeTransaction = {
|
|
1606
1653
|
id: number;
|
|
1607
1654
|
new (context: NativeDatabase, options?: NativeTransactionOptions): NativeTransaction;
|
|
1655
|
+
abandonWrites(): void;
|
|
1608
1656
|
abort(): void;
|
|
1609
1657
|
commit(resolve: (retrySignal?: number) => void, reject: (err: Error) => void): void;
|
|
1610
1658
|
commitSync(): void;
|
|
@@ -1755,6 +1803,11 @@ type NativeDatabaseOptions = {
|
|
|
1755
1803
|
* is algorithm-specific; omit to use the algorithm's default.
|
|
1756
1804
|
*/
|
|
1757
1805
|
compressionLevel?: number;
|
|
1806
|
+
/**
|
|
1807
|
+
* Apply `compression` to every column family the underlying `DB::Open` opens, rather than
|
|
1808
|
+
* only the one named by `name`. Requires an explicit `compression`.
|
|
1809
|
+
*/
|
|
1810
|
+
compressionForAllColumnFamilies?: boolean;
|
|
1758
1811
|
dbWriteBufferSize?: number;
|
|
1759
1812
|
disableWAL?: boolean;
|
|
1760
1813
|
enableStats?: boolean;
|
|
@@ -1812,8 +1865,8 @@ type NativeDatabase = {
|
|
|
1812
1865
|
clear(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
1813
1866
|
clearSync(): void;
|
|
1814
1867
|
close(): void;
|
|
1815
|
-
compact(resolve: ResolveCallback<void>, reject: RejectCallback, start?: Key, end?: Key): void;
|
|
1816
|
-
compactSync(start?: Key, end?: Key): void;
|
|
1868
|
+
compact(resolve: ResolveCallback<void>, reject: RejectCallback, start?: Key, end?: Key, bottommost?: boolean): void;
|
|
1869
|
+
compactSync(start?: Key, end?: Key, bottommost?: boolean): void;
|
|
1817
1870
|
columns: string[];
|
|
1818
1871
|
createCheckpoint(resolve: ResolveCallback<void>, reject: RejectCallback, targetPath: string): void;
|
|
1819
1872
|
destroy(): void;
|
package/dist/index.d.mts
CHANGED
|
@@ -255,6 +255,18 @@ type StoreRemoveOptions = DBITransactional | unknown;
|
|
|
255
255
|
type CompactOptions = {
|
|
256
256
|
start?: Key;
|
|
257
257
|
end?: Key;
|
|
258
|
+
/**
|
|
259
|
+
* Compact the bottommost level as well, rewriting every file in range.
|
|
260
|
+
*
|
|
261
|
+
* RocksDB skips the bottommost level by default when no compaction filter is installed, and
|
|
262
|
+
* that is where most of the data sits — so an ordinary `compact()` leaves it untouched. Since a
|
|
263
|
+
* changed `compression` algorithm only governs newly written files, rewriting that level is the
|
|
264
|
+
* only way to re-encode data that already exists.
|
|
265
|
+
*
|
|
266
|
+
* This rewrites the whole range regardless of whether RocksDB considers it worth doing, so it
|
|
267
|
+
* is as expensive as the data is large. Defaults to `false`.
|
|
268
|
+
*/
|
|
269
|
+
bottommost?: boolean;
|
|
258
270
|
};
|
|
259
271
|
/**
|
|
260
272
|
* A RocksDB block/blob compression algorithm. Which algorithms are actually
|
|
@@ -302,6 +314,27 @@ interface StoreOptions extends Omit<NativeDatabaseOptions, "compression" | "comp
|
|
|
302
314
|
* @default 'lz4'
|
|
303
315
|
*/
|
|
304
316
|
compression?: CompressionOption;
|
|
317
|
+
/**
|
|
318
|
+
* Apply `compression` to every column family in the database, not only the one being opened.
|
|
319
|
+
*
|
|
320
|
+
* RocksDB opens all of a database's column families in a single native call, and by default
|
|
321
|
+
* each of the ones you did not name keeps its persisted algorithm. That is right when codecs
|
|
322
|
+
* are chosen per table, but it leaves a caller that wants one codec for the whole database
|
|
323
|
+
* unable to say so: those families are already open at their old algorithm before it gets a
|
|
324
|
+
* chance to ask, and a column family's compression cannot be changed while it is open.
|
|
325
|
+
*
|
|
326
|
+
* Setting this applies the requested algorithm to all of them instead — including families
|
|
327
|
+
* that were persisted with a different one, which is the point when adopting a codec on a
|
|
328
|
+
* database that predates it.
|
|
329
|
+
*
|
|
330
|
+
* Only meaningful with an explicit `compression` (it throws otherwise), and only on the open
|
|
331
|
+
* that actually creates the database handle; later opens of the same path reuse that handle
|
|
332
|
+
* and cannot revisit the decision. As always, the algorithm governs newly written files —
|
|
333
|
+
* existing SST/blob files keep theirs until rewritten (see `compact({ bottommost: true })`).
|
|
334
|
+
*
|
|
335
|
+
* @default false
|
|
336
|
+
*/
|
|
337
|
+
compressionForAllColumnFamilies?: boolean;
|
|
305
338
|
decoder?: Encoder | null;
|
|
306
339
|
encoder?: Encoder | null;
|
|
307
340
|
encoding?: Encoding;
|
|
@@ -375,6 +408,11 @@ declare class Store {
|
|
|
375
408
|
* store's column family. Normalized and applied when the database opens.
|
|
376
409
|
*/
|
|
377
410
|
compression?: CompressionOption;
|
|
411
|
+
/**
|
|
412
|
+
* Whether `compression` applies to every column family in the database rather than just this
|
|
413
|
+
* store's. See `RocksDatabaseOptions.compressionForAllColumnFamilies`.
|
|
414
|
+
*/
|
|
415
|
+
compressionForAllColumnFamilies: boolean;
|
|
378
416
|
/**
|
|
379
417
|
* Whether to disable the write ahead log.
|
|
380
418
|
*/
|
|
@@ -750,6 +788,15 @@ declare class Transaction extends DBI {
|
|
|
750
788
|
* @param options - The options for the transaction.
|
|
751
789
|
*/
|
|
752
790
|
constructor(store: Store, options?: NativeTransactionOptions);
|
|
791
|
+
/**
|
|
792
|
+
* Release the staged writes' verification-table write intents without
|
|
793
|
+
* closing the transaction, barring any later commit or write. For a
|
|
794
|
+
* transaction kept open only for its outstanding read iterators after the
|
|
795
|
+
* writes were replayed onto another transaction: otherwise other writers'
|
|
796
|
+
* coordinated-retry commits park on those intents until it is aborted.
|
|
797
|
+
* Reads keep working, including read-your-own-writes.
|
|
798
|
+
*/
|
|
799
|
+
abandonWrites(): void;
|
|
753
800
|
/**
|
|
754
801
|
* Abort the transaction.
|
|
755
802
|
*/
|
|
@@ -1605,6 +1652,7 @@ type NativeTransactionOptions = {
|
|
|
1605
1652
|
type NativeTransaction = {
|
|
1606
1653
|
id: number;
|
|
1607
1654
|
new (context: NativeDatabase, options?: NativeTransactionOptions): NativeTransaction;
|
|
1655
|
+
abandonWrites(): void;
|
|
1608
1656
|
abort(): void;
|
|
1609
1657
|
commit(resolve: (retrySignal?: number) => void, reject: (err: Error) => void): void;
|
|
1610
1658
|
commitSync(): void;
|
|
@@ -1755,6 +1803,11 @@ type NativeDatabaseOptions = {
|
|
|
1755
1803
|
* is algorithm-specific; omit to use the algorithm's default.
|
|
1756
1804
|
*/
|
|
1757
1805
|
compressionLevel?: number;
|
|
1806
|
+
/**
|
|
1807
|
+
* Apply `compression` to every column family the underlying `DB::Open` opens, rather than
|
|
1808
|
+
* only the one named by `name`. Requires an explicit `compression`.
|
|
1809
|
+
*/
|
|
1810
|
+
compressionForAllColumnFamilies?: boolean;
|
|
1758
1811
|
dbWriteBufferSize?: number;
|
|
1759
1812
|
disableWAL?: boolean;
|
|
1760
1813
|
enableStats?: boolean;
|
|
@@ -1812,8 +1865,8 @@ type NativeDatabase = {
|
|
|
1812
1865
|
clear(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
1813
1866
|
clearSync(): void;
|
|
1814
1867
|
close(): void;
|
|
1815
|
-
compact(resolve: ResolveCallback<void>, reject: RejectCallback, start?: Key, end?: Key): void;
|
|
1816
|
-
compactSync(start?: Key, end?: Key): void;
|
|
1868
|
+
compact(resolve: ResolveCallback<void>, reject: RejectCallback, start?: Key, end?: Key, bottommost?: boolean): void;
|
|
1869
|
+
compactSync(start?: Key, end?: Key, bottommost?: boolean): void;
|
|
1817
1870
|
columns: string[];
|
|
1818
1871
|
createCheckpoint(resolve: ResolveCallback<void>, reject: RejectCallback, targetPath: string): void;
|
|
1819
1872
|
destroy(): void;
|
package/dist/index.mjs
CHANGED
|
@@ -1280,6 +1280,11 @@ var Store = class {
|
|
|
1280
1280
|
*/
|
|
1281
1281
|
compression;
|
|
1282
1282
|
/**
|
|
1283
|
+
* Whether `compression` applies to every column family in the database rather than just this
|
|
1284
|
+
* store's. See `RocksDatabaseOptions.compressionForAllColumnFamilies`.
|
|
1285
|
+
*/
|
|
1286
|
+
compressionForAllColumnFamilies = false;
|
|
1287
|
+
/**
|
|
1283
1288
|
* Whether to disable the write ahead log.
|
|
1284
1289
|
*/
|
|
1285
1290
|
disableWAL;
|
|
@@ -1438,6 +1443,7 @@ var Store = class {
|
|
|
1438
1443
|
const { keyEncoding, readKey, writeKey } = initKeyEncoder(options?.keyEncoding, options?.keyEncoder);
|
|
1439
1444
|
this.db = new NativeDatabase();
|
|
1440
1445
|
this.compression = options?.compression;
|
|
1446
|
+
this.compressionForAllColumnFamilies = options?.compressionForAllColumnFamilies === true;
|
|
1441
1447
|
this.dbWriteBufferSize = options?.dbWriteBufferSize;
|
|
1442
1448
|
this.decoder = options?.decoder ?? null;
|
|
1443
1449
|
this.disableWAL = options?.disableWAL ?? false;
|
|
@@ -1507,7 +1513,7 @@ var Store = class {
|
|
|
1507
1513
|
const end = this.encodeKey(options.end);
|
|
1508
1514
|
endBuffer = Buffer.from(end.subarray(end.start, end.end));
|
|
1509
1515
|
}
|
|
1510
|
-
return new Promise((resolve, reject) => this.db.compact(resolve, reject, startBuffer, endBuffer));
|
|
1516
|
+
return new Promise((resolve, reject) => this.db.compact(resolve, reject, startBuffer, endBuffer, options?.bottommost === true));
|
|
1511
1517
|
}
|
|
1512
1518
|
async backup(target, options) {
|
|
1513
1519
|
if (typeof target !== "string" && typeof target?.getWriter === "function") return backupToStream(this.db, target, options);
|
|
@@ -1535,7 +1541,7 @@ var Store = class {
|
|
|
1535
1541
|
const end = this.encodeKey(options.end);
|
|
1536
1542
|
endBuffer = Buffer.from(end.subarray(end.start, end.end));
|
|
1537
1543
|
}
|
|
1538
|
-
this.db.compactSync(startBuffer, endBuffer);
|
|
1544
|
+
this.db.compactSync(startBuffer, endBuffer, options?.bottommost === true);
|
|
1539
1545
|
}
|
|
1540
1546
|
/**
|
|
1541
1547
|
* Decodes a key from the database.
|
|
@@ -1752,6 +1758,7 @@ var Store = class {
|
|
|
1752
1758
|
this.db.open(this.path, {
|
|
1753
1759
|
compression,
|
|
1754
1760
|
compressionLevel,
|
|
1761
|
+
compressionForAllColumnFamilies: this.compressionForAllColumnFamilies,
|
|
1755
1762
|
dbWriteBufferSize: this.dbWriteBufferSize,
|
|
1756
1763
|
disableWAL: this.disableWAL,
|
|
1757
1764
|
enableStats: this.enableStats,
|
|
@@ -1934,7 +1941,7 @@ var Transaction = class extends DBI {
|
|
|
1934
1941
|
if (store.readOnly) {
|
|
1935
1942
|
super(store);
|
|
1936
1943
|
this.#txn = { id: 0 };
|
|
1937
|
-
this.abort = this.commitSync = this.setTimestamp = () => {};
|
|
1944
|
+
this.abandonWrites = this.abort = this.commitSync = this.setTimestamp = () => {};
|
|
1938
1945
|
this.commit = async () => {};
|
|
1939
1946
|
this.getTimestamp = () => 0;
|
|
1940
1947
|
} else {
|
|
@@ -1944,6 +1951,17 @@ var Transaction = class extends DBI {
|
|
|
1944
1951
|
}
|
|
1945
1952
|
}
|
|
1946
1953
|
/**
|
|
1954
|
+
* Release the staged writes' verification-table write intents without
|
|
1955
|
+
* closing the transaction, barring any later commit or write. For a
|
|
1956
|
+
* transaction kept open only for its outstanding read iterators after the
|
|
1957
|
+
* writes were replayed onto another transaction: otherwise other writers'
|
|
1958
|
+
* coordinated-retry commits park on those intents until it is aborted.
|
|
1959
|
+
* Reads keep working, including read-your-own-writes.
|
|
1960
|
+
*/
|
|
1961
|
+
abandonWrites() {
|
|
1962
|
+
this.#txn.abandonWrites();
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1947
1965
|
* Abort the transaction.
|
|
1948
1966
|
*/
|
|
1949
1967
|
abort() {
|
|
@@ -3017,7 +3035,7 @@ function loadLastPosition(transactionLog, readUncommitted) {
|
|
|
3017
3035
|
//#region src/index.ts
|
|
3018
3036
|
const versions = {
|
|
3019
3037
|
rocksdb: version,
|
|
3020
|
-
"rocksdb-js": "2.
|
|
3038
|
+
"rocksdb-js": "2.7.0"
|
|
3021
3039
|
};
|
|
3022
3040
|
|
|
3023
3041
|
//#endregion
|