Skip to content

Commit

Permalink
expose memtable flush
Browse files Browse the repository at this point in the history
This can be used to avoid log replays on startup, for example
  • Loading branch information
arnetheduck committed Oct 27, 2024
1 parent 1e0d262 commit 018fd77
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rocksdb/rocksdb.nim
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,22 @@ proc releaseSnapshot*(db: RocksDbRef, snapshot: SnapshotRef) =
rocksdb_release_snapshot(db.cPtr, snapshot.cPtr)
snapshot.setClosed()

proc flush*(db: RocksDbRef, cfs: openArray[ColFamilyHandleRef]): RocksDBResult[void] =
withLock(db.lock):
if not db.isClosed():
var cfs = cfs.mapIt(it.cPtr)
var errors: cstring
var opts = rocksdb_flushoptions_create()
defer:
rocksdb_flushoptions_destroy(opts)
rocksdb_flushoptions_set_wait(opts, 1)
rocksdb_flush_cfs(
db.cPtr, opts, addr cfs[0], cint(cfs.len), cast[cstringArray](errors.addr)
)
bailOnErrors(errors)

ok()

proc close*(db: RocksDbRef) =
## Close the `RocksDbRef` which will release the connection to the database
## and free the memory associated with it. `close` is idempotent and can
Expand Down

0 comments on commit 018fd77

Please sign in to comment.