@harperfast/rocksdb-js 2.2.0 → 2.3.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 +28 -0
- package/dist/index.cjs +35 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.mjs +36 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.cts
CHANGED
|
@@ -1189,6 +1189,7 @@ type NativeDatabase = {
|
|
|
1189
1189
|
compact(resolve: ResolveCallback<void>, reject: RejectCallback, start?: Key, end?: Key): void;
|
|
1190
1190
|
compactSync(start?: Key, end?: Key): void;
|
|
1191
1191
|
columns: string[];
|
|
1192
|
+
createCheckpoint(resolve: ResolveCallback<void>, reject: RejectCallback, targetPath: string): void;
|
|
1192
1193
|
destroy(): void;
|
|
1193
1194
|
drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
1194
1195
|
dropSync(): void;
|
|
@@ -1823,6 +1824,31 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
1823
1824
|
*/
|
|
1824
1825
|
backup(backupDir: string, options?: BackupOptions): Promise<number>;
|
|
1825
1826
|
/**
|
|
1827
|
+
* Creates a hardlinked, point-in-time, fully independent copy of the entire
|
|
1828
|
+
* database (all column families) at `targetPath` and resolves once written.
|
|
1829
|
+
*
|
|
1830
|
+
* Unlike a backup, a checkpoint is a normal, writable sibling database: open
|
|
1831
|
+
* it with {@link RocksDatabase.open} and it diverges independently from the
|
|
1832
|
+
* source. SST and blob files are hardlinked when `targetPath` is on the same
|
|
1833
|
+
* filesystem as the database and copied otherwise (other files such as the
|
|
1834
|
+
* MANIFEST are always copied), so the operation is near-instant on the same
|
|
1835
|
+
* filesystem. The memtable is flushed so the checkpoint includes the latest
|
|
1836
|
+
* writes even when the WAL is disabled.
|
|
1837
|
+
*
|
|
1838
|
+
* Parent directories are created as needed. `targetPath` itself must not
|
|
1839
|
+
* already exist (RocksDB creates the checkpoint directory) and rejects with
|
|
1840
|
+
* `Create checkpoint failed: target path exists` if it does. The caller is
|
|
1841
|
+
* responsible for eventual cleanup of the directory.
|
|
1842
|
+
*
|
|
1843
|
+
* @example
|
|
1844
|
+
* ```typescript
|
|
1845
|
+
* const db = RocksDatabase.open('/path/to/database');
|
|
1846
|
+
* await db.createCheckpoint('/path/to/checkpoint');
|
|
1847
|
+
* const branch = RocksDatabase.open('/path/to/checkpoint');
|
|
1848
|
+
* ```
|
|
1849
|
+
*/
|
|
1850
|
+
createCheckpoint(targetPath: string): Promise<void>;
|
|
1851
|
+
/**
|
|
1826
1852
|
* Compacts the entire key range of the database synchronously.
|
|
1827
1853
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
1828
1854
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -1189,6 +1189,7 @@ type NativeDatabase = {
|
|
|
1189
1189
|
compact(resolve: ResolveCallback<void>, reject: RejectCallback, start?: Key, end?: Key): void;
|
|
1190
1190
|
compactSync(start?: Key, end?: Key): void;
|
|
1191
1191
|
columns: string[];
|
|
1192
|
+
createCheckpoint(resolve: ResolveCallback<void>, reject: RejectCallback, targetPath: string): void;
|
|
1192
1193
|
destroy(): void;
|
|
1193
1194
|
drop(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
1194
1195
|
dropSync(): void;
|
|
@@ -1823,6 +1824,31 @@ declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
1823
1824
|
*/
|
|
1824
1825
|
backup(backupDir: string, options?: BackupOptions): Promise<number>;
|
|
1825
1826
|
/**
|
|
1827
|
+
* Creates a hardlinked, point-in-time, fully independent copy of the entire
|
|
1828
|
+
* database (all column families) at `targetPath` and resolves once written.
|
|
1829
|
+
*
|
|
1830
|
+
* Unlike a backup, a checkpoint is a normal, writable sibling database: open
|
|
1831
|
+
* it with {@link RocksDatabase.open} and it diverges independently from the
|
|
1832
|
+
* source. SST and blob files are hardlinked when `targetPath` is on the same
|
|
1833
|
+
* filesystem as the database and copied otherwise (other files such as the
|
|
1834
|
+
* MANIFEST are always copied), so the operation is near-instant on the same
|
|
1835
|
+
* filesystem. The memtable is flushed so the checkpoint includes the latest
|
|
1836
|
+
* writes even when the WAL is disabled.
|
|
1837
|
+
*
|
|
1838
|
+
* Parent directories are created as needed. `targetPath` itself must not
|
|
1839
|
+
* already exist (RocksDB creates the checkpoint directory) and rejects with
|
|
1840
|
+
* `Create checkpoint failed: target path exists` if it does. The caller is
|
|
1841
|
+
* responsible for eventual cleanup of the directory.
|
|
1842
|
+
*
|
|
1843
|
+
* @example
|
|
1844
|
+
* ```typescript
|
|
1845
|
+
* const db = RocksDatabase.open('/path/to/database');
|
|
1846
|
+
* await db.createCheckpoint('/path/to/checkpoint');
|
|
1847
|
+
* const branch = RocksDatabase.open('/path/to/checkpoint');
|
|
1848
|
+
* ```
|
|
1849
|
+
*/
|
|
1850
|
+
createCheckpoint(targetPath: string): Promise<void>;
|
|
1851
|
+
/**
|
|
1826
1852
|
* Compacts the entire key range of the database synchronously.
|
|
1827
1853
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
1828
1854
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
|
-
import { closeSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
|
|
3
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { mkdir } from "node:fs/promises";
|
|
@@ -1502,6 +1502,40 @@ var RocksDatabase = class RocksDatabase extends DBI {
|
|
|
1502
1502
|
return this.store.backup(backupDir, options);
|
|
1503
1503
|
}
|
|
1504
1504
|
/**
|
|
1505
|
+
* Creates a hardlinked, point-in-time, fully independent copy of the entire
|
|
1506
|
+
* database (all column families) at `targetPath` and resolves once written.
|
|
1507
|
+
*
|
|
1508
|
+
* Unlike a backup, a checkpoint is a normal, writable sibling database: open
|
|
1509
|
+
* it with {@link RocksDatabase.open} and it diverges independently from the
|
|
1510
|
+
* source. SST and blob files are hardlinked when `targetPath` is on the same
|
|
1511
|
+
* filesystem as the database and copied otherwise (other files such as the
|
|
1512
|
+
* MANIFEST are always copied), so the operation is near-instant on the same
|
|
1513
|
+
* filesystem. The memtable is flushed so the checkpoint includes the latest
|
|
1514
|
+
* writes even when the WAL is disabled.
|
|
1515
|
+
*
|
|
1516
|
+
* Parent directories are created as needed. `targetPath` itself must not
|
|
1517
|
+
* already exist (RocksDB creates the checkpoint directory) and rejects with
|
|
1518
|
+
* `Create checkpoint failed: target path exists` if it does. The caller is
|
|
1519
|
+
* responsible for eventual cleanup of the directory.
|
|
1520
|
+
*
|
|
1521
|
+
* @example
|
|
1522
|
+
* ```typescript
|
|
1523
|
+
* const db = RocksDatabase.open('/path/to/database');
|
|
1524
|
+
* await db.createCheckpoint('/path/to/checkpoint');
|
|
1525
|
+
* const branch = RocksDatabase.open('/path/to/checkpoint');
|
|
1526
|
+
* ```
|
|
1527
|
+
*/
|
|
1528
|
+
createCheckpoint(targetPath) {
|
|
1529
|
+
return new Promise((resolve, reject) => {
|
|
1530
|
+
if (existsSync(targetPath)) {
|
|
1531
|
+
reject(/* @__PURE__ */ new Error("Create checkpoint failed: target path exists"));
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
1535
|
+
this.store.db.createCheckpoint(resolve, reject, targetPath);
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1505
1539
|
* Compacts the entire key range of the database synchronously.
|
|
1506
1540
|
* This triggers manual compaction which removes tombstones and reclaims space.
|
|
1507
1541
|
*
|
|
@@ -2350,7 +2384,7 @@ function loadLastPosition(transactionLog, readUncommitted) {
|
|
|
2350
2384
|
//#region src/index.ts
|
|
2351
2385
|
const versions = {
|
|
2352
2386
|
rocksdb: version,
|
|
2353
|
-
"rocksdb-js": "2.
|
|
2387
|
+
"rocksdb-js": "2.3.0"
|
|
2354
2388
|
};
|
|
2355
2389
|
|
|
2356
2390
|
//#endregion
|