Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose function for listing existing column families #48

Merged
merged 6 commits into from
Jun 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions rocksdb/rocksdb.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,40 @@ type
writeOpts: WriteOptionsRef
ingestOptsPtr: IngestExternalFilesOptionsPtr

proc listRocksDbCFs*(
mjfh marked this conversation as resolved.
Show resolved Hide resolved
path: string;
dbOpts = defaultDbOptions();
mjfh marked this conversation as resolved.
Show resolved Hide resolved
): RocksDBResult[seq[string]] =
## List exisiting column families on disk. This might be used to find out
## whether there were some columns missing with the version on disk.
##
## Column families previously used must be declared when re-opening an
## existing database. So this function can be used to add some CFs
## on-the-fly to the opener list of CFs
##
## Note that the on-the-fly adding might not be needed in the way described
## above once rocksdb has been upgraded to the latest version, see comments
## at the end of ./columnfamily/cfhandle.nim.
##
var
lencf: csize_t
errors: cstring
let
cList = rocksdb_list_column_families(
mjfh marked this conversation as resolved.
Show resolved Hide resolved
dbOpts.cPtr,
path.cstring,
addr lencf,
cast[cstringArray](errors.addr))
bailOnErrors(errors)

var cfs: seq[string]
for n in 0 ..< lencf:
if cList[n].isNil:
return err("short reply")
cfs.add $cList[n]

ok cfs

proc openRocksDb*(
path: string,
dbOpts = defaultDbOptions(),
Expand Down
Loading