Merge pull request #20 from status-im/max-open-files

Allow setting max open files in RocksDbInstance init
This commit is contained in:
kdeme 2019-07-16 21:12:30 +02:00 committed by GitHub
commit 5b1307cb1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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: