@harperfast/rocksdb-js 2.10.0 → 2.12.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/dist/index.d.cts CHANGED
@@ -178,6 +178,14 @@ export declare const backups: {
178
178
  * Verifies a backup's file sizes, and optionally their checksums (which
179
179
  * requires reading all backed-up data).
180
180
  *
181
+ * Set `verifyTables: true` to also prove this build can read the backup
182
+ * before restoring it: every table file is opened, one at a time, and its
183
+ * footer (including `format_version`) and properties must be readable, and
184
+ * every compression algorithm it records must be supported by this build.
185
+ * A checksum-valid table written by a newer or differently built RocksDB
186
+ * otherwise passes and fails on the first read after a restore. Blob files
187
+ * are not checked.
188
+ *
181
189
  * When the backup was created with `transactionLogs: true`, the backup's
182
190
  * transaction log snapshot (`<backupDir>/transaction_logs/<backupId>/`) is
183
191
  * also validated — every log file's header and entry framing must be intact
@@ -186,6 +194,7 @@ export declare const backups: {
186
194
  */
187
195
  verify(backupDir: string, backupId: number, options?: {
188
196
  verifyWithChecksum?: boolean;
197
+ verifyTables?: boolean;
189
198
  verifyTransactionLogs?: boolean;
190
199
  }): Promise<void>;
191
200
  };
@@ -648,6 +657,7 @@ export declare class Store {
648
657
  /**
649
658
  * The target maximum size of a transaction log before rotation. Transactions
650
659
  * are never split across files, so one transaction may exceed this target.
660
+ * Defaults to 16 MiB. `0` (formerly unlimited) is rejected at open.
651
661
  */
652
662
  transactionLogMaxSize?: number;
653
663
  /**
@@ -661,6 +671,11 @@ export declare class Store {
661
671
  * The path to the transaction logs directory.
662
672
  */
663
673
  transactionLogsPath?: string;
674
+ /**
675
+ * The transaction log whose batch keys this process originates; seeds the
676
+ * monotonic timestamp floor at open. See `StoreOptions.timestampFloorLog`.
677
+ */
678
+ timestampFloorLog?: string;
664
679
  /**
665
680
  * Whether this store's column family participates in the VerificationTable.
666
681
  */
@@ -1378,6 +1393,7 @@ type StatsBasics = {
1378
1393
  "txnlog.replayGapBytes": number;
1379
1394
  "commitPipeline.logQueueDepth": number;
1380
1395
  "commitPipeline.commitQueueDepth": number;
1396
+ "commitPipeline.commitThreads": number;
1381
1397
  "columnFamily.pendingReclaims": number;
1382
1398
  "writeBufferManager.bufferSize": number;
1383
1399
  "writeBufferManager.memoryUsage": number;
@@ -1952,7 +1968,8 @@ type NativeTransaction = {
1952
1968
  type LogBuffer = Buffer & {
1953
1969
  dataView: DataView;
1954
1970
  logId: number;
1955
- size: number;
1971
+ readonly readableExtent: number;
1972
+ size?: number;
1956
1973
  };
1957
1974
  type TransactionLogQueryOptions = {
1958
1975
  start?: number;
@@ -2008,6 +2025,7 @@ type TransactionLogStats = {
2008
2025
  oldestFileAgeMs: number;
2009
2026
  purgeableFiles: number;
2010
2027
  retainedUnflushedFiles: number;
2028
+ retentionPins: number;
2011
2029
  lastPurgeMs: number;
2012
2030
  };
2013
2031
  totals: {
@@ -2035,12 +2053,13 @@ export type TransactionLog = {
2035
2053
  name: string;
2036
2054
  path: string;
2037
2055
  query(options?: TransactionLogQueryOptions): IterableIterator<TransactionEntry>;
2038
- _currentLogBuffer: LogBuffer;
2056
+ _currentLogBuffer: WeakRef<LogBuffer> | undefined;
2039
2057
  _findPosition(timestamp: number): number;
2040
2058
  _getLastCommittedPosition(): Buffer;
2041
2059
  _getLastFlushed(): number;
2042
2060
  _getMemoryMapOfFile(sequenceId: number): LogBuffer | undefined;
2043
2061
  _lastCommittedPosition: Float64Array;
2062
+ _nextLogId(sequenceId: number): number;
2044
2063
  _logBuffers: Map<number, WeakRef<LogBuffer>>;
2045
2064
  };
2046
2065
  /**
@@ -2130,9 +2149,31 @@ type NativeDatabaseOptions = {
2130
2149
  secondaryPath?: string;
2131
2150
  statsLevel?: (typeof stats.StatsLevel)[keyof typeof stats.StatsLevel];
2132
2151
  transactionLogMaxAgeThreshold?: number;
2152
+ /** Target segment size in bytes; defaults to 16 MiB. `0` is rejected. */
2133
2153
  transactionLogMaxSize?: number;
2134
2154
  transactionLogRetentionMs?: number;
2135
2155
  transactionLogsPath?: string;
2156
+ /**
2157
+ * The name of the transaction log whose batch keys this process originates
2158
+ * (the log it passes to `useLog()` for its own writes).
2159
+ *
2160
+ * At open, the process-wide monotonic timestamp floor is raised above every
2161
+ * batch key still durable in that log, so a backward wall-clock step between
2162
+ * runs cannot reissue a transaction timestamp that is already a key in it.
2163
+ *
2164
+ * Name only a log this process originates. A log written under timestamps
2165
+ * adopted from another node (a replication receiver calling
2166
+ * `transaction.setTimestamp()`) is keyed by that node's clock, and seeding
2167
+ * from it would ratchet this process's clock to the fastest of those nodes
2168
+ * on every restart. Unset (the default), the floor is left alone; native
2169
+ * code cannot tell the two kinds of log apart.
2170
+ *
2171
+ * Safety check: an incomplete scan or a key implausibly far ahead of the
2172
+ * wall clock rejects this open rather than risk issuing a duplicate key.
2173
+ * The floor is process-wide, so it is shared by every database open in the
2174
+ * process.
2175
+ */
2176
+ timestampFloorLog?: string;
2136
2177
  /**
2137
2178
  * When true, transaction writes to this column family invalidate the
2138
2179
  * VerificationTable slot for each written key at write time (not at
@@ -2191,9 +2232,9 @@ type FlushOptions = {
2191
2232
  * the descriptor is process-global and shared across `worker_threads`, so the stall lands on
2192
2233
  * every other column family and every other handle that opened the same path — not just the
2193
2234
  * one you called. It also relocates the hang rather than removing it: a stalled `db->Write()`
2194
- * blocks the database's single `CommitWorker` thread, which dispatches every
2195
- * `Transaction.commit()` in order, so the stall queues up every commit behind it — including
2196
- * ones from callers that never touched flush — until the stall clears.
2235
+ * blocks each of the database's `CommitWorker` threads that reaches it, so the stall queues up
2236
+ * every async `Transaction.commit()` behind them — including ones from callers that never
2237
+ * touched flush — until the stall clears.
2197
2238
  *
2198
2239
  * Note this is a *different* knob from the `writeBufferManagerAllowStall` config, and their
2199
2240
  * polarity is nearly opposite: that one decides whether the WriteBufferManager may stall
@@ -2271,6 +2312,7 @@ type NativeDatabase = {
2271
2312
  removeListener(event: string | BufferWithDataView, callback: () => void): boolean;
2272
2313
  removeSync(key: BufferWithDataView, txnId?: number): void;
2273
2314
  resume(): void;
2315
+ setCompression(algorithm: string, level?: number): void;
2274
2316
  setDefaultKeyBuffer(buffer: Buffer | Uint8Array | null): void;
2275
2317
  setDefaultValueBuffer(buffer: Buffer | Uint8Array | null): void;
2276
2318
  setIteratorState(buffer: Buffer | Uint8Array): void;
@@ -2282,6 +2324,38 @@ type NativeDatabase = {
2282
2324
  };
2283
2325
  type RocksDatabaseConfig = {
2284
2326
  blockCacheSize?: number;
2327
+ /**
2328
+ * Number of commit lock buckets each writable optimistic database allocates
2329
+ * when opened with parallel validation. Defaults to 65,536 (about 2.5 MiB per
2330
+ * database on Linux x64; RocksDB's own default is 2^20); accepts integers
2331
+ * from 16 through 16,777,216. Applies to databases opened after the call; open
2332
+ * databases keep their count. Smaller pools only cost throughput when several
2333
+ * commits to the same database overlap (`commitThreads`, `commitSync()`
2334
+ * callers) and their keys collide, which large transactions make likely:
2335
+ * raise the count for databases that commit hundreds of keys at a time. This
2336
+ * does not limit transaction size.
2337
+ */
2338
+ occLockBuckets?: number;
2339
+ /**
2340
+ * How writable optimistic databases opened after the call validate commits.
2341
+ * `'parallel'` (default, RocksDB's default) uses the `occLockBuckets` pool and
2342
+ * lets concurrent commits share a RocksDB write. `'serial'` validates inside
2343
+ * the write group and allocates no bucket pool, but RocksDB never batches its
2344
+ * commits with other writers, so a database's concurrent commits (its
2345
+ * `commitThreads` and any `commitSync()` callers) lose most of their
2346
+ * throughput. Open databases keep their policy.
2347
+ */
2348
+ occValidation?: "parallel" | "serial";
2349
+ /**
2350
+ * Maximum number of dedicated threads each database opened after the call uses
2351
+ * to commit async transactions. Threads start only when commits overlap, so a
2352
+ * database committed to one transaction at a time owns one. Defaults to
2353
+ * `min(4, hardware concurrency)`; accepts integers from 1 through 64. With 1,
2354
+ * async commits to a database run one at a time in dispatch order; with more,
2355
+ * concurrent commits finish (and their promises resolve) in any order, as
2356
+ * concurrent `commitSync()` calls always have. Open databases keep their limit.
2357
+ */
2358
+ commitThreads?: number;
2285
2359
  /**
2286
2360
  * Number of slots in the process-global verification table. Each slot is
2287
2361
  * 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
@@ -2496,6 +2570,16 @@ export declare const supportedCompression: readonly string[];
2496
2570
  declare const NativeDatabase: NativeDatabase;
2497
2571
  declare const NativeTransaction: NativeTransaction;
2498
2572
  export declare const TransactionLog: TransactionLog;
2573
+ /**
2574
+ * Returns the status of every database currently held by the native registry.
2575
+ * Walks every registered descriptor, so it samples live state rather than
2576
+ * reading a stored property.
2577
+ */
2578
+ export declare const getRegistryStatus: () => RegistryStatus;
2579
+ /**
2580
+ * @deprecated Use {@link getRegistryStatus} instead. This alias will be removed
2581
+ * in v3.0.0.
2582
+ */
2499
2583
  export declare const registryStatus: () => RegistryStatus;
2500
2584
  /**
2501
2585
  * Flushes every open database and waits for outstanding compactions, then
@@ -2844,6 +2928,51 @@ export declare class RocksDatabase extends DBI<DBITransactional> {
2844
2928
  * ```
2845
2929
  */
2846
2930
  get compression(): CompressionInfo;
2931
+ /**
2932
+ * Dynamically changes the compression algorithm (and optional level) for
2933
+ * this database's column family on an already-open database — no close, no
2934
+ * reopen, and it does not conflict with another handle that already has
2935
+ * this column family open (unlike an explicit open-time `compression`
2936
+ * mismatch). That other handle's live options change too, silently,
2937
+ * without notice; a later explicit reopen of it is compared against the
2938
+ * new value, so a stale request it still holds can then conflict. Backed
2939
+ * by RocksDB's `DB::SetOptions()`, which documents both `compression` and
2940
+ * `blob_compression_type` as mutable column family options.
2941
+ *
2942
+ * This governs only *newly written* files (the next flush and any future
2943
+ * compaction output) going forward; SST and blob files already on disk
2944
+ * keep their existing compression until they are rewritten by a later
2945
+ * compaction. `compact()`'s default options can skip already-bottommost
2946
+ * files; use `compact({ bottommost: true })` to rewrite them under the new
2947
+ * codec. This is the live-mutation counterpart to the open-time
2948
+ * `compression` option — see the README's Compression section for when to
2949
+ * use each.
2950
+ *
2951
+ * @example
2952
+ * ```typescript
2953
+ * const db = RocksDatabase.open('/path/to/db', { compression: 'none' });
2954
+ * db.setCompression({ algorithm: 'zstd', level: 19 });
2955
+ * // new writes are now compressed with zstd; existing SSTs are untouched
2956
+ * // until compacted.
2957
+ * ```
2958
+ */
2959
+ setCompression(compression: CompressionOption): void;
2960
+ /**
2961
+ * Resyncs the store's cached open-time compression option from the live
2962
+ * database state after `setCompression()`. Also clears
2963
+ * `compressionForAllColumnFamilies`: that flag means "apply this option to
2964
+ * every column family opened for this database", which no longer describes
2965
+ * a live change scoped to a single column family — leaving it set would
2966
+ * restamp every other family with this algorithm on the next
2967
+ * same-instance `close()` + `open()`.
2968
+ *
2969
+ * The flag clear is unconditional (a plain assignment, so it cannot itself
2970
+ * fail) and comes first: a concurrent close racing the live-state read
2971
+ * below throws "Database not open" from the getter, and that read failing
2972
+ * must not also skip the flag clear -- otherwise the same restamp this
2973
+ * method exists to prevent survives on the next open().
2974
+ */
2975
+ private syncStoreCompressionFromLive;
2847
2976
  /**
2848
2977
  * The informational-log settings currently in effect for this database,
2849
2978
  * read live from RocksDB, as `{ maxLogFileSize, infoLogLevel }`. These are
package/dist/index.d.mts CHANGED
@@ -178,6 +178,14 @@ export declare const backups: {
178
178
  * Verifies a backup's file sizes, and optionally their checksums (which
179
179
  * requires reading all backed-up data).
180
180
  *
181
+ * Set `verifyTables: true` to also prove this build can read the backup
182
+ * before restoring it: every table file is opened, one at a time, and its
183
+ * footer (including `format_version`) and properties must be readable, and
184
+ * every compression algorithm it records must be supported by this build.
185
+ * A checksum-valid table written by a newer or differently built RocksDB
186
+ * otherwise passes and fails on the first read after a restore. Blob files
187
+ * are not checked.
188
+ *
181
189
  * When the backup was created with `transactionLogs: true`, the backup's
182
190
  * transaction log snapshot (`<backupDir>/transaction_logs/<backupId>/`) is
183
191
  * also validated — every log file's header and entry framing must be intact
@@ -186,6 +194,7 @@ export declare const backups: {
186
194
  */
187
195
  verify(backupDir: string, backupId: number, options?: {
188
196
  verifyWithChecksum?: boolean;
197
+ verifyTables?: boolean;
189
198
  verifyTransactionLogs?: boolean;
190
199
  }): Promise<void>;
191
200
  };
@@ -648,6 +657,7 @@ export declare class Store {
648
657
  /**
649
658
  * The target maximum size of a transaction log before rotation. Transactions
650
659
  * are never split across files, so one transaction may exceed this target.
660
+ * Defaults to 16 MiB. `0` (formerly unlimited) is rejected at open.
651
661
  */
652
662
  transactionLogMaxSize?: number;
653
663
  /**
@@ -661,6 +671,11 @@ export declare class Store {
661
671
  * The path to the transaction logs directory.
662
672
  */
663
673
  transactionLogsPath?: string;
674
+ /**
675
+ * The transaction log whose batch keys this process originates; seeds the
676
+ * monotonic timestamp floor at open. See `StoreOptions.timestampFloorLog`.
677
+ */
678
+ timestampFloorLog?: string;
664
679
  /**
665
680
  * Whether this store's column family participates in the VerificationTable.
666
681
  */
@@ -1378,6 +1393,7 @@ type StatsBasics = {
1378
1393
  "txnlog.replayGapBytes": number;
1379
1394
  "commitPipeline.logQueueDepth": number;
1380
1395
  "commitPipeline.commitQueueDepth": number;
1396
+ "commitPipeline.commitThreads": number;
1381
1397
  "columnFamily.pendingReclaims": number;
1382
1398
  "writeBufferManager.bufferSize": number;
1383
1399
  "writeBufferManager.memoryUsage": number;
@@ -1952,7 +1968,8 @@ type NativeTransaction = {
1952
1968
  type LogBuffer = Buffer & {
1953
1969
  dataView: DataView;
1954
1970
  logId: number;
1955
- size: number;
1971
+ readonly readableExtent: number;
1972
+ size?: number;
1956
1973
  };
1957
1974
  type TransactionLogQueryOptions = {
1958
1975
  start?: number;
@@ -2008,6 +2025,7 @@ type TransactionLogStats = {
2008
2025
  oldestFileAgeMs: number;
2009
2026
  purgeableFiles: number;
2010
2027
  retainedUnflushedFiles: number;
2028
+ retentionPins: number;
2011
2029
  lastPurgeMs: number;
2012
2030
  };
2013
2031
  totals: {
@@ -2035,12 +2053,13 @@ export type TransactionLog = {
2035
2053
  name: string;
2036
2054
  path: string;
2037
2055
  query(options?: TransactionLogQueryOptions): IterableIterator<TransactionEntry>;
2038
- _currentLogBuffer: LogBuffer;
2056
+ _currentLogBuffer: WeakRef<LogBuffer> | undefined;
2039
2057
  _findPosition(timestamp: number): number;
2040
2058
  _getLastCommittedPosition(): Buffer;
2041
2059
  _getLastFlushed(): number;
2042
2060
  _getMemoryMapOfFile(sequenceId: number): LogBuffer | undefined;
2043
2061
  _lastCommittedPosition: Float64Array;
2062
+ _nextLogId(sequenceId: number): number;
2044
2063
  _logBuffers: Map<number, WeakRef<LogBuffer>>;
2045
2064
  };
2046
2065
  /**
@@ -2130,9 +2149,31 @@ type NativeDatabaseOptions = {
2130
2149
  secondaryPath?: string;
2131
2150
  statsLevel?: (typeof stats.StatsLevel)[keyof typeof stats.StatsLevel];
2132
2151
  transactionLogMaxAgeThreshold?: number;
2152
+ /** Target segment size in bytes; defaults to 16 MiB. `0` is rejected. */
2133
2153
  transactionLogMaxSize?: number;
2134
2154
  transactionLogRetentionMs?: number;
2135
2155
  transactionLogsPath?: string;
2156
+ /**
2157
+ * The name of the transaction log whose batch keys this process originates
2158
+ * (the log it passes to `useLog()` for its own writes).
2159
+ *
2160
+ * At open, the process-wide monotonic timestamp floor is raised above every
2161
+ * batch key still durable in that log, so a backward wall-clock step between
2162
+ * runs cannot reissue a transaction timestamp that is already a key in it.
2163
+ *
2164
+ * Name only a log this process originates. A log written under timestamps
2165
+ * adopted from another node (a replication receiver calling
2166
+ * `transaction.setTimestamp()`) is keyed by that node's clock, and seeding
2167
+ * from it would ratchet this process's clock to the fastest of those nodes
2168
+ * on every restart. Unset (the default), the floor is left alone; native
2169
+ * code cannot tell the two kinds of log apart.
2170
+ *
2171
+ * Safety check: an incomplete scan or a key implausibly far ahead of the
2172
+ * wall clock rejects this open rather than risk issuing a duplicate key.
2173
+ * The floor is process-wide, so it is shared by every database open in the
2174
+ * process.
2175
+ */
2176
+ timestampFloorLog?: string;
2136
2177
  /**
2137
2178
  * When true, transaction writes to this column family invalidate the
2138
2179
  * VerificationTable slot for each written key at write time (not at
@@ -2191,9 +2232,9 @@ type FlushOptions = {
2191
2232
  * the descriptor is process-global and shared across `worker_threads`, so the stall lands on
2192
2233
  * every other column family and every other handle that opened the same path — not just the
2193
2234
  * one you called. It also relocates the hang rather than removing it: a stalled `db->Write()`
2194
- * blocks the database's single `CommitWorker` thread, which dispatches every
2195
- * `Transaction.commit()` in order, so the stall queues up every commit behind it — including
2196
- * ones from callers that never touched flush — until the stall clears.
2235
+ * blocks each of the database's `CommitWorker` threads that reaches it, so the stall queues up
2236
+ * every async `Transaction.commit()` behind them — including ones from callers that never
2237
+ * touched flush — until the stall clears.
2197
2238
  *
2198
2239
  * Note this is a *different* knob from the `writeBufferManagerAllowStall` config, and their
2199
2240
  * polarity is nearly opposite: that one decides whether the WriteBufferManager may stall
@@ -2271,6 +2312,7 @@ type NativeDatabase = {
2271
2312
  removeListener(event: string | BufferWithDataView, callback: () => void): boolean;
2272
2313
  removeSync(key: BufferWithDataView, txnId?: number): void;
2273
2314
  resume(): void;
2315
+ setCompression(algorithm: string, level?: number): void;
2274
2316
  setDefaultKeyBuffer(buffer: Buffer | Uint8Array | null): void;
2275
2317
  setDefaultValueBuffer(buffer: Buffer | Uint8Array | null): void;
2276
2318
  setIteratorState(buffer: Buffer | Uint8Array): void;
@@ -2282,6 +2324,38 @@ type NativeDatabase = {
2282
2324
  };
2283
2325
  type RocksDatabaseConfig = {
2284
2326
  blockCacheSize?: number;
2327
+ /**
2328
+ * Number of commit lock buckets each writable optimistic database allocates
2329
+ * when opened with parallel validation. Defaults to 65,536 (about 2.5 MiB per
2330
+ * database on Linux x64; RocksDB's own default is 2^20); accepts integers
2331
+ * from 16 through 16,777,216. Applies to databases opened after the call; open
2332
+ * databases keep their count. Smaller pools only cost throughput when several
2333
+ * commits to the same database overlap (`commitThreads`, `commitSync()`
2334
+ * callers) and their keys collide, which large transactions make likely:
2335
+ * raise the count for databases that commit hundreds of keys at a time. This
2336
+ * does not limit transaction size.
2337
+ */
2338
+ occLockBuckets?: number;
2339
+ /**
2340
+ * How writable optimistic databases opened after the call validate commits.
2341
+ * `'parallel'` (default, RocksDB's default) uses the `occLockBuckets` pool and
2342
+ * lets concurrent commits share a RocksDB write. `'serial'` validates inside
2343
+ * the write group and allocates no bucket pool, but RocksDB never batches its
2344
+ * commits with other writers, so a database's concurrent commits (its
2345
+ * `commitThreads` and any `commitSync()` callers) lose most of their
2346
+ * throughput. Open databases keep their policy.
2347
+ */
2348
+ occValidation?: "parallel" | "serial";
2349
+ /**
2350
+ * Maximum number of dedicated threads each database opened after the call uses
2351
+ * to commit async transactions. Threads start only when commits overlap, so a
2352
+ * database committed to one transaction at a time owns one. Defaults to
2353
+ * `min(4, hardware concurrency)`; accepts integers from 1 through 64. With 1,
2354
+ * async commits to a database run one at a time in dispatch order; with more,
2355
+ * concurrent commits finish (and their promises resolve) in any order, as
2356
+ * concurrent `commitSync()` calls always have. Open databases keep their limit.
2357
+ */
2358
+ commitThreads?: number;
2285
2359
  /**
2286
2360
  * Number of slots in the process-global verification table. Each slot is
2287
2361
  * 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
@@ -2496,6 +2570,16 @@ export declare const supportedCompression: readonly string[];
2496
2570
  declare const NativeDatabase: NativeDatabase;
2497
2571
  declare const NativeTransaction: NativeTransaction;
2498
2572
  export declare const TransactionLog: TransactionLog;
2573
+ /**
2574
+ * Returns the status of every database currently held by the native registry.
2575
+ * Walks every registered descriptor, so it samples live state rather than
2576
+ * reading a stored property.
2577
+ */
2578
+ export declare const getRegistryStatus: () => RegistryStatus;
2579
+ /**
2580
+ * @deprecated Use {@link getRegistryStatus} instead. This alias will be removed
2581
+ * in v3.0.0.
2582
+ */
2499
2583
  export declare const registryStatus: () => RegistryStatus;
2500
2584
  /**
2501
2585
  * Flushes every open database and waits for outstanding compactions, then
@@ -2844,6 +2928,51 @@ export declare class RocksDatabase extends DBI<DBITransactional> {
2844
2928
  * ```
2845
2929
  */
2846
2930
  get compression(): CompressionInfo;
2931
+ /**
2932
+ * Dynamically changes the compression algorithm (and optional level) for
2933
+ * this database's column family on an already-open database — no close, no
2934
+ * reopen, and it does not conflict with another handle that already has
2935
+ * this column family open (unlike an explicit open-time `compression`
2936
+ * mismatch). That other handle's live options change too, silently,
2937
+ * without notice; a later explicit reopen of it is compared against the
2938
+ * new value, so a stale request it still holds can then conflict. Backed
2939
+ * by RocksDB's `DB::SetOptions()`, which documents both `compression` and
2940
+ * `blob_compression_type` as mutable column family options.
2941
+ *
2942
+ * This governs only *newly written* files (the next flush and any future
2943
+ * compaction output) going forward; SST and blob files already on disk
2944
+ * keep their existing compression until they are rewritten by a later
2945
+ * compaction. `compact()`'s default options can skip already-bottommost
2946
+ * files; use `compact({ bottommost: true })` to rewrite them under the new
2947
+ * codec. This is the live-mutation counterpart to the open-time
2948
+ * `compression` option — see the README's Compression section for when to
2949
+ * use each.
2950
+ *
2951
+ * @example
2952
+ * ```typescript
2953
+ * const db = RocksDatabase.open('/path/to/db', { compression: 'none' });
2954
+ * db.setCompression({ algorithm: 'zstd', level: 19 });
2955
+ * // new writes are now compressed with zstd; existing SSTs are untouched
2956
+ * // until compacted.
2957
+ * ```
2958
+ */
2959
+ setCompression(compression: CompressionOption): void;
2960
+ /**
2961
+ * Resyncs the store's cached open-time compression option from the live
2962
+ * database state after `setCompression()`. Also clears
2963
+ * `compressionForAllColumnFamilies`: that flag means "apply this option to
2964
+ * every column family opened for this database", which no longer describes
2965
+ * a live change scoped to a single column family — leaving it set would
2966
+ * restamp every other family with this algorithm on the next
2967
+ * same-instance `close()` + `open()`.
2968
+ *
2969
+ * The flag clear is unconditional (a plain assignment, so it cannot itself
2970
+ * fail) and comes first: a concurrent close racing the live-state read
2971
+ * below throws "Database not open" from the getter, and that read failing
2972
+ * must not also skip the flag clear -- otherwise the same restamp this
2973
+ * method exists to prevent survives on the next open().
2974
+ */
2975
+ private syncStoreCompressionFromLive;
2847
2976
  /**
2848
2977
  * The informational-log settings currently in effect for this database,
2849
2978
  * read live from RocksDB, as `{ maxLogFileSize, infoLogLevel }`. These are