Allow setting max open files in RocksDbInstance init

This commit is contained in:
kdeme 2019-07-16 15:51:52 +02:00
parent 60faf6af17
commit a48aaf2215
No known key found for this signature in database
GPG Key ID: 4E8DD21420AF43F5
1 changed files with 5 additions and 1 deletions

View File

@ -103,7 +103,8 @@ proc init*(rocks: var RocksDBInstance,
dbPath, dbBackupPath: string, dbPath, dbBackupPath: string,
readOnly = false, readOnly = false,
cpus = countProcessors(), cpus = countProcessors(),
createIfMissing = true): RocksDBResult[void] = createIfMissing = true,
maxOpenFiles = -1): RocksDBResult[void] =
rocks.options = rocksdb_options_create() rocks.options = rocksdb_options_create()
rocks.readOptions = rocksdb_readoptions_create() rocks.readOptions = rocksdb_readoptions_create()
rocks.writeOptions = rocksdb_writeoptions_create() rocks.writeOptions = rocksdb_writeoptions_create()
@ -114,6 +115,9 @@ proc init*(rocks: var RocksDBInstance,
# snappy support (for example Fedora 28, certain Ubuntu versions) # snappy support (for example Fedora 28, certain Ubuntu versions)
# rocksdb_options_optimize_level_style_compaction(options, 0); # rocksdb_options_optimize_level_style_compaction(options, 0);
rocksdb_options_set_create_if_missing(rocks.options, uint8(createIfMissing)) rocksdb_options_set_create_if_missing(rocks.options, uint8(createIfMissing))
# default set to keep all files open (-1), allow setting it to a specific
# value, e.g. in case the application limit would be reached.
rocksdb_options_set_max_open_files(rocks.options, maxOpenFiles.cint)
var errors: cstring var errors: cstring
if readOnly: if readOnly: