Skip to content

Commit

Permalink
Remove features not supported by older versions of RocksDB to fix CI …
Browse files Browse the repository at this point in the history
…(temporary fix).
  • Loading branch information
bhartnett committed Feb 21, 2024
1 parent 2ffcffc commit 55c2b29
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
10 changes: 7 additions & 3 deletions rocksdb/columnfamily/cfopts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ proc defaultColFamilyOptions*(): ColFamilyOptionsRef =
opts.setCreateMissingColumnFamilies(true)
return opts

proc getCreateMissingColumnFamilies*(cfOpts: ColFamilyOptionsRef): bool =
doAssert not cfOpts.isClosed()
rocksdb_options_get_create_missing_column_families(cfOpts.cPtr).bool
# TODO: These procs below will not work unless using the latest version of rocksdb
# Currently, when installing librocksdb-dev on linux the RocksDb version used is 6.11.4
# Need to complete this task: https://github.com/status-im/nim-rocksdb/issues/10

# proc getCreateMissingColumnFamilies*(cfOpts: ColFamilyOptionsRef): bool =
# doAssert not cfOpts.isClosed()
# rocksdb_options_get_create_missing_column_families(cfOpts.cPtr).bool

proc close*(cfOpts: var ColFamilyOptionsRef) =
if not cfOpts.isClosed():
Expand Down
22 changes: 13 additions & 9 deletions rocksdb/options/dbopts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ proc defaultDbOptions*(): DbOptionsRef =
opts.setCreateMissingColumnFamilies(true)
return opts

proc getCreateIfMissing*(dbOpts: DbOptionsRef): bool =
doAssert not dbOpts.isClosed()
rocksdb_options_get_create_if_missing(dbOpts.cPtr).bool
# TODO: These procs below will not work unless using the latest version of rocksdb
# Currently, when installing librocksdb-dev on linux the RocksDb version used is 6.11.4
# Need to complete this task: https://github.com/status-im/nim-rocksdb/issues/10

proc getMaxOpenFiles*(dbOpts: DbOptionsRef): int =
doAssert not dbOpts.isClosed()
rocksdb_options_get_max_open_files(dbOpts.cPtr).int
# proc getCreateIfMissing*(dbOpts: DbOptionsRef): bool =
# doAssert not dbOpts.isClosed()
# rocksdb_options_get_create_if_missing(dbOpts.cPtr).bool

proc getCreateMissingColumnFamilies*(dbOpts: DbOptionsRef): bool =
doAssert not dbOpts.isClosed()
rocksdb_options_get_create_missing_column_families(dbOpts.cPtr).bool
# proc getMaxOpenFiles*(dbOpts: DbOptionsRef): int =
# doAssert not dbOpts.isClosed()
# rocksdb_options_get_max_open_files(dbOpts.cPtr).int

# proc getCreateMissingColumnFamilies*(dbOpts: DbOptionsRef): bool =
# doAssert not dbOpts.isClosed()
# rocksdb_options_get_create_missing_column_families(dbOpts.cPtr).bool

proc close*(dbOpts: var DbOptionsRef) =
if not dbOpts.isClosed():
Expand Down
8 changes: 4 additions & 4 deletions tests/columnfamily/test_cfopts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ suite "ColFamilyOptionsRef Tests":
var cfOpts = newColFamilyOptions()

check not cfOpts.cPtr.isNil()
check not cfOpts.getCreateMissingColumnFamilies()
# check not cfOpts.getCreateMissingColumnFamilies()

cfOpts.setCreateMissingColumnFamilies(true)
check cfOpts.getCreateMissingColumnFamilies()
# check cfOpts.getCreateMissingColumnFamilies()

cfOpts.close()

test "Test defaultColFamilyOptions":
var cfOpts = defaultColFamilyOptions()

check not cfOpts.cPtr.isNil()
check cfOpts.getCreateMissingColumnFamilies()
# check cfOpts.getCreateMissingColumnFamilies()

cfOpts.setCreateMissingColumnFamilies(false)
check not cfOpts.getCreateMissingColumnFamilies()
# check not cfOpts.getCreateMissingColumnFamilies()

cfOpts.close()

Expand Down
22 changes: 11 additions & 11 deletions tests/options/test_dbopts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ suite "DbOptionsRef Tests":
dbOpts.setMaxOpenFiles(10)
dbOpts.setCreateMissingColumnFamilies(false)

check:
dbOpts.getCreateIfMissing()
dbOpts.getMaxOpenFiles() == 10
not dbOpts.getCreateMissingColumnFamilies()
# check:
# dbOpts.getCreateIfMissing()
# dbOpts.getMaxOpenFiles() == 10
# not dbOpts.getCreateMissingColumnFamilies()

dbOpts.close()

Expand All @@ -36,18 +36,18 @@ suite "DbOptionsRef Tests":

check:
not dbOpts.cPtr.isNil()
dbOpts.getCreateIfMissing()
dbOpts.getMaxOpenFiles() == -1
dbOpts.getCreateMissingColumnFamilies()
# dbOpts.getCreateIfMissing()
# dbOpts.getMaxOpenFiles() == -1
# dbOpts.getCreateMissingColumnFamilies()

dbOpts.setCreateIfMissing(false)
dbOpts.setMaxOpenFiles(100)
dbOpts.setCreateMissingColumnFamilies(false)

check:
not dbOpts.getCreateIfMissing()
dbOpts.getMaxOpenFiles() == 100
not dbOpts.getCreateMissingColumnFamilies()
# check:
# not dbOpts.getCreateIfMissing()
# dbOpts.getMaxOpenFiles() == 100
# not dbOpts.getCreateMissingColumnFamilies()

dbOpts.close()

Expand Down

0 comments on commit 55c2b29

Please sign in to comment.