diff --git a/README.md b/README.md index ccaf3ac..cb10454 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A Nim wrapper for [Facebook's RocksDB](https://github.com/facebook/rocksdb), a p ## Current status -Nim-RocksDB currently provides a wrapper for the low-level functions of RocksDB +Nim-RocksDB provides a wrapper for the low-level functions in the librocksdb c library. ## Requirements @@ -30,14 +30,6 @@ nim c -d:LibrocksbStaticArgs='-l:librocksdb.a' --gcc.linkerexe=g++ --threads:on (we need the C++ linker profile because it's a C++ library) -## Future directions - -In the future, Nim-RocksDB might provide a high-level API that: - -- is more in line with Nim conventions (types in CamelCase), -- automatically checks for errors, -- leverage Nim features like destructors for automatic resource cleanup. - ### Contribution Any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any diff --git a/rocksdb.nim b/rocksdb.nim index 3578789..50f30fa 100644 --- a/rocksdb.nim +++ b/rocksdb.nim @@ -1,5 +1,5 @@ # Nim-RocksDB -# Copyright 2018 Status Research & Development GmbH +# Copyright 2018-2024 Status Research & Development GmbH # Licensed under either of # # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) @@ -7,230 +7,6 @@ # # at your option. This file may not be copied, modified, or distributed except according to those terms. -{.push raises: [Defect].} +import ./rocksdb/[backup, rocksdb] -import cpuinfo, options, stew/[byteutils, results] - -from system/ansi_c import c_free - -export results - -const useCApi = true - -when useCApi: - import rocksdb/librocksdb - export librocksdb - -else: - {.error: "The C++ API of RocksDB is not supported yet".} - - # The intention of this template is that it will hide the - # difference between the C and C++ APIs for objects such - # as Read/WriteOptions, which are allocated either on the - # stack or the heap. - template initResource(resourceName) = - var res = resourceName() - res - -type - RocksDBInstance* = object - db*: rocksdb_t - backupEngine: rocksdb_backup_engine_t - options*: rocksdb_options_t - readOptions*: rocksdb_readoptions_t - writeOptions: rocksdb_writeoptions_t - dbPath: string # needed for clear() - - DataProc* = proc(val: openArray[byte]) {.gcsafe, raises: [Defect].} - - RocksDBResult*[T] = Result[T, string] - -template bailOnErrors {.dirty.} = - if not errors.isNil: - result.err($errors) - rocksdb_free(errors) - return - -proc init*(rocks: var RocksDBInstance, - dbPath, dbBackupPath: string, - readOnly = false, - cpus = countProcessors(), - createIfMissing = true, - maxOpenFiles = -1): RocksDBResult[void] = - rocks.options = rocksdb_options_create() - rocks.readOptions = rocksdb_readoptions_create() - rocks.writeOptions = rocksdb_writeoptions_create() - rocks.dbPath = dbPath - - # Optimize RocksDB. This is the easiest way to get RocksDB to perform well: - rocksdb_options_increase_parallelism(rocks.options, cpus.int32) - # This requires snappy - disabled because rocksdb is not always compiled with - # snappy support (for example Fedora 28, certain Ubuntu versions) - # rocksdb_options_optimize_level_style_compaction(options, 0); - 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 - if readOnly: - rocks.db = rocksdb_open_for_read_only(rocks.options, dbPath, 0'u8, errors.addr) - else: - rocks.db = rocksdb_open(rocks.options, dbPath, errors.addr) - bailOnErrors() - rocks.backupEngine = rocksdb_backup_engine_open(rocks.options, - dbBackupPath, errors.addr) - bailOnErrors() - ok() - -template initRocksDB*(args: varargs[untyped]): Option[RocksDBInstance] = - var db: RocksDBInstance - if not init(db, args): - none(RocksDBInstance) - else: - some(db) - -template getImpl(T: type) {.dirty.} = - if key.len <= 0: - return err("rocksdb: key cannot be empty on get") - - var - errors: cstring - len: csize_t - data = rocksdb_get(db.db, db.readOptions, - cast[cstring](unsafeAddr key[0]), csize_t(key.len), - addr len, addr errors) - bailOnErrors() - if not data.isNil: - result = ok(toOpenArray(data, 0, int(len) - 1).to(T)) - rocksdb_free(data) - else: - result = err("") - -proc get*(db: RocksDBInstance, key: openArray[byte], onData: DataProc): RocksDBResult[bool] = - if key.len <= 0: - return err("rocksdb: key cannot be empty on get") - - var - errors: cstring - len: csize_t - data = rocksdb_get(db.db, db.readOptions, - cast[cstring](unsafeAddr key[0]), csize_t(key.len), - addr len, addr errors) - bailOnErrors() - if not data.isNil: - # TODO onData may raise a Defect - in theory we could catch it and free the - # memory but this has a small overhead - setjmp (C) or RTTI (C++) - - # reconsider this once the exception dust settles - onData(toOpenArrayByte(data, 0, int(len) - 1)) - rocksdb_free(data) - ok(true) - else: - ok(false) - -proc get*(db: RocksDBInstance, key: openArray[byte]): RocksDBResult[string] {.deprecated: "DataProc".} = - ## Get value for `key`. If no value exists, set `result.ok` to `false`, - ## and result.error to `""`. - var res: RocksDBResult[string] - proc onData(data: openArray[byte]) = - res.ok(string.fromBytes(data)) - - if ? db.get(key, onData): - res - else: - ok("") - -proc getBytes*(db: RocksDBInstance, key: openArray[byte]): RocksDBResult[seq[byte]] {.deprecated: "DataProc".} = - ## Get value for `key`. If no value exists, set `result.ok` to `false`, - ## and result.error to `""`. - var res: RocksDBResult[seq[byte]] - proc onData(data: openArray[byte]) = - res.ok(@data) - - if ? db.get(key, onData): - res - else: - err("") - -proc put*(db: RocksDBInstance, key, val: openArray[byte]): RocksDBResult[void] = - if key.len <= 0: - return err("rocksdb: key cannot be empty on put") - - var - errors: cstring - - rocksdb_put(db.db, db.writeOptions, - cast[cstring](unsafeAddr key[0]), csize_t(key.len), - cast[cstring](if val.len > 0: unsafeAddr val[0] else: nil), - csize_t(val.len), - errors.addr) - - bailOnErrors() - ok() - -proc contains*(db: RocksDBInstance, key: openArray[byte]): RocksDBResult[bool] = - if key.len <= 0: - return err("rocksdb: key cannot be empty on contains") - - var - errors: cstring - len: csize_t - data = rocksdb_get(db.db, db.readOptions, - cast[cstring](unsafeAddr key[0]), csize_t(key.len), - addr len, errors.addr) - bailOnErrors() - if not data.isNil: - rocksdb_free(data) - ok(true) - else: - ok(false) - -proc del*(db: RocksDBInstance, key: openArray[byte]): RocksDBResult[bool] = - if key.len <= 0: - return err("rocksdb: key cannot be empty on del") - - # This seems like a bad idea, but right now I don't want to - # get sidetracked by this. --Adam - if not db.contains(key).get: - return ok(false) - - var errors: cstring - rocksdb_delete(db.db, db.writeOptions, - cast[cstring](unsafeAddr key[0]), csize_t(key.len), - errors.addr) - bailOnErrors() - ok(true) - -proc clear*(db: var RocksDBInstance): RocksDBResult[bool] = - raiseAssert "unimplemented" - -proc backup*(db: RocksDBInstance): RocksDBResult[void] = - var errors: cstring - rocksdb_backup_engine_create_new_backup(db.backupEngine, db.db, errors.addr) - bailOnErrors() - ok() - -# XXX: destructors are just too buggy at the moment: -# https://github.com/nim-lang/Nim/issues/8112 -# proc `=destroy`*(db: var RocksDBInstance) = -proc close*(db: var RocksDBInstance) = - template freeField(name) = - type FieldType = typeof db.`name` - if db.`name`.isNil: - `rocksdb name destroy`(db.`name`) - db.`name` = FieldType(nil) - template setFieldToNil(name) = - type FieldType = typeof db.`name` - db.`name` = FieldType(nil) - - freeField(writeOptions) - freeField(readOptions) - freeField(options) - - if not db.backupEngine.isNil: - rocksdb_backup_engine_close(db.backupEngine) - setFieldToNil(backupEngine) - - if not db.db.isNil: - rocksdb_close(db.db) - setFieldToNil(db) +export backup, rocksdb \ No newline at end of file diff --git a/rocksdb.nimble b/rocksdb.nimble index ee0e2d0..b0b8e2e 100644 --- a/rocksdb.nimble +++ b/rocksdb.nimble @@ -1,5 +1,5 @@ packageName = "rocksdb" -version = "0.3.1" +version = "0.4.0" author = "Status Research & Development GmbH" description = "A wrapper for Facebook's RocksDB, an embeddable, persistent key-value store for fast storage" license = "Apache License 2.0 or GPLv2" @@ -7,9 +7,10 @@ skipDirs = @["examples", "tests"] mode = ScriptMode.Verbose ### Dependencies -requires "nim >= 1.2.0", +requires "nim >= 1.6.0", "stew", - "tempfile" + "tempfile", + "unittest2" proc test(args, path: string) = if not dirExists "build": @@ -18,7 +19,7 @@ proc test(args, path: string) = " --outdir:build -r --hints:off --threads:on --skipParentCfg " & path task test, "Run tests": - test "", "tests/all.nim" + test "", "tests/test_all.nim" # Too troublesome to install "librocksdb.a" in CI, but this is how we would # test it (we need the C++ linker profile because it's a C++ library): # test "-d:LibrocksbStaticArgs='-l:librocksdb.a' --gcc.linkerexe=g++", "tests/all.nim" diff --git a/rocksdb/backup.nim b/rocksdb/backup.nim new file mode 100644 index 0000000..8e39270 --- /dev/null +++ b/rocksdb/backup.nim @@ -0,0 +1,93 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + ./lib/librocksdb, + ./internal/utils, + ./options/backupopts, + ./rocksdb + +export + results, + backupopts, + rocksdb + +type + BackupEnginePtr* = ptr rocksdb_backup_engine_t + + BackupEngineRef* = ref object + cPtr: BackupEnginePtr + path: string + backupOpts: BackupEngineOptionsRef + +proc openBackupEngine*( + path: string, + backupOpts = defaultBackupEngineOptions()): RocksDBResult[BackupEngineRef] = + + var errors: cstring + let backupEnginePtr = rocksdb_backup_engine_open( + backupOpts.cPtr, + path.cstring, + cast[cstringArray](errors.addr)) + bailOnErrors(errors) + + let engine = BackupEngineRef( + cPtr: backupEnginePtr, + path: path, + backupOpts: backupOpts) + ok(engine) + +template isClosed*(backupEngine: BackupEngineRef): bool = + backupEngine.cPtr.isNil() + +proc createNewBackup*( + backupEngine: BackupEngineRef, + db: RocksDbRef): RocksDBResult[void] = + doAssert not backupEngine.isClosed() + + var errors: cstring + rocksdb_backup_engine_create_new_backup( + backupEngine.cPtr, + db.cPtr, + cast[cstringArray](errors.addr)) + bailOnErrors(errors) + + ok() + +proc restoreDbFromLatestBackup*( + backupEngine: BackupEngineRef, + dbDir: string, + walDir = dbDir, + keepLogFiles = false): RocksDBResult[void] = + doAssert not backupEngine.isClosed() + + let restoreOptions = rocksdb_restore_options_create() + rocksdb_restore_options_set_keep_log_files(restoreOptions, keepLogFiles.cint) + + var errors: cstring + rocksdb_backup_engine_restore_db_from_latest_backup( + backupEngine.cPtr, + dbDir.cstring, + walDir.cstring, + restoreOptions, + cast[cstringArray](errors.addr)) + bailOnErrors(errors) + + rocksdb_restore_options_destroy(restoreOptions) + + ok() + +proc close*(backupEngine: var BackupEngineRef) = + if not backupEngine.isClosed(): + rocksdb_backup_engine_close(backupEngine.cPtr) + backupEngine.cPtr = nil + + diff --git a/rocksdb/columnfamily/cfdescriptor.nim b/rocksdb/columnfamily/cfdescriptor.nim new file mode 100644 index 0000000..2cb7983 --- /dev/null +++ b/rocksdb/columnfamily/cfdescriptor.nim @@ -0,0 +1,44 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + ../internal/utils, + ./cfopts + +export cfopts + +type + ColFamilyDescriptor* = object + name: string + options: ColFamilyOptionsRef + +proc initColFamilyDescriptor*( + name: string, + options = defaultColFamilyOptions()): ColFamilyDescriptor = + ColFamilyDescriptor(name: name, options: options) + +template name*(descriptor: ColFamilyDescriptor): string = + descriptor.name + +template options*(descriptor: ColFamilyDescriptor): ColFamilyOptionsRef = + descriptor.options + +template isDefault*(descriptor: ColFamilyDescriptor): bool = + descriptor.name == DEFAULT_COLUMN_FAMILY_NAME + +template defaultColFamilyDescriptor*(): ColFamilyDescriptor = + initColFamilyDescriptor(DEFAULT_COLUMN_FAMILY_NAME) + +template isClosed*(descriptor: ColFamilyDescriptor): bool = + descriptor.options.isClosed() + +template close*(descriptor: var ColFamilyDescriptor) = + descriptor.options.close() diff --git a/rocksdb/columnfamily/cfhandle.nim b/rocksdb/columnfamily/cfhandle.nim new file mode 100644 index 0000000..1a0a625 --- /dev/null +++ b/rocksdb/columnfamily/cfhandle.nim @@ -0,0 +1,50 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + ../lib/librocksdb + +type + ColFamilyHandlePtr* = ptr rocksdb_column_family_handle_t + + ColFamilyHandleRef* = ref object + cPtr: ColFamilyHandlePtr + +proc newColFamilyHandle*(cPtr: ColFamilyHandlePtr): ColFamilyHandleRef = + ColFamilyHandleRef(cPtr: cPtr) + +template isClosed*(handle: ColFamilyHandleRef): bool = + handle.cPtr.isNil() + +proc cPtr*(handle: ColFamilyHandleRef): ColFamilyHandlePtr = + doAssert not handle.isClosed() + handle.cPtr + +# 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 getId*(handle: ColFamilyHandleRef): int = +# doAssert not handle.isClosed() +# rocksdb_column_family_handle_get_id(handle.cPtr).int + +# proc getName*(handle: ColFamilyHandleRef): string = +# doAssert not handle.isClosed() +# var nameLen: csize_t +# $rocksdb_column_family_handle_get_name(handle.cPtr, nameLen.addr) + +# template isDefault*(handle: ColFamilyHandleRef): bool = +# handle.getName() == DEFAULT_COLUMN_FAMILY_NAME + +proc close*(handle: var ColFamilyHandleRef) = + if not handle.isClosed(): + rocksdb_column_family_handle_destroy(handle.cPtr) + handle.cPtr = nil \ No newline at end of file diff --git a/rocksdb/columnfamily/cfopts.nim b/rocksdb/columnfamily/cfopts.nim new file mode 100644 index 0000000..be04b40 --- /dev/null +++ b/rocksdb/columnfamily/cfopts.nim @@ -0,0 +1,53 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + ../lib/librocksdb + +type + ColFamilyOptionsPtr* = ptr rocksdb_options_t + + ColFamilyOptionsRef* = ref object + cPtr: ColFamilyOptionsPtr + +proc newColFamilyOptions*(): ColFamilyOptionsRef = + ColFamilyOptionsRef(cPtr: rocksdb_options_create()) + +template isClosed*(cfOpts: ColFamilyOptionsRef): bool = + cfOpts.cPtr.isNil() + +proc cPtr*(cfOpts: ColFamilyOptionsRef): ColFamilyOptionsPtr = + doAssert not cfOpts.isClosed() + cfOpts.cPtr + +proc setCreateMissingColumnFamilies*(cfOpts: var ColFamilyOptionsRef, flag: bool) = + doAssert not cfOpts.isClosed() + rocksdb_options_set_create_missing_column_families(cfOpts.cPtr, flag.uint8) + +proc defaultColFamilyOptions*(): ColFamilyOptionsRef = + var opts = newColFamilyOptions() + # Enable creating column families if they do not exist + opts.setCreateMissingColumnFamilies(true) + return opts + +# 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(): + rocksdb_options_destroy(cfOpts.cPtr) + cfOpts.cPtr = nil + diff --git a/rocksdb/headers/c.h b/rocksdb/headers/c.h deleted file mode 100644 index 680dc3e..0000000 --- a/rocksdb/headers/c.h +++ /dev/null @@ -1,1568 +0,0 @@ -// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. -// This source code is licensed under both the GPLv2 (found in the -// COPYING file in the root directory) and Apache 2.0 License -// (found in the LICENSE.Apache file in the root directory). - -/* Copyright (c) 2011 The LevelDB Authors. All rights reserved. - Use of this source code is governed by a BSD-style license that can be - found in the LICENSE file. See the AUTHORS file for names of contributors. - - C bindings for rocksdb. May be useful as a stable ABI that can be - used by programs that keep rocksdb in a shared library, or for - a JNI api. - - Does not support: - . getters for the option types - . custom comparators that implement key shortening - . capturing post-write-snapshot - . custom iter, db, env, cache implementations using just the C bindings - - Some conventions: - - (1) We expose just opaque struct pointers and functions to clients. - This allows us to change internal representations without having to - recompile clients. - - (2) For simplicity, there is no equivalent to the Slice type. Instead, - the caller has to pass the pointer and length as separate - arguments. - - (3) Errors are represented by a null-terminated c string. NULL - means no error. All operations that can raise an error are passed - a "char** errptr" as the last argument. One of the following must - be true on entry: - *errptr == NULL - *errptr points to a malloc()ed null-terminated error message - On success, a leveldb routine leaves *errptr unchanged. - On failure, leveldb frees the old value of *errptr and - set *errptr to a malloc()ed error message. - - (4) Bools have the type unsigned char (0 == false; rest == true) - - (5) All of the pointer arguments must be non-NULL. -*/ - -#ifndef STORAGE_ROCKSDB_INCLUDE_C_H_ -#define STORAGE_ROCKSDB_INCLUDE_C_H_ - -#pragma once - -#ifdef C2NIM -# def ROCKSDB_LIBRARY_API -# dynlib librocksdb -# cdecl -# if defined(windows) -# define librocksdb "librocksdb.dll" -# elif defined(macosx) -# define librocksdb "librocksdb.dylib" -# else -# define librocksdb "librocksdb.so" -# endif -# mangle uint32_t uint32 -# mangle uint16_t uint16 -# mangle uint8_t uint8 -# mangle uint64_t uint64 -# mangle int32_t int32 -# mangle int16_t int16 -# mangle int8_t int8 -# mangle int64_t int64 -# mangle cuchar uint8 -#else -# ifdef _WIN32 -# ifdef ROCKSDB_DLL -# ifdef ROCKSDB_LIBRARY_EXPORTS -# define ROCKSDB_LIBRARY_API __declspec(dllexport) -# else -# define ROCKSDB_LIBRARY_API __declspec(dllimport) -# endif -# else -# define ROCKSDB_LIBRARY_API -# endif -# else -# define ROCKSDB_LIBRARY_API -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -/* Exported types */ - -typedef struct rocksdb_t rocksdb_t; -typedef struct rocksdb_backup_engine_t rocksdb_backup_engine_t; -typedef struct rocksdb_backup_engine_info_t rocksdb_backup_engine_info_t; -typedef struct rocksdb_restore_options_t rocksdb_restore_options_t; -typedef struct rocksdb_cache_t rocksdb_cache_t; -typedef struct rocksdb_compactionfilter_t rocksdb_compactionfilter_t; -typedef struct rocksdb_compactionfiltercontext_t - rocksdb_compactionfiltercontext_t; -typedef struct rocksdb_compactionfilterfactory_t - rocksdb_compactionfilterfactory_t; -typedef struct rocksdb_comparator_t rocksdb_comparator_t; -typedef struct rocksdb_dbpath_t rocksdb_dbpath_t; -typedef struct rocksdb_env_t rocksdb_env_t; -typedef struct rocksdb_fifo_compaction_options_t rocksdb_fifo_compaction_options_t; -typedef struct rocksdb_filelock_t rocksdb_filelock_t; -typedef struct rocksdb_filterpolicy_t rocksdb_filterpolicy_t; -typedef struct rocksdb_flushoptions_t rocksdb_flushoptions_t; -typedef struct rocksdb_iterator_t rocksdb_iterator_t; -typedef struct rocksdb_logger_t rocksdb_logger_t; -typedef struct rocksdb_mergeoperator_t rocksdb_mergeoperator_t; -typedef struct rocksdb_options_t rocksdb_options_t; -typedef struct rocksdb_compactoptions_t rocksdb_compactoptions_t; -typedef struct rocksdb_block_based_table_options_t - rocksdb_block_based_table_options_t; -typedef struct rocksdb_cuckoo_table_options_t - rocksdb_cuckoo_table_options_t; -typedef struct rocksdb_randomfile_t rocksdb_randomfile_t; -typedef struct rocksdb_readoptions_t rocksdb_readoptions_t; -typedef struct rocksdb_seqfile_t rocksdb_seqfile_t; -typedef struct rocksdb_slicetransform_t rocksdb_slicetransform_t; -typedef struct rocksdb_snapshot_t rocksdb_snapshot_t; -typedef struct rocksdb_writablefile_t rocksdb_writablefile_t; -typedef struct rocksdb_writebatch_t rocksdb_writebatch_t; -typedef struct rocksdb_writebatch_wi_t rocksdb_writebatch_wi_t; -typedef struct rocksdb_writeoptions_t rocksdb_writeoptions_t; -typedef struct rocksdb_universal_compaction_options_t rocksdb_universal_compaction_options_t; -typedef struct rocksdb_livefiles_t rocksdb_livefiles_t; -typedef struct rocksdb_column_family_handle_t rocksdb_column_family_handle_t; -typedef struct rocksdb_envoptions_t rocksdb_envoptions_t; -typedef struct rocksdb_ingestexternalfileoptions_t rocksdb_ingestexternalfileoptions_t; -typedef struct rocksdb_sstfilewriter_t rocksdb_sstfilewriter_t; -typedef struct rocksdb_ratelimiter_t rocksdb_ratelimiter_t; -typedef struct rocksdb_pinnableslice_t rocksdb_pinnableslice_t; -typedef struct rocksdb_transactiondb_options_t rocksdb_transactiondb_options_t; -typedef struct rocksdb_transactiondb_t rocksdb_transactiondb_t; -typedef struct rocksdb_transaction_options_t rocksdb_transaction_options_t; -typedef struct rocksdb_optimistictransactiondb_t - rocksdb_optimistictransactiondb_t; -typedef struct rocksdb_optimistictransaction_options_t - rocksdb_optimistictransaction_options_t; -typedef struct rocksdb_transaction_t rocksdb_transaction_t; -typedef struct rocksdb_checkpoint_t rocksdb_checkpoint_t; - -/* DB operations */ - -extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open( - const rocksdb_options_t* options, const char* name, char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_for_read_only( - const rocksdb_options_t* options, const char* name, - unsigned char error_if_log_file_exist, char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_backup_engine_t* rocksdb_backup_engine_open( - const rocksdb_options_t* options, const char* path, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_create_new_backup( - rocksdb_backup_engine_t* be, rocksdb_t* db, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_purge_old_backups( - rocksdb_backup_engine_t* be, uint32_t num_backups_to_keep, char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_restore_options_t* -rocksdb_restore_options_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_restore_options_destroy( - rocksdb_restore_options_t* opt); -extern ROCKSDB_LIBRARY_API void rocksdb_restore_options_set_keep_log_files( - rocksdb_restore_options_t* opt, int v); - -extern ROCKSDB_LIBRARY_API void -rocksdb_backup_engine_restore_db_from_latest_backup( - rocksdb_backup_engine_t* be, const char* db_dir, const char* wal_dir, - const rocksdb_restore_options_t* restore_options, char** errptr); - -extern ROCKSDB_LIBRARY_API const rocksdb_backup_engine_info_t* -rocksdb_backup_engine_get_backup_info(rocksdb_backup_engine_t* be); - -extern ROCKSDB_LIBRARY_API int rocksdb_backup_engine_info_count( - const rocksdb_backup_engine_info_t* info); - -extern ROCKSDB_LIBRARY_API int64_t -rocksdb_backup_engine_info_timestamp(const rocksdb_backup_engine_info_t* info, - int index); - -extern ROCKSDB_LIBRARY_API uint32_t -rocksdb_backup_engine_info_backup_id(const rocksdb_backup_engine_info_t* info, - int index); - -extern ROCKSDB_LIBRARY_API uint64_t -rocksdb_backup_engine_info_size(const rocksdb_backup_engine_info_t* info, - int index); - -extern ROCKSDB_LIBRARY_API uint32_t rocksdb_backup_engine_info_number_files( - const rocksdb_backup_engine_info_t* info, int index); - -extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_info_destroy( - const rocksdb_backup_engine_info_t* info); - -extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_close( - rocksdb_backup_engine_t* be); - -extern ROCKSDB_LIBRARY_API rocksdb_checkpoint_t* -rocksdb_checkpoint_object_create(rocksdb_t* db, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_checkpoint_create( - rocksdb_checkpoint_t* checkpoint, const char* checkpoint_dir, - uint64_t log_size_for_flush, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_checkpoint_object_destroy( - rocksdb_checkpoint_t* checkpoint); - -extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_column_families( - const rocksdb_options_t* options, const char* name, int num_column_families, - const char** column_family_names, - const rocksdb_options_t** column_family_options, - rocksdb_column_family_handle_t** column_family_handles, char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_t* -rocksdb_open_for_read_only_column_families( - const rocksdb_options_t* options, const char* name, int num_column_families, - const char** column_family_names, - const rocksdb_options_t** column_family_options, - rocksdb_column_family_handle_t** column_family_handles, - unsigned char error_if_log_file_exist, char** errptr); - -extern ROCKSDB_LIBRARY_API char** rocksdb_list_column_families( - const rocksdb_options_t* options, const char* name, size_t* lencf, - char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_list_column_families_destroy( - char** list, size_t len); - -extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t* -rocksdb_create_column_family(rocksdb_t* db, - const rocksdb_options_t* column_family_options, - const char* column_family_name, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_drop_column_family( - rocksdb_t* db, rocksdb_column_family_handle_t* handle, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_column_family_handle_destroy( - rocksdb_column_family_handle_t*); - -extern ROCKSDB_LIBRARY_API void rocksdb_close(rocksdb_t* db); - -extern ROCKSDB_LIBRARY_API void rocksdb_put( - rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, - size_t keylen, const char* val, size_t vallen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_put_cf( - rocksdb_t* db, const rocksdb_writeoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, - size_t keylen, const char* val, size_t vallen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_delete( - rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, - size_t keylen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_delete_cf( - rocksdb_t* db, const rocksdb_writeoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, - size_t keylen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_merge( - rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, - size_t keylen, const char* val, size_t vallen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_merge_cf( - rocksdb_t* db, const rocksdb_writeoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, - size_t keylen, const char* val, size_t vallen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_write( - rocksdb_t* db, const rocksdb_writeoptions_t* options, - rocksdb_writebatch_t* batch, char** errptr); - -/* Returns NULL if not found. A malloc()ed array otherwise. - Stores the length of the array in *vallen. */ -extern ROCKSDB_LIBRARY_API char* rocksdb_get( - rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, - size_t keylen, size_t* vallen, char** errptr); - -extern ROCKSDB_LIBRARY_API char* rocksdb_get_cf( - rocksdb_t* db, const rocksdb_readoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, - size_t keylen, size_t* vallen, char** errptr); - -// if values_list[i] == NULL and errs[i] == NULL, -// then we got status.IsNotFound(), which we will not return. -// all errors except status status.ok() and status.IsNotFound() are returned. -// -// errs, values_list and values_list_sizes must be num_keys in length, -// allocated by the caller. -// errs is a list of strings as opposed to the conventional one error, -// where errs[i] is the status for retrieval of keys_list[i]. -// each non-NULL errs entry is a malloc()ed, null terminated string. -// each non-NULL values_list entry is a malloc()ed array, with -// the length for each stored in values_list_sizes[i]. -extern ROCKSDB_LIBRARY_API void rocksdb_multi_get( - rocksdb_t* db, const rocksdb_readoptions_t* options, size_t num_keys, - const char* const* keys_list, const size_t* keys_list_sizes, - char** values_list, size_t* values_list_sizes, char** errs); - -extern ROCKSDB_LIBRARY_API void rocksdb_multi_get_cf( - rocksdb_t* db, const rocksdb_readoptions_t* options, - const rocksdb_column_family_handle_t* const* column_families, - size_t num_keys, const char* const* keys_list, - const size_t* keys_list_sizes, char** values_list, - size_t* values_list_sizes, char** errs); - -extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* rocksdb_create_iterator( - rocksdb_t* db, const rocksdb_readoptions_t* options); - -extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* rocksdb_create_iterator_cf( - rocksdb_t* db, const rocksdb_readoptions_t* options, - rocksdb_column_family_handle_t* column_family); - -extern ROCKSDB_LIBRARY_API void rocksdb_create_iterators( - rocksdb_t *db, rocksdb_readoptions_t* opts, - rocksdb_column_family_handle_t** column_families, - rocksdb_iterator_t** iterators, size_t size, char** errptr); - -extern ROCKSDB_LIBRARY_API const rocksdb_snapshot_t* rocksdb_create_snapshot( - rocksdb_t* db); - -extern ROCKSDB_LIBRARY_API void rocksdb_release_snapshot( - rocksdb_t* db, const rocksdb_snapshot_t* snapshot); - -/* Returns NULL if property name is unknown. - Else returns a pointer to a malloc()-ed null-terminated value. */ -extern ROCKSDB_LIBRARY_API char* rocksdb_property_value(rocksdb_t* db, - const char* propname); -/* returns 0 on success, -1 otherwise */ -int rocksdb_property_int( - rocksdb_t* db, - const char* propname, uint64_t *out_val); - -extern ROCKSDB_LIBRARY_API char* rocksdb_property_value_cf( - rocksdb_t* db, rocksdb_column_family_handle_t* column_family, - const char* propname); - -extern ROCKSDB_LIBRARY_API void rocksdb_approximate_sizes( - rocksdb_t* db, int num_ranges, const char* const* range_start_key, - const size_t* range_start_key_len, const char* const* range_limit_key, - const size_t* range_limit_key_len, uint64_t* sizes); - -extern ROCKSDB_LIBRARY_API void rocksdb_approximate_sizes_cf( - rocksdb_t* db, rocksdb_column_family_handle_t* column_family, - int num_ranges, const char* const* range_start_key, - const size_t* range_start_key_len, const char* const* range_limit_key, - const size_t* range_limit_key_len, uint64_t* sizes); - -extern ROCKSDB_LIBRARY_API void rocksdb_compact_range(rocksdb_t* db, - const char* start_key, - size_t start_key_len, - const char* limit_key, - size_t limit_key_len); - -extern ROCKSDB_LIBRARY_API void rocksdb_compact_range_cf( - rocksdb_t* db, rocksdb_column_family_handle_t* column_family, - const char* start_key, size_t start_key_len, const char* limit_key, - size_t limit_key_len); - -extern ROCKSDB_LIBRARY_API void rocksdb_compact_range_opt( - rocksdb_t* db, rocksdb_compactoptions_t* opt, const char* start_key, - size_t start_key_len, const char* limit_key, size_t limit_key_len); - -extern ROCKSDB_LIBRARY_API void rocksdb_compact_range_cf_opt( - rocksdb_t* db, rocksdb_column_family_handle_t* column_family, - rocksdb_compactoptions_t* opt, const char* start_key, size_t start_key_len, - const char* limit_key, size_t limit_key_len); - -extern ROCKSDB_LIBRARY_API void rocksdb_delete_file(rocksdb_t* db, - const char* name); - -extern ROCKSDB_LIBRARY_API const rocksdb_livefiles_t* rocksdb_livefiles( - rocksdb_t* db); - -extern ROCKSDB_LIBRARY_API void rocksdb_flush( - rocksdb_t* db, const rocksdb_flushoptions_t* options, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_disable_file_deletions(rocksdb_t* db, - char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_enable_file_deletions( - rocksdb_t* db, unsigned char force, char** errptr); - -/* Management operations */ - -extern ROCKSDB_LIBRARY_API void rocksdb_destroy_db( - const rocksdb_options_t* options, const char* name, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_repair_db( - const rocksdb_options_t* options, const char* name, char** errptr); - -/* Iterator */ - -extern ROCKSDB_LIBRARY_API void rocksdb_iter_destroy(rocksdb_iterator_t*); -extern ROCKSDB_LIBRARY_API unsigned char rocksdb_iter_valid( - const rocksdb_iterator_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_iter_seek_to_first(rocksdb_iterator_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_iter_seek_to_last(rocksdb_iterator_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_iter_seek(rocksdb_iterator_t*, - const char* k, size_t klen); -extern ROCKSDB_LIBRARY_API void rocksdb_iter_seek_for_prev(rocksdb_iterator_t*, - const char* k, - size_t klen); -extern ROCKSDB_LIBRARY_API void rocksdb_iter_next(rocksdb_iterator_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_iter_prev(rocksdb_iterator_t*); -extern ROCKSDB_LIBRARY_API const char* rocksdb_iter_key( - const rocksdb_iterator_t*, size_t* klen); -extern ROCKSDB_LIBRARY_API const char* rocksdb_iter_value( - const rocksdb_iterator_t*, size_t* vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_iter_get_error( - const rocksdb_iterator_t*, char** errptr); - -/* Write batch */ - -extern ROCKSDB_LIBRARY_API rocksdb_writebatch_t* rocksdb_writebatch_create(); -extern ROCKSDB_LIBRARY_API rocksdb_writebatch_t* rocksdb_writebatch_create_from( - const char* rep, size_t size); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_destroy( - rocksdb_writebatch_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_clear(rocksdb_writebatch_t*); -extern ROCKSDB_LIBRARY_API int rocksdb_writebatch_count(rocksdb_writebatch_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_put(rocksdb_writebatch_t*, - const char* key, - size_t klen, - const char* val, - size_t vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_put_cf( - rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, - const char* key, size_t klen, const char* val, size_t vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_putv( - rocksdb_writebatch_t* b, int num_keys, const char* const* keys_list, - const size_t* keys_list_sizes, int num_values, - const char* const* values_list, const size_t* values_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_putv_cf( - rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, - int num_keys, const char* const* keys_list, const size_t* keys_list_sizes, - int num_values, const char* const* values_list, - const size_t* values_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_merge(rocksdb_writebatch_t*, - const char* key, - size_t klen, - const char* val, - size_t vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_merge_cf( - rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, - const char* key, size_t klen, const char* val, size_t vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_mergev( - rocksdb_writebatch_t* b, int num_keys, const char* const* keys_list, - const size_t* keys_list_sizes, int num_values, - const char* const* values_list, const size_t* values_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_mergev_cf( - rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, - int num_keys, const char* const* keys_list, const size_t* keys_list_sizes, - int num_values, const char* const* values_list, - const size_t* values_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete(rocksdb_writebatch_t*, - const char* key, - size_t klen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_cf( - rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, - const char* key, size_t klen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_deletev( - rocksdb_writebatch_t* b, int num_keys, const char* const* keys_list, - const size_t* keys_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_deletev_cf( - rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, - int num_keys, const char* const* keys_list, const size_t* keys_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_range( - rocksdb_writebatch_t* b, const char* start_key, size_t start_key_len, - const char* end_key, size_t end_key_len); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_range_cf( - rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, - const char* start_key, size_t start_key_len, const char* end_key, - size_t end_key_len); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_rangev( - rocksdb_writebatch_t* b, int num_keys, const char* const* start_keys_list, - const size_t* start_keys_list_sizes, const char* const* end_keys_list, - const size_t* end_keys_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_rangev_cf( - rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, - int num_keys, const char* const* start_keys_list, - const size_t* start_keys_list_sizes, const char* const* end_keys_list, - const size_t* end_keys_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_put_log_data( - rocksdb_writebatch_t*, const char* blob, size_t len); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_iterate( - rocksdb_writebatch_t*, void* state, - void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), - void (*deleted)(void*, const char* k, size_t klen)); -extern ROCKSDB_LIBRARY_API const char* rocksdb_writebatch_data( - rocksdb_writebatch_t*, size_t* size); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_set_save_point( - rocksdb_writebatch_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_rollback_to_save_point( - rocksdb_writebatch_t*, char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_pop_save_point( - rocksdb_writebatch_t*, char** errptr); - -/* Write batch with index */ - -extern ROCKSDB_LIBRARY_API rocksdb_writebatch_wi_t* rocksdb_writebatch_wi_create( - size_t reserved_bytes, - unsigned char overwrite_keys); -extern ROCKSDB_LIBRARY_API rocksdb_writebatch_wi_t* rocksdb_writebatch_wi_create_from( - const char* rep, size_t size); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_destroy( - rocksdb_writebatch_wi_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_clear(rocksdb_writebatch_wi_t*); -extern ROCKSDB_LIBRARY_API int rocksdb_writebatch_wi_count(rocksdb_writebatch_wi_t* b); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_put(rocksdb_writebatch_wi_t*, - const char* key, - size_t klen, - const char* val, - size_t vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_put_cf( - rocksdb_writebatch_wi_t*, rocksdb_column_family_handle_t* column_family, - const char* key, size_t klen, const char* val, size_t vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_putv( - rocksdb_writebatch_wi_t* b, int num_keys, const char* const* keys_list, - const size_t* keys_list_sizes, int num_values, - const char* const* values_list, const size_t* values_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_putv_cf( - rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, - int num_keys, const char* const* keys_list, const size_t* keys_list_sizes, - int num_values, const char* const* values_list, - const size_t* values_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_merge(rocksdb_writebatch_wi_t*, - const char* key, - size_t klen, - const char* val, - size_t vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_merge_cf( - rocksdb_writebatch_wi_t*, rocksdb_column_family_handle_t* column_family, - const char* key, size_t klen, const char* val, size_t vlen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_mergev( - rocksdb_writebatch_wi_t* b, int num_keys, const char* const* keys_list, - const size_t* keys_list_sizes, int num_values, - const char* const* values_list, const size_t* values_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_mergev_cf( - rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, - int num_keys, const char* const* keys_list, const size_t* keys_list_sizes, - int num_values, const char* const* values_list, - const size_t* values_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete(rocksdb_writebatch_wi_t*, - const char* key, - size_t klen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_cf( - rocksdb_writebatch_wi_t*, rocksdb_column_family_handle_t* column_family, - const char* key, size_t klen); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_deletev( - rocksdb_writebatch_wi_t* b, int num_keys, const char* const* keys_list, - const size_t* keys_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_deletev_cf( - rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, - int num_keys, const char* const* keys_list, const size_t* keys_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_range( - rocksdb_writebatch_wi_t* b, const char* start_key, size_t start_key_len, - const char* end_key, size_t end_key_len); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_range_cf( - rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, - const char* start_key, size_t start_key_len, const char* end_key, - size_t end_key_len); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_rangev( - rocksdb_writebatch_wi_t* b, int num_keys, const char* const* start_keys_list, - const size_t* start_keys_list_sizes, const char* const* end_keys_list, - const size_t* end_keys_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_rangev_cf( - rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, - int num_keys, const char* const* start_keys_list, - const size_t* start_keys_list_sizes, const char* const* end_keys_list, - const size_t* end_keys_list_sizes); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_put_log_data( - rocksdb_writebatch_wi_t*, const char* blob, size_t len); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_iterate( - rocksdb_writebatch_wi_t* b, - void* state, - void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), - void (*deleted)(void*, const char* k, size_t klen)); -extern ROCKSDB_LIBRARY_API const char* rocksdb_writebatch_wi_data( - rocksdb_writebatch_wi_t* b, - size_t* size); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_set_save_point( - rocksdb_writebatch_wi_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_rollback_to_save_point( - rocksdb_writebatch_wi_t*, char** errptr); -extern ROCKSDB_LIBRARY_API char* rocksdb_writebatch_wi_get_from_batch( - rocksdb_writebatch_wi_t* wbwi, - const rocksdb_options_t* options, - const char* key, size_t keylen, - size_t* vallen, - char** errptr); -extern ROCKSDB_LIBRARY_API char* rocksdb_writebatch_wi_get_from_batch_cf( - rocksdb_writebatch_wi_t* wbwi, - const rocksdb_options_t* options, - rocksdb_column_family_handle_t* column_family, - const char* key, size_t keylen, - size_t* vallen, - char** errptr); -extern ROCKSDB_LIBRARY_API char* rocksdb_writebatch_wi_get_from_batch_and_db( - rocksdb_writebatch_wi_t* wbwi, - rocksdb_t* db, - const rocksdb_readoptions_t* options, - const char* key, size_t keylen, - size_t* vallen, - char** errptr); -extern ROCKSDB_LIBRARY_API char* rocksdb_writebatch_wi_get_from_batch_and_db_cf( - rocksdb_writebatch_wi_t* wbwi, - rocksdb_t* db, - const rocksdb_readoptions_t* options, - rocksdb_column_family_handle_t* column_family, - const char* key, size_t keylen, - size_t* vallen, - char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_write_writebatch_wi( - rocksdb_t* db, - const rocksdb_writeoptions_t* options, - rocksdb_writebatch_wi_t* wbwi, - char** errptr); -extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* rocksdb_writebatch_wi_create_iterator_with_base( - rocksdb_writebatch_wi_t* wbwi, - rocksdb_iterator_t* base_iterator); -extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* rocksdb_writebatch_wi_create_iterator_with_base_cf( - rocksdb_writebatch_wi_t* wbwi, - rocksdb_iterator_t* base_iterator, - rocksdb_column_family_handle_t* cf); - - -/* Block based table options */ - -extern ROCKSDB_LIBRARY_API rocksdb_block_based_table_options_t* -rocksdb_block_based_options_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_destroy( - rocksdb_block_based_table_options_t* options); -extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_block_size( - rocksdb_block_based_table_options_t* options, size_t block_size); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_block_size_deviation( - rocksdb_block_based_table_options_t* options, int block_size_deviation); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_block_restart_interval( - rocksdb_block_based_table_options_t* options, int block_restart_interval); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_index_block_restart_interval( - rocksdb_block_based_table_options_t* options, int index_block_restart_interval); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_metadata_block_size( - rocksdb_block_based_table_options_t* options, uint64_t metadata_block_size); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_partition_filters( - rocksdb_block_based_table_options_t* options, unsigned char partition_filters); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_use_delta_encoding( - rocksdb_block_based_table_options_t* options, unsigned char use_delta_encoding); -extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_filter_policy( - rocksdb_block_based_table_options_t* options, - rocksdb_filterpolicy_t* filter_policy); -extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_no_block_cache( - rocksdb_block_based_table_options_t* options, unsigned char no_block_cache); -extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_block_cache( - rocksdb_block_based_table_options_t* options, rocksdb_cache_t* block_cache); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_block_cache_compressed( - rocksdb_block_based_table_options_t* options, - rocksdb_cache_t* block_cache_compressed); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_whole_key_filtering( - rocksdb_block_based_table_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_format_version( - rocksdb_block_based_table_options_t*, int); -enum { - rocksdb_block_based_table_index_type_binary_search = 0, - rocksdb_block_based_table_index_type_hash_search = 1, - rocksdb_block_based_table_index_type_two_level_index_search = 2, -}; -extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_index_type( - rocksdb_block_based_table_options_t*, int); // uses one of the above enums -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_hash_index_allow_collision( - rocksdb_block_based_table_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_cache_index_and_filter_blocks( - rocksdb_block_based_table_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority( - rocksdb_block_based_table_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache( - rocksdb_block_based_table_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_block_based_table_factory( - rocksdb_options_t* opt, rocksdb_block_based_table_options_t* table_options); - -/* Cuckoo table options */ - -extern ROCKSDB_LIBRARY_API rocksdb_cuckoo_table_options_t* -rocksdb_cuckoo_options_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_destroy( - rocksdb_cuckoo_table_options_t* options); -extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_set_hash_ratio( - rocksdb_cuckoo_table_options_t* options, double v); -extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_set_max_search_depth( - rocksdb_cuckoo_table_options_t* options, uint32_t v); -extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_set_cuckoo_block_size( - rocksdb_cuckoo_table_options_t* options, uint32_t v); -extern ROCKSDB_LIBRARY_API void -rocksdb_cuckoo_options_set_identity_as_first_hash( - rocksdb_cuckoo_table_options_t* options, unsigned char v); -extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_set_use_module_hash( - rocksdb_cuckoo_table_options_t* options, unsigned char v); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_cuckoo_table_factory( - rocksdb_options_t* opt, rocksdb_cuckoo_table_options_t* table_options); - -/* Options */ -extern ROCKSDB_LIBRARY_API void rocksdb_set_options( - rocksdb_t* db, int count, const char* const keys[], const char* const values[], char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_options_t* rocksdb_options_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_options_destroy(rocksdb_options_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_increase_parallelism( - rocksdb_options_t* opt, int total_threads); -extern ROCKSDB_LIBRARY_API void rocksdb_options_optimize_for_point_lookup( - rocksdb_options_t* opt, uint64_t block_cache_size_mb); -extern ROCKSDB_LIBRARY_API void rocksdb_options_optimize_level_style_compaction( - rocksdb_options_t* opt, uint64_t memtable_memory_budget); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_optimize_universal_style_compaction( - rocksdb_options_t* opt, uint64_t memtable_memory_budget); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_allow_ingest_behind(rocksdb_options_t*, - unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compaction_filter( - rocksdb_options_t*, rocksdb_compactionfilter_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compaction_filter_factory( - rocksdb_options_t*, rocksdb_compactionfilterfactory_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_compaction_readahead_size( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_comparator( - rocksdb_options_t*, rocksdb_comparator_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_merge_operator( - rocksdb_options_t*, rocksdb_mergeoperator_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_uint64add_merge_operator( - rocksdb_options_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression_per_level( - rocksdb_options_t* opt, int* level_values, size_t num_levels); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_create_if_missing( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_create_missing_column_families(rocksdb_options_t*, - unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_error_if_exists( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_paranoid_checks( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_db_paths(rocksdb_options_t*, - const rocksdb_dbpath_t** path_values, - size_t num_paths); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_env(rocksdb_options_t*, - rocksdb_env_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_info_log(rocksdb_options_t*, - rocksdb_logger_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_info_log_level( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_write_buffer_size( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_db_write_buffer_size( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_open_files( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_file_opening_threads( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_total_wal_size( - rocksdb_options_t* opt, uint64_t n); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression_options( - rocksdb_options_t*, int, int, int, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_prefix_extractor( - rocksdb_options_t*, rocksdb_slicetransform_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_num_levels( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_level0_file_num_compaction_trigger(rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_level0_slowdown_writes_trigger(rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_level0_stop_writes_trigger( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_mem_compaction_level( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_target_file_size_base( - rocksdb_options_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_target_file_size_multiplier( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_bytes_for_level_base( - rocksdb_options_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_level_compaction_dynamic_level_bytes(rocksdb_options_t*, - unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_max_bytes_for_level_multiplier(rocksdb_options_t*, double); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_max_bytes_for_level_multiplier_additional( - rocksdb_options_t*, int* level_values, size_t num_levels); -extern ROCKSDB_LIBRARY_API void rocksdb_options_enable_statistics( - rocksdb_options_t*); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_skip_stats_update_on_db_open(rocksdb_options_t* opt, - unsigned char val); - -/* returns a pointer to a malloc()-ed, null terminated string */ -extern ROCKSDB_LIBRARY_API char* rocksdb_options_statistics_get_string( - rocksdb_options_t* opt); - -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_write_buffer_number( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_min_write_buffer_number_to_merge(rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_max_write_buffer_number_to_maintain(rocksdb_options_t*, - int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_background_compactions( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_base_background_compactions( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_background_flushes( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_log_file_size( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_log_file_time_to_roll( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_keep_log_file_num( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_recycle_log_file_num( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_soft_rate_limit( - rocksdb_options_t*, double); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hard_rate_limit( - rocksdb_options_t*, double); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_soft_pending_compaction_bytes_limit( - rocksdb_options_t* opt, size_t v); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hard_pending_compaction_bytes_limit( - rocksdb_options_t* opt, size_t v); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_rate_limit_delay_max_milliseconds(rocksdb_options_t*, - unsigned int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_manifest_file_size( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_table_cache_numshardbits( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_table_cache_remove_scan_count_limit(rocksdb_options_t*, - int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_arena_block_size( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_use_fsync( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_db_log_dir( - rocksdb_options_t*, const char*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_wal_dir(rocksdb_options_t*, - const char*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_WAL_ttl_seconds( - rocksdb_options_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_WAL_size_limit_MB( - rocksdb_options_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_manifest_preallocation_size( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_purge_redundant_kvs_while_flush(rocksdb_options_t*, - unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_allow_mmap_reads( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_allow_mmap_writes( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_use_direct_reads( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_use_direct_io_for_flush_and_compaction(rocksdb_options_t*, - unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_is_fd_close_on_exec( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_skip_log_error_on_recovery( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_stats_dump_period_sec( - rocksdb_options_t*, unsigned int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_advise_random_on_open( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_access_hint_on_compaction_start(rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_use_adaptive_mutex( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_bytes_per_sync( - rocksdb_options_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_wal_bytes_per_sync( - rocksdb_options_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_writable_file_max_buffer_size(rocksdb_options_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_allow_concurrent_memtable_write(rocksdb_options_t*, - unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_enable_write_thread_adaptive_yield(rocksdb_options_t*, - unsigned char); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_max_sequential_skip_in_iterations(rocksdb_options_t*, - uint64_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_disable_auto_compactions( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_optimize_filters_for_hits( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_delete_obsolete_files_period_micros(rocksdb_options_t*, - uint64_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_prepare_for_bulk_load( - rocksdb_options_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_memtable_vector_rep( - rocksdb_options_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_memtable_prefix_bloom_size_ratio( - rocksdb_options_t*, double); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_compaction_bytes( - rocksdb_options_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hash_skip_list_rep( - rocksdb_options_t*, size_t, int32_t, int32_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hash_link_list_rep( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_plain_table_factory( - rocksdb_options_t*, uint32_t, int, double, size_t); - -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_min_level_to_compress( - rocksdb_options_t* opt, int level); - -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_memtable_huge_page_size( - rocksdb_options_t*, size_t); - -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_successive_merges( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_bloom_locality( - rocksdb_options_t*, uint32_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_inplace_update_support( - rocksdb_options_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_inplace_update_num_locks( - rocksdb_options_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_report_bg_io_stats( - rocksdb_options_t*, int); - -enum { - rocksdb_tolerate_corrupted_tail_records_recovery = 0, - rocksdb_absolute_consistency_recovery = 1, - rocksdb_point_in_time_recovery = 2, - rocksdb_skip_any_corrupted_records_recovery = 3 -}; -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_wal_recovery_mode( - rocksdb_options_t*, int); - -enum { - rocksdb_no_compression = 0, - rocksdb_snappy_compression = 1, - rocksdb_zlib_compression = 2, - rocksdb_bz2_compression = 3, - rocksdb_lz4_compression = 4, - rocksdb_lz4hc_compression = 5, - rocksdb_xpress_compression = 6, - rocksdb_zstd_compression = 7 -}; -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression( - rocksdb_options_t*, int); - -enum { - rocksdb_level_compaction = 0, - rocksdb_universal_compaction = 1, - rocksdb_fifo_compaction = 2 -}; -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compaction_style( - rocksdb_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_options_set_universal_compaction_options( - rocksdb_options_t*, rocksdb_universal_compaction_options_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_fifo_compaction_options( - rocksdb_options_t* opt, rocksdb_fifo_compaction_options_t* fifo); -extern ROCKSDB_LIBRARY_API void rocksdb_options_set_ratelimiter( - rocksdb_options_t* opt, rocksdb_ratelimiter_t* limiter); - -/* RateLimiter */ -extern ROCKSDB_LIBRARY_API rocksdb_ratelimiter_t* rocksdb_ratelimiter_create( - int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness); -extern ROCKSDB_LIBRARY_API void rocksdb_ratelimiter_destroy(rocksdb_ratelimiter_t*); - -/* Compaction Filter */ - -extern ROCKSDB_LIBRARY_API rocksdb_compactionfilter_t* -rocksdb_compactionfilter_create( - void* state, void (*destructor)(void*), - unsigned char (*filter)(void*, int level, const char* key, - size_t key_length, const char* existing_value, - size_t value_length, char** new_value, - size_t* new_value_length, - unsigned char* value_changed), - const char* (*name)(void*)); -extern ROCKSDB_LIBRARY_API void rocksdb_compactionfilter_set_ignore_snapshots( - rocksdb_compactionfilter_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_compactionfilter_destroy( - rocksdb_compactionfilter_t*); - -/* Compaction Filter Context */ - -extern ROCKSDB_LIBRARY_API unsigned char -rocksdb_compactionfiltercontext_is_full_compaction( - rocksdb_compactionfiltercontext_t* context); - -extern ROCKSDB_LIBRARY_API unsigned char -rocksdb_compactionfiltercontext_is_manual_compaction( - rocksdb_compactionfiltercontext_t* context); - -/* Compaction Filter Factory */ - -extern ROCKSDB_LIBRARY_API rocksdb_compactionfilterfactory_t* -rocksdb_compactionfilterfactory_create( - void* state, void (*destructor)(void*), - rocksdb_compactionfilter_t* (*create_compaction_filter)( - void*, rocksdb_compactionfiltercontext_t* context), - const char* (*name)(void*)); -extern ROCKSDB_LIBRARY_API void rocksdb_compactionfilterfactory_destroy( - rocksdb_compactionfilterfactory_t*); - -/* Comparator */ - -extern ROCKSDB_LIBRARY_API rocksdb_comparator_t* rocksdb_comparator_create( - void* state, void (*destructor)(void*), - int (*compare)(void*, const char* a, size_t alen, const char* b, - size_t blen), - const char* (*name)(void*)); -extern ROCKSDB_LIBRARY_API void rocksdb_comparator_destroy( - rocksdb_comparator_t*); - -/* Filter policy */ - -extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t* rocksdb_filterpolicy_create( - void* state, void (*destructor)(void*), - char* (*create_filter)(void*, const char* const* key_array, - const size_t* key_length_array, int num_keys, - size_t* filter_length), - unsigned char (*key_may_match)(void*, const char* key, size_t length, - const char* filter, size_t filter_length), - void (*delete_filter)(void*, const char* filter, size_t filter_length), - const char* (*name)(void*)); -extern ROCKSDB_LIBRARY_API void rocksdb_filterpolicy_destroy( - rocksdb_filterpolicy_t*); - -extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t* -rocksdb_filterpolicy_create_bloom(int bits_per_key); -extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t* -rocksdb_filterpolicy_create_bloom_full(int bits_per_key); - -/* Merge Operator */ - -extern ROCKSDB_LIBRARY_API rocksdb_mergeoperator_t* -rocksdb_mergeoperator_create( - void* state, void (*destructor)(void*), - char* (*full_merge)(void*, const char* key, size_t key_length, - const char* existing_value, - size_t existing_value_length, - const char* const* operands_list, - const size_t* operands_list_length, int num_operands, - unsigned char* success, size_t* new_value_length), - char* (*partial_merge)(void*, const char* key, size_t key_length, - const char* const* operands_list, - const size_t* operands_list_length, int num_operands, - unsigned char* success, size_t* new_value_length), - void (*delete_value)(void*, const char* value, size_t value_length), - const char* (*name)(void*)); -extern ROCKSDB_LIBRARY_API void rocksdb_mergeoperator_destroy( - rocksdb_mergeoperator_t*); - -/* Read options */ - -extern ROCKSDB_LIBRARY_API rocksdb_readoptions_t* rocksdb_readoptions_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_destroy( - rocksdb_readoptions_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_verify_checksums( - rocksdb_readoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_fill_cache( - rocksdb_readoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_snapshot( - rocksdb_readoptions_t*, const rocksdb_snapshot_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iterate_upper_bound( - rocksdb_readoptions_t*, const char* key, size_t keylen); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iterate_lower_bound( - rocksdb_readoptions_t*, const char* key, size_t keylen); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_read_tier( - rocksdb_readoptions_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_tailing( - rocksdb_readoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_managed( - rocksdb_readoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_readahead_size( - rocksdb_readoptions_t*, size_t); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_prefix_same_as_start( - rocksdb_readoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_pin_data( - rocksdb_readoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_total_order_seek( - rocksdb_readoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_max_skippable_internal_keys( - rocksdb_readoptions_t*, uint64_t); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_background_purge_on_iterator_cleanup( - rocksdb_readoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_ignore_range_deletions( - rocksdb_readoptions_t*, unsigned char); - -/* Write options */ - -extern ROCKSDB_LIBRARY_API rocksdb_writeoptions_t* -rocksdb_writeoptions_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_destroy( - rocksdb_writeoptions_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_set_sync( - rocksdb_writeoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_disable_WAL( - rocksdb_writeoptions_t* opt, int disable); -extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_set_ignore_missing_column_families( - rocksdb_writeoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_set_no_slowdown( - rocksdb_writeoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_set_low_pri( - rocksdb_writeoptions_t*, unsigned char); - -/* Compact range options */ - -extern ROCKSDB_LIBRARY_API rocksdb_compactoptions_t* -rocksdb_compactoptions_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_destroy( - rocksdb_compactoptions_t*); -extern ROCKSDB_LIBRARY_API void -rocksdb_compactoptions_set_exclusive_manual_compaction( - rocksdb_compactoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_change_level( - rocksdb_compactoptions_t*, unsigned char); -extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_target_level( - rocksdb_compactoptions_t*, int); - -/* Flush options */ - -extern ROCKSDB_LIBRARY_API rocksdb_flushoptions_t* -rocksdb_flushoptions_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_flushoptions_destroy( - rocksdb_flushoptions_t*); -extern ROCKSDB_LIBRARY_API void rocksdb_flushoptions_set_wait( - rocksdb_flushoptions_t*, unsigned char); - -/* Cache */ - -extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_lru( - size_t capacity); -extern ROCKSDB_LIBRARY_API void rocksdb_cache_destroy(rocksdb_cache_t* cache); -extern ROCKSDB_LIBRARY_API void rocksdb_cache_set_capacity( - rocksdb_cache_t* cache, size_t capacity); -extern ROCKSDB_LIBRARY_API size_t -rocksdb_cache_get_usage(rocksdb_cache_t* cache); -extern ROCKSDB_LIBRARY_API size_t -rocksdb_cache_get_pinned_usage(rocksdb_cache_t* cache); - -/* DBPath */ - -extern ROCKSDB_LIBRARY_API rocksdb_dbpath_t* rocksdb_dbpath_create(const char* path, uint64_t target_size); -extern ROCKSDB_LIBRARY_API void rocksdb_dbpath_destroy(rocksdb_dbpath_t*); - -/* Env */ - -extern ROCKSDB_LIBRARY_API rocksdb_env_t* rocksdb_create_default_env(); -extern ROCKSDB_LIBRARY_API rocksdb_env_t* rocksdb_create_mem_env(); -extern ROCKSDB_LIBRARY_API void rocksdb_env_set_background_threads( - rocksdb_env_t* env, int n); -extern ROCKSDB_LIBRARY_API void -rocksdb_env_set_high_priority_background_threads(rocksdb_env_t* env, int n); -extern ROCKSDB_LIBRARY_API void rocksdb_env_join_all_threads( - rocksdb_env_t* env); -extern ROCKSDB_LIBRARY_API void rocksdb_env_destroy(rocksdb_env_t*); - -extern ROCKSDB_LIBRARY_API rocksdb_envoptions_t* rocksdb_envoptions_create(); -extern ROCKSDB_LIBRARY_API void rocksdb_envoptions_destroy( - rocksdb_envoptions_t* opt); - -/* SstFile */ - -extern ROCKSDB_LIBRARY_API rocksdb_sstfilewriter_t* -rocksdb_sstfilewriter_create(const rocksdb_envoptions_t* env, - const rocksdb_options_t* io_options); -extern ROCKSDB_LIBRARY_API rocksdb_sstfilewriter_t* -rocksdb_sstfilewriter_create_with_comparator( - const rocksdb_envoptions_t* env, const rocksdb_options_t* io_options, - const rocksdb_comparator_t* comparator); -extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_open( - rocksdb_sstfilewriter_t* writer, const char* name, char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_add( - rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, - const char* val, size_t vallen, char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_put( - rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, - const char* val, size_t vallen, char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_merge( - rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, - const char* val, size_t vallen, char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_delete( - rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, - char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_finish( - rocksdb_sstfilewriter_t* writer, char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_destroy( - rocksdb_sstfilewriter_t* writer); - -extern ROCKSDB_LIBRARY_API rocksdb_ingestexternalfileoptions_t* -rocksdb_ingestexternalfileoptions_create(); -extern ROCKSDB_LIBRARY_API void -rocksdb_ingestexternalfileoptions_set_move_files( - rocksdb_ingestexternalfileoptions_t* opt, unsigned char move_files); -extern ROCKSDB_LIBRARY_API void -rocksdb_ingestexternalfileoptions_set_snapshot_consistency( - rocksdb_ingestexternalfileoptions_t* opt, - unsigned char snapshot_consistency); -extern ROCKSDB_LIBRARY_API void -rocksdb_ingestexternalfileoptions_set_allow_global_seqno( - rocksdb_ingestexternalfileoptions_t* opt, unsigned char allow_global_seqno); -extern ROCKSDB_LIBRARY_API void -rocksdb_ingestexternalfileoptions_set_allow_blocking_flush( - rocksdb_ingestexternalfileoptions_t* opt, - unsigned char allow_blocking_flush); -extern ROCKSDB_LIBRARY_API void -rocksdb_ingestexternalfileoptions_set_ingest_behind( - rocksdb_ingestexternalfileoptions_t* opt, - unsigned char ingest_behind); -extern ROCKSDB_LIBRARY_API void rocksdb_ingestexternalfileoptions_destroy( - rocksdb_ingestexternalfileoptions_t* opt); - -extern ROCKSDB_LIBRARY_API void rocksdb_ingest_external_file( - rocksdb_t* db, const char* const* file_list, const size_t list_len, - const rocksdb_ingestexternalfileoptions_t* opt, char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_ingest_external_file_cf( - rocksdb_t* db, rocksdb_column_family_handle_t* handle, - const char* const* file_list, const size_t list_len, - const rocksdb_ingestexternalfileoptions_t* opt, char** errptr); - -/* SliceTransform */ - -extern ROCKSDB_LIBRARY_API rocksdb_slicetransform_t* -rocksdb_slicetransform_create( - void* state, void (*destructor)(void*), - char* (*transform)(void*, const char* key, size_t length, - size_t* dst_length), - unsigned char (*in_domain)(void*, const char* key, size_t length), - unsigned char (*in_range)(void*, const char* key, size_t length), - const char* (*name)(void*)); -extern ROCKSDB_LIBRARY_API rocksdb_slicetransform_t* - rocksdb_slicetransform_create_fixed_prefix(size_t); -extern ROCKSDB_LIBRARY_API rocksdb_slicetransform_t* -rocksdb_slicetransform_create_noop(); -extern ROCKSDB_LIBRARY_API void rocksdb_slicetransform_destroy( - rocksdb_slicetransform_t*); - -/* Universal Compaction options */ - -enum { - rocksdb_similar_size_compaction_stop_style = 0, - rocksdb_total_size_compaction_stop_style = 1 -}; - -extern ROCKSDB_LIBRARY_API rocksdb_universal_compaction_options_t* -rocksdb_universal_compaction_options_create(); -extern ROCKSDB_LIBRARY_API void -rocksdb_universal_compaction_options_set_size_ratio( - rocksdb_universal_compaction_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_universal_compaction_options_set_min_merge_width( - rocksdb_universal_compaction_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_universal_compaction_options_set_max_merge_width( - rocksdb_universal_compaction_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_universal_compaction_options_set_max_size_amplification_percent( - rocksdb_universal_compaction_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_universal_compaction_options_set_compression_size_percent( - rocksdb_universal_compaction_options_t*, int); -extern ROCKSDB_LIBRARY_API void -rocksdb_universal_compaction_options_set_stop_style( - rocksdb_universal_compaction_options_t*, int); -extern ROCKSDB_LIBRARY_API void rocksdb_universal_compaction_options_destroy( - rocksdb_universal_compaction_options_t*); - -extern ROCKSDB_LIBRARY_API rocksdb_fifo_compaction_options_t* -rocksdb_fifo_compaction_options_create(); -extern ROCKSDB_LIBRARY_API void -rocksdb_fifo_compaction_options_set_max_table_files_size( - rocksdb_fifo_compaction_options_t* fifo_opts, uint64_t size); -extern ROCKSDB_LIBRARY_API void rocksdb_fifo_compaction_options_destroy( - rocksdb_fifo_compaction_options_t* fifo_opts); - -extern ROCKSDB_LIBRARY_API int rocksdb_livefiles_count( - const rocksdb_livefiles_t*); -extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_name( - const rocksdb_livefiles_t*, int index); -extern ROCKSDB_LIBRARY_API int rocksdb_livefiles_level( - const rocksdb_livefiles_t*, int index); -extern ROCKSDB_LIBRARY_API size_t -rocksdb_livefiles_size(const rocksdb_livefiles_t*, int index); -extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_smallestkey( - const rocksdb_livefiles_t*, int index, size_t* size); -extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_largestkey( - const rocksdb_livefiles_t*, int index, size_t* size); -extern ROCKSDB_LIBRARY_API void rocksdb_livefiles_destroy( - const rocksdb_livefiles_t*); - -/* Utility Helpers */ - -extern ROCKSDB_LIBRARY_API void rocksdb_get_options_from_string( - const rocksdb_options_t* base_options, const char* opts_str, - rocksdb_options_t* new_options, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_delete_file_in_range( - rocksdb_t* db, const char* start_key, size_t start_key_len, - const char* limit_key, size_t limit_key_len, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_delete_file_in_range_cf( - rocksdb_t* db, rocksdb_column_family_handle_t* column_family, - const char* start_key, size_t start_key_len, const char* limit_key, - size_t limit_key_len, char** errptr); - -/* Transactions */ - -extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t* -rocksdb_transactiondb_create_column_family( - rocksdb_transactiondb_t* txn_db, - const rocksdb_options_t* column_family_options, - const char* column_family_name, char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_transactiondb_t* rocksdb_transactiondb_open( - const rocksdb_options_t* options, - const rocksdb_transactiondb_options_t* txn_db_options, const char* name, - char** errptr); - -extern ROCKSDB_LIBRARY_API const rocksdb_snapshot_t* -rocksdb_transactiondb_create_snapshot(rocksdb_transactiondb_t* txn_db); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_release_snapshot( - rocksdb_transactiondb_t* txn_db, const rocksdb_snapshot_t* snapshot); - -extern ROCKSDB_LIBRARY_API rocksdb_transaction_t* rocksdb_transaction_begin( - rocksdb_transactiondb_t* txn_db, - const rocksdb_writeoptions_t* write_options, - const rocksdb_transaction_options_t* txn_options, - rocksdb_transaction_t* old_txn); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_commit( - rocksdb_transaction_t* txn, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_rollback( - rocksdb_transaction_t* txn, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_set_savepoint( - rocksdb_transaction_t* txn); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_rollback_to_savepoint( - rocksdb_transaction_t* txn, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_destroy( - rocksdb_transaction_t* txn); - -// This snapshot should be freed using rocksdb_free -extern ROCKSDB_LIBRARY_API const rocksdb_snapshot_t* -rocksdb_transaction_get_snapshot(rocksdb_transaction_t* txn); - -extern ROCKSDB_LIBRARY_API char* rocksdb_transaction_get( - rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, - const char* key, size_t klen, size_t* vlen, char** errptr); - -extern ROCKSDB_LIBRARY_API char* rocksdb_transaction_get_cf( - rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, - size_t* vlen, char** errptr); - -extern ROCKSDB_LIBRARY_API char* rocksdb_transaction_get_for_update( - rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, - const char* key, size_t klen, size_t* vlen, unsigned char exclusive, - char** errptr); - -extern ROCKSDB_LIBRARY_API char* rocksdb_transactiondb_get( - rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, - const char* key, size_t klen, size_t* vlen, char** errptr); - -extern ROCKSDB_LIBRARY_API char* rocksdb_transactiondb_get_cf( - rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, - size_t keylen, size_t* vallen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_put( - rocksdb_transaction_t* txn, const char* key, size_t klen, const char* val, - size_t vlen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_put_cf( - rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, - const char* key, size_t klen, const char* val, size_t vlen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_put( - rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, - const char* key, size_t klen, const char* val, size_t vlen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_put_cf( - rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, - size_t keylen, const char* val, size_t vallen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_write( - rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, - rocksdb_writebatch_t *batch, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_merge( - rocksdb_transaction_t* txn, const char* key, size_t klen, const char* val, - size_t vlen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_merge( - rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, - const char* key, size_t klen, const char* val, size_t vlen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_delete( - rocksdb_transaction_t* txn, const char* key, size_t klen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_delete_cf( - rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, - const char* key, size_t klen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_delete( - rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, - const char* key, size_t klen, char** errptr); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_delete_cf( - rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, - size_t keylen, char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* -rocksdb_transaction_create_iterator(rocksdb_transaction_t* txn, - const rocksdb_readoptions_t* options); - -extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* -rocksdb_transaction_create_iterator_cf( - rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, - rocksdb_column_family_handle_t* column_family); - -extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* -rocksdb_transactiondb_create_iterator(rocksdb_transactiondb_t* txn_db, - const rocksdb_readoptions_t* options); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_close( - rocksdb_transactiondb_t* txn_db); - -extern ROCKSDB_LIBRARY_API rocksdb_checkpoint_t* -rocksdb_transactiondb_checkpoint_object_create(rocksdb_transactiondb_t* txn_db, - char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_optimistictransactiondb_t* -rocksdb_optimistictransactiondb_open(const rocksdb_options_t* options, - const char* name, char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_optimistictransactiondb_t* -rocksdb_optimistictransactiondb_open_column_families( - const rocksdb_options_t* options, const char* name, int num_column_families, - const char** column_family_names, - const rocksdb_options_t** column_family_options, - rocksdb_column_family_handle_t** column_family_handles, char** errptr); - -extern ROCKSDB_LIBRARY_API rocksdb_t* -rocksdb_optimistictransactiondb_get_base_db( - rocksdb_optimistictransactiondb_t* otxn_db); - -extern ROCKSDB_LIBRARY_API void rocksdb_optimistictransactiondb_close_base_db( - rocksdb_t* base_db); - -extern ROCKSDB_LIBRARY_API rocksdb_transaction_t* -rocksdb_optimistictransaction_begin( - rocksdb_optimistictransactiondb_t* otxn_db, - const rocksdb_writeoptions_t* write_options, - const rocksdb_optimistictransaction_options_t* otxn_options, - rocksdb_transaction_t* old_txn); - -extern ROCKSDB_LIBRARY_API void rocksdb_optimistictransactiondb_close( - rocksdb_optimistictransactiondb_t* otxn_db); - -/* Transaction Options */ - -extern ROCKSDB_LIBRARY_API rocksdb_transactiondb_options_t* -rocksdb_transactiondb_options_create(); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_options_destroy( - rocksdb_transactiondb_options_t* opt); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_options_set_max_num_locks( - rocksdb_transactiondb_options_t* opt, int64_t max_num_locks); - -extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_options_set_num_stripes( - rocksdb_transactiondb_options_t* opt, size_t num_stripes); - -extern ROCKSDB_LIBRARY_API void -rocksdb_transactiondb_options_set_transaction_lock_timeout( - rocksdb_transactiondb_options_t* opt, int64_t txn_lock_timeout); - -extern ROCKSDB_LIBRARY_API void -rocksdb_transactiondb_options_set_default_lock_timeout( - rocksdb_transactiondb_options_t* opt, int64_t default_lock_timeout); - -extern ROCKSDB_LIBRARY_API rocksdb_transaction_options_t* -rocksdb_transaction_options_create(); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_destroy( - rocksdb_transaction_options_t* opt); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_set_snapshot( - rocksdb_transaction_options_t* opt, unsigned char v); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_deadlock_detect( - rocksdb_transaction_options_t* opt, unsigned char v); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_lock_timeout( - rocksdb_transaction_options_t* opt, int64_t lock_timeout); - -extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_expiration( - rocksdb_transaction_options_t* opt, int64_t expiration); - -extern ROCKSDB_LIBRARY_API void -rocksdb_transaction_options_set_deadlock_detect_depth( - rocksdb_transaction_options_t* opt, int64_t depth); - -extern ROCKSDB_LIBRARY_API void -rocksdb_transaction_options_set_max_write_batch_size( - rocksdb_transaction_options_t* opt, size_t size); - -extern ROCKSDB_LIBRARY_API rocksdb_optimistictransaction_options_t* -rocksdb_optimistictransaction_options_create(); - -extern ROCKSDB_LIBRARY_API void rocksdb_optimistictransaction_options_destroy( - rocksdb_optimistictransaction_options_t* opt); - -extern ROCKSDB_LIBRARY_API void -rocksdb_optimistictransaction_options_set_set_snapshot( - rocksdb_optimistictransaction_options_t* opt, unsigned char v); - -// referring to convention (3), this should be used by client -// to free memory that was malloc()ed -extern ROCKSDB_LIBRARY_API void rocksdb_free(void* ptr); - -extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* rocksdb_get_pinned( - rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, - size_t keylen, char** errptr); -extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* rocksdb_get_pinned_cf( - rocksdb_t* db, const rocksdb_readoptions_t* options, - rocksdb_column_family_handle_t* column_family, const char* key, - size_t keylen, char** errptr); -extern ROCKSDB_LIBRARY_API void rocksdb_pinnableslice_destroy( - rocksdb_pinnableslice_t* v); -extern ROCKSDB_LIBRARY_API const char* rocksdb_pinnableslice_value( - const rocksdb_pinnableslice_t* t, size_t* vlen); - -#ifdef __cplusplus -} /* end extern "C" */ -#endif - -#endif /* STORAGE_ROCKSDB_INCLUDE_C_H_ */ diff --git a/rocksdb/internal/cftable.nim b/rocksdb/internal/cftable.nim new file mode 100644 index 0000000..7061309 --- /dev/null +++ b/rocksdb/internal/cftable.nim @@ -0,0 +1,42 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + std/tables, + ../columnfamily/cfhandle + +type + ColFamilyTableRef* = ref object + columnFamilies: TableRef[string, ColFamilyHandleRef] + +proc newColFamilyTable*(): ColFamilyTableRef = + ColFamilyTableRef(columnFamilies: newTable[string, ColFamilyHandleRef]()) + +template isClosed*(table: ColFamilyTableRef): bool = + table.columnFamilies.isNil() + +proc put*( + table: var ColFamilyTableRef, + name: string, + handle: ColFamilyHandlePtr) = + doAssert not table.isClosed() + doAssert not handle.isNil() + table.columnFamilies[name] = newColFamilyHandle(handle) + +proc get*(table: ColFamilyTableRef, name: string): ColFamilyHandleRef = + doAssert not table.isClosed() + table.columnFamilies.getOrDefault(name) + +proc close*(table: var ColFamilyTableRef) = + if not table.isClosed(): + for _, v in table.columnFamilies.mpairs(): + v.close() + table.columnFamilies = nil \ No newline at end of file diff --git a/rocksdb/internal/utils.nim b/rocksdb/internal/utils.nim new file mode 100644 index 0000000..045f3ba --- /dev/null +++ b/rocksdb/internal/utils.nim @@ -0,0 +1,21 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + ../lib/librocksdb + +const DEFAULT_COLUMN_FAMILY_NAME* = "default" + +template bailOnErrors*(errors: cstring): auto = + if not errors.isNil: + let res = err($(errors)) + rocksdb_free(errors) + return res \ No newline at end of file diff --git a/rocksdb/lib/headers/c.h b/rocksdb/lib/headers/c.h new file mode 100644 index 0000000..94a8cb7 --- /dev/null +++ b/rocksdb/lib/headers/c.h @@ -0,0 +1,3042 @@ +// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. +// This source code is licensed under both the GPLv2 (found in the +// COPYING file in the root directory) and Apache 2.0 License +// (found in the LICENSE.Apache file in the root directory). + +/* Copyright (c) 2011 The LevelDB Authors. All rights reserved. + Use of this source code is governed by a BSD-style license that can be + found in the LICENSE file. See the AUTHORS file for names of contributors. + + C bindings for rocksdb. May be useful as a stable ABI that can be + used by programs that keep rocksdb in a shared library, or for + a JNI api. + + Does not support: + . getters for the option types + . custom comparators that implement key shortening + . capturing post-write-snapshot + . custom iter, db, env, cache implementations using just the C bindings + + Some conventions: + + (1) We expose just opaque struct pointers and functions to clients. + This allows us to change internal representations without having to + recompile clients. + + (2) For simplicity, there is no equivalent to the Slice type. Instead, + the caller has to pass the pointer and length as separate + arguments. + + (3) Errors are represented by a null-terminated c string. NULL + means no error. All operations that can raise an error are passed + a "char** errptr" as the last argument. One of the following must + be true on entry: + *errptr == NULL + *errptr points to a malloc()ed null-terminated error message + On success, a leveldb routine leaves *errptr unchanged. + On failure, leveldb frees the old value of *errptr and + set *errptr to a malloc()ed error message. + + (4) Bools have the type unsigned char (0 == false; rest == true) + + (5) All of the pointer arguments must be non-NULL. +*/ + +#pragma once + +#ifdef C2NIM +# def ROCKSDB_LIBRARY_API +# dynlib librocksdb +# cdecl +# if defined(windows) +# define librocksdb "librocksdb.dll" +# elif defined(macosx) +# define librocksdb "librocksdb.dylib" +# else +# define librocksdb "librocksdb.so" +# endif +# mangle uint32_t uint32 +# mangle uint16_t uint16 +# mangle uint8_t uint8 +# mangle uint64_t uint64 +# mangle int32_t int32 +# mangle int16_t int16 +# mangle int8_t int8 +# mangle int64_t int64 +# mangle cuchar uint8 +#else +# ifdef _WIN32 +# ifdef ROCKSDB_DLL +# ifdef ROCKSDB_LIBRARY_EXPORTS +# define ROCKSDB_LIBRARY_API __declspec(dllexport) +# else +# define ROCKSDB_LIBRARY_API __declspec(dllimport) +# endif +# else +# define ROCKSDB_LIBRARY_API +# endif +# else +# define ROCKSDB_LIBRARY_API +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/* Exported types */ + +typedef struct rocksdb_t rocksdb_t; +typedef struct rocksdb_backup_engine_t rocksdb_backup_engine_t; +typedef struct rocksdb_backup_engine_info_t rocksdb_backup_engine_info_t; +typedef struct rocksdb_backup_engine_options_t rocksdb_backup_engine_options_t; +typedef struct rocksdb_restore_options_t rocksdb_restore_options_t; +typedef struct rocksdb_memory_allocator_t rocksdb_memory_allocator_t; +typedef struct rocksdb_lru_cache_options_t rocksdb_lru_cache_options_t; +typedef struct rocksdb_hyper_clock_cache_options_t + rocksdb_hyper_clock_cache_options_t; +typedef struct rocksdb_cache_t rocksdb_cache_t; +typedef struct rocksdb_write_buffer_manager_t rocksdb_write_buffer_manager_t; +typedef struct rocksdb_compactionfilter_t rocksdb_compactionfilter_t; +typedef struct rocksdb_compactionfiltercontext_t + rocksdb_compactionfiltercontext_t; +typedef struct rocksdb_compactionfilterfactory_t + rocksdb_compactionfilterfactory_t; +typedef struct rocksdb_comparator_t rocksdb_comparator_t; +typedef struct rocksdb_dbpath_t rocksdb_dbpath_t; +typedef struct rocksdb_env_t rocksdb_env_t; +typedef struct rocksdb_fifo_compaction_options_t + rocksdb_fifo_compaction_options_t; +typedef struct rocksdb_filelock_t rocksdb_filelock_t; +typedef struct rocksdb_filterpolicy_t rocksdb_filterpolicy_t; +typedef struct rocksdb_flushoptions_t rocksdb_flushoptions_t; +typedef struct rocksdb_iterator_t rocksdb_iterator_t; +typedef struct rocksdb_logger_t rocksdb_logger_t; +typedef struct rocksdb_mergeoperator_t rocksdb_mergeoperator_t; +typedef struct rocksdb_options_t rocksdb_options_t; +typedef struct rocksdb_compactoptions_t rocksdb_compactoptions_t; +typedef struct rocksdb_block_based_table_options_t + rocksdb_block_based_table_options_t; +typedef struct rocksdb_cuckoo_table_options_t rocksdb_cuckoo_table_options_t; +typedef struct rocksdb_randomfile_t rocksdb_randomfile_t; +typedef struct rocksdb_readoptions_t rocksdb_readoptions_t; +typedef struct rocksdb_seqfile_t rocksdb_seqfile_t; +typedef struct rocksdb_slicetransform_t rocksdb_slicetransform_t; +typedef struct rocksdb_snapshot_t rocksdb_snapshot_t; +typedef struct rocksdb_writablefile_t rocksdb_writablefile_t; +typedef struct rocksdb_writebatch_t rocksdb_writebatch_t; +typedef struct rocksdb_writebatch_wi_t rocksdb_writebatch_wi_t; +typedef struct rocksdb_writeoptions_t rocksdb_writeoptions_t; +typedef struct rocksdb_universal_compaction_options_t + rocksdb_universal_compaction_options_t; +typedef struct rocksdb_livefiles_t rocksdb_livefiles_t; +typedef struct rocksdb_column_family_handle_t rocksdb_column_family_handle_t; +typedef struct rocksdb_column_family_metadata_t + rocksdb_column_family_metadata_t; +typedef struct rocksdb_level_metadata_t rocksdb_level_metadata_t; +typedef struct rocksdb_sst_file_metadata_t rocksdb_sst_file_metadata_t; +typedef struct rocksdb_envoptions_t rocksdb_envoptions_t; +typedef struct rocksdb_ingestexternalfileoptions_t + rocksdb_ingestexternalfileoptions_t; +typedef struct rocksdb_sstfilewriter_t rocksdb_sstfilewriter_t; +typedef struct rocksdb_ratelimiter_t rocksdb_ratelimiter_t; +typedef struct rocksdb_perfcontext_t rocksdb_perfcontext_t; +typedef struct rocksdb_pinnableslice_t rocksdb_pinnableslice_t; +typedef struct rocksdb_transactiondb_options_t rocksdb_transactiondb_options_t; +typedef struct rocksdb_transactiondb_t rocksdb_transactiondb_t; +typedef struct rocksdb_transaction_options_t rocksdb_transaction_options_t; +typedef struct rocksdb_optimistictransactiondb_t + rocksdb_optimistictransactiondb_t; +typedef struct rocksdb_optimistictransaction_options_t + rocksdb_optimistictransaction_options_t; +typedef struct rocksdb_transaction_t rocksdb_transaction_t; +typedef struct rocksdb_checkpoint_t rocksdb_checkpoint_t; +typedef struct rocksdb_wal_iterator_t rocksdb_wal_iterator_t; +typedef struct rocksdb_wal_readoptions_t rocksdb_wal_readoptions_t; +typedef struct rocksdb_memory_consumers_t rocksdb_memory_consumers_t; +typedef struct rocksdb_memory_usage_t rocksdb_memory_usage_t; +typedef struct rocksdb_statistics_histogram_data_t + rocksdb_statistics_histogram_data_t; +typedef struct rocksdb_wait_for_compact_options_t + rocksdb_wait_for_compact_options_t; + +/* DB operations */ + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open( + const rocksdb_options_t* options, const char* name, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_with_ttl( + const rocksdb_options_t* options, const char* name, int ttl, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_for_read_only( + const rocksdb_options_t* options, const char* name, + unsigned char error_if_wal_file_exists, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_as_secondary( + const rocksdb_options_t* options, const char* name, + const char* secondary_path, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_backup_engine_t* rocksdb_backup_engine_open( + const rocksdb_options_t* options, const char* path, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_backup_engine_t* +rocksdb_backup_engine_open_opts(const rocksdb_backup_engine_options_t* options, + rocksdb_env_t* env, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_create_new_backup( + rocksdb_backup_engine_t* be, rocksdb_t* db, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_create_new_backup_flush( + rocksdb_backup_engine_t* be, rocksdb_t* db, + unsigned char flush_before_backup, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_purge_old_backups( + rocksdb_backup_engine_t* be, uint32_t num_backups_to_keep, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_restore_options_t* +rocksdb_restore_options_create(void); +extern ROCKSDB_LIBRARY_API void rocksdb_restore_options_destroy( + rocksdb_restore_options_t* opt); +extern ROCKSDB_LIBRARY_API void rocksdb_restore_options_set_keep_log_files( + rocksdb_restore_options_t* opt, int v); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_verify_backup( + rocksdb_backup_engine_t* be, uint32_t backup_id, char** errptr); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_restore_db_from_latest_backup( + rocksdb_backup_engine_t* be, const char* db_dir, const char* wal_dir, + const rocksdb_restore_options_t* restore_options, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_restore_db_from_backup( + rocksdb_backup_engine_t* be, const char* db_dir, const char* wal_dir, + const rocksdb_restore_options_t* restore_options, const uint32_t backup_id, + char** errptr); + +extern ROCKSDB_LIBRARY_API const rocksdb_backup_engine_info_t* +rocksdb_backup_engine_get_backup_info(rocksdb_backup_engine_t* be); + +extern ROCKSDB_LIBRARY_API int rocksdb_backup_engine_info_count( + const rocksdb_backup_engine_info_t* info); + +extern ROCKSDB_LIBRARY_API int64_t rocksdb_backup_engine_info_timestamp( + const rocksdb_backup_engine_info_t* info, int index); + +extern ROCKSDB_LIBRARY_API uint32_t rocksdb_backup_engine_info_backup_id( + const rocksdb_backup_engine_info_t* info, int index); + +extern ROCKSDB_LIBRARY_API uint64_t rocksdb_backup_engine_info_size( + const rocksdb_backup_engine_info_t* info, int index); + +extern ROCKSDB_LIBRARY_API uint32_t rocksdb_backup_engine_info_number_files( + const rocksdb_backup_engine_info_t* info, int index); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_info_destroy( + const rocksdb_backup_engine_info_t* info); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_close( + rocksdb_backup_engine_t* be); + +extern ROCKSDB_LIBRARY_API void rocksdb_put_with_ts( + rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, + size_t keylen, const char* ts, size_t tslen, const char* val, size_t vallen, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_put_cf_with_ts( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, const char* ts, size_t tslen, const char* val, size_t vallen, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete_with_ts( + rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, + size_t keylen, const char* ts, size_t tslen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete_cf_with_ts( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, const char* ts, size_t tslen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_singledelete( + rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, + size_t keylen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_singledelete_cf( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_singledelete_with_ts( + rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, + size_t keylen, const char* ts, size_t tslen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_singledelete_cf_with_ts( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, const char* ts, size_t tslen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_increase_full_history_ts_low( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + const char* ts_low, size_t ts_lowlen, char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_get_full_history_ts_low( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + size_t* ts_lowlen, char** errptr); + +/* BackupEngineOptions */ + +extern ROCKSDB_LIBRARY_API rocksdb_backup_engine_options_t* +rocksdb_backup_engine_options_create(const char* backup_dir); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_options_set_backup_dir( + rocksdb_backup_engine_options_t* options, const char* backup_dir); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_options_set_env( + rocksdb_backup_engine_options_t* options, rocksdb_env_t* env); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_share_table_files( + rocksdb_backup_engine_options_t* options, unsigned char val); + +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_backup_engine_options_get_share_table_files( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_options_set_sync( + rocksdb_backup_engine_options_t* options, unsigned char val); + +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_backup_engine_options_get_sync( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_destroy_old_data( + rocksdb_backup_engine_options_t* options, unsigned char val); + +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_backup_engine_options_get_destroy_old_data( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_backup_log_files( + rocksdb_backup_engine_options_t* options, unsigned char val); + +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_backup_engine_options_get_backup_log_files( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_backup_rate_limit( + rocksdb_backup_engine_options_t* options, uint64_t limit); + +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_backup_engine_options_get_backup_rate_limit( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_restore_rate_limit( + rocksdb_backup_engine_options_t* options, uint64_t limit); + +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_backup_engine_options_get_restore_rate_limit( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_max_background_operations( + rocksdb_backup_engine_options_t* options, int val); + +extern ROCKSDB_LIBRARY_API int +rocksdb_backup_engine_options_get_max_background_operations( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_callback_trigger_interval_size( + rocksdb_backup_engine_options_t* options, uint64_t size); + +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_backup_engine_options_get_callback_trigger_interval_size( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_max_valid_backups_to_open( + rocksdb_backup_engine_options_t* options, int val); + +extern ROCKSDB_LIBRARY_API int +rocksdb_backup_engine_options_get_max_valid_backups_to_open( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void +rocksdb_backup_engine_options_set_share_files_with_checksum_naming( + rocksdb_backup_engine_options_t* options, int val); + +extern ROCKSDB_LIBRARY_API int +rocksdb_backup_engine_options_get_share_files_with_checksum_naming( + rocksdb_backup_engine_options_t* options); + +extern ROCKSDB_LIBRARY_API void rocksdb_backup_engine_options_destroy( + rocksdb_backup_engine_options_t*); + +/* Checkpoint */ + +extern ROCKSDB_LIBRARY_API rocksdb_checkpoint_t* +rocksdb_checkpoint_object_create(rocksdb_t* db, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_checkpoint_create( + rocksdb_checkpoint_t* checkpoint, const char* checkpoint_dir, + uint64_t log_size_for_flush, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_checkpoint_object_destroy( + rocksdb_checkpoint_t* checkpoint); + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_and_trim_history( + const rocksdb_options_t* options, const char* name, int num_column_families, + const char* const* column_family_names, + const rocksdb_options_t* const* column_family_options, + rocksdb_column_family_handle_t** column_family_handles, char* trim_ts, + size_t trim_tslen, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_column_families( + const rocksdb_options_t* options, const char* name, int num_column_families, + const char* const* column_family_names, + const rocksdb_options_t* const* column_family_options, + rocksdb_column_family_handle_t** column_family_handles, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_column_families_with_ttl( + const rocksdb_options_t* options, const char* name, int num_column_families, + const char* const* column_family_names, + const rocksdb_options_t* const* column_family_options, + rocksdb_column_family_handle_t** column_family_handles, const int* ttls, + char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_t* +rocksdb_open_for_read_only_column_families( + const rocksdb_options_t* options, const char* name, int num_column_families, + const char* const* column_family_names, + const rocksdb_options_t* const* column_family_options, + rocksdb_column_family_handle_t** column_family_handles, + unsigned char error_if_wal_file_exists, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_open_as_secondary_column_families( + const rocksdb_options_t* options, const char* name, + const char* secondary_path, int num_column_families, + const char* const* column_family_names, + const rocksdb_options_t* const* column_family_options, + rocksdb_column_family_handle_t** column_family_handles, char** errptr); + +extern ROCKSDB_LIBRARY_API char** rocksdb_list_column_families( + const rocksdb_options_t* options, const char* name, size_t* lencf, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_list_column_families_destroy( + char** list, size_t len); + +extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t* +rocksdb_create_column_family(rocksdb_t* db, + const rocksdb_options_t* column_family_options, + const char* column_family_name, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t** +rocksdb_create_column_families(rocksdb_t* db, + const rocksdb_options_t* column_family_options, + int num_column_families, + const char* const* column_family_names, + size_t* lencfs, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_create_column_families_destroy( + rocksdb_column_family_handle_t** list); + +extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t* +rocksdb_create_column_family_with_ttl( + rocksdb_t* db, const rocksdb_options_t* column_family_options, + const char* column_family_name, int ttl, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_drop_column_family( + rocksdb_t* db, rocksdb_column_family_handle_t* handle, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_column_family_handle_destroy( + rocksdb_column_family_handle_t*); + +extern ROCKSDB_LIBRARY_API uint32_t +rocksdb_column_family_handle_get_id(rocksdb_column_family_handle_t* handle); + +extern ROCKSDB_LIBRARY_API char* rocksdb_column_family_handle_get_name( + rocksdb_column_family_handle_t* handle, size_t* name_len); + +extern ROCKSDB_LIBRARY_API void rocksdb_close(rocksdb_t* db); + +extern ROCKSDB_LIBRARY_API void rocksdb_put( + rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, + size_t keylen, const char* val, size_t vallen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_put_cf( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, const char* val, size_t vallen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete( + rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, + size_t keylen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete_cf( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete_range_cf( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* start_key, + size_t start_key_len, const char* end_key, size_t end_key_len, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_merge( + rocksdb_t* db, const rocksdb_writeoptions_t* options, const char* key, + size_t keylen, const char* val, size_t vallen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_merge_cf( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, const char* val, size_t vallen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_write( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_writebatch_t* batch, char** errptr); + +/* Returns NULL if not found. A malloc()ed array otherwise. + Stores the length of the array in *vallen. */ +extern ROCKSDB_LIBRARY_API char* rocksdb_get( + rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, + size_t keylen, size_t* vallen, char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_get_with_ts( + rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, + size_t keylen, size_t* vallen, char** ts, size_t* tslen, char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_get_cf( + rocksdb_t* db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, size_t* vallen, char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_get_cf_with_ts( + rocksdb_t* db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, size_t* vallen, char** ts, size_t* tslen, char** errptr); + +// if values_list[i] == NULL and errs[i] == NULL, +// then we got status.IsNotFound(), which we will not return. +// all errors except status status.ok() and status.IsNotFound() are returned. +// +// errs, values_list and values_list_sizes must be num_keys in length, +// allocated by the caller. +// errs is a list of strings as opposed to the conventional one error, +// where errs[i] is the status for retrieval of keys_list[i]. +// each non-NULL errs entry is a malloc()ed, null terminated string. +// each non-NULL values_list entry is a malloc()ed array, with +// the length for each stored in values_list_sizes[i]. +extern ROCKSDB_LIBRARY_API void rocksdb_multi_get( + rocksdb_t* db, const rocksdb_readoptions_t* options, size_t num_keys, + const char* const* keys_list, const size_t* keys_list_sizes, + char** values_list, size_t* values_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API void rocksdb_multi_get_with_ts( + rocksdb_t* db, const rocksdb_readoptions_t* options, size_t num_keys, + const char* const* keys_list, const size_t* keys_list_sizes, + char** values_list, size_t* values_list_sizes, char** timestamp_list, + size_t* timestamp_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API void rocksdb_multi_get_cf( + rocksdb_t* db, const rocksdb_readoptions_t* options, + const rocksdb_column_family_handle_t* const* column_families, + size_t num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, char** values_list, + size_t* values_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API void rocksdb_multi_get_cf_with_ts( + rocksdb_t* db, const rocksdb_readoptions_t* options, + const rocksdb_column_family_handle_t* const* column_families, + size_t num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, char** values_list, + size_t* values_list_sizes, char** timestamps_list, + size_t* timestamps_list_sizes, char** errs); + +// The MultiGet API that improves performance by batching operations +// in the read path for greater efficiency. Currently, only the block based +// table format with full filters are supported. Other table formats such +// as plain table, block based table with block based filters and +// partitioned indexes will still work, but will not get any performance +// benefits. +// +// Note that all the keys passed to this API are restricted to a single +// column family. +// +// Parameters - +// db - the RocksDB instance. +// options - ReadOptions +// column_family - ColumnFamilyHandle* that the keys belong to. All the keys +// passed to the API are restricted to a single column family +// num_keys - Number of keys to lookup +// keys_list - Pointer to C style array of keys with num_keys elements +// keys_list_sizes - Pointer to C style array of the size of corresponding key +// in key_list with num_keys elements. +// values - Pointer to C style array of PinnableSlices with num_keys elements +// statuses - Pointer to C style array of Status with num_keys elements +// sorted_input - If true, it means the input keys are already sorted by key +// order, so the MultiGet() API doesn't have to sort them +// again. If false, the keys will be copied and sorted +// internally by the API - the input array will not be +// modified +extern ROCKSDB_LIBRARY_API void rocksdb_batched_multi_get_cf( + rocksdb_t* db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, size_t num_keys, + const char* const* keys_list, const size_t* keys_list_sizes, + rocksdb_pinnableslice_t** values, char** errs, const bool sorted_input); + +// The value is only allocated (using malloc) and returned if it is found and +// value_found isn't NULL. In that case the user is responsible for freeing it. +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_key_may_exist( + rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, + size_t key_len, char** value, size_t* val_len, const char* timestamp, + size_t timestamp_len, unsigned char* value_found); + +// The value is only allocated (using malloc) and returned if it is found and +// value_found isn't NULL. In that case the user is responsible for freeing it. +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_key_may_exist_cf( + rocksdb_t* db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t key_len, char** value, size_t* val_len, const char* timestamp, + size_t timestamp_len, unsigned char* value_found); + +extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* rocksdb_create_iterator( + rocksdb_t* db, const rocksdb_readoptions_t* options); + +extern ROCKSDB_LIBRARY_API rocksdb_wal_iterator_t* rocksdb_get_updates_since( + rocksdb_t* db, uint64_t seq_number, + const rocksdb_wal_readoptions_t* options, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* rocksdb_create_iterator_cf( + rocksdb_t* db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family); + +extern ROCKSDB_LIBRARY_API void rocksdb_create_iterators( + rocksdb_t* db, rocksdb_readoptions_t* opts, + rocksdb_column_family_handle_t** column_families, + rocksdb_iterator_t** iterators, size_t size, char** errptr); + +extern ROCKSDB_LIBRARY_API const rocksdb_snapshot_t* rocksdb_create_snapshot( + rocksdb_t* db); + +extern ROCKSDB_LIBRARY_API void rocksdb_release_snapshot( + rocksdb_t* db, const rocksdb_snapshot_t* snapshot); + +/* Returns NULL if property name is unknown. + Else returns a pointer to a malloc()-ed null-terminated value. */ +extern ROCKSDB_LIBRARY_API char* rocksdb_property_value(rocksdb_t* db, + const char* propname); +/* returns 0 on success, -1 otherwise */ +extern ROCKSDB_LIBRARY_API int rocksdb_property_int(rocksdb_t* db, + const char* propname, + uint64_t* out_val); + +/* returns 0 on success, -1 otherwise */ +extern ROCKSDB_LIBRARY_API int rocksdb_property_int_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + const char* propname, uint64_t* out_val); + +extern ROCKSDB_LIBRARY_API char* rocksdb_property_value_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + const char* propname); + +extern ROCKSDB_LIBRARY_API void rocksdb_approximate_sizes( + rocksdb_t* db, int num_ranges, const char* const* range_start_key, + const size_t* range_start_key_len, const char* const* range_limit_key, + const size_t* range_limit_key_len, uint64_t* sizes, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_approximate_sizes_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + int num_ranges, const char* const* range_start_key, + const size_t* range_start_key_len, const char* const* range_limit_key, + const size_t* range_limit_key_len, uint64_t* sizes, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_compact_range(rocksdb_t* db, + const char* start_key, + size_t start_key_len, + const char* limit_key, + size_t limit_key_len); + +extern ROCKSDB_LIBRARY_API void rocksdb_compact_range_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + const char* start_key, size_t start_key_len, const char* limit_key, + size_t limit_key_len); + +extern ROCKSDB_LIBRARY_API void rocksdb_suggest_compact_range( + rocksdb_t* db, const char* start_key, size_t start_key_len, + const char* limit_key, size_t limit_key_len, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_suggest_compact_range_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + const char* start_key, size_t start_key_len, const char* limit_key, + size_t limit_key_len, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_compact_range_opt( + rocksdb_t* db, rocksdb_compactoptions_t* opt, const char* start_key, + size_t start_key_len, const char* limit_key, size_t limit_key_len); + +extern ROCKSDB_LIBRARY_API void rocksdb_compact_range_cf_opt( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + rocksdb_compactoptions_t* opt, const char* start_key, size_t start_key_len, + const char* limit_key, size_t limit_key_len); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete_file(rocksdb_t* db, + const char* name); + +extern ROCKSDB_LIBRARY_API const rocksdb_livefiles_t* rocksdb_livefiles( + rocksdb_t* db); + +extern ROCKSDB_LIBRARY_API void rocksdb_flush( + rocksdb_t* db, const rocksdb_flushoptions_t* options, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_flush_cf( + rocksdb_t* db, const rocksdb_flushoptions_t* options, + rocksdb_column_family_handle_t* column_family, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_flush_cfs( + rocksdb_t* db, const rocksdb_flushoptions_t* options, + rocksdb_column_family_handle_t** column_family, int num_column_families, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_flush_wal(rocksdb_t* db, + unsigned char sync, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_disable_file_deletions(rocksdb_t* db, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_enable_file_deletions( + rocksdb_t* db, unsigned char force, char** errptr); + +/* Management operations */ + +extern ROCKSDB_LIBRARY_API void rocksdb_destroy_db( + const rocksdb_options_t* options, const char* name, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_repair_db( + const rocksdb_options_t* options, const char* name, char** errptr); + +/* Iterator */ + +extern ROCKSDB_LIBRARY_API void rocksdb_iter_destroy(rocksdb_iterator_t*); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_iter_valid( + const rocksdb_iterator_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_iter_seek_to_first(rocksdb_iterator_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_iter_seek_to_last(rocksdb_iterator_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_iter_seek(rocksdb_iterator_t*, + const char* k, size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_iter_seek_for_prev(rocksdb_iterator_t*, + const char* k, + size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_iter_next(rocksdb_iterator_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_iter_prev(rocksdb_iterator_t*); +extern ROCKSDB_LIBRARY_API const char* rocksdb_iter_key( + const rocksdb_iterator_t*, size_t* klen); +extern ROCKSDB_LIBRARY_API const char* rocksdb_iter_value( + const rocksdb_iterator_t*, size_t* vlen); +extern ROCKSDB_LIBRARY_API const char* rocksdb_iter_timestamp( + const rocksdb_iterator_t*, size_t* tslen); +extern ROCKSDB_LIBRARY_API void rocksdb_iter_get_error( + const rocksdb_iterator_t*, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_wal_iter_next( + rocksdb_wal_iterator_t* iter); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_wal_iter_valid( + const rocksdb_wal_iterator_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_wal_iter_status( + const rocksdb_wal_iterator_t* iter, char** errptr); +extern ROCKSDB_LIBRARY_API rocksdb_writebatch_t* rocksdb_wal_iter_get_batch( + const rocksdb_wal_iterator_t* iter, uint64_t* seq); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_get_latest_sequence_number(rocksdb_t* db); +extern ROCKSDB_LIBRARY_API void rocksdb_wal_iter_destroy( + const rocksdb_wal_iterator_t* iter); + +/* Write batch */ + +extern ROCKSDB_LIBRARY_API rocksdb_writebatch_t* rocksdb_writebatch_create( + void); +extern ROCKSDB_LIBRARY_API rocksdb_writebatch_t* rocksdb_writebatch_create_from( + const char* rep, size_t size); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_destroy( + rocksdb_writebatch_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_clear(rocksdb_writebatch_t*); +extern ROCKSDB_LIBRARY_API int rocksdb_writebatch_count(rocksdb_writebatch_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_put(rocksdb_writebatch_t*, + const char* key, + size_t klen, + const char* val, + size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_put_cf( + rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* val, size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_put_cf_with_ts( + rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* ts, size_t tslen, const char* val, + size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_putv( + rocksdb_writebatch_t* b, int num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, int num_values, + const char* const* values_list, const size_t* values_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_putv_cf( + rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, + int num_keys, const char* const* keys_list, const size_t* keys_list_sizes, + int num_values, const char* const* values_list, + const size_t* values_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_merge(rocksdb_writebatch_t*, + const char* key, + size_t klen, + const char* val, + size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_merge_cf( + rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* val, size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_mergev( + rocksdb_writebatch_t* b, int num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, int num_values, + const char* const* values_list, const size_t* values_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_mergev_cf( + rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, + int num_keys, const char* const* keys_list, const size_t* keys_list_sizes, + int num_values, const char* const* values_list, + const size_t* values_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete(rocksdb_writebatch_t*, + const char* key, + size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_singledelete( + rocksdb_writebatch_t* b, const char* key, size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_cf( + rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_cf_with_ts( + rocksdb_writebatch_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* ts, size_t tslen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_singledelete_cf( + rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_singledelete_cf_with_ts( + rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* ts, size_t tslen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_deletev( + rocksdb_writebatch_t* b, int num_keys, const char* const* keys_list, + const size_t* keys_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_deletev_cf( + rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, + int num_keys, const char* const* keys_list, const size_t* keys_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_range( + rocksdb_writebatch_t* b, const char* start_key, size_t start_key_len, + const char* end_key, size_t end_key_len); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_range_cf( + rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, + const char* start_key, size_t start_key_len, const char* end_key, + size_t end_key_len); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_rangev( + rocksdb_writebatch_t* b, int num_keys, const char* const* start_keys_list, + const size_t* start_keys_list_sizes, const char* const* end_keys_list, + const size_t* end_keys_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_delete_rangev_cf( + rocksdb_writebatch_t* b, rocksdb_column_family_handle_t* column_family, + int num_keys, const char* const* start_keys_list, + const size_t* start_keys_list_sizes, const char* const* end_keys_list, + const size_t* end_keys_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_put_log_data( + rocksdb_writebatch_t*, const char* blob, size_t len); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_iterate( + rocksdb_writebatch_t*, void* state, + void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), + void (*deleted)(void*, const char* k, size_t klen)); +extern ROCKSDB_LIBRARY_API const char* rocksdb_writebatch_data( + rocksdb_writebatch_t*, size_t* size); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_set_save_point( + rocksdb_writebatch_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_rollback_to_save_point( + rocksdb_writebatch_t*, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_pop_save_point( + rocksdb_writebatch_t*, char** errptr); + +/* Write batch with index */ + +extern ROCKSDB_LIBRARY_API rocksdb_writebatch_wi_t* +rocksdb_writebatch_wi_create(size_t reserved_bytes, + unsigned char overwrite_keys); +extern ROCKSDB_LIBRARY_API rocksdb_writebatch_wi_t* +rocksdb_writebatch_wi_create_from(const char* rep, size_t size); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_destroy( + rocksdb_writebatch_wi_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_clear( + rocksdb_writebatch_wi_t*); +extern ROCKSDB_LIBRARY_API int rocksdb_writebatch_wi_count( + rocksdb_writebatch_wi_t* b); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_put( + rocksdb_writebatch_wi_t*, const char* key, size_t klen, const char* val, + size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_put_cf( + rocksdb_writebatch_wi_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* val, size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_putv( + rocksdb_writebatch_wi_t* b, int num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, int num_values, + const char* const* values_list, const size_t* values_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_putv_cf( + rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, + int num_keys, const char* const* keys_list, const size_t* keys_list_sizes, + int num_values, const char* const* values_list, + const size_t* values_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_merge( + rocksdb_writebatch_wi_t*, const char* key, size_t klen, const char* val, + size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_merge_cf( + rocksdb_writebatch_wi_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* val, size_t vlen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_mergev( + rocksdb_writebatch_wi_t* b, int num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, int num_values, + const char* const* values_list, const size_t* values_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_mergev_cf( + rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, + int num_keys, const char* const* keys_list, const size_t* keys_list_sizes, + int num_values, const char* const* values_list, + const size_t* values_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete( + rocksdb_writebatch_wi_t*, const char* key, size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_singledelete( + rocksdb_writebatch_wi_t*, const char* key, size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_cf( + rocksdb_writebatch_wi_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_singledelete_cf( + rocksdb_writebatch_wi_t*, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_deletev( + rocksdb_writebatch_wi_t* b, int num_keys, const char* const* keys_list, + const size_t* keys_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_deletev_cf( + rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, + int num_keys, const char* const* keys_list, const size_t* keys_list_sizes); +// DO NOT USE - rocksdb_writebatch_wi_delete_range is not yet supported +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_range( + rocksdb_writebatch_wi_t* b, const char* start_key, size_t start_key_len, + const char* end_key, size_t end_key_len); +// DO NOT USE - rocksdb_writebatch_wi_delete_range_cf is not yet supported +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_range_cf( + rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, + const char* start_key, size_t start_key_len, const char* end_key, + size_t end_key_len); +// DO NOT USE - rocksdb_writebatch_wi_delete_rangev is not yet supported +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_rangev( + rocksdb_writebatch_wi_t* b, int num_keys, + const char* const* start_keys_list, const size_t* start_keys_list_sizes, + const char* const* end_keys_list, const size_t* end_keys_list_sizes); +// DO NOT USE - rocksdb_writebatch_wi_delete_rangev_cf is not yet supported +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_delete_rangev_cf( + rocksdb_writebatch_wi_t* b, rocksdb_column_family_handle_t* column_family, + int num_keys, const char* const* start_keys_list, + const size_t* start_keys_list_sizes, const char* const* end_keys_list, + const size_t* end_keys_list_sizes); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_put_log_data( + rocksdb_writebatch_wi_t*, const char* blob, size_t len); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_iterate( + rocksdb_writebatch_wi_t* b, void* state, + void (*put)(void*, const char* k, size_t klen, const char* v, size_t vlen), + void (*deleted)(void*, const char* k, size_t klen)); +extern ROCKSDB_LIBRARY_API const char* rocksdb_writebatch_wi_data( + rocksdb_writebatch_wi_t* b, size_t* size); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_set_save_point( + rocksdb_writebatch_wi_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writebatch_wi_rollback_to_save_point( + rocksdb_writebatch_wi_t*, char** errptr); +extern ROCKSDB_LIBRARY_API char* rocksdb_writebatch_wi_get_from_batch( + rocksdb_writebatch_wi_t* wbwi, const rocksdb_options_t* options, + const char* key, size_t keylen, size_t* vallen, char** errptr); +extern ROCKSDB_LIBRARY_API char* rocksdb_writebatch_wi_get_from_batch_cf( + rocksdb_writebatch_wi_t* wbwi, const rocksdb_options_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, size_t* vallen, char** errptr); +extern ROCKSDB_LIBRARY_API char* rocksdb_writebatch_wi_get_from_batch_and_db( + rocksdb_writebatch_wi_t* wbwi, rocksdb_t* db, + const rocksdb_readoptions_t* options, const char* key, size_t keylen, + size_t* vallen, char** errptr); +extern ROCKSDB_LIBRARY_API char* rocksdb_writebatch_wi_get_from_batch_and_db_cf( + rocksdb_writebatch_wi_t* wbwi, rocksdb_t* db, + const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, size_t* vallen, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_write_writebatch_wi( + rocksdb_t* db, const rocksdb_writeoptions_t* options, + rocksdb_writebatch_wi_t* wbwi, char** errptr); +extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* +rocksdb_writebatch_wi_create_iterator_with_base( + rocksdb_writebatch_wi_t* wbwi, rocksdb_iterator_t* base_iterator); +extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* +rocksdb_writebatch_wi_create_iterator_with_base_cf( + rocksdb_writebatch_wi_t* wbwi, rocksdb_iterator_t* base_iterator, + rocksdb_column_family_handle_t* cf); + +/* Options utils */ + +// Load the latest rocksdb options from the specified db_path. +// +// On success, num_column_families will be updated with a non-zero +// number indicating the number of column families. +// The returned db_options, column_family_names, and column_family_options +// should be released via rocksdb_load_latest_options_destroy(). +// +// On error, a non-null errptr that includes the error message will be +// returned. db_options, column_family_names, and column_family_options +// will be set to NULL. +extern ROCKSDB_LIBRARY_API void rocksdb_load_latest_options( + const char* db_path, rocksdb_env_t* env, bool ignore_unknown_options, + rocksdb_cache_t* cache, rocksdb_options_t** db_options, + size_t* num_column_families, char*** column_family_names, + rocksdb_options_t*** column_family_options, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_load_latest_options_destroy( + rocksdb_options_t* db_options, char** list_column_family_names, + rocksdb_options_t** list_column_family_options, size_t len); + +/* Block based table options */ + +extern ROCKSDB_LIBRARY_API rocksdb_block_based_table_options_t* +rocksdb_block_based_options_create(void); +extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_destroy( + rocksdb_block_based_table_options_t* options); +extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_checksum( + rocksdb_block_based_table_options_t*, char); +extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_block_size( + rocksdb_block_based_table_options_t* options, size_t block_size); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_block_size_deviation( + rocksdb_block_based_table_options_t* options, int block_size_deviation); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_block_restart_interval( + rocksdb_block_based_table_options_t* options, int block_restart_interval); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_index_block_restart_interval( + rocksdb_block_based_table_options_t* options, + int index_block_restart_interval); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_metadata_block_size( + rocksdb_block_based_table_options_t* options, uint64_t metadata_block_size); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_partition_filters( + rocksdb_block_based_table_options_t* options, + unsigned char partition_filters); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_optimize_filters_for_memory( + rocksdb_block_based_table_options_t* options, + unsigned char optimize_filters_for_memory); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_use_delta_encoding( + rocksdb_block_based_table_options_t* options, + unsigned char use_delta_encoding); +extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_filter_policy( + rocksdb_block_based_table_options_t* options, + rocksdb_filterpolicy_t* filter_policy); +extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_no_block_cache( + rocksdb_block_based_table_options_t* options, unsigned char no_block_cache); +extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_block_cache( + rocksdb_block_based_table_options_t* options, rocksdb_cache_t* block_cache); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_whole_key_filtering( + rocksdb_block_based_table_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_format_version( + rocksdb_block_based_table_options_t*, int); +enum { + rocksdb_block_based_table_index_type_binary_search = 0, + rocksdb_block_based_table_index_type_hash_search = 1, + rocksdb_block_based_table_index_type_two_level_index_search = 2, +}; +extern ROCKSDB_LIBRARY_API void rocksdb_block_based_options_set_index_type( + rocksdb_block_based_table_options_t*, int); // uses one of the above enums +enum { + rocksdb_block_based_table_data_block_index_type_binary_search = 0, + rocksdb_block_based_table_data_block_index_type_binary_search_and_hash = 1, +}; +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_data_block_index_type( + rocksdb_block_based_table_options_t*, int); // uses one of the above enums +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_data_block_hash_ratio( + rocksdb_block_based_table_options_t* options, double v); +// rocksdb_block_based_options_set_hash_index_allow_collision() +// is removed since BlockBasedTableOptions.hash_index_allow_collision() +// is removed +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_cache_index_and_filter_blocks( + rocksdb_block_based_table_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority( + rocksdb_block_based_table_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache( + rocksdb_block_based_table_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API void +rocksdb_block_based_options_set_pin_top_level_index_and_filter( + rocksdb_block_based_table_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_block_based_table_factory( + rocksdb_options_t* opt, rocksdb_block_based_table_options_t* table_options); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_write_buffer_manager( + rocksdb_options_t* opt, rocksdb_write_buffer_manager_t* wbm); + +/* Cuckoo table options */ + +extern ROCKSDB_LIBRARY_API rocksdb_cuckoo_table_options_t* +rocksdb_cuckoo_options_create(void); +extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_destroy( + rocksdb_cuckoo_table_options_t* options); +extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_set_hash_ratio( + rocksdb_cuckoo_table_options_t* options, double v); +extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_set_max_search_depth( + rocksdb_cuckoo_table_options_t* options, uint32_t v); +extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_set_cuckoo_block_size( + rocksdb_cuckoo_table_options_t* options, uint32_t v); +extern ROCKSDB_LIBRARY_API void +rocksdb_cuckoo_options_set_identity_as_first_hash( + rocksdb_cuckoo_table_options_t* options, unsigned char v); +extern ROCKSDB_LIBRARY_API void rocksdb_cuckoo_options_set_use_module_hash( + rocksdb_cuckoo_table_options_t* options, unsigned char v); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_cuckoo_table_factory( + rocksdb_options_t* opt, rocksdb_cuckoo_table_options_t* table_options); + +/* Options */ +extern ROCKSDB_LIBRARY_API void rocksdb_set_options(rocksdb_t* db, int count, + const char* const keys[], + const char* const values[], + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_set_options_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* handle, int count, + const char* const keys[], const char* const values[], char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_options_t* rocksdb_options_create(void); +extern ROCKSDB_LIBRARY_API void rocksdb_options_destroy(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API rocksdb_options_t* rocksdb_options_create_copy( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_increase_parallelism( + rocksdb_options_t* opt, int total_threads); +extern ROCKSDB_LIBRARY_API void rocksdb_options_optimize_for_point_lookup( + rocksdb_options_t* opt, uint64_t block_cache_size_mb); +extern ROCKSDB_LIBRARY_API void rocksdb_options_optimize_level_style_compaction( + rocksdb_options_t* opt, uint64_t memtable_memory_budget); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_optimize_universal_style_compaction( + rocksdb_options_t* opt, uint64_t memtable_memory_budget); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_allow_ingest_behind( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_allow_ingest_behind(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compaction_filter( + rocksdb_options_t*, rocksdb_compactionfilter_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compaction_filter_factory( + rocksdb_options_t*, rocksdb_compactionfilterfactory_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_compaction_readahead_size( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_compaction_readahead_size(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_comparator( + rocksdb_options_t*, rocksdb_comparator_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_merge_operator( + rocksdb_options_t*, rocksdb_mergeoperator_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_uint64add_merge_operator( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression_per_level( + rocksdb_options_t* opt, const int* level_values, size_t num_levels); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_create_if_missing( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_create_if_missing( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_create_missing_column_families(rocksdb_options_t*, + unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_create_missing_column_families(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_error_if_exists( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_error_if_exists( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_paranoid_checks( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_paranoid_checks( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_db_paths( + rocksdb_options_t*, const rocksdb_dbpath_t** path_values, size_t num_paths); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_cf_paths( + rocksdb_options_t*, const rocksdb_dbpath_t** path_values, size_t num_paths); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_env(rocksdb_options_t*, + rocksdb_env_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_info_log(rocksdb_options_t*, + rocksdb_logger_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_info_log_level( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_info_log_level( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_write_buffer_size( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_write_buffer_size(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_db_write_buffer_size( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_db_write_buffer_size(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_open_files( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_max_open_files( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_file_opening_threads( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_max_file_opening_threads( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_total_wal_size( + rocksdb_options_t* opt, uint64_t n); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_max_total_wal_size(rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression_options( + rocksdb_options_t*, int, int, int, int); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_compression_options_zstd_max_train_bytes(rocksdb_options_t*, + int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_compression_options_zstd_max_train_bytes( + rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_compression_options_use_zstd_dict_trainer( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_compression_options_use_zstd_dict_trainer( + rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_compression_options_parallel_threads(rocksdb_options_t*, + int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_compression_options_parallel_threads( + rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_compression_options_max_dict_buffer_bytes( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_compression_options_max_dict_buffer_bytes( + rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_bottommost_compression_options(rocksdb_options_t*, int, int, + int, int, unsigned char); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_bottommost_compression_options_zstd_max_train_bytes( + rocksdb_options_t*, int, unsigned char); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_bottommost_compression_options_use_zstd_dict_trainer( + rocksdb_options_t*, unsigned char, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_bottommost_compression_options_use_zstd_dict_trainer( + rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_bottommost_compression_options_max_dict_buffer_bytes( + rocksdb_options_t*, uint64_t, unsigned char); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_prefix_extractor( + rocksdb_options_t*, rocksdb_slicetransform_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_num_levels( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_num_levels( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_level0_file_num_compaction_trigger(rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_level0_file_num_compaction_trigger(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_level0_slowdown_writes_trigger(rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_level0_slowdown_writes_trigger(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_level0_stop_writes_trigger( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_level0_stop_writes_trigger( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_target_file_size_base( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_target_file_size_base(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_target_file_size_multiplier( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_target_file_size_multiplier( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_bytes_for_level_base( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_max_bytes_for_level_base(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_level_compaction_dynamic_level_bytes(rocksdb_options_t*, + unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_level_compaction_dynamic_level_bytes(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_max_bytes_for_level_multiplier(rocksdb_options_t*, double); +extern ROCKSDB_LIBRARY_API double +rocksdb_options_get_max_bytes_for_level_multiplier(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_max_bytes_for_level_multiplier_additional( + rocksdb_options_t*, int* level_values, size_t num_levels); +extern ROCKSDB_LIBRARY_API void rocksdb_options_enable_statistics( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_periodic_compaction_seconds( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_periodic_compaction_seconds(rocksdb_options_t*); + +enum { + rocksdb_statistics_level_disable_all = 0, + rocksdb_statistics_level_except_tickers = + rocksdb_statistics_level_disable_all, + rocksdb_statistics_level_except_histogram_or_timers = 1, + rocksdb_statistics_level_except_timers = 2, + rocksdb_statistics_level_except_detailed_timers = 3, + rocksdb_statistics_level_except_time_for_mutex = 4, + rocksdb_statistics_level_all = 5, +}; + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_statistics_level( + rocksdb_options_t*, int level); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_statistics_level( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_skip_stats_update_on_db_open(rocksdb_options_t* opt, + unsigned char val); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_skip_stats_update_on_db_open(rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_skip_checking_sst_file_sizes_on_db_open( + rocksdb_options_t* opt, unsigned char val); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_skip_checking_sst_file_sizes_on_db_open( + rocksdb_options_t* opt); + +/* Blob Options Settings */ +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_enable_blob_files( + rocksdb_options_t* opt, unsigned char val); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_enable_blob_files( + rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_min_blob_size( + rocksdb_options_t* opt, uint64_t val); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_min_blob_size(rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_file_size( + rocksdb_options_t* opt, uint64_t val); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_blob_file_size(rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_compression_type( + rocksdb_options_t* opt, int val); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_blob_compression_type( + rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_enable_blob_gc( + rocksdb_options_t* opt, unsigned char val); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_enable_blob_gc( + rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_gc_age_cutoff( + rocksdb_options_t* opt, double val); +extern ROCKSDB_LIBRARY_API double rocksdb_options_get_blob_gc_age_cutoff( + rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_gc_force_threshold( + rocksdb_options_t* opt, double val); +extern ROCKSDB_LIBRARY_API double rocksdb_options_get_blob_gc_force_threshold( + rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_blob_compaction_readahead_size(rocksdb_options_t* opt, + uint64_t val); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_blob_compaction_readahead_size(rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_file_starting_level( + rocksdb_options_t* opt, int val); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_blob_file_starting_level( + rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_blob_cache( + rocksdb_options_t* opt, rocksdb_cache_t* blob_cache); + +enum { + rocksdb_prepopulate_blob_disable = 0, + rocksdb_prepopulate_blob_flush_only = 1 +}; + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_prepopulate_blob_cache( + rocksdb_options_t* opt, int val); + +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_prepopulate_blob_cache( + rocksdb_options_t* opt); + +/* returns a pointer to a malloc()-ed, null terminated string */ +extern ROCKSDB_LIBRARY_API char* rocksdb_options_statistics_get_string( + rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API uint64_t rocksdb_options_statistics_get_ticker_count( + rocksdb_options_t* opt, uint32_t ticker_type); +extern ROCKSDB_LIBRARY_API void rocksdb_options_statistics_get_histogram_data( + rocksdb_options_t* opt, uint32_t histogram_type, + rocksdb_statistics_histogram_data_t* const data); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_write_buffer_number( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_max_write_buffer_number( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_min_write_buffer_number_to_merge(rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_min_write_buffer_number_to_merge(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_max_write_buffer_number_to_maintain(rocksdb_options_t*, + int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_max_write_buffer_number_to_maintain(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_max_write_buffer_size_to_maintain(rocksdb_options_t*, + int64_t); +extern ROCKSDB_LIBRARY_API int64_t +rocksdb_options_get_max_write_buffer_size_to_maintain(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_enable_pipelined_write( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_enable_pipelined_write(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_unordered_write( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_unordered_write( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_subcompactions( + rocksdb_options_t*, uint32_t); +extern ROCKSDB_LIBRARY_API uint32_t +rocksdb_options_get_max_subcompactions(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_background_jobs( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_max_background_jobs( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_background_compactions( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_max_background_compactions( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_background_flushes( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_max_background_flushes( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_log_file_size( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_max_log_file_size(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_log_file_time_to_roll( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_log_file_time_to_roll(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_keep_log_file_num( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_keep_log_file_num(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_recycle_log_file_num( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_recycle_log_file_num(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_soft_pending_compaction_bytes_limit(rocksdb_options_t* opt, + size_t v); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_soft_pending_compaction_bytes_limit(rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_hard_pending_compaction_bytes_limit(rocksdb_options_t* opt, + size_t v); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_hard_pending_compaction_bytes_limit(rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_manifest_file_size( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_max_manifest_file_size(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_table_cache_numshardbits( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_table_cache_numshardbits( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_arena_block_size( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_arena_block_size(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_use_fsync( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_use_fsync( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_db_log_dir( + rocksdb_options_t*, const char*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_wal_dir(rocksdb_options_t*, + const char*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_WAL_ttl_seconds( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_WAL_ttl_seconds(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_WAL_size_limit_MB( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_WAL_size_limit_MB(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_manifest_preallocation_size( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_manifest_preallocation_size(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_allow_mmap_reads( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_allow_mmap_reads( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_allow_mmap_writes( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_allow_mmap_writes( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_use_direct_reads( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_use_direct_reads( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_use_direct_io_for_flush_and_compaction(rocksdb_options_t*, + unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_use_direct_io_for_flush_and_compaction(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_is_fd_close_on_exec( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_is_fd_close_on_exec(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_stats_dump_period_sec( + rocksdb_options_t*, unsigned int); +extern ROCKSDB_LIBRARY_API unsigned int +rocksdb_options_get_stats_dump_period_sec(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_stats_persist_period_sec( + rocksdb_options_t*, unsigned int); +extern ROCKSDB_LIBRARY_API unsigned int +rocksdb_options_get_stats_persist_period_sec(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_advise_random_on_open( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_advise_random_on_open(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_access_hint_on_compaction_start(rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_options_get_access_hint_on_compaction_start(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_use_adaptive_mutex( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_use_adaptive_mutex( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_bytes_per_sync( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_bytes_per_sync(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_wal_bytes_per_sync( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_wal_bytes_per_sync(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_writable_file_max_buffer_size(rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_writable_file_max_buffer_size(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_allow_concurrent_memtable_write(rocksdb_options_t*, + unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_allow_concurrent_memtable_write(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_enable_write_thread_adaptive_yield(rocksdb_options_t*, + unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_enable_write_thread_adaptive_yield(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_max_sequential_skip_in_iterations(rocksdb_options_t*, + uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_max_sequential_skip_in_iterations(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_disable_auto_compactions( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_disable_auto_compactions(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_optimize_filters_for_hits( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_optimize_filters_for_hits(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_delete_obsolete_files_period_micros(rocksdb_options_t*, + uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_delete_obsolete_files_period_micros(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_prepare_for_bulk_load( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_memtable_vector_rep( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_memtable_prefix_bloom_size_ratio(rocksdb_options_t*, + double); +extern ROCKSDB_LIBRARY_API double +rocksdb_options_get_memtable_prefix_bloom_size_ratio(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_compaction_bytes( + rocksdb_options_t*, uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_options_get_max_compaction_bytes(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hash_skip_list_rep( + rocksdb_options_t*, size_t, int32_t, int32_t); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_hash_link_list_rep( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_plain_table_factory( + rocksdb_options_t*, uint32_t, int, double, size_t, size_t, char, + unsigned char, unsigned char); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_min_level_to_compress( + rocksdb_options_t* opt, int level); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_memtable_huge_page_size( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_memtable_huge_page_size(rocksdb_options_t*); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_max_successive_merges( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_max_successive_merges(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_bloom_locality( + rocksdb_options_t*, uint32_t); +extern ROCKSDB_LIBRARY_API uint32_t +rocksdb_options_get_bloom_locality(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_inplace_update_support( + rocksdb_options_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_inplace_update_support(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_inplace_update_num_locks( + rocksdb_options_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_options_get_inplace_update_num_locks(rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_report_bg_io_stats( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_report_bg_io_stats( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_avoid_unnecessary_blocking_io(rocksdb_options_t*, + unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_options_get_avoid_unnecessary_blocking_io(rocksdb_options_t*); + +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_experimental_mempurge_threshold(rocksdb_options_t*, double); +extern ROCKSDB_LIBRARY_API double +rocksdb_options_get_experimental_mempurge_threshold(rocksdb_options_t*); + +enum { + rocksdb_tolerate_corrupted_tail_records_recovery = 0, + rocksdb_absolute_consistency_recovery = 1, + rocksdb_point_in_time_recovery = 2, + rocksdb_skip_any_corrupted_records_recovery = 3 +}; +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_wal_recovery_mode( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_wal_recovery_mode( + rocksdb_options_t*); + +enum { + rocksdb_no_compression = 0, + rocksdb_snappy_compression = 1, + rocksdb_zlib_compression = 2, + rocksdb_bz2_compression = 3, + rocksdb_lz4_compression = 4, + rocksdb_lz4hc_compression = 5, + rocksdb_xpress_compression = 6, + rocksdb_zstd_compression = 7 +}; +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compression( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_compression( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_bottommost_compression( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_bottommost_compression( + rocksdb_options_t*); + +enum { + rocksdb_level_compaction = 0, + rocksdb_universal_compaction = 1, + rocksdb_fifo_compaction = 2 +}; +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_compaction_style( + rocksdb_options_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_compaction_style( + rocksdb_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_universal_compaction_options( + rocksdb_options_t*, rocksdb_universal_compaction_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_fifo_compaction_options( + rocksdb_options_t* opt, rocksdb_fifo_compaction_options_t* fifo); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_ratelimiter( + rocksdb_options_t* opt, rocksdb_ratelimiter_t* limiter); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_atomic_flush( + rocksdb_options_t* opt, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_atomic_flush( + rocksdb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_row_cache( + rocksdb_options_t* opt, rocksdb_cache_t* cache); + +extern ROCKSDB_LIBRARY_API void +rocksdb_options_add_compact_on_deletion_collector_factory( + rocksdb_options_t*, size_t window_size, size_t num_dels_trigger); +extern ROCKSDB_LIBRARY_API void +rocksdb_options_add_compact_on_deletion_collector_factory_del_ratio( + rocksdb_options_t*, size_t window_size, size_t num_dels_trigger, + double deletion_ratio); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_manual_wal_flush( + rocksdb_options_t* opt, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_options_get_manual_wal_flush( + rocksdb_options_t* opt); +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_wal_compression( + rocksdb_options_t* opt, int); +extern ROCKSDB_LIBRARY_API int rocksdb_options_get_wal_compression( + rocksdb_options_t* opt); + +/* RateLimiter */ +extern ROCKSDB_LIBRARY_API rocksdb_ratelimiter_t* rocksdb_ratelimiter_create( + int64_t rate_bytes_per_sec, int64_t refill_period_us, int32_t fairness); +extern ROCKSDB_LIBRARY_API rocksdb_ratelimiter_t* +rocksdb_ratelimiter_create_auto_tuned(int64_t rate_bytes_per_sec, + int64_t refill_period_us, + int32_t fairness); +extern ROCKSDB_LIBRARY_API void rocksdb_ratelimiter_destroy( + rocksdb_ratelimiter_t*); + +/* PerfContext */ +enum { + rocksdb_uninitialized = 0, + rocksdb_disable = 1, + rocksdb_enable_count = 2, + rocksdb_enable_time_except_for_mutex = 3, + rocksdb_enable_time = 4, + rocksdb_out_of_bounds = 5 +}; + +enum { + rocksdb_user_key_comparison_count = 0, + rocksdb_block_cache_hit_count, + rocksdb_block_read_count, + rocksdb_block_read_byte, + rocksdb_block_read_time, + rocksdb_block_checksum_time, + rocksdb_block_decompress_time, + rocksdb_get_read_bytes, + rocksdb_multiget_read_bytes, + rocksdb_iter_read_bytes, + rocksdb_internal_key_skipped_count, + rocksdb_internal_delete_skipped_count, + rocksdb_internal_recent_skipped_count, + rocksdb_internal_merge_count, + rocksdb_get_snapshot_time, + rocksdb_get_from_memtable_time, + rocksdb_get_from_memtable_count, + rocksdb_get_post_process_time, + rocksdb_get_from_output_files_time, + rocksdb_seek_on_memtable_time, + rocksdb_seek_on_memtable_count, + rocksdb_next_on_memtable_count, + rocksdb_prev_on_memtable_count, + rocksdb_seek_child_seek_time, + rocksdb_seek_child_seek_count, + rocksdb_seek_min_heap_time, + rocksdb_seek_max_heap_time, + rocksdb_seek_internal_seek_time, + rocksdb_find_next_user_entry_time, + rocksdb_write_wal_time, + rocksdb_write_memtable_time, + rocksdb_write_delay_time, + rocksdb_write_pre_and_post_process_time, + rocksdb_db_mutex_lock_nanos, + rocksdb_db_condition_wait_nanos, + rocksdb_merge_operator_time_nanos, + rocksdb_read_index_block_nanos, + rocksdb_read_filter_block_nanos, + rocksdb_new_table_block_iter_nanos, + rocksdb_new_table_iterator_nanos, + rocksdb_block_seek_nanos, + rocksdb_find_table_nanos, + rocksdb_bloom_memtable_hit_count, + rocksdb_bloom_memtable_miss_count, + rocksdb_bloom_sst_hit_count, + rocksdb_bloom_sst_miss_count, + rocksdb_key_lock_wait_time, + rocksdb_key_lock_wait_count, + rocksdb_env_new_sequential_file_nanos, + rocksdb_env_new_random_access_file_nanos, + rocksdb_env_new_writable_file_nanos, + rocksdb_env_reuse_writable_file_nanos, + rocksdb_env_new_random_rw_file_nanos, + rocksdb_env_new_directory_nanos, + rocksdb_env_file_exists_nanos, + rocksdb_env_get_children_nanos, + rocksdb_env_get_children_file_attributes_nanos, + rocksdb_env_delete_file_nanos, + rocksdb_env_create_dir_nanos, + rocksdb_env_create_dir_if_missing_nanos, + rocksdb_env_delete_dir_nanos, + rocksdb_env_get_file_size_nanos, + rocksdb_env_get_file_modification_time_nanos, + rocksdb_env_rename_file_nanos, + rocksdb_env_link_file_nanos, + rocksdb_env_lock_file_nanos, + rocksdb_env_unlock_file_nanos, + rocksdb_env_new_logger_nanos, + rocksdb_number_async_seek, + rocksdb_blob_cache_hit_count, + rocksdb_blob_read_count, + rocksdb_blob_read_byte, + rocksdb_blob_read_time, + rocksdb_blob_checksum_time, + rocksdb_blob_decompress_time, + rocksdb_internal_range_del_reseek_count, + rocksdb_block_read_cpu_time, + rocksdb_total_metric_count = 79 +}; + +extern ROCKSDB_LIBRARY_API void rocksdb_set_perf_level(int); +extern ROCKSDB_LIBRARY_API rocksdb_perfcontext_t* rocksdb_perfcontext_create( + void); +extern ROCKSDB_LIBRARY_API void rocksdb_perfcontext_reset( + rocksdb_perfcontext_t* context); +extern ROCKSDB_LIBRARY_API char* rocksdb_perfcontext_report( + rocksdb_perfcontext_t* context, unsigned char exclude_zero_counters); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_perfcontext_metric(rocksdb_perfcontext_t* context, int metric); +extern ROCKSDB_LIBRARY_API void rocksdb_perfcontext_destroy( + rocksdb_perfcontext_t* context); + +/* Compaction Filter */ + +extern ROCKSDB_LIBRARY_API rocksdb_compactionfilter_t* +rocksdb_compactionfilter_create( + void* state, void (*destructor)(void*), + unsigned char (*filter)(void*, int level, const char* key, + size_t key_length, const char* existing_value, + size_t value_length, char** new_value, + size_t* new_value_length, + unsigned char* value_changed), + const char* (*name)(void*)); +extern ROCKSDB_LIBRARY_API void rocksdb_compactionfilter_set_ignore_snapshots( + rocksdb_compactionfilter_t*, unsigned char); +extern ROCKSDB_LIBRARY_API void rocksdb_compactionfilter_destroy( + rocksdb_compactionfilter_t*); + +/* Compaction Filter Context */ + +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_compactionfiltercontext_is_full_compaction( + rocksdb_compactionfiltercontext_t* context); + +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_compactionfiltercontext_is_manual_compaction( + rocksdb_compactionfiltercontext_t* context); + +/* Compaction Filter Factory */ + +extern ROCKSDB_LIBRARY_API rocksdb_compactionfilterfactory_t* +rocksdb_compactionfilterfactory_create( + void* state, void (*destructor)(void*), + rocksdb_compactionfilter_t* (*create_compaction_filter)( + void*, rocksdb_compactionfiltercontext_t* context), + const char* (*name)(void*)); +extern ROCKSDB_LIBRARY_API void rocksdb_compactionfilterfactory_destroy( + rocksdb_compactionfilterfactory_t*); + +/* Comparator */ + +extern ROCKSDB_LIBRARY_API rocksdb_comparator_t* rocksdb_comparator_create( + void* state, void (*destructor)(void*), + int (*compare)(void*, const char* a, size_t alen, const char* b, + size_t blen), + const char* (*name)(void*)); +extern ROCKSDB_LIBRARY_API void rocksdb_comparator_destroy( + rocksdb_comparator_t*); + +extern ROCKSDB_LIBRARY_API rocksdb_comparator_t* +rocksdb_comparator_with_ts_create( + void* state, void (*destructor)(void*), + int (*compare)(void*, const char* a, size_t alen, const char* b, + size_t blen), + int (*compare_ts)(void*, const char* a_ts, size_t a_tslen, const char* b_ts, + size_t b_tslen), + int (*compare_without_ts)(void*, const char* a, size_t alen, + unsigned char a_has_ts, const char* b, + size_t blen, unsigned char b_has_ts), + const char* (*name)(void*), size_t timestamp_size); + +/* Filter policy */ + +extern ROCKSDB_LIBRARY_API void rocksdb_filterpolicy_destroy( + rocksdb_filterpolicy_t*); + +extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t* +rocksdb_filterpolicy_create_bloom(double bits_per_key); +extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t* +rocksdb_filterpolicy_create_bloom_full(double bits_per_key); +extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t* +rocksdb_filterpolicy_create_ribbon(double bloom_equivalent_bits_per_key); +extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t* +rocksdb_filterpolicy_create_ribbon_hybrid(double bloom_equivalent_bits_per_key, + int bloom_before_level); + +/* Merge Operator */ + +extern ROCKSDB_LIBRARY_API rocksdb_mergeoperator_t* +rocksdb_mergeoperator_create( + void* state, void (*destructor)(void*), + char* (*full_merge)(void*, const char* key, size_t key_length, + const char* existing_value, + size_t existing_value_length, + const char* const* operands_list, + const size_t* operands_list_length, int num_operands, + unsigned char* success, size_t* new_value_length), + char* (*partial_merge)(void*, const char* key, size_t key_length, + const char* const* operands_list, + const size_t* operands_list_length, int num_operands, + unsigned char* success, size_t* new_value_length), + void (*delete_value)(void*, const char* value, size_t value_length), + const char* (*name)(void*)); +extern ROCKSDB_LIBRARY_API void rocksdb_mergeoperator_destroy( + rocksdb_mergeoperator_t*); + +/* Read options */ + +extern ROCKSDB_LIBRARY_API rocksdb_readoptions_t* rocksdb_readoptions_create( + void); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_destroy( + rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_verify_checksums( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_verify_checksums(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_fill_cache( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_fill_cache( + rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_snapshot( + rocksdb_readoptions_t*, const rocksdb_snapshot_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iterate_upper_bound( + rocksdb_readoptions_t*, const char* key, size_t keylen); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iterate_lower_bound( + rocksdb_readoptions_t*, const char* key, size_t keylen); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_read_tier( + rocksdb_readoptions_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_readoptions_get_read_tier( + rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_tailing( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_tailing( + rocksdb_readoptions_t*); +// The functionality that this option controlled has been removed. +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_managed( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_readahead_size( + rocksdb_readoptions_t*, size_t); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_readoptions_get_readahead_size(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_prefix_same_as_start( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_prefix_same_as_start(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_pin_data( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_pin_data( + rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_total_order_seek( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_total_order_seek(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_readoptions_set_max_skippable_internal_keys(rocksdb_readoptions_t*, + uint64_t); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_readoptions_get_max_skippable_internal_keys(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_readoptions_set_background_purge_on_iterator_cleanup( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_background_purge_on_iterator_cleanup( + rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_ignore_range_deletions( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_readoptions_get_ignore_range_deletions(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_deadline( + rocksdb_readoptions_t*, uint64_t microseconds); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_readoptions_get_deadline(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_io_timeout( + rocksdb_readoptions_t*, uint64_t microseconds); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_readoptions_get_io_timeout(rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_async_io( + rocksdb_readoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_async_io( + rocksdb_readoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_timestamp( + rocksdb_readoptions_t*, const char* ts, size_t tslen); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iter_start_ts( + rocksdb_readoptions_t*, const char* ts, size_t tslen); +extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_auto_readahead_size( + rocksdb_readoptions_t*, unsigned char); + +/* Write options */ + +extern ROCKSDB_LIBRARY_API rocksdb_writeoptions_t* rocksdb_writeoptions_create( + void); +extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_destroy( + rocksdb_writeoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_set_sync( + rocksdb_writeoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_writeoptions_get_sync( + rocksdb_writeoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_disable_WAL( + rocksdb_writeoptions_t* opt, int disable); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_writeoptions_get_disable_WAL( + rocksdb_writeoptions_t* opt); +extern ROCKSDB_LIBRARY_API void +rocksdb_writeoptions_set_ignore_missing_column_families(rocksdb_writeoptions_t*, + unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_writeoptions_get_ignore_missing_column_families( + rocksdb_writeoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_set_no_slowdown( + rocksdb_writeoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_writeoptions_get_no_slowdown( + rocksdb_writeoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_writeoptions_set_low_pri( + rocksdb_writeoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_writeoptions_get_low_pri( + rocksdb_writeoptions_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_writeoptions_set_memtable_insert_hint_per_batch(rocksdb_writeoptions_t*, + unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_writeoptions_get_memtable_insert_hint_per_batch( + rocksdb_writeoptions_t*); + +/* Compact range options */ + +extern ROCKSDB_LIBRARY_API rocksdb_compactoptions_t* +rocksdb_compactoptions_create(void); +extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_destroy( + rocksdb_compactoptions_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_compactoptions_set_exclusive_manual_compaction( + rocksdb_compactoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_compactoptions_get_exclusive_manual_compaction( + rocksdb_compactoptions_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_compactoptions_set_bottommost_level_compaction( + rocksdb_compactoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_compactoptions_get_bottommost_level_compaction( + rocksdb_compactoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_change_level( + rocksdb_compactoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_compactoptions_get_change_level(rocksdb_compactoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_target_level( + rocksdb_compactoptions_t*, int); +extern ROCKSDB_LIBRARY_API int rocksdb_compactoptions_get_target_level( + rocksdb_compactoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_compactoptions_set_full_history_ts_low( + rocksdb_compactoptions_t*, char* ts, size_t tslen); + +/* Flush options */ + +extern ROCKSDB_LIBRARY_API rocksdb_flushoptions_t* rocksdb_flushoptions_create( + void); +extern ROCKSDB_LIBRARY_API void rocksdb_flushoptions_destroy( + rocksdb_flushoptions_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_flushoptions_set_wait( + rocksdb_flushoptions_t*, unsigned char); +extern ROCKSDB_LIBRARY_API unsigned char rocksdb_flushoptions_get_wait( + rocksdb_flushoptions_t*); + +/* Memory allocator */ + +extern ROCKSDB_LIBRARY_API rocksdb_memory_allocator_t* +rocksdb_jemalloc_nodump_allocator_create(char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_memory_allocator_destroy( + rocksdb_memory_allocator_t*); + +/* Cache */ + +extern ROCKSDB_LIBRARY_API rocksdb_lru_cache_options_t* +rocksdb_lru_cache_options_create(void); +extern ROCKSDB_LIBRARY_API void rocksdb_lru_cache_options_destroy( + rocksdb_lru_cache_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_lru_cache_options_set_capacity( + rocksdb_lru_cache_options_t*, size_t); +extern ROCKSDB_LIBRARY_API void rocksdb_lru_cache_options_set_num_shard_bits( + rocksdb_lru_cache_options_t*, int); +extern ROCKSDB_LIBRARY_API void rocksdb_lru_cache_options_set_memory_allocator( + rocksdb_lru_cache_options_t*, rocksdb_memory_allocator_t*); + +extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_lru( + size_t capacity); +extern ROCKSDB_LIBRARY_API rocksdb_cache_t* +rocksdb_cache_create_lru_with_strict_capacity_limit(size_t capacity); +extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_lru_opts( + const rocksdb_lru_cache_options_t*); + +extern ROCKSDB_LIBRARY_API void rocksdb_cache_destroy(rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API void rocksdb_cache_disown_data( + rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API void rocksdb_cache_set_capacity( + rocksdb_cache_t* cache, size_t capacity); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_cache_get_capacity(const rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_cache_get_usage(const rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_cache_get_pinned_usage(const rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_cache_get_table_address_count(const rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_cache_get_occupancy_count(const rocksdb_cache_t* cache); + +/* WriteBufferManager */ + +extern ROCKSDB_LIBRARY_API rocksdb_write_buffer_manager_t* +rocksdb_write_buffer_manager_create(size_t buffer_size, bool allow_stall); +extern ROCKSDB_LIBRARY_API rocksdb_write_buffer_manager_t* +rocksdb_write_buffer_manager_create_with_cache(size_t buffer_size, + const rocksdb_cache_t* cache, + bool allow_stall); + +extern ROCKSDB_LIBRARY_API void rocksdb_write_buffer_manager_destroy( + rocksdb_write_buffer_manager_t* wbm); +extern ROCKSDB_LIBRARY_API bool rocksdb_write_buffer_manager_enabled( + rocksdb_write_buffer_manager_t* wbm); +extern ROCKSDB_LIBRARY_API bool rocksdb_write_buffer_manager_cost_to_cache( + rocksdb_write_buffer_manager_t* wbm); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_write_buffer_manager_memory_usage(rocksdb_write_buffer_manager_t* wbm); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_write_buffer_manager_mutable_memtable_memory_usage( + rocksdb_write_buffer_manager_t* wbm); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_write_buffer_manager_dummy_entries_in_cache_usage( + rocksdb_write_buffer_manager_t* wbm); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_write_buffer_manager_buffer_size(rocksdb_write_buffer_manager_t* wbm); +extern ROCKSDB_LIBRARY_API void rocksdb_write_buffer_manager_set_buffer_size( + rocksdb_write_buffer_manager_t* wbm, size_t new_size); +extern ROCKSDB_LIBRARY_API void rocksdb_write_buffer_manager_set_allow_stall( + rocksdb_write_buffer_manager_t* wbm, bool new_allow_stall); + +/* HyperClockCache */ + +extern ROCKSDB_LIBRARY_API rocksdb_hyper_clock_cache_options_t* +rocksdb_hyper_clock_cache_options_create(size_t capacity, + size_t estimated_entry_charge); +extern ROCKSDB_LIBRARY_API void rocksdb_hyper_clock_cache_options_destroy( + rocksdb_hyper_clock_cache_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_hyper_clock_cache_options_set_capacity( + rocksdb_hyper_clock_cache_options_t*, size_t); +extern ROCKSDB_LIBRARY_API void +rocksdb_hyper_clock_cache_options_set_estimated_entry_charge( + rocksdb_hyper_clock_cache_options_t*, size_t); +extern ROCKSDB_LIBRARY_API void +rocksdb_hyper_clock_cache_options_set_num_shard_bits( + rocksdb_hyper_clock_cache_options_t*, int); +extern ROCKSDB_LIBRARY_API void +rocksdb_hyper_clock_cache_options_set_memory_allocator( + rocksdb_hyper_clock_cache_options_t*, rocksdb_memory_allocator_t*); + +extern ROCKSDB_LIBRARY_API rocksdb_cache_t* rocksdb_cache_create_hyper_clock( + size_t capacity, size_t estimated_entry_charge); +extern ROCKSDB_LIBRARY_API rocksdb_cache_t* +rocksdb_cache_create_hyper_clock_opts( + const rocksdb_hyper_clock_cache_options_t*); + +/* DBPath */ + +extern ROCKSDB_LIBRARY_API rocksdb_dbpath_t* rocksdb_dbpath_create( + const char* path, uint64_t target_size); +extern ROCKSDB_LIBRARY_API void rocksdb_dbpath_destroy(rocksdb_dbpath_t*); + +/* Env */ + +extern ROCKSDB_LIBRARY_API rocksdb_env_t* rocksdb_create_default_env(void); +extern ROCKSDB_LIBRARY_API rocksdb_env_t* rocksdb_create_mem_env(void); +extern ROCKSDB_LIBRARY_API void rocksdb_env_set_background_threads( + rocksdb_env_t* env, int n); +extern ROCKSDB_LIBRARY_API int rocksdb_env_get_background_threads( + rocksdb_env_t* env); +extern ROCKSDB_LIBRARY_API void +rocksdb_env_set_high_priority_background_threads(rocksdb_env_t* env, int n); +extern ROCKSDB_LIBRARY_API int rocksdb_env_get_high_priority_background_threads( + rocksdb_env_t* env); +extern ROCKSDB_LIBRARY_API void rocksdb_env_set_low_priority_background_threads( + rocksdb_env_t* env, int n); +extern ROCKSDB_LIBRARY_API int rocksdb_env_get_low_priority_background_threads( + rocksdb_env_t* env); +extern ROCKSDB_LIBRARY_API void +rocksdb_env_set_bottom_priority_background_threads(rocksdb_env_t* env, int n); +extern ROCKSDB_LIBRARY_API int +rocksdb_env_get_bottom_priority_background_threads(rocksdb_env_t* env); +extern ROCKSDB_LIBRARY_API void rocksdb_env_join_all_threads( + rocksdb_env_t* env); +extern ROCKSDB_LIBRARY_API void rocksdb_env_lower_thread_pool_io_priority( + rocksdb_env_t* env); +extern ROCKSDB_LIBRARY_API void +rocksdb_env_lower_high_priority_thread_pool_io_priority(rocksdb_env_t* env); +extern ROCKSDB_LIBRARY_API void rocksdb_env_lower_thread_pool_cpu_priority( + rocksdb_env_t* env); +extern ROCKSDB_LIBRARY_API void +rocksdb_env_lower_high_priority_thread_pool_cpu_priority(rocksdb_env_t* env); + +extern ROCKSDB_LIBRARY_API void rocksdb_env_destroy(rocksdb_env_t*); + +extern ROCKSDB_LIBRARY_API rocksdb_envoptions_t* rocksdb_envoptions_create( + void); +extern ROCKSDB_LIBRARY_API void rocksdb_envoptions_destroy( + rocksdb_envoptions_t* opt); +extern ROCKSDB_LIBRARY_API void rocksdb_create_dir_if_missing( + rocksdb_env_t* env, const char* path, char** errptr); + +/* SstFile */ + +extern ROCKSDB_LIBRARY_API rocksdb_sstfilewriter_t* +rocksdb_sstfilewriter_create(const rocksdb_envoptions_t* env, + const rocksdb_options_t* io_options); +extern ROCKSDB_LIBRARY_API rocksdb_sstfilewriter_t* +rocksdb_sstfilewriter_create_with_comparator( + const rocksdb_envoptions_t* env, const rocksdb_options_t* io_options, + const rocksdb_comparator_t* comparator); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_open( + rocksdb_sstfilewriter_t* writer, const char* name, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_add( + rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, + const char* val, size_t vallen, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_put( + rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, + const char* val, size_t vallen, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_put_with_ts( + rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, + const char* ts, size_t tslen, const char* val, size_t vallen, + char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_merge( + rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, + const char* val, size_t vallen, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_delete( + rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, + char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_delete_with_ts( + rocksdb_sstfilewriter_t* writer, const char* key, size_t keylen, + const char* ts, size_t tslen, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_delete_range( + rocksdb_sstfilewriter_t* writer, const char* begin_key, size_t begin_keylen, + const char* end_key, size_t end_keylen, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_finish( + rocksdb_sstfilewriter_t* writer, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_file_size( + rocksdb_sstfilewriter_t* writer, uint64_t* file_size); +extern ROCKSDB_LIBRARY_API void rocksdb_sstfilewriter_destroy( + rocksdb_sstfilewriter_t* writer); +extern ROCKSDB_LIBRARY_API rocksdb_ingestexternalfileoptions_t* +rocksdb_ingestexternalfileoptions_create(void); +extern ROCKSDB_LIBRARY_API void +rocksdb_ingestexternalfileoptions_set_move_files( + rocksdb_ingestexternalfileoptions_t* opt, unsigned char move_files); +extern ROCKSDB_LIBRARY_API void +rocksdb_ingestexternalfileoptions_set_snapshot_consistency( + rocksdb_ingestexternalfileoptions_t* opt, + unsigned char snapshot_consistency); +extern ROCKSDB_LIBRARY_API void +rocksdb_ingestexternalfileoptions_set_allow_global_seqno( + rocksdb_ingestexternalfileoptions_t* opt, unsigned char allow_global_seqno); +extern ROCKSDB_LIBRARY_API void +rocksdb_ingestexternalfileoptions_set_allow_blocking_flush( + rocksdb_ingestexternalfileoptions_t* opt, + unsigned char allow_blocking_flush); +extern ROCKSDB_LIBRARY_API void +rocksdb_ingestexternalfileoptions_set_ingest_behind( + rocksdb_ingestexternalfileoptions_t* opt, unsigned char ingest_behind); +extern ROCKSDB_LIBRARY_API void +rocksdb_ingestexternalfileoptions_set_fail_if_not_bottommost_level( + rocksdb_ingestexternalfileoptions_t* opt, + unsigned char fail_if_not_bottommost_level); + +extern ROCKSDB_LIBRARY_API void rocksdb_ingestexternalfileoptions_destroy( + rocksdb_ingestexternalfileoptions_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_ingest_external_file( + rocksdb_t* db, const char* const* file_list, const size_t list_len, + const rocksdb_ingestexternalfileoptions_t* opt, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_ingest_external_file_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* handle, + const char* const* file_list, const size_t list_len, + const rocksdb_ingestexternalfileoptions_t* opt, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_try_catch_up_with_primary( + rocksdb_t* db, char** errptr); + +/* SliceTransform */ + +extern ROCKSDB_LIBRARY_API rocksdb_slicetransform_t* +rocksdb_slicetransform_create( + void* state, void (*destructor)(void*), + char* (*transform)(void*, const char* key, size_t length, + size_t* dst_length), + unsigned char (*in_domain)(void*, const char* key, size_t length), + unsigned char (*in_range)(void*, const char* key, size_t length), + const char* (*name)(void*)); +extern ROCKSDB_LIBRARY_API rocksdb_slicetransform_t* + rocksdb_slicetransform_create_fixed_prefix(size_t); +extern ROCKSDB_LIBRARY_API rocksdb_slicetransform_t* +rocksdb_slicetransform_create_noop(void); +extern ROCKSDB_LIBRARY_API void rocksdb_slicetransform_destroy( + rocksdb_slicetransform_t*); + +/* Universal Compaction options */ + +enum { + rocksdb_similar_size_compaction_stop_style = 0, + rocksdb_total_size_compaction_stop_style = 1 +}; + +extern ROCKSDB_LIBRARY_API rocksdb_universal_compaction_options_t* +rocksdb_universal_compaction_options_create(void); +extern ROCKSDB_LIBRARY_API void +rocksdb_universal_compaction_options_set_size_ratio( + rocksdb_universal_compaction_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_universal_compaction_options_get_size_ratio( + rocksdb_universal_compaction_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_universal_compaction_options_set_min_merge_width( + rocksdb_universal_compaction_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_universal_compaction_options_get_min_merge_width( + rocksdb_universal_compaction_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_universal_compaction_options_set_max_merge_width( + rocksdb_universal_compaction_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_universal_compaction_options_get_max_merge_width( + rocksdb_universal_compaction_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_universal_compaction_options_set_max_size_amplification_percent( + rocksdb_universal_compaction_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_universal_compaction_options_get_max_size_amplification_percent( + rocksdb_universal_compaction_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_universal_compaction_options_set_compression_size_percent( + rocksdb_universal_compaction_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_universal_compaction_options_get_compression_size_percent( + rocksdb_universal_compaction_options_t*); +extern ROCKSDB_LIBRARY_API void +rocksdb_universal_compaction_options_set_stop_style( + rocksdb_universal_compaction_options_t*, int); +extern ROCKSDB_LIBRARY_API int +rocksdb_universal_compaction_options_get_stop_style( + rocksdb_universal_compaction_options_t*); +extern ROCKSDB_LIBRARY_API void rocksdb_universal_compaction_options_destroy( + rocksdb_universal_compaction_options_t*); + +extern ROCKSDB_LIBRARY_API rocksdb_fifo_compaction_options_t* +rocksdb_fifo_compaction_options_create(void); +extern ROCKSDB_LIBRARY_API void +rocksdb_fifo_compaction_options_set_allow_compaction( + rocksdb_fifo_compaction_options_t* fifo_opts, + unsigned char allow_compaction); +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_fifo_compaction_options_get_allow_compaction( + rocksdb_fifo_compaction_options_t* fifo_opts); +extern ROCKSDB_LIBRARY_API void +rocksdb_fifo_compaction_options_set_max_table_files_size( + rocksdb_fifo_compaction_options_t* fifo_opts, uint64_t size); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_fifo_compaction_options_get_max_table_files_size( + rocksdb_fifo_compaction_options_t* fifo_opts); +extern ROCKSDB_LIBRARY_API void rocksdb_fifo_compaction_options_destroy( + rocksdb_fifo_compaction_options_t* fifo_opts); + +extern ROCKSDB_LIBRARY_API int rocksdb_livefiles_count( + const rocksdb_livefiles_t*); +extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_column_family_name( + const rocksdb_livefiles_t*, int index); +extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_name( + const rocksdb_livefiles_t*, int index); +extern ROCKSDB_LIBRARY_API int rocksdb_livefiles_level( + const rocksdb_livefiles_t*, int index); +extern ROCKSDB_LIBRARY_API size_t +rocksdb_livefiles_size(const rocksdb_livefiles_t*, int index); +extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_smallestkey( + const rocksdb_livefiles_t*, int index, size_t* size); +extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_largestkey( + const rocksdb_livefiles_t*, int index, size_t* size); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_livefiles_entries(const rocksdb_livefiles_t*, int index); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_livefiles_deletions(const rocksdb_livefiles_t*, int index); +extern ROCKSDB_LIBRARY_API void rocksdb_livefiles_destroy( + const rocksdb_livefiles_t*); + +/* Utility Helpers */ + +extern ROCKSDB_LIBRARY_API void rocksdb_get_options_from_string( + const rocksdb_options_t* base_options, const char* opts_str, + rocksdb_options_t* new_options, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete_file_in_range( + rocksdb_t* db, const char* start_key, size_t start_key_len, + const char* limit_key, size_t limit_key_len, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_delete_file_in_range_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family, + const char* start_key, size_t start_key_len, const char* limit_key, + size_t limit_key_len, char** errptr); + +/* MetaData */ + +extern ROCKSDB_LIBRARY_API rocksdb_column_family_metadata_t* +rocksdb_get_column_family_metadata(rocksdb_t* db); + +/** + * Returns the rocksdb_column_family_metadata_t of the specified + * column family. + * + * Note that the caller is responsible to release the returned memory + * using rocksdb_column_family_metadata_destroy. + */ +extern ROCKSDB_LIBRARY_API rocksdb_column_family_metadata_t* +rocksdb_get_column_family_metadata_cf( + rocksdb_t* db, rocksdb_column_family_handle_t* column_family); + +extern ROCKSDB_LIBRARY_API void rocksdb_column_family_metadata_destroy( + rocksdb_column_family_metadata_t* cf_meta); + +extern ROCKSDB_LIBRARY_API uint64_t rocksdb_column_family_metadata_get_size( + rocksdb_column_family_metadata_t* cf_meta); + +extern ROCKSDB_LIBRARY_API size_t rocksdb_column_family_metadata_get_file_count( + rocksdb_column_family_metadata_t* cf_meta); + +extern ROCKSDB_LIBRARY_API char* rocksdb_column_family_metadata_get_name( + rocksdb_column_family_metadata_t* cf_meta); + +extern ROCKSDB_LIBRARY_API size_t +rocksdb_column_family_metadata_get_level_count( + rocksdb_column_family_metadata_t* cf_meta); + +/** + * Returns the rocksdb_level_metadata_t of the ith level from the specified + * column family metadata. + * + * If the specified i is greater than or equal to the number of levels + * in the specified column family, then NULL will be returned. + * + * Note that the caller is responsible to release the returned memory + * using rocksdb_level_metadata_destroy before releasing its parent + * rocksdb_column_family_metadata_t. + */ +extern ROCKSDB_LIBRARY_API rocksdb_level_metadata_t* +rocksdb_column_family_metadata_get_level_metadata( + rocksdb_column_family_metadata_t* cf_meta, size_t i); + +/** + * Releases the specified rocksdb_level_metadata_t. + * + * Note that the specified rocksdb_level_metadata_t must be released + * before the release of its parent rocksdb_column_family_metadata_t. + */ +extern ROCKSDB_LIBRARY_API void rocksdb_level_metadata_destroy( + rocksdb_level_metadata_t* level_meta); + +extern ROCKSDB_LIBRARY_API int rocksdb_level_metadata_get_level( + rocksdb_level_metadata_t* level_meta); + +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_level_metadata_get_size(rocksdb_level_metadata_t* level_meta); + +extern ROCKSDB_LIBRARY_API size_t +rocksdb_level_metadata_get_file_count(rocksdb_level_metadata_t* level_meta); + +/** + * Returns the sst_file_metadata_t of the ith file from the specified level + * metadata. + * + * If the specified i is greater than or equal to the number of files + * in the specified level, then NULL will be returned. + * + * Note that the caller is responsible to release the returned memory + * using rocksdb_sst_file_metadata_destroy before releasing its + * parent rocksdb_level_metadata_t. + */ +extern ROCKSDB_LIBRARY_API rocksdb_sst_file_metadata_t* +rocksdb_level_metadata_get_sst_file_metadata( + rocksdb_level_metadata_t* level_meta, size_t i); + +/** + * Releases the specified rocksdb_sst_file_metadata_t. + * + * Note that the specified rocksdb_sst_file_metadata_t must be released + * before the release of its parent rocksdb_level_metadata_t. + */ +extern ROCKSDB_LIBRARY_API void rocksdb_sst_file_metadata_destroy( + rocksdb_sst_file_metadata_t* file_meta); + +extern ROCKSDB_LIBRARY_API char* +rocksdb_sst_file_metadata_get_relative_filename( + rocksdb_sst_file_metadata_t* file_meta); + +extern ROCKSDB_LIBRARY_API char* rocksdb_sst_file_metadata_get_directory( + rocksdb_sst_file_metadata_t* file_meta); + +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_sst_file_metadata_get_size(rocksdb_sst_file_metadata_t* file_meta); + +/** + * Returns the smallest key of the specified sst file. + * The caller is responsible for releasing the returned memory. + * + * @param file_meta the metadata of an SST file to obtain its smallest key. + * @param len the out value which will contain the length of the returned key + * after the function call. + */ +extern ROCKSDB_LIBRARY_API char* rocksdb_sst_file_metadata_get_smallestkey( + rocksdb_sst_file_metadata_t* file_meta, size_t* len); + +/** + * Returns the smallest key of the specified sst file. + * The caller is responsible for releasing the returned memory. + * + * @param file_meta the metadata of an SST file to obtain its smallest key. + * @param len the out value which will contain the length of the returned key + * after the function call. + */ +extern ROCKSDB_LIBRARY_API char* rocksdb_sst_file_metadata_get_largestkey( + rocksdb_sst_file_metadata_t* file_meta, size_t* len); + +/* Transactions */ + +extern ROCKSDB_LIBRARY_API rocksdb_column_family_handle_t* +rocksdb_transactiondb_create_column_family( + rocksdb_transactiondb_t* txn_db, + const rocksdb_options_t* column_family_options, + const char* column_family_name, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_transactiondb_t* rocksdb_transactiondb_open( + const rocksdb_options_t* options, + const rocksdb_transactiondb_options_t* txn_db_options, const char* name, + char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_transactiondb_t* +rocksdb_transactiondb_open_column_families( + const rocksdb_options_t* options, + const rocksdb_transactiondb_options_t* txn_db_options, const char* name, + int num_column_families, const char* const* column_family_names, + const rocksdb_options_t* const* column_family_options, + rocksdb_column_family_handle_t** column_family_handles, char** errptr); + +extern ROCKSDB_LIBRARY_API const rocksdb_snapshot_t* +rocksdb_transactiondb_create_snapshot(rocksdb_transactiondb_t* txn_db); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_release_snapshot( + rocksdb_transactiondb_t* txn_db, const rocksdb_snapshot_t* snapshot); + +extern ROCKSDB_LIBRARY_API char* rocksdb_transactiondb_property_value( + rocksdb_transactiondb_t* db, const char* propname); + +extern ROCKSDB_LIBRARY_API int rocksdb_transactiondb_property_int( + rocksdb_transactiondb_t* db, const char* propname, uint64_t* out_val); + +extern ROCKSDB_LIBRARY_API rocksdb_t* rocksdb_transactiondb_get_base_db( + rocksdb_transactiondb_t* txn_db); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_close_base_db( + rocksdb_t* base_db); + +extern ROCKSDB_LIBRARY_API rocksdb_transaction_t* rocksdb_transaction_begin( + rocksdb_transactiondb_t* txn_db, + const rocksdb_writeoptions_t* write_options, + const rocksdb_transaction_options_t* txn_options, + rocksdb_transaction_t* old_txn); + +extern ROCKSDB_LIBRARY_API rocksdb_transaction_t** +rocksdb_transactiondb_get_prepared_transactions(rocksdb_transactiondb_t* txn_db, + size_t* cnt); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_set_name( + rocksdb_transaction_t* txn, const char* name, size_t name_len, + char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_transaction_get_name( + rocksdb_transaction_t* txn, size_t* name_len); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_prepare( + rocksdb_transaction_t* txn, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_commit( + rocksdb_transaction_t* txn, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_rollback( + rocksdb_transaction_t* txn, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_set_savepoint( + rocksdb_transaction_t* txn); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_rollback_to_savepoint( + rocksdb_transaction_t* txn, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_destroy( + rocksdb_transaction_t* txn); + +extern ROCKSDB_LIBRARY_API rocksdb_writebatch_wi_t* +rocksdb_transaction_get_writebatch_wi(rocksdb_transaction_t* txn); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_rebuild_from_writebatch( + rocksdb_transaction_t* txn, rocksdb_writebatch_t* writebatch, + char** errptr); + +// This rocksdb_writebatch_wi_t should be freed with rocksdb_free +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_rebuild_from_writebatch_wi( + rocksdb_transaction_t* txn, rocksdb_writebatch_wi_t* wi, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_set_commit_timestamp( + rocksdb_transaction_t* txn, uint64_t commit_timestamp); + +extern ROCKSDB_LIBRARY_API void +rocksdb_transaction_set_read_timestamp_for_validation( + rocksdb_transaction_t* txn, uint64_t read_timestamp); + +// This snapshot should be freed using rocksdb_free +extern ROCKSDB_LIBRARY_API const rocksdb_snapshot_t* +rocksdb_transaction_get_snapshot(rocksdb_transaction_t* txn); + +extern ROCKSDB_LIBRARY_API char* rocksdb_transaction_get( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + const char* key, size_t klen, size_t* vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* +rocksdb_transaction_get_pinned(rocksdb_transaction_t* txn, + const rocksdb_readoptions_t* options, + const char* key, size_t klen, char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_transaction_get_cf( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, + size_t* vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* +rocksdb_transaction_get_pinned_cf(rocksdb_transaction_t* txn, + const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_transaction_get_for_update( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + const char* key, size_t klen, size_t* vlen, unsigned char exclusive, + char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* +rocksdb_transaction_get_pinned_for_update(rocksdb_transaction_t* txn, + const rocksdb_readoptions_t* options, + const char* key, size_t klen, + unsigned char exclusive, + char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_transaction_get_for_update_cf( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, + size_t* vlen, unsigned char exclusive, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* +rocksdb_transaction_get_pinned_for_update_cf( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, + unsigned char exclusive, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_multi_get( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + size_t num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, char** values_list, + size_t* values_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_multi_get_for_update( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + size_t num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, char** values_list, + size_t* values_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_multi_get_cf( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + const rocksdb_column_family_handle_t* const* column_families, + size_t num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, char** values_list, + size_t* values_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_multi_get_for_update_cf( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + const rocksdb_column_family_handle_t* const* column_families, + size_t num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, char** values_list, + size_t* values_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API char* rocksdb_transactiondb_get( + rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, + const char* key, size_t klen, size_t* vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* +rocksdb_transactiondb_get_pinned(rocksdb_transactiondb_t* txn_db, + const rocksdb_readoptions_t* options, + const char* key, size_t klen, char** errptr); + +extern ROCKSDB_LIBRARY_API char* rocksdb_transactiondb_get_cf( + rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, size_t* vallen, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* +rocksdb_transactiondb_get_pinned_cf( + rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_multi_get( + rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, + size_t num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, char** values_list, + size_t* values_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_multi_get_cf( + rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, + const rocksdb_column_family_handle_t* const* column_families, + size_t num_keys, const char* const* keys_list, + const size_t* keys_list_sizes, char** values_list, + size_t* values_list_sizes, char** errs); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_put( + rocksdb_transaction_t* txn, const char* key, size_t klen, const char* val, + size_t vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_put_cf( + rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* val, size_t vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_put( + rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, + const char* key, size_t klen, const char* val, size_t vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_put_cf( + rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, const char* val, size_t vallen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_write( + rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, + rocksdb_writebatch_t* batch, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_merge( + rocksdb_transaction_t* txn, const char* key, size_t klen, const char* val, + size_t vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_merge_cf( + rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, const char* val, size_t vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_merge( + rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, + const char* key, size_t klen, const char* val, size_t vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_merge_cf( + rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, size_t klen, + const char* val, size_t vlen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_delete( + rocksdb_transaction_t* txn, const char* key, size_t klen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_delete_cf( + rocksdb_transaction_t* txn, rocksdb_column_family_handle_t* column_family, + const char* key, size_t klen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_delete( + rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, + const char* key, size_t klen, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_delete_cf( + rocksdb_transactiondb_t* txn_db, const rocksdb_writeoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* +rocksdb_transaction_create_iterator(rocksdb_transaction_t* txn, + const rocksdb_readoptions_t* options); + +extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* +rocksdb_transaction_create_iterator_cf( + rocksdb_transaction_t* txn, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family); + +extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* +rocksdb_transactiondb_create_iterator(rocksdb_transactiondb_t* txn_db, + const rocksdb_readoptions_t* options); + +extern ROCKSDB_LIBRARY_API rocksdb_iterator_t* +rocksdb_transactiondb_create_iterator_cf( + rocksdb_transactiondb_t* txn_db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_close( + rocksdb_transactiondb_t* txn_db); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_flush( + rocksdb_transactiondb_t* txn_db, const rocksdb_flushoptions_t* options, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_flush_cf( + rocksdb_transactiondb_t* txn_db, const rocksdb_flushoptions_t* options, + rocksdb_column_family_handle_t* column_family, char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_flush_cfs( + rocksdb_transactiondb_t* txn_db, const rocksdb_flushoptions_t* options, + rocksdb_column_family_handle_t** column_families, int num_column_families, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_flush_wal( + rocksdb_transactiondb_t* txn_db, unsigned char sync, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_checkpoint_t* +rocksdb_transactiondb_checkpoint_object_create(rocksdb_transactiondb_t* txn_db, + char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_optimistictransactiondb_t* +rocksdb_optimistictransactiondb_open(const rocksdb_options_t* options, + const char* name, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_optimistictransactiondb_t* +rocksdb_optimistictransactiondb_open_column_families( + const rocksdb_options_t* options, const char* name, int num_column_families, + const char* const* column_family_names, + const rocksdb_options_t* const* column_family_options, + rocksdb_column_family_handle_t** column_family_handles, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_t* +rocksdb_optimistictransactiondb_get_base_db( + rocksdb_optimistictransactiondb_t* otxn_db); + +extern ROCKSDB_LIBRARY_API void rocksdb_optimistictransactiondb_close_base_db( + rocksdb_t* base_db); + +extern ROCKSDB_LIBRARY_API rocksdb_transaction_t* +rocksdb_optimistictransaction_begin( + rocksdb_optimistictransactiondb_t* otxn_db, + const rocksdb_writeoptions_t* write_options, + const rocksdb_optimistictransaction_options_t* otxn_options, + rocksdb_transaction_t* old_txn); + +extern ROCKSDB_LIBRARY_API void rocksdb_optimistictransactiondb_write( + rocksdb_optimistictransactiondb_t* otxn_db, + const rocksdb_writeoptions_t* options, rocksdb_writebatch_t* batch, + char** errptr); + +extern ROCKSDB_LIBRARY_API void rocksdb_optimistictransactiondb_close( + rocksdb_optimistictransactiondb_t* otxn_db); + +extern ROCKSDB_LIBRARY_API rocksdb_checkpoint_t* +rocksdb_optimistictransactiondb_checkpoint_object_create( + rocksdb_optimistictransactiondb_t* otxn_db, char** errptr); + +/* Transaction Options */ + +extern ROCKSDB_LIBRARY_API rocksdb_transactiondb_options_t* +rocksdb_transactiondb_options_create(void); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_options_destroy( + rocksdb_transactiondb_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_options_set_max_num_locks( + rocksdb_transactiondb_options_t* opt, int64_t max_num_locks); + +extern ROCKSDB_LIBRARY_API void rocksdb_transactiondb_options_set_num_stripes( + rocksdb_transactiondb_options_t* opt, size_t num_stripes); + +extern ROCKSDB_LIBRARY_API void +rocksdb_transactiondb_options_set_transaction_lock_timeout( + rocksdb_transactiondb_options_t* opt, int64_t txn_lock_timeout); + +extern ROCKSDB_LIBRARY_API void +rocksdb_transactiondb_options_set_default_lock_timeout( + rocksdb_transactiondb_options_t* opt, int64_t default_lock_timeout); + +extern ROCKSDB_LIBRARY_API rocksdb_transaction_options_t* +rocksdb_transaction_options_create(void); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_destroy( + rocksdb_transaction_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_set_snapshot( + rocksdb_transaction_options_t* opt, unsigned char v); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_deadlock_detect( + rocksdb_transaction_options_t* opt, unsigned char v); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_lock_timeout( + rocksdb_transaction_options_t* opt, int64_t lock_timeout); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_expiration( + rocksdb_transaction_options_t* opt, int64_t expiration); + +extern ROCKSDB_LIBRARY_API void +rocksdb_transaction_options_set_deadlock_detect_depth( + rocksdb_transaction_options_t* opt, int64_t depth); + +extern ROCKSDB_LIBRARY_API void +rocksdb_transaction_options_set_max_write_batch_size( + rocksdb_transaction_options_t* opt, size_t size); + +extern ROCKSDB_LIBRARY_API void rocksdb_transaction_options_set_skip_prepare( + rocksdb_transaction_options_t* opt, unsigned char v); + +extern ROCKSDB_LIBRARY_API rocksdb_optimistictransaction_options_t* +rocksdb_optimistictransaction_options_create(void); + +extern ROCKSDB_LIBRARY_API void rocksdb_optimistictransaction_options_destroy( + rocksdb_optimistictransaction_options_t* opt); + +extern ROCKSDB_LIBRARY_API void +rocksdb_optimistictransaction_options_set_set_snapshot( + rocksdb_optimistictransaction_options_t* opt, unsigned char v); + +extern ROCKSDB_LIBRARY_API char* rocksdb_optimistictransactiondb_property_value( + rocksdb_optimistictransactiondb_t* db, const char* propname); + +extern ROCKSDB_LIBRARY_API int rocksdb_optimistictransactiondb_property_int( + rocksdb_optimistictransactiondb_t* db, const char* propname, + uint64_t* out_val); + +// referring to convention (3), this should be used by client +// to free memory that was malloc()ed +extern ROCKSDB_LIBRARY_API void rocksdb_free(void* ptr); + +extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* rocksdb_get_pinned( + rocksdb_t* db, const rocksdb_readoptions_t* options, const char* key, + size_t keylen, char** errptr); +extern ROCKSDB_LIBRARY_API rocksdb_pinnableslice_t* rocksdb_get_pinned_cf( + rocksdb_t* db, const rocksdb_readoptions_t* options, + rocksdb_column_family_handle_t* column_family, const char* key, + size_t keylen, char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_pinnableslice_destroy( + rocksdb_pinnableslice_t* v); +extern ROCKSDB_LIBRARY_API const char* rocksdb_pinnableslice_value( + const rocksdb_pinnableslice_t* t, size_t* vlen); + +extern ROCKSDB_LIBRARY_API rocksdb_memory_consumers_t* +rocksdb_memory_consumers_create(void); +extern ROCKSDB_LIBRARY_API void rocksdb_memory_consumers_add_db( + rocksdb_memory_consumers_t* consumers, rocksdb_t* db); +extern ROCKSDB_LIBRARY_API void rocksdb_memory_consumers_add_cache( + rocksdb_memory_consumers_t* consumers, rocksdb_cache_t* cache); +extern ROCKSDB_LIBRARY_API void rocksdb_memory_consumers_destroy( + rocksdb_memory_consumers_t* consumers); +extern ROCKSDB_LIBRARY_API rocksdb_memory_usage_t* +rocksdb_approximate_memory_usage_create(rocksdb_memory_consumers_t* consumers, + char** errptr); +extern ROCKSDB_LIBRARY_API void rocksdb_approximate_memory_usage_destroy( + rocksdb_memory_usage_t* usage); + +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_approximate_memory_usage_get_mem_table_total( + rocksdb_memory_usage_t* memory_usage); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_approximate_memory_usage_get_mem_table_unflushed( + rocksdb_memory_usage_t* memory_usage); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_approximate_memory_usage_get_mem_table_readers_total( + rocksdb_memory_usage_t* memory_usage); +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_approximate_memory_usage_get_cache_total( + rocksdb_memory_usage_t* memory_usage); + +extern ROCKSDB_LIBRARY_API void rocksdb_options_set_dump_malloc_stats( + rocksdb_options_t*, unsigned char); + +extern ROCKSDB_LIBRARY_API void +rocksdb_options_set_memtable_whole_key_filtering(rocksdb_options_t*, + unsigned char); + +extern ROCKSDB_LIBRARY_API void rocksdb_cancel_all_background_work( + rocksdb_t* db, unsigned char wait); + +extern ROCKSDB_LIBRARY_API void rocksdb_disable_manual_compaction( + rocksdb_t* db); + +extern ROCKSDB_LIBRARY_API void rocksdb_enable_manual_compaction(rocksdb_t* db); + +extern ROCKSDB_LIBRARY_API rocksdb_statistics_histogram_data_t* +rocksdb_statistics_histogram_data_create(void); +extern ROCKSDB_LIBRARY_API void rocksdb_statistics_histogram_data_destroy( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API double rocksdb_statistics_histogram_data_get_median( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API double rocksdb_statistics_histogram_data_get_p95( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API double rocksdb_statistics_histogram_data_get_p99( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API double rocksdb_statistics_histogram_data_get_average( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API double rocksdb_statistics_histogram_data_get_std_dev( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API double rocksdb_statistics_histogram_data_get_max( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API uint64_t rocksdb_statistics_histogram_data_get_count( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API uint64_t rocksdb_statistics_histogram_data_get_sum( + rocksdb_statistics_histogram_data_t* data); +extern ROCKSDB_LIBRARY_API double rocksdb_statistics_histogram_data_get_min( + rocksdb_statistics_histogram_data_t* data); + +extern ROCKSDB_LIBRARY_API void rocksdb_wait_for_compact( + rocksdb_t* db, rocksdb_wait_for_compact_options_t* options, char** errptr); + +extern ROCKSDB_LIBRARY_API rocksdb_wait_for_compact_options_t* +rocksdb_wait_for_compact_options_create(void); + +extern ROCKSDB_LIBRARY_API void rocksdb_wait_for_compact_options_destroy( + rocksdb_wait_for_compact_options_t* opt); + +extern ROCKSDB_LIBRARY_API void +rocksdb_wait_for_compact_options_set_abort_on_pause( + rocksdb_wait_for_compact_options_t* opt, unsigned char v); + +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_wait_for_compact_options_get_abort_on_pause( + rocksdb_wait_for_compact_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_wait_for_compact_options_set_flush( + rocksdb_wait_for_compact_options_t* opt, unsigned char v); + +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_wait_for_compact_options_get_flush( + rocksdb_wait_for_compact_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_wait_for_compact_options_set_close_db( + rocksdb_wait_for_compact_options_t* opt, unsigned char v); + +extern ROCKSDB_LIBRARY_API unsigned char +rocksdb_wait_for_compact_options_get_close_db( + rocksdb_wait_for_compact_options_t* opt); + +extern ROCKSDB_LIBRARY_API void rocksdb_wait_for_compact_options_set_timeout( + rocksdb_wait_for_compact_options_t* opt, uint64_t microseconds); + +extern ROCKSDB_LIBRARY_API uint64_t +rocksdb_wait_for_compact_options_get_timeout( + rocksdb_wait_for_compact_options_t* opt); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif \ No newline at end of file diff --git a/rocksdb/lib/librocksdb.nim b/rocksdb/lib/librocksdb.nim new file mode 100644 index 0000000..db11310 --- /dev/null +++ b/rocksdb/lib/librocksdb.nim @@ -0,0 +1,3205 @@ +# Copyright 2018-2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +# Nim-RocksDB is a wrapper for Facebook's RocksDB +# RocksDB License +# Copyright (c) 2011-present, Facebook, Inc. All rights reserved. +# Source code can be found at https://github.com/facebook/rocksdb +# under both the GPLv2 (found in the COPYING file in the RocksDB root directory) and Apache 2.0 License +# (found in the LICENSE.Apache file in the RocksDB root directory). + +# RocksDB is derived work of LevelDB +# LevelDB License +# Copyright (c) 2011 The LevelDB Authors. All rights reserved. +# Source code can be found at https://github.com/google/leveldb +# Use of this source code is governed by a BSD-style license that can be +# found in the LevelDB LICENSE file. See the AUTHORS file for names of contributors. + +## This file exposes the low-level C API of RocksDB + +{.push raises: [].} + +when defined(windows): + const librocksdb = "librocksdb(|_lite).dll" +elif defined(macosx): + const librocksdb = "librocksdb(|_lite).dylib" +else: + # TODO linking to just the .so file here is wrong: + # * soname of library is librocksdb.so.X.Y, indicating that ABI compatibility + # is kept for patches only, and may break for minor versions + # * linking like this makes the wrapper swallow any ABI version that the user + # happens to have installed when running the application - notably this may + # be completely different from what the developer used when writing the + # wrapper + # * with good luck, the above will lead to crashes that are hard to diagnose + # with bad luck, it will be exploited as a security hole + # * Fedora28 for example ships with soname librocksdb.so.5.7 while Ubuntu + # 14.04 (what travis uses at the time of writing) comes with 4.5! + const librocksdb = "librocksdb(|_lite).so" +## Exported types + +proc shouldUseNativeLinking(): bool {.compileTime.} = + when defined(linux): + return true + +const LibrocksbStaticArgs {.strdefine.}: string = "" + +type + rocksdb_t* = object + rocksdb_backup_engine_t* = object + rocksdb_backup_engine_info_t* = object + rocksdb_backup_engine_options_t* = object + rocksdb_restore_options_t* = object + rocksdb_cache_t* = object + rocksdb_compactionfilter_t* = object + rocksdb_compactionfiltercontext_t* = object + rocksdb_compactionfilterfactory_t* = object + rocksdb_comparator_t* = object + rocksdb_dbpath_t* = object + rocksdb_env_t* = object + rocksdb_fifo_compaction_options_t* = object + rocksdb_filelock_t* = object + rocksdb_filterpolicy_t* = object + rocksdb_flushoptions_t* = object + rocksdb_iterator_t* = object + rocksdb_logger_t* = object + rocksdb_mergeoperator_t* = object + rocksdb_options_t* = object + rocksdb_compactoptions_t* = object + rocksdb_block_based_table_options_t* = object + rocksdb_cuckoo_table_options_t* = object + rocksdb_randomfile_t* = object + rocksdb_readoptions_t* = object + rocksdb_seqfile_t* = object + rocksdb_slicetransform_t* = object + rocksdb_snapshot_t* = object + rocksdb_writablefile_t* = object + rocksdb_writebatch_t* = object + rocksdb_writebatch_wi_t* = object + rocksdb_writeoptions_t* = object + rocksdb_universal_compaction_options_t* = object + rocksdb_livefiles_t* = object + rocksdb_column_family_handle_t* = object + rocksdb_envoptions_t* = object + rocksdb_ingestexternalfileoptions_t* = object + rocksdb_sstfilewriter_t* = object + rocksdb_ratelimiter_t* = object + rocksdb_pinnableslice_t* = object + rocksdb_transactiondb_options_t* = object + rocksdb_transactiondb_t* = object + rocksdb_transaction_options_t* = object + rocksdb_optimistictransactiondb_t* = object + rocksdb_optimistictransaction_options_t* = object + rocksdb_transaction_t* = object + rocksdb_checkpoint_t* = object + rocksdb_wal_readoptions_t* = object + rocksdb_wal_iterator_t* = object + rocksdb_write_buffer_manager_t* = object + rocksdb_statistics_histogram_data_t* = object + rocksdb_perfcontext_t* = object + rocksdb_memory_allocator_t* = object + rocksdb_lru_cache_options_t* = object + rocksdb_hyper_clock_cache_options_t* = object + rocksdb_level_metadata_t* = object + rocksdb_sst_file_metadata_t* = object + rocksdb_column_family_metadata_t* = object + rocksdb_memory_usage_t* = object + rocksdb_memory_consumers_t* = object + rocksdb_wait_for_compact_options_t* = object + +## DB operations + +when LibrocksbStaticArgs != "": + {.pragma: importrocks, importc, cdecl.} + {.passL: LibrocksbStaticArgs.} + when defined(windows): + {.passL: "-lshlwapi -lrpcrt4".} +else: + when shouldUseNativeLinking(): + {.pragma: importrocks, importc, cdecl.} + {.passL: "-lrocksdb".} + else: + {.pragma: importrocks, importc, cdecl, dynlib: librocksdb.} + +proc rocksdb_open*(options: ptr rocksdb_options_t; name: cstring; errptr: cstringArray): ptr rocksdb_t {. + cdecl, importc: "rocksdb_open", dynlib: librocksdb.} +proc rocksdb_open_with_ttl*(options: ptr rocksdb_options_t; name: cstring; ttl: cint; + errptr: cstringArray): ptr rocksdb_t {.cdecl, + importc: "rocksdb_open_with_ttl", dynlib: librocksdb.} +proc rocksdb_open_for_read_only*(options: ptr rocksdb_options_t; name: cstring; + error_if_wal_file_exists: uint8; + errptr: cstringArray): ptr rocksdb_t {.cdecl, + importc: "rocksdb_open_for_read_only", dynlib: librocksdb.} +proc rocksdb_open_as_secondary*(options: ptr rocksdb_options_t; name: cstring; + secondary_path: cstring; errptr: cstringArray): ptr rocksdb_t {. + cdecl, importc: "rocksdb_open_as_secondary", dynlib: librocksdb.} +proc rocksdb_backup_engine_open*(options: ptr rocksdb_options_t; path: cstring; + errptr: cstringArray): ptr rocksdb_backup_engine_t {. + cdecl, importc: "rocksdb_backup_engine_open", dynlib: librocksdb.} +proc rocksdb_backup_engine_open_opts*(options: ptr rocksdb_backup_engine_options_t; + env: ptr rocksdb_env_t; errptr: cstringArray): ptr rocksdb_backup_engine_t {. + cdecl, importc: "rocksdb_backup_engine_open_opts", dynlib: librocksdb.} +proc rocksdb_backup_engine_create_new_backup*(be: ptr rocksdb_backup_engine_t; + db: ptr rocksdb_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_backup_engine_create_new_backup", dynlib: librocksdb.} +proc rocksdb_backup_engine_create_new_backup_flush*( + be: ptr rocksdb_backup_engine_t; db: ptr rocksdb_t; flush_before_backup: uint8; + errptr: cstringArray) {.cdecl, importc: "rocksdb_backup_engine_create_new_backup_flush", + dynlib: librocksdb.} +proc rocksdb_backup_engine_purge_old_backups*(be: ptr rocksdb_backup_engine_t; + num_backups_to_keep: uint32; errptr: cstringArray) {.cdecl, + importc: "rocksdb_backup_engine_purge_old_backups", dynlib: librocksdb.} +proc rocksdb_restore_options_create*(): ptr rocksdb_restore_options_t {.cdecl, + importc: "rocksdb_restore_options_create", dynlib: librocksdb.} +proc rocksdb_restore_options_destroy*(opt: ptr rocksdb_restore_options_t) {.cdecl, + importc: "rocksdb_restore_options_destroy", dynlib: librocksdb.} +proc rocksdb_restore_options_set_keep_log_files*( + opt: ptr rocksdb_restore_options_t; v: cint) {.cdecl, + importc: "rocksdb_restore_options_set_keep_log_files", dynlib: librocksdb.} +proc rocksdb_backup_engine_verify_backup*(be: ptr rocksdb_backup_engine_t; + backup_id: uint32; errptr: cstringArray) {.cdecl, + importc: "rocksdb_backup_engine_verify_backup", dynlib: librocksdb.} +proc rocksdb_backup_engine_restore_db_from_latest_backup*( + be: ptr rocksdb_backup_engine_t; db_dir: cstring; wal_dir: cstring; + restore_options: ptr rocksdb_restore_options_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_backup_engine_restore_db_from_latest_backup", + dynlib: librocksdb.} +proc rocksdb_backup_engine_restore_db_from_backup*( + be: ptr rocksdb_backup_engine_t; db_dir: cstring; wal_dir: cstring; + restore_options: ptr rocksdb_restore_options_t; backup_id: uint32; + errptr: cstringArray) {.cdecl, importc: "rocksdb_backup_engine_restore_db_from_backup", + dynlib: librocksdb.} +proc rocksdb_backup_engine_get_backup_info*(be: ptr rocksdb_backup_engine_t): ptr rocksdb_backup_engine_info_t {. + cdecl, importc: "rocksdb_backup_engine_get_backup_info", dynlib: librocksdb.} +proc rocksdb_backup_engine_info_count*(info: ptr rocksdb_backup_engine_info_t): cint {. + cdecl, importc: "rocksdb_backup_engine_info_count", dynlib: librocksdb.} +proc rocksdb_backup_engine_info_timestamp*( + info: ptr rocksdb_backup_engine_info_t; index: cint): int64 {.cdecl, + importc: "rocksdb_backup_engine_info_timestamp", dynlib: librocksdb.} +proc rocksdb_backup_engine_info_backup_id*( + info: ptr rocksdb_backup_engine_info_t; index: cint): uint32 {.cdecl, + importc: "rocksdb_backup_engine_info_backup_id", dynlib: librocksdb.} +proc rocksdb_backup_engine_info_size*(info: ptr rocksdb_backup_engine_info_t; + index: cint): uint64 {.cdecl, + importc: "rocksdb_backup_engine_info_size", dynlib: librocksdb.} +proc rocksdb_backup_engine_info_number_files*( + info: ptr rocksdb_backup_engine_info_t; index: cint): uint32 {.cdecl, + importc: "rocksdb_backup_engine_info_number_files", dynlib: librocksdb.} +proc rocksdb_backup_engine_info_destroy*(info: ptr rocksdb_backup_engine_info_t) {. + cdecl, importc: "rocksdb_backup_engine_info_destroy", dynlib: librocksdb.} +proc rocksdb_backup_engine_close*(be: ptr rocksdb_backup_engine_t) {.cdecl, + importc: "rocksdb_backup_engine_close", dynlib: librocksdb.} +proc rocksdb_put_with_ts*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + key: cstring; keylen: csize_t; ts: cstring; tslen: csize_t; + val: cstring; vallen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_put_with_ts", dynlib: librocksdb.} +proc rocksdb_put_cf_with_ts*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; ts: cstring; + tslen: csize_t; val: cstring; vallen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_put_cf_with_ts", dynlib: librocksdb.} +proc rocksdb_delete_with_ts*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + key: cstring; keylen: csize_t; ts: cstring; + tslen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_delete_with_ts", dynlib: librocksdb.} +proc rocksdb_delete_cf_with_ts*(db: ptr rocksdb_t; + options: ptr rocksdb_writeoptions_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; ts: cstring; + tslen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_delete_cf_with_ts", dynlib: librocksdb.} +proc rocksdb_singledelete*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + key: cstring; keylen: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_singledelete", dynlib: librocksdb.} +proc rocksdb_singledelete_cf*(db: ptr rocksdb_t; + options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_singledelete_cf", dynlib: librocksdb.} +proc rocksdb_singledelete_with_ts*(db: ptr rocksdb_t; + options: ptr rocksdb_writeoptions_t; + key: cstring; keylen: csize_t; ts: cstring; + tslen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_singledelete_with_ts", dynlib: librocksdb.} +proc rocksdb_singledelete_cf_with_ts*(db: ptr rocksdb_t; + options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; + ts: cstring; tslen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_singledelete_cf_with_ts", dynlib: librocksdb.} +proc rocksdb_increase_full_history_ts_low*(db: ptr rocksdb_t; + column_family: ptr rocksdb_column_family_handle_t; ts_low: cstring; + ts_lowlen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_increase_full_history_ts_low", dynlib: librocksdb.} +proc rocksdb_get_full_history_ts_low*(db: ptr rocksdb_t; column_family: ptr rocksdb_column_family_handle_t; + ts_lowlen: ptr csize_t; errptr: cstringArray): cstring {. + cdecl, importc: "rocksdb_get_full_history_ts_low", dynlib: librocksdb.} +## BackupEngineOptions + +proc rocksdb_backup_engine_options_create*(backup_dir: cstring): ptr rocksdb_backup_engine_options_t {. + cdecl, importc: "rocksdb_backup_engine_options_create", dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_backup_dir*( + options: ptr rocksdb_backup_engine_options_t; backup_dir: cstring) {.cdecl, + importc: "rocksdb_backup_engine_options_set_backup_dir", dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_env*( + options: ptr rocksdb_backup_engine_options_t; env: ptr rocksdb_env_t) {.cdecl, + importc: "rocksdb_backup_engine_options_set_env", dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_share_table_files*( + options: ptr rocksdb_backup_engine_options_t; val: uint8) {.cdecl, + importc: "rocksdb_backup_engine_options_set_share_table_files", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_share_table_files*( + options: ptr rocksdb_backup_engine_options_t): uint8 {.cdecl, + importc: "rocksdb_backup_engine_options_get_share_table_files", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_sync*( + options: ptr rocksdb_backup_engine_options_t; val: uint8) {.cdecl, + importc: "rocksdb_backup_engine_options_set_sync", dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_sync*( + options: ptr rocksdb_backup_engine_options_t): uint8 {.cdecl, + importc: "rocksdb_backup_engine_options_get_sync", dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_destroy_old_data*( + options: ptr rocksdb_backup_engine_options_t; val: uint8) {.cdecl, + importc: "rocksdb_backup_engine_options_set_destroy_old_data", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_destroy_old_data*( + options: ptr rocksdb_backup_engine_options_t): uint8 {.cdecl, + importc: "rocksdb_backup_engine_options_get_destroy_old_data", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_backup_log_files*( + options: ptr rocksdb_backup_engine_options_t; val: uint8) {.cdecl, + importc: "rocksdb_backup_engine_options_set_backup_log_files", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_backup_log_files*( + options: ptr rocksdb_backup_engine_options_t): uint8 {.cdecl, + importc: "rocksdb_backup_engine_options_get_backup_log_files", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_backup_rate_limit*( + options: ptr rocksdb_backup_engine_options_t; limit: uint64) {.cdecl, + importc: "rocksdb_backup_engine_options_set_backup_rate_limit", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_backup_rate_limit*( + options: ptr rocksdb_backup_engine_options_t): uint64 {.cdecl, + importc: "rocksdb_backup_engine_options_get_backup_rate_limit", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_restore_rate_limit*( + options: ptr rocksdb_backup_engine_options_t; limit: uint64) {.cdecl, + importc: "rocksdb_backup_engine_options_set_restore_rate_limit", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_restore_rate_limit*( + options: ptr rocksdb_backup_engine_options_t): uint64 {.cdecl, + importc: "rocksdb_backup_engine_options_get_restore_rate_limit", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_max_background_operations*( + options: ptr rocksdb_backup_engine_options_t; val: cint) {.cdecl, + importc: "rocksdb_backup_engine_options_set_max_background_operations", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_max_background_operations*( + options: ptr rocksdb_backup_engine_options_t): cint {.cdecl, + importc: "rocksdb_backup_engine_options_get_max_background_operations", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_callback_trigger_interval_size*( + options: ptr rocksdb_backup_engine_options_t; size: uint64) {.cdecl, importc: "rocksdb_backup_engine_options_set_callback_trigger_interval_size", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_callback_trigger_interval_size*( + options: ptr rocksdb_backup_engine_options_t): uint64 {.cdecl, importc: "rocksdb_backup_engine_options_get_callback_trigger_interval_size", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_max_valid_backups_to_open*( + options: ptr rocksdb_backup_engine_options_t; val: cint) {.cdecl, + importc: "rocksdb_backup_engine_options_set_max_valid_backups_to_open", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_max_valid_backups_to_open*( + options: ptr rocksdb_backup_engine_options_t): cint {.cdecl, + importc: "rocksdb_backup_engine_options_get_max_valid_backups_to_open", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_set_share_files_with_checksum_naming*( + options: ptr rocksdb_backup_engine_options_t; val: cint) {.cdecl, importc: "rocksdb_backup_engine_options_set_share_files_with_checksum_naming", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_get_share_files_with_checksum_naming*( + options: ptr rocksdb_backup_engine_options_t): cint {.cdecl, importc: "rocksdb_backup_engine_options_get_share_files_with_checksum_naming", + dynlib: librocksdb.} +proc rocksdb_backup_engine_options_destroy*( + a1: ptr rocksdb_backup_engine_options_t) {.cdecl, + importc: "rocksdb_backup_engine_options_destroy", dynlib: librocksdb.} +## Checkpoint + +proc rocksdb_checkpoint_object_create*(db: ptr rocksdb_t; errptr: cstringArray): ptr rocksdb_checkpoint_t {. + cdecl, importc: "rocksdb_checkpoint_object_create", dynlib: librocksdb.} +proc rocksdb_checkpoint_create*(checkpoint: ptr rocksdb_checkpoint_t; + checkpoint_dir: cstring; + log_size_for_flush: uint64; errptr: cstringArray) {. + cdecl, importc: "rocksdb_checkpoint_create", dynlib: librocksdb.} +proc rocksdb_checkpoint_object_destroy*(checkpoint: ptr rocksdb_checkpoint_t) {. + cdecl, importc: "rocksdb_checkpoint_object_destroy", dynlib: librocksdb.} +proc rocksdb_open_and_trim_history*(options: ptr rocksdb_options_t; name: cstring; + num_column_families: cint; + column_family_names: cstringArray; + column_family_options: ptr ptr rocksdb_options_t; column_family_handles: ptr ptr rocksdb_column_family_handle_t; + trim_ts: cstring; trim_tslen: csize_t; + errptr: cstringArray): ptr rocksdb_t {.cdecl, + importc: "rocksdb_open_and_trim_history", dynlib: librocksdb.} +proc rocksdb_open_column_families*(options: ptr rocksdb_options_t; name: cstring; + num_column_families: cint; + column_family_names: cstringArray; + column_family_options: ptr ptr rocksdb_options_t; column_family_handles: ptr ptr rocksdb_column_family_handle_t; + errptr: cstringArray): ptr rocksdb_t {.cdecl, + importc: "rocksdb_open_column_families", dynlib: librocksdb.} +proc rocksdb_open_column_families_with_ttl*(options: ptr rocksdb_options_t; + name: cstring; num_column_families: cint; column_family_names: cstringArray; + column_family_options: ptr ptr rocksdb_options_t; + column_family_handles: ptr ptr rocksdb_column_family_handle_t; ttls: ptr cint; + errptr: cstringArray): ptr rocksdb_t {.cdecl, importc: "rocksdb_open_column_families_with_ttl", + dynlib: librocksdb.} +proc rocksdb_open_for_read_only_column_families*(options: ptr rocksdb_options_t; + name: cstring; num_column_families: cint; column_family_names: cstringArray; + column_family_options: ptr ptr rocksdb_options_t; + column_family_handles: ptr ptr rocksdb_column_family_handle_t; + error_if_wal_file_exists: uint8; errptr: cstringArray): ptr rocksdb_t {.cdecl, + importc: "rocksdb_open_for_read_only_column_families", dynlib: librocksdb.} +proc rocksdb_open_as_secondary_column_families*(options: ptr rocksdb_options_t; + name: cstring; secondary_path: cstring; num_column_families: cint; + column_family_names: cstringArray; + column_family_options: ptr ptr rocksdb_options_t; + column_family_handles: ptr ptr rocksdb_column_family_handle_t; + errptr: cstringArray): ptr rocksdb_t {.cdecl, importc: "rocksdb_open_as_secondary_column_families", + dynlib: librocksdb.} +proc rocksdb_list_column_families*(options: ptr rocksdb_options_t; name: cstring; + lencf: ptr csize_t; errptr: cstringArray): cstringArray {. + cdecl, importc: "rocksdb_list_column_families", dynlib: librocksdb.} +proc rocksdb_list_column_families_destroy*(list: cstringArray; len: csize_t) {.cdecl, + importc: "rocksdb_list_column_families_destroy", dynlib: librocksdb.} +proc rocksdb_create_column_family*(db: ptr rocksdb_t; + column_family_options: ptr rocksdb_options_t; + column_family_name: cstring; + errptr: cstringArray): ptr rocksdb_column_family_handle_t {. + cdecl, importc: "rocksdb_create_column_family", dynlib: librocksdb.} +proc rocksdb_create_column_families*(db: ptr rocksdb_t; column_family_options: ptr rocksdb_options_t; + num_column_families: cint; + column_family_names: cstringArray; + lencfs: ptr csize_t; errptr: cstringArray): ptr ptr rocksdb_column_family_handle_t {. + cdecl, importc: "rocksdb_create_column_families", dynlib: librocksdb.} +proc rocksdb_create_column_families_destroy*( + list: ptr ptr rocksdb_column_family_handle_t) {.cdecl, + importc: "rocksdb_create_column_families_destroy", dynlib: librocksdb.} +proc rocksdb_create_column_family_with_ttl*(db: ptr rocksdb_t; + column_family_options: ptr rocksdb_options_t; column_family_name: cstring; + ttl: cint; errptr: cstringArray): ptr rocksdb_column_family_handle_t {.cdecl, + importc: "rocksdb_create_column_family_with_ttl", dynlib: librocksdb.} +proc rocksdb_drop_column_family*(db: ptr rocksdb_t; + handle: ptr rocksdb_column_family_handle_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_drop_column_family", dynlib: librocksdb.} +proc rocksdb_column_family_handle_destroy*(a1: ptr rocksdb_column_family_handle_t) {. + cdecl, importc: "rocksdb_column_family_handle_destroy", dynlib: librocksdb.} +proc rocksdb_column_family_handle_get_id*( + handle: ptr rocksdb_column_family_handle_t): uint32 {.cdecl, + importc: "rocksdb_column_family_handle_get_id", dynlib: librocksdb.} +proc rocksdb_column_family_handle_get_name*( + handle: ptr rocksdb_column_family_handle_t; name_len: ptr csize_t): cstring {. + cdecl, importc: "rocksdb_column_family_handle_get_name", dynlib: librocksdb.} +proc rocksdb_close*(db: ptr rocksdb_t) {.cdecl, importc: "rocksdb_close", + dynlib: librocksdb.} +proc rocksdb_put*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; key: cstring; + keylen: csize_t; val: cstring; vallen: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_put", dynlib: librocksdb.} +proc rocksdb_put_cf*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; val: cstring; vallen: csize_t; + errptr: cstringArray) {.cdecl, importc: "rocksdb_put_cf", + dynlib: librocksdb.} +proc rocksdb_delete*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + key: cstring; keylen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_delete", dynlib: librocksdb.} +proc rocksdb_delete_cf*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_delete_cf", dynlib: librocksdb.} +proc rocksdb_delete_range_cf*(db: ptr rocksdb_t; + options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + start_key: cstring; start_key_len: csize_t; + end_key: cstring; end_key_len: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_delete_range_cf", dynlib: librocksdb.} +proc rocksdb_merge*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + key: cstring; keylen: csize_t; val: cstring; vallen: csize_t; + errptr: cstringArray) {.cdecl, importc: "rocksdb_merge", + dynlib: librocksdb.} +proc rocksdb_merge_cf*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; val: cstring; vallen: csize_t; + errptr: cstringArray) {.cdecl, importc: "rocksdb_merge_cf", + dynlib: librocksdb.} +proc rocksdb_write*(db: ptr rocksdb_t; options: ptr rocksdb_writeoptions_t; + batch: ptr rocksdb_writebatch_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_write", dynlib: librocksdb.} +## Returns NULL if not found. A malloc()ed array otherwise. +## Stores the length of the array in *vallen. + +proc rocksdb_get*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; key: cstring; + keylen: csize_t; vallen: ptr csize_t; errptr: cstringArray): cstring {. + cdecl, importc: "rocksdb_get", dynlib: librocksdb.} +proc rocksdb_get_with_ts*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; + key: cstring; keylen: csize_t; vallen: ptr csize_t; + ts: cstringArray; tslen: ptr csize_t; errptr: cstringArray): cstring {. + cdecl, importc: "rocksdb_get_with_ts", dynlib: librocksdb.} +proc rocksdb_get_cf*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; vallen: ptr csize_t; + errptr: cstringArray): cstring {.cdecl, + importc: "rocksdb_get_cf", dynlib: librocksdb.} +proc rocksdb_get_cf_with_ts*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; vallen: ptr csize_t; + ts: cstringArray; tslen: ptr csize_t; + errptr: cstringArray): cstring {.cdecl, + importc: "rocksdb_get_cf_with_ts", dynlib: librocksdb.} +## if values_list[i] == NULL and errs[i] == NULL, +## then we got status.IsNotFound(), which we will not return. +## all errors except status status.ok() and status.IsNotFound() are returned. +## +## errs, values_list and values_list_sizes must be num_keys in length, +## allocated by the caller. +## errs is a list of strings as opposed to the conventional one error, +## where errs[i] is the status for retrieval of keys_list[i]. +## each non-NULL errs entry is a malloc()ed, null terminated string. +## each non-NULL values_list entry is a malloc()ed array, with +## the length for each stored in values_list_sizes[i]. + +proc rocksdb_multi_get*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; + num_keys: csize_t; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; values_list: cstringArray; + values_list_sizes: ptr csize_t; errs: cstringArray) {.cdecl, + importc: "rocksdb_multi_get", dynlib: librocksdb.} +proc rocksdb_multi_get_with_ts*(db: ptr rocksdb_t; + options: ptr rocksdb_readoptions_t; + num_keys: csize_t; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; + values_list: cstringArray; + values_list_sizes: ptr csize_t; + timestamp_list: cstringArray; + timestamp_list_sizes: ptr csize_t; + errs: cstringArray) {.cdecl, + importc: "rocksdb_multi_get_with_ts", dynlib: librocksdb.} +proc rocksdb_multi_get_cf*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; + column_families: ptr ptr rocksdb_column_family_handle_t; num_keys: csize_t; + keys_list: cstringArray; keys_list_sizes: ptr csize_t; + values_list: cstringArray; + values_list_sizes: ptr csize_t; errs: cstringArray) {. + cdecl, importc: "rocksdb_multi_get_cf", dynlib: librocksdb.} +proc rocksdb_multi_get_cf_with_ts*(db: ptr rocksdb_t; + options: ptr rocksdb_readoptions_t; + column_families: ptr ptr rocksdb_column_family_handle_t; num_keys: csize_t; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t; + values_list: cstringArray; + values_list_sizes: ptr csize_t; + timestamps_list: cstringArray; + timestamps_list_sizes: ptr csize_t; + errs: cstringArray) {.cdecl, + importc: "rocksdb_multi_get_cf_with_ts", dynlib: librocksdb.} +## The MultiGet API that improves performance by batching operations +## in the read path for greater efficiency. Currently, only the block based +## table format with full filters are supported. Other table formats such +## as plain table, block based table with block based filters and +## partitioned indexes will still work, but will not get any performance +## benefits. +## +## Note that all the keys passed to this API are restricted to a single +## column family. +## +## Parameters - +## db - the RocksDB instance. +## options - ReadOptions +## column_family - ColumnFamilyHandle* that the keys belong to. All the keys +## passed to the API are restricted to a single column family +## num_keys - Number of keys to lookup +## keys_list - Pointer to C style array of keys with num_keys elements +## keys_list_sizes - Pointer to C style array of the size of corresponding key +## in key_list with num_keys elements. +## values - Pointer to C style array of PinnableSlices with num_keys elements +## statuses - Pointer to C style array of Status with num_keys elements +## sorted_input - If true, it means the input keys are already sorted by key +## order, so the MultiGet() API doesn't have to sort them +## again. If false, the keys will be copied and sorted +## internally by the API - the input array will not be +## modified + +proc rocksdb_batched_multi_get_cf*(db: ptr rocksdb_t; + options: ptr rocksdb_readoptions_t; column_family: ptr rocksdb_column_family_handle_t; + num_keys: csize_t; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; + values: ptr ptr rocksdb_pinnableslice_t; + errs: cstringArray; sorted_input: bool) {.cdecl, + importc: "rocksdb_batched_multi_get_cf", dynlib: librocksdb.} +## The value is only allocated (using malloc) and returned if it is found and +## value_found isn't NULL. In that case the user is responsible for freeing it. + +proc rocksdb_key_may_exist*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; + key: cstring; key_len: csize_t; value: cstringArray; + val_len: ptr csize_t; timestamp: cstring; + timestamp_len: csize_t; value_found: ptr uint8): uint8 {. + cdecl, importc: "rocksdb_key_may_exist", dynlib: librocksdb.} +## The value is only allocated (using malloc) and returned if it is found and +## value_found isn't NULL. In that case the user is responsible for freeing it. + +proc rocksdb_key_may_exist_cf*(db: ptr rocksdb_t; + options: ptr rocksdb_readoptions_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; key_len: csize_t; value: cstringArray; + val_len: ptr csize_t; timestamp: cstring; + timestamp_len: csize_t; value_found: ptr uint8): uint8 {. + cdecl, importc: "rocksdb_key_may_exist_cf", dynlib: librocksdb.} +proc rocksdb_create_iterator*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t): ptr rocksdb_iterator_t {. + cdecl, importc: "rocksdb_create_iterator", dynlib: librocksdb.} +proc rocksdb_get_updates_since*(db: ptr rocksdb_t; seq_number: uint64; + options: ptr rocksdb_wal_readoptions_t; + errptr: cstringArray): ptr rocksdb_wal_iterator_t {. + cdecl, importc: "rocksdb_get_updates_since", dynlib: librocksdb.} +proc rocksdb_create_iterator_cf*(db: ptr rocksdb_t; + options: ptr rocksdb_readoptions_t; column_family: ptr rocksdb_column_family_handle_t): ptr rocksdb_iterator_t {. + cdecl, importc: "rocksdb_create_iterator_cf", dynlib: librocksdb.} +proc rocksdb_create_iterators*(db: ptr rocksdb_t; opts: ptr rocksdb_readoptions_t; + column_families: ptr ptr rocksdb_column_family_handle_t; + iterators: ptr ptr rocksdb_iterator_t; size: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_create_iterators", dynlib: librocksdb.} +proc rocksdb_create_snapshot*(db: ptr rocksdb_t): ptr rocksdb_snapshot_t {.cdecl, + importc: "rocksdb_create_snapshot", dynlib: librocksdb.} +proc rocksdb_release_snapshot*(db: ptr rocksdb_t; snapshot: ptr rocksdb_snapshot_t) {. + cdecl, importc: "rocksdb_release_snapshot", dynlib: librocksdb.} +## Returns NULL if property name is unknown. +## Else returns a pointer to a malloc()-ed null-terminated value. + +proc rocksdb_property_value*(db: ptr rocksdb_t; propname: cstring): cstring {.cdecl, + importc: "rocksdb_property_value", dynlib: librocksdb.} +## returns 0 on success, -1 otherwise + +proc rocksdb_property_int*(db: ptr rocksdb_t; propname: cstring; out_val: ptr uint64): cint {. + cdecl, importc: "rocksdb_property_int", dynlib: librocksdb.} +## returns 0 on success, -1 otherwise + +proc rocksdb_property_int_cf*(db: ptr rocksdb_t; + column_family: ptr rocksdb_column_family_handle_t; + propname: cstring; out_val: ptr uint64): cint {.cdecl, + importc: "rocksdb_property_int_cf", dynlib: librocksdb.} +proc rocksdb_property_value_cf*(db: ptr rocksdb_t; column_family: ptr rocksdb_column_family_handle_t; + propname: cstring): cstring {.cdecl, + importc: "rocksdb_property_value_cf", dynlib: librocksdb.} +proc rocksdb_approximate_sizes*(db: ptr rocksdb_t; num_ranges: cint; + range_start_key: cstringArray; + range_start_key_len: ptr csize_t; + range_limit_key: cstringArray; + range_limit_key_len: ptr csize_t; sizes: ptr uint64; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_approximate_sizes", dynlib: librocksdb.} +proc rocksdb_approximate_sizes_cf*(db: ptr rocksdb_t; column_family: ptr rocksdb_column_family_handle_t; + num_ranges: cint; range_start_key: cstringArray; + range_start_key_len: ptr csize_t; + range_limit_key: cstringArray; + range_limit_key_len: ptr csize_t; + sizes: ptr uint64; errptr: cstringArray) {.cdecl, + importc: "rocksdb_approximate_sizes_cf", dynlib: librocksdb.} +proc rocksdb_compact_range*(db: ptr rocksdb_t; start_key: cstring; + start_key_len: csize_t; limit_key: cstring; + limit_key_len: csize_t) {.cdecl, + importc: "rocksdb_compact_range", dynlib: librocksdb.} +proc rocksdb_compact_range_cf*(db: ptr rocksdb_t; column_family: ptr rocksdb_column_family_handle_t; + start_key: cstring; start_key_len: csize_t; + limit_key: cstring; limit_key_len: csize_t) {.cdecl, + importc: "rocksdb_compact_range_cf", dynlib: librocksdb.} +proc rocksdb_suggest_compact_range*(db: ptr rocksdb_t; start_key: cstring; + start_key_len: csize_t; limit_key: cstring; + limit_key_len: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_suggest_compact_range", dynlib: librocksdb.} +proc rocksdb_suggest_compact_range_cf*(db: ptr rocksdb_t; column_family: ptr rocksdb_column_family_handle_t; + start_key: cstring; start_key_len: csize_t; + limit_key: cstring; limit_key_len: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_suggest_compact_range_cf", dynlib: librocksdb.} +proc rocksdb_compact_range_opt*(db: ptr rocksdb_t; + opt: ptr rocksdb_compactoptions_t; + start_key: cstring; start_key_len: csize_t; + limit_key: cstring; limit_key_len: csize_t) {.cdecl, + importc: "rocksdb_compact_range_opt", dynlib: librocksdb.} +proc rocksdb_compact_range_cf_opt*(db: ptr rocksdb_t; column_family: ptr rocksdb_column_family_handle_t; + opt: ptr rocksdb_compactoptions_t; + start_key: cstring; start_key_len: csize_t; + limit_key: cstring; limit_key_len: csize_t) {. + cdecl, importc: "rocksdb_compact_range_cf_opt", dynlib: librocksdb.} +proc rocksdb_delete_file*(db: ptr rocksdb_t; name: cstring) {.cdecl, + importc: "rocksdb_delete_file", dynlib: librocksdb.} +proc rocksdb_livefiles*(db: ptr rocksdb_t): ptr rocksdb_livefiles_t {.cdecl, + importc: "rocksdb_livefiles", dynlib: librocksdb.} +proc rocksdb_flush*(db: ptr rocksdb_t; options: ptr rocksdb_flushoptions_t; + errptr: cstringArray) {.cdecl, importc: "rocksdb_flush", + dynlib: librocksdb.} +proc rocksdb_flush_cf*(db: ptr rocksdb_t; options: ptr rocksdb_flushoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + errptr: cstringArray) {.cdecl, importc: "rocksdb_flush_cf", + dynlib: librocksdb.} +proc rocksdb_flush_cfs*(db: ptr rocksdb_t; options: ptr rocksdb_flushoptions_t; + column_family: ptr ptr rocksdb_column_family_handle_t; + num_column_families: cint; errptr: cstringArray) {.cdecl, + importc: "rocksdb_flush_cfs", dynlib: librocksdb.} +proc rocksdb_flush_wal*(db: ptr rocksdb_t; sync: uint8; errptr: cstringArray) {.cdecl, + importc: "rocksdb_flush_wal", dynlib: librocksdb.} +proc rocksdb_disable_file_deletions*(db: ptr rocksdb_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_disable_file_deletions", dynlib: librocksdb.} +proc rocksdb_enable_file_deletions*(db: ptr rocksdb_t; force: uint8; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_enable_file_deletions", dynlib: librocksdb.} +## Management operations + +proc rocksdb_destroy_db*(options: ptr rocksdb_options_t; name: cstring; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_destroy_db", dynlib: librocksdb.} +proc rocksdb_repair_db*(options: ptr rocksdb_options_t; name: cstring; + errptr: cstringArray) {.cdecl, importc: "rocksdb_repair_db", + dynlib: librocksdb.} +## Iterator + +proc rocksdb_iter_destroy*(a1: ptr rocksdb_iterator_t) {.cdecl, + importc: "rocksdb_iter_destroy", dynlib: librocksdb.} +proc rocksdb_iter_valid*(a1: ptr rocksdb_iterator_t): uint8 {.cdecl, + importc: "rocksdb_iter_valid", dynlib: librocksdb.} +proc rocksdb_iter_seek_to_first*(a1: ptr rocksdb_iterator_t) {.cdecl, + importc: "rocksdb_iter_seek_to_first", dynlib: librocksdb.} +proc rocksdb_iter_seek_to_last*(a1: ptr rocksdb_iterator_t) {.cdecl, + importc: "rocksdb_iter_seek_to_last", dynlib: librocksdb.} +proc rocksdb_iter_seek*(a1: ptr rocksdb_iterator_t; k: cstring; klen: csize_t) {.cdecl, + importc: "rocksdb_iter_seek", dynlib: librocksdb.} +proc rocksdb_iter_seek_for_prev*(a1: ptr rocksdb_iterator_t; k: cstring; klen: csize_t) {. + cdecl, importc: "rocksdb_iter_seek_for_prev", dynlib: librocksdb.} +proc rocksdb_iter_next*(a1: ptr rocksdb_iterator_t) {.cdecl, + importc: "rocksdb_iter_next", dynlib: librocksdb.} +proc rocksdb_iter_prev*(a1: ptr rocksdb_iterator_t) {.cdecl, + importc: "rocksdb_iter_prev", dynlib: librocksdb.} +proc rocksdb_iter_key*(a1: ptr rocksdb_iterator_t; klen: ptr csize_t): cstring {.cdecl, + importc: "rocksdb_iter_key", dynlib: librocksdb.} +proc rocksdb_iter_value*(a1: ptr rocksdb_iterator_t; vlen: ptr csize_t): cstring {. + cdecl, importc: "rocksdb_iter_value", dynlib: librocksdb.} +proc rocksdb_iter_timestamp*(a1: ptr rocksdb_iterator_t; tslen: ptr csize_t): cstring {. + cdecl, importc: "rocksdb_iter_timestamp", dynlib: librocksdb.} +proc rocksdb_iter_get_error*(a1: ptr rocksdb_iterator_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_iter_get_error", dynlib: librocksdb.} +proc rocksdb_wal_iter_next*(iter: ptr rocksdb_wal_iterator_t) {.cdecl, + importc: "rocksdb_wal_iter_next", dynlib: librocksdb.} +proc rocksdb_wal_iter_valid*(a1: ptr rocksdb_wal_iterator_t): uint8 {.cdecl, + importc: "rocksdb_wal_iter_valid", dynlib: librocksdb.} +proc rocksdb_wal_iter_status*(iter: ptr rocksdb_wal_iterator_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_wal_iter_status", dynlib: librocksdb.} +proc rocksdb_wal_iter_get_batch*(iter: ptr rocksdb_wal_iterator_t; seq: ptr uint64): ptr rocksdb_writebatch_t {. + cdecl, importc: "rocksdb_wal_iter_get_batch", dynlib: librocksdb.} +proc rocksdb_get_latest_sequence_number*(db: ptr rocksdb_t): uint64 {.cdecl, + importc: "rocksdb_get_latest_sequence_number", dynlib: librocksdb.} +proc rocksdb_wal_iter_destroy*(iter: ptr rocksdb_wal_iterator_t) {.cdecl, + importc: "rocksdb_wal_iter_destroy", dynlib: librocksdb.} +## Write batch + +proc rocksdb_writebatch_create*(): ptr rocksdb_writebatch_t {.cdecl, + importc: "rocksdb_writebatch_create", dynlib: librocksdb.} +proc rocksdb_writebatch_create_from*(rep: cstring; size: csize_t): ptr rocksdb_writebatch_t {. + cdecl, importc: "rocksdb_writebatch_create_from", dynlib: librocksdb.} +proc rocksdb_writebatch_destroy*(a1: ptr rocksdb_writebatch_t) {.cdecl, + importc: "rocksdb_writebatch_destroy", dynlib: librocksdb.} +proc rocksdb_writebatch_clear*(a1: ptr rocksdb_writebatch_t) {.cdecl, + importc: "rocksdb_writebatch_clear", dynlib: librocksdb.} +proc rocksdb_writebatch_count*(a1: ptr rocksdb_writebatch_t): cint {.cdecl, + importc: "rocksdb_writebatch_count", dynlib: librocksdb.} +proc rocksdb_writebatch_put*(a1: ptr rocksdb_writebatch_t; key: cstring; + klen: csize_t; val: cstring; vlen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_put", dynlib: librocksdb.} +proc rocksdb_writebatch_put_cf*(a1: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; val: cstring; + vlen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_put_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_put_cf_with_ts*(a1: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; ts: cstring; + tslen: csize_t; val: cstring; vlen: csize_t) {. + cdecl, importc: "rocksdb_writebatch_put_cf_with_ts", dynlib: librocksdb.} +proc rocksdb_writebatch_putv*(b: ptr rocksdb_writebatch_t; num_keys: cint; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t; num_values: cint; + values_list: cstringArray; + values_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_putv", dynlib: librocksdb.} +proc rocksdb_writebatch_putv_cf*(b: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + num_keys: cint; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; num_values: cint; + values_list: cstringArray; + values_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_putv_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_merge*(a1: ptr rocksdb_writebatch_t; key: cstring; + klen: csize_t; val: cstring; vlen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_merge", dynlib: librocksdb.} +proc rocksdb_writebatch_merge_cf*(a1: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; val: cstring; + vlen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_merge_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_mergev*(b: ptr rocksdb_writebatch_t; num_keys: cint; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t; num_values: cint; + values_list: cstringArray; + values_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_mergev", dynlib: librocksdb.} +proc rocksdb_writebatch_mergev_cf*(b: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + num_keys: cint; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; num_values: cint; + values_list: cstringArray; + values_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_mergev_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_delete*(a1: ptr rocksdb_writebatch_t; key: cstring; + klen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_delete", dynlib: librocksdb.} +proc rocksdb_writebatch_singledelete*(b: ptr rocksdb_writebatch_t; key: cstring; + klen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_singledelete", dynlib: librocksdb.} +proc rocksdb_writebatch_delete_cf*(a1: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_delete_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_delete_cf_with_ts*(a1: ptr rocksdb_writebatch_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; klen: csize_t; + ts: cstring; tslen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_delete_cf_with_ts", + dynlib: librocksdb.} +proc rocksdb_writebatch_singledelete_cf*(b: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_singledelete_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_singledelete_cf_with_ts*(b: ptr rocksdb_writebatch_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; klen: csize_t; + ts: cstring; tslen: csize_t) {.cdecl, importc: "rocksdb_writebatch_singledelete_cf_with_ts", + dynlib: librocksdb.} +proc rocksdb_writebatch_deletev*(b: ptr rocksdb_writebatch_t; num_keys: cint; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_deletev", dynlib: librocksdb.} +proc rocksdb_writebatch_deletev_cf*(b: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + num_keys: cint; keys_list: cstringArray; + keys_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_deletev_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_delete_range*(b: ptr rocksdb_writebatch_t; + start_key: cstring; start_key_len: csize_t; + end_key: cstring; end_key_len: csize_t) {. + cdecl, importc: "rocksdb_writebatch_delete_range", dynlib: librocksdb.} +proc rocksdb_writebatch_delete_range_cf*(b: ptr rocksdb_writebatch_t; column_family: ptr rocksdb_column_family_handle_t; + start_key: cstring; + start_key_len: csize_t; end_key: cstring; + end_key_len: csize_t) {.cdecl, + importc: "rocksdb_writebatch_delete_range_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_delete_rangev*(b: ptr rocksdb_writebatch_t; num_keys: cint; + start_keys_list: cstringArray; + start_keys_list_sizes: ptr csize_t; + end_keys_list: cstringArray; + end_keys_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_delete_rangev", dynlib: librocksdb.} +proc rocksdb_writebatch_delete_rangev_cf*(b: ptr rocksdb_writebatch_t; + column_family: ptr rocksdb_column_family_handle_t; num_keys: cint; + start_keys_list: cstringArray; start_keys_list_sizes: ptr csize_t; + end_keys_list: cstringArray; end_keys_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_delete_rangev_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_put_log_data*(a1: ptr rocksdb_writebatch_t; blob: cstring; + len: csize_t) {.cdecl, + importc: "rocksdb_writebatch_put_log_data", dynlib: librocksdb.} +proc rocksdb_writebatch_iterate*(a1: ptr rocksdb_writebatch_t; state: pointer; put: proc ( + a1: pointer; k: cstring; klen: csize_t; v: cstring; vlen: csize_t) {.cdecl.}; deleted: proc ( + a1: pointer; k: cstring; klen: csize_t) {.cdecl.}) {.cdecl, + importc: "rocksdb_writebatch_iterate", dynlib: librocksdb.} +proc rocksdb_writebatch_data*(a1: ptr rocksdb_writebatch_t; size: ptr csize_t): cstring {. + cdecl, importc: "rocksdb_writebatch_data", dynlib: librocksdb.} +proc rocksdb_writebatch_set_save_point*(a1: ptr rocksdb_writebatch_t) {.cdecl, + importc: "rocksdb_writebatch_set_save_point", dynlib: librocksdb.} +proc rocksdb_writebatch_rollback_to_save_point*(a1: ptr rocksdb_writebatch_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_writebatch_rollback_to_save_point", + dynlib: librocksdb.} +proc rocksdb_writebatch_pop_save_point*(a1: ptr rocksdb_writebatch_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_writebatch_pop_save_point", dynlib: librocksdb.} +## Write batch with index + +proc rocksdb_writebatch_wi_create*(reserved_bytes: csize_t; overwrite_keys: uint8): ptr rocksdb_writebatch_wi_t {. + cdecl, importc: "rocksdb_writebatch_wi_create", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_create_from*(rep: cstring; size: csize_t): ptr rocksdb_writebatch_wi_t {. + cdecl, importc: "rocksdb_writebatch_wi_create_from", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_destroy*(a1: ptr rocksdb_writebatch_wi_t) {.cdecl, + importc: "rocksdb_writebatch_wi_destroy", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_clear*(a1: ptr rocksdb_writebatch_wi_t) {.cdecl, + importc: "rocksdb_writebatch_wi_clear", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_count*(b: ptr rocksdb_writebatch_wi_t): cint {.cdecl, + importc: "rocksdb_writebatch_wi_count", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_put*(a1: ptr rocksdb_writebatch_wi_t; key: cstring; + klen: csize_t; val: cstring; vlen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_put", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_put_cf*(a1: ptr rocksdb_writebatch_wi_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; val: cstring; + vlen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_put_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_putv*(b: ptr rocksdb_writebatch_wi_t; num_keys: cint; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t; num_values: cint; + values_list: cstringArray; + values_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_putv", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_putv_cf*(b: ptr rocksdb_writebatch_wi_t; column_family: ptr rocksdb_column_family_handle_t; + num_keys: cint; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; num_values: cint; + values_list: cstringArray; + values_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_putv_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_merge*(a1: ptr rocksdb_writebatch_wi_t; key: cstring; + klen: csize_t; val: cstring; vlen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_merge", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_merge_cf*(a1: ptr rocksdb_writebatch_wi_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; val: cstring; + vlen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_merge_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_mergev*(b: ptr rocksdb_writebatch_wi_t; num_keys: cint; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t; num_values: cint; + values_list: cstringArray; + values_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_mergev", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_mergev_cf*(b: ptr rocksdb_writebatch_wi_t; column_family: ptr rocksdb_column_family_handle_t; + num_keys: cint; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; + num_values: cint; values_list: cstringArray; + values_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_mergev_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_delete*(a1: ptr rocksdb_writebatch_wi_t; key: cstring; + klen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_delete", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_singledelete*(a1: ptr rocksdb_writebatch_wi_t; + key: cstring; klen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_singledelete", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_delete_cf*(a1: ptr rocksdb_writebatch_wi_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_delete_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_singledelete_cf*(a1: ptr rocksdb_writebatch_wi_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; klen: csize_t) {. + cdecl, importc: "rocksdb_writebatch_wi_singledelete_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_deletev*(b: ptr rocksdb_writebatch_wi_t; num_keys: cint; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_deletev", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_deletev_cf*(b: ptr rocksdb_writebatch_wi_t; column_family: ptr rocksdb_column_family_handle_t; + num_keys: cint; keys_list: cstringArray; + keys_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_deletev_cf", dynlib: librocksdb.} +## DO NOT USE - rocksdb_writebatch_wi_delete_range is not yet supported + +proc rocksdb_writebatch_wi_delete_range*(b: ptr rocksdb_writebatch_wi_t; + start_key: cstring; + start_key_len: csize_t; end_key: cstring; + end_key_len: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_delete_range", dynlib: librocksdb.} +## DO NOT USE - rocksdb_writebatch_wi_delete_range_cf is not yet supported + +proc rocksdb_writebatch_wi_delete_range_cf*(b: ptr rocksdb_writebatch_wi_t; + column_family: ptr rocksdb_column_family_handle_t; start_key: cstring; + start_key_len: csize_t; end_key: cstring; end_key_len: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_delete_range_cf", dynlib: librocksdb.} +## DO NOT USE - rocksdb_writebatch_wi_delete_rangev is not yet supported + +proc rocksdb_writebatch_wi_delete_rangev*(b: ptr rocksdb_writebatch_wi_t; + num_keys: cint; start_keys_list: cstringArray; + start_keys_list_sizes: ptr csize_t; end_keys_list: cstringArray; + end_keys_list_sizes: ptr csize_t) {.cdecl, importc: "rocksdb_writebatch_wi_delete_rangev", + dynlib: librocksdb.} +## DO NOT USE - rocksdb_writebatch_wi_delete_rangev_cf is not yet supported + +proc rocksdb_writebatch_wi_delete_rangev_cf*(b: ptr rocksdb_writebatch_wi_t; + column_family: ptr rocksdb_column_family_handle_t; num_keys: cint; + start_keys_list: cstringArray; start_keys_list_sizes: ptr csize_t; + end_keys_list: cstringArray; end_keys_list_sizes: ptr csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_delete_rangev_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_put_log_data*(a1: ptr rocksdb_writebatch_wi_t; + blob: cstring; len: csize_t) {.cdecl, + importc: "rocksdb_writebatch_wi_put_log_data", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_iterate*(b: ptr rocksdb_writebatch_wi_t; state: pointer; + put: proc (a1: pointer; k: cstring; klen: csize_t; v: cstring; vlen: csize_t) {.cdecl.}; + deleted: proc (a1: pointer; k: cstring; klen: csize_t) {.cdecl.}) {.cdecl, + importc: "rocksdb_writebatch_wi_iterate", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_data*(b: ptr rocksdb_writebatch_wi_t; size: ptr csize_t): cstring {. + cdecl, importc: "rocksdb_writebatch_wi_data", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_set_save_point*(a1: ptr rocksdb_writebatch_wi_t) {.cdecl, + importc: "rocksdb_writebatch_wi_set_save_point", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_rollback_to_save_point*( + a1: ptr rocksdb_writebatch_wi_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_writebatch_wi_rollback_to_save_point", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_get_from_batch*(wbwi: ptr rocksdb_writebatch_wi_t; + options: ptr rocksdb_options_t; key: cstring; keylen: csize_t; vallen: ptr csize_t; + errptr: cstringArray): cstring {.cdecl, importc: "rocksdb_writebatch_wi_get_from_batch", + dynlib: librocksdb.} +proc rocksdb_writebatch_wi_get_from_batch_cf*(wbwi: ptr rocksdb_writebatch_wi_t; + options: ptr rocksdb_options_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; + vallen: ptr csize_t; errptr: cstringArray): cstring {.cdecl, + importc: "rocksdb_writebatch_wi_get_from_batch_cf", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_get_from_batch_and_db*( + wbwi: ptr rocksdb_writebatch_wi_t; db: ptr rocksdb_t; + options: ptr rocksdb_readoptions_t; key: cstring; keylen: csize_t; + vallen: ptr csize_t; errptr: cstringArray): cstring {.cdecl, + importc: "rocksdb_writebatch_wi_get_from_batch_and_db", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_get_from_batch_and_db_cf*( + wbwi: ptr rocksdb_writebatch_wi_t; db: ptr rocksdb_t; + options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; + vallen: ptr csize_t; errptr: cstringArray): cstring {.cdecl, + importc: "rocksdb_writebatch_wi_get_from_batch_and_db_cf", dynlib: librocksdb.} +proc rocksdb_write_writebatch_wi*(db: ptr rocksdb_t; + options: ptr rocksdb_writeoptions_t; + wbwi: ptr rocksdb_writebatch_wi_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_write_writebatch_wi", dynlib: librocksdb.} +proc rocksdb_writebatch_wi_create_iterator_with_base*( + wbwi: ptr rocksdb_writebatch_wi_t; base_iterator: ptr rocksdb_iterator_t): ptr rocksdb_iterator_t {. + cdecl, importc: "rocksdb_writebatch_wi_create_iterator_with_base", + dynlib: librocksdb.} +proc rocksdb_writebatch_wi_create_iterator_with_base_cf*( + wbwi: ptr rocksdb_writebatch_wi_t; base_iterator: ptr rocksdb_iterator_t; + cf: ptr rocksdb_column_family_handle_t): ptr rocksdb_iterator_t {.cdecl, + importc: "rocksdb_writebatch_wi_create_iterator_with_base_cf", + dynlib: librocksdb.} +## Options utils +## Load the latest rocksdb options from the specified db_path. +## +## On success, num_column_families will be updated with a non-zero +## number indicating the number of column families. +## The returned db_options, column_family_names, and column_family_options +## should be released via rocksdb_load_latest_options_destroy(). +## +## On error, a non-null errptr that includes the error message will be +## returned. db_options, column_family_names, and column_family_options +## will be set to NULL. + +proc rocksdb_load_latest_options*(db_path: cstring; env: ptr rocksdb_env_t; + ignore_unknown_options: bool; + cache: ptr rocksdb_cache_t; + db_options: ptr ptr rocksdb_options_t; + num_column_families: ptr csize_t; + column_family_names: ptr cstringArray; + column_family_options: ptr ptr ptr rocksdb_options_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_load_latest_options", dynlib: librocksdb.} +proc rocksdb_load_latest_options_destroy*(db_options: ptr rocksdb_options_t; + list_column_family_names: cstringArray; + list_column_family_options: ptr ptr rocksdb_options_t; len: csize_t) {.cdecl, + importc: "rocksdb_load_latest_options_destroy", dynlib: librocksdb.} +## Block based table options + +proc rocksdb_block_based_options_create*(): ptr rocksdb_block_based_table_options_t {. + cdecl, importc: "rocksdb_block_based_options_create", dynlib: librocksdb.} +proc rocksdb_block_based_options_destroy*( + options: ptr rocksdb_block_based_table_options_t) {.cdecl, + importc: "rocksdb_block_based_options_destroy", dynlib: librocksdb.} +proc rocksdb_block_based_options_set_checksum*( + a1: ptr rocksdb_block_based_table_options_t; a2: char) {.cdecl, + importc: "rocksdb_block_based_options_set_checksum", dynlib: librocksdb.} +proc rocksdb_block_based_options_set_block_size*( + options: ptr rocksdb_block_based_table_options_t; block_size: csize_t) {.cdecl, + importc: "rocksdb_block_based_options_set_block_size", dynlib: librocksdb.} +proc rocksdb_block_based_options_set_block_size_deviation*( + options: ptr rocksdb_block_based_table_options_t; block_size_deviation: cint) {. + cdecl, importc: "rocksdb_block_based_options_set_block_size_deviation", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_block_restart_interval*( + options: ptr rocksdb_block_based_table_options_t; block_restart_interval: cint) {. + cdecl, importc: "rocksdb_block_based_options_set_block_restart_interval", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_index_block_restart_interval*( + options: ptr rocksdb_block_based_table_options_t; + index_block_restart_interval: cint) {.cdecl, importc: "rocksdb_block_based_options_set_index_block_restart_interval", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_metadata_block_size*( + options: ptr rocksdb_block_based_table_options_t; metadata_block_size: uint64) {. + cdecl, importc: "rocksdb_block_based_options_set_metadata_block_size", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_partition_filters*( + options: ptr rocksdb_block_based_table_options_t; partition_filters: uint8) {. + cdecl, importc: "rocksdb_block_based_options_set_partition_filters", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_optimize_filters_for_memory*( + options: ptr rocksdb_block_based_table_options_t; + optimize_filters_for_memory: uint8) {.cdecl, importc: "rocksdb_block_based_options_set_optimize_filters_for_memory", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_use_delta_encoding*( + options: ptr rocksdb_block_based_table_options_t; use_delta_encoding: uint8) {. + cdecl, importc: "rocksdb_block_based_options_set_use_delta_encoding", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_filter_policy*( + options: ptr rocksdb_block_based_table_options_t; + filter_policy: ptr rocksdb_filterpolicy_t) {.cdecl, + importc: "rocksdb_block_based_options_set_filter_policy", dynlib: librocksdb.} +proc rocksdb_block_based_options_set_no_block_cache*( + options: ptr rocksdb_block_based_table_options_t; no_block_cache: uint8) {.cdecl, + importc: "rocksdb_block_based_options_set_no_block_cache", dynlib: librocksdb.} +proc rocksdb_block_based_options_set_block_cache*( + options: ptr rocksdb_block_based_table_options_t; + block_cache: ptr rocksdb_cache_t) {.cdecl, importc: "rocksdb_block_based_options_set_block_cache", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_whole_key_filtering*( + a1: ptr rocksdb_block_based_table_options_t; a2: uint8) {.cdecl, + importc: "rocksdb_block_based_options_set_whole_key_filtering", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_format_version*( + a1: ptr rocksdb_block_based_table_options_t; a2: cint) {.cdecl, + importc: "rocksdb_block_based_options_set_format_version", dynlib: librocksdb.} +const + rocksdb_block_based_table_index_type_binary_search* = 0 + rocksdb_block_based_table_index_type_hash_search* = 1 + rocksdb_block_based_table_index_type_two_level_index_search* = 2 + +proc rocksdb_block_based_options_set_index_type*( + a1: ptr rocksdb_block_based_table_options_t; a2: cint) {.cdecl, + importc: "rocksdb_block_based_options_set_index_type", dynlib: librocksdb.} +## uses one of the above enums + +const + rocksdb_block_based_table_data_block_index_type_binary_search* = 0 + rocksdb_block_based_table_data_block_index_type_binary_search_and_hash* = 1 + +proc rocksdb_block_based_options_set_data_block_index_type*( + a1: ptr rocksdb_block_based_table_options_t; a2: cint) {.cdecl, + importc: "rocksdb_block_based_options_set_data_block_index_type", + dynlib: librocksdb.} +## uses one of the above enums + +proc rocksdb_block_based_options_set_data_block_hash_ratio*( + options: ptr rocksdb_block_based_table_options_t; v: cdouble) {.cdecl, + importc: "rocksdb_block_based_options_set_data_block_hash_ratio", + dynlib: librocksdb.} +## rocksdb_block_based_options_set_hash_index_allow_collision() +## is removed since BlockBasedTableOptions.hash_index_allow_collision() +## is removed + +proc rocksdb_block_based_options_set_cache_index_and_filter_blocks*( + a1: ptr rocksdb_block_based_table_options_t; a2: uint8) {.cdecl, + importc: "rocksdb_block_based_options_set_cache_index_and_filter_blocks", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority*( + a1: ptr rocksdb_block_based_table_options_t; a2: uint8) {.cdecl, importc: "rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache*( + a1: ptr rocksdb_block_based_table_options_t; a2: uint8) {.cdecl, importc: "rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache", + dynlib: librocksdb.} +proc rocksdb_block_based_options_set_pin_top_level_index_and_filter*( + a1: ptr rocksdb_block_based_table_options_t; a2: uint8) {.cdecl, + importc: "rocksdb_block_based_options_set_pin_top_level_index_and_filter", + dynlib: librocksdb.} +proc rocksdb_options_set_block_based_table_factory*(opt: ptr rocksdb_options_t; + table_options: ptr rocksdb_block_based_table_options_t) {.cdecl, + importc: "rocksdb_options_set_block_based_table_factory", dynlib: librocksdb.} +proc rocksdb_options_set_write_buffer_manager*(opt: ptr rocksdb_options_t; + wbm: ptr rocksdb_write_buffer_manager_t) {.cdecl, + importc: "rocksdb_options_set_write_buffer_manager", dynlib: librocksdb.} +## Cuckoo table options + +proc rocksdb_cuckoo_options_create*(): ptr rocksdb_cuckoo_table_options_t {.cdecl, + importc: "rocksdb_cuckoo_options_create", dynlib: librocksdb.} +proc rocksdb_cuckoo_options_destroy*(options: ptr rocksdb_cuckoo_table_options_t) {. + cdecl, importc: "rocksdb_cuckoo_options_destroy", dynlib: librocksdb.} +proc rocksdb_cuckoo_options_set_hash_ratio*( + options: ptr rocksdb_cuckoo_table_options_t; v: cdouble) {.cdecl, + importc: "rocksdb_cuckoo_options_set_hash_ratio", dynlib: librocksdb.} +proc rocksdb_cuckoo_options_set_max_search_depth*( + options: ptr rocksdb_cuckoo_table_options_t; v: uint32) {.cdecl, + importc: "rocksdb_cuckoo_options_set_max_search_depth", dynlib: librocksdb.} +proc rocksdb_cuckoo_options_set_cuckoo_block_size*( + options: ptr rocksdb_cuckoo_table_options_t; v: uint32) {.cdecl, + importc: "rocksdb_cuckoo_options_set_cuckoo_block_size", dynlib: librocksdb.} +proc rocksdb_cuckoo_options_set_identity_as_first_hash*( + options: ptr rocksdb_cuckoo_table_options_t; v: uint8) {.cdecl, + importc: "rocksdb_cuckoo_options_set_identity_as_first_hash", + dynlib: librocksdb.} +proc rocksdb_cuckoo_options_set_use_module_hash*( + options: ptr rocksdb_cuckoo_table_options_t; v: uint8) {.cdecl, + importc: "rocksdb_cuckoo_options_set_use_module_hash", dynlib: librocksdb.} +proc rocksdb_options_set_cuckoo_table_factory*(opt: ptr rocksdb_options_t; + table_options: ptr rocksdb_cuckoo_table_options_t) {.cdecl, + importc: "rocksdb_options_set_cuckoo_table_factory", dynlib: librocksdb.} +## Options + +proc rocksdb_set_options*(db: ptr rocksdb_t; count: cint; keys: ptr cstring; + values: ptr cstring; errptr: cstringArray) {.cdecl, + importc: "rocksdb_set_options", dynlib: librocksdb.} +proc rocksdb_set_options_cf*(db: ptr rocksdb_t; + handle: ptr rocksdb_column_family_handle_t; + count: cint; keys: ptr cstring; values: ptr cstring; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_set_options_cf", dynlib: librocksdb.} +proc rocksdb_options_create*(): ptr rocksdb_options_t {.cdecl, + importc: "rocksdb_options_create", dynlib: librocksdb.} +proc rocksdb_options_destroy*(a1: ptr rocksdb_options_t) {.cdecl, + importc: "rocksdb_options_destroy", dynlib: librocksdb.} +proc rocksdb_options_create_copy*(a1: ptr rocksdb_options_t): ptr rocksdb_options_t {. + cdecl, importc: "rocksdb_options_create_copy", dynlib: librocksdb.} +proc rocksdb_options_increase_parallelism*(opt: ptr rocksdb_options_t; + total_threads: cint) {.cdecl, importc: "rocksdb_options_increase_parallelism", + dynlib: librocksdb.} +proc rocksdb_options_optimize_for_point_lookup*(opt: ptr rocksdb_options_t; + block_cache_size_mb: uint64) {.cdecl, importc: "rocksdb_options_optimize_for_point_lookup", + dynlib: librocksdb.} +proc rocksdb_options_optimize_level_style_compaction*(opt: ptr rocksdb_options_t; + memtable_memory_budget: uint64) {.cdecl, importc: "rocksdb_options_optimize_level_style_compaction", + dynlib: librocksdb.} +proc rocksdb_options_optimize_universal_style_compaction*( + opt: ptr rocksdb_options_t; memtable_memory_budget: uint64) {.cdecl, + importc: "rocksdb_options_optimize_universal_style_compaction", + dynlib: librocksdb.} +proc rocksdb_options_set_allow_ingest_behind*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_allow_ingest_behind", dynlib: librocksdb.} +proc rocksdb_options_get_allow_ingest_behind*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_allow_ingest_behind", dynlib: librocksdb.} +proc rocksdb_options_set_compaction_filter*(a1: ptr rocksdb_options_t; + a2: ptr rocksdb_compactionfilter_t) {.cdecl, importc: "rocksdb_options_set_compaction_filter", + dynlib: librocksdb.} +proc rocksdb_options_set_compaction_filter_factory*(a1: ptr rocksdb_options_t; + a2: ptr rocksdb_compactionfilterfactory_t) {.cdecl, + importc: "rocksdb_options_set_compaction_filter_factory", dynlib: librocksdb.} +proc rocksdb_options_compaction_readahead_size*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_options_compaction_readahead_size", + dynlib: librocksdb.} +proc rocksdb_options_get_compaction_readahead_size*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_compaction_readahead_size", + dynlib: librocksdb.} +proc rocksdb_options_set_comparator*(a1: ptr rocksdb_options_t; + a2: ptr rocksdb_comparator_t) {.cdecl, + importc: "rocksdb_options_set_comparator", dynlib: librocksdb.} +proc rocksdb_options_set_merge_operator*(a1: ptr rocksdb_options_t; + a2: ptr rocksdb_mergeoperator_t) {.cdecl, + importc: "rocksdb_options_set_merge_operator", dynlib: librocksdb.} +proc rocksdb_options_set_uint64add_merge_operator*(a1: ptr rocksdb_options_t) {. + cdecl, importc: "rocksdb_options_set_uint64add_merge_operator", + dynlib: librocksdb.} +proc rocksdb_options_set_compression_per_level*(opt: ptr rocksdb_options_t; + level_values: ptr cint; num_levels: csize_t) {.cdecl, + importc: "rocksdb_options_set_compression_per_level", dynlib: librocksdb.} +proc rocksdb_options_set_create_if_missing*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_create_if_missing", dynlib: librocksdb.} +proc rocksdb_options_get_create_if_missing*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_create_if_missing", dynlib: librocksdb.} +proc rocksdb_options_set_create_missing_column_families*( + a1: ptr rocksdb_options_t; a2: uint8) {.cdecl, importc: "rocksdb_options_set_create_missing_column_families", + dynlib: librocksdb.} +proc rocksdb_options_get_create_missing_column_families*( + a1: ptr rocksdb_options_t): uint8 {.cdecl, importc: "rocksdb_options_get_create_missing_column_families", + dynlib: librocksdb.} +proc rocksdb_options_set_error_if_exists*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_error_if_exists", dynlib: librocksdb.} +proc rocksdb_options_get_error_if_exists*(a1: ptr rocksdb_options_t): uint8 {.cdecl, + importc: "rocksdb_options_get_error_if_exists", dynlib: librocksdb.} +proc rocksdb_options_set_paranoid_checks*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_paranoid_checks", dynlib: librocksdb.} +proc rocksdb_options_get_paranoid_checks*(a1: ptr rocksdb_options_t): uint8 {.cdecl, + importc: "rocksdb_options_get_paranoid_checks", dynlib: librocksdb.} +proc rocksdb_options_set_db_paths*(a1: ptr rocksdb_options_t; + path_values: ptr ptr rocksdb_dbpath_t; + num_paths: csize_t) {.cdecl, + importc: "rocksdb_options_set_db_paths", dynlib: librocksdb.} +proc rocksdb_options_set_cf_paths*(a1: ptr rocksdb_options_t; + path_values: ptr ptr rocksdb_dbpath_t; + num_paths: csize_t) {.cdecl, + importc: "rocksdb_options_set_cf_paths", dynlib: librocksdb.} +proc rocksdb_options_set_env*(a1: ptr rocksdb_options_t; a2: ptr rocksdb_env_t) {. + cdecl, importc: "rocksdb_options_set_env", dynlib: librocksdb.} +proc rocksdb_options_set_info_log*(a1: ptr rocksdb_options_t; + a2: ptr rocksdb_logger_t) {.cdecl, + importc: "rocksdb_options_set_info_log", dynlib: librocksdb.} +proc rocksdb_options_set_info_log_level*(a1: ptr rocksdb_options_t; a2: cint) {.cdecl, + importc: "rocksdb_options_set_info_log_level", dynlib: librocksdb.} +proc rocksdb_options_get_info_log_level*(a1: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_info_log_level", dynlib: librocksdb.} +proc rocksdb_options_set_write_buffer_size*(a1: ptr rocksdb_options_t; a2: csize_t) {. + cdecl, importc: "rocksdb_options_set_write_buffer_size", dynlib: librocksdb.} +proc rocksdb_options_get_write_buffer_size*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_write_buffer_size", dynlib: librocksdb.} +proc rocksdb_options_set_db_write_buffer_size*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_options_set_db_write_buffer_size", + dynlib: librocksdb.} +proc rocksdb_options_get_db_write_buffer_size*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_db_write_buffer_size", dynlib: librocksdb.} +proc rocksdb_options_set_max_open_files*(a1: ptr rocksdb_options_t; a2: cint) {.cdecl, + importc: "rocksdb_options_set_max_open_files", dynlib: librocksdb.} +proc rocksdb_options_get_max_open_files*(a1: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_max_open_files", dynlib: librocksdb.} +proc rocksdb_options_set_max_file_opening_threads*(a1: ptr rocksdb_options_t; + a2: cint) {.cdecl, importc: "rocksdb_options_set_max_file_opening_threads", + dynlib: librocksdb.} +proc rocksdb_options_get_max_file_opening_threads*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_max_file_opening_threads", + dynlib: librocksdb.} +proc rocksdb_options_set_max_total_wal_size*(opt: ptr rocksdb_options_t; n: uint64) {. + cdecl, importc: "rocksdb_options_set_max_total_wal_size", dynlib: librocksdb.} +proc rocksdb_options_get_max_total_wal_size*(opt: ptr rocksdb_options_t): uint64 {. + cdecl, importc: "rocksdb_options_get_max_total_wal_size", dynlib: librocksdb.} +proc rocksdb_options_set_compression_options*(a1: ptr rocksdb_options_t; a2: cint; + a3: cint; a4: cint; a5: cint) {.cdecl, importc: "rocksdb_options_set_compression_options", + dynlib: librocksdb.} +proc rocksdb_options_set_compression_options_zstd_max_train_bytes*( + a1: ptr rocksdb_options_t; a2: cint) {.cdecl, importc: "rocksdb_options_set_compression_options_zstd_max_train_bytes", + dynlib: librocksdb.} +proc rocksdb_options_get_compression_options_zstd_max_train_bytes*( + opt: ptr rocksdb_options_t): cint {.cdecl, importc: "rocksdb_options_get_compression_options_zstd_max_train_bytes", + dynlib: librocksdb.} +proc rocksdb_options_set_compression_options_use_zstd_dict_trainer*( + a1: ptr rocksdb_options_t; a2: uint8) {.cdecl, importc: "rocksdb_options_set_compression_options_use_zstd_dict_trainer", + dynlib: librocksdb.} +proc rocksdb_options_get_compression_options_use_zstd_dict_trainer*( + opt: ptr rocksdb_options_t): uint8 {.cdecl, importc: "rocksdb_options_get_compression_options_use_zstd_dict_trainer", + dynlib: librocksdb.} +proc rocksdb_options_set_compression_options_parallel_threads*( + a1: ptr rocksdb_options_t; a2: cint) {.cdecl, importc: "rocksdb_options_set_compression_options_parallel_threads", + dynlib: librocksdb.} +proc rocksdb_options_get_compression_options_parallel_threads*( + opt: ptr rocksdb_options_t): cint {.cdecl, importc: "rocksdb_options_get_compression_options_parallel_threads", + dynlib: librocksdb.} +proc rocksdb_options_set_compression_options_max_dict_buffer_bytes*( + a1: ptr rocksdb_options_t; a2: uint64) {.cdecl, importc: "rocksdb_options_set_compression_options_max_dict_buffer_bytes", + dynlib: librocksdb.} +proc rocksdb_options_get_compression_options_max_dict_buffer_bytes*( + opt: ptr rocksdb_options_t): uint64 {.cdecl, importc: "rocksdb_options_get_compression_options_max_dict_buffer_bytes", + dynlib: librocksdb.} +proc rocksdb_options_set_bottommost_compression_options*( + a1: ptr rocksdb_options_t; a2: cint; a3: cint; a4: cint; a5: cint; a6: uint8) {.cdecl, + importc: "rocksdb_options_set_bottommost_compression_options", + dynlib: librocksdb.} +proc rocksdb_options_set_bottommost_compression_options_zstd_max_train_bytes*( + a1: ptr rocksdb_options_t; a2: cint; a3: uint8) {.cdecl, importc: "rocksdb_options_set_bottommost_compression_options_zstd_max_train_bytes", + dynlib: librocksdb.} +proc rocksdb_options_set_bottommost_compression_options_use_zstd_dict_trainer*( + a1: ptr rocksdb_options_t; a2: uint8; a3: uint8) {.cdecl, importc: "rocksdb_options_set_bottommost_compression_options_use_zstd_dict_trainer", + dynlib: librocksdb.} +proc rocksdb_options_get_bottommost_compression_options_use_zstd_dict_trainer*( + opt: ptr rocksdb_options_t): uint8 {.cdecl, importc: "rocksdb_options_get_bottommost_compression_options_use_zstd_dict_trainer", + dynlib: librocksdb.} +proc rocksdb_options_set_bottommost_compression_options_max_dict_buffer_bytes*( + a1: ptr rocksdb_options_t; a2: uint64; a3: uint8) {.cdecl, importc: "rocksdb_options_set_bottommost_compression_options_max_dict_buffer_bytes", + dynlib: librocksdb.} +proc rocksdb_options_set_prefix_extractor*(a1: ptr rocksdb_options_t; + a2: ptr rocksdb_slicetransform_t) {.cdecl, importc: "rocksdb_options_set_prefix_extractor", + dynlib: librocksdb.} +proc rocksdb_options_set_num_levels*(a1: ptr rocksdb_options_t; a2: cint) {.cdecl, + importc: "rocksdb_options_set_num_levels", dynlib: librocksdb.} +proc rocksdb_options_get_num_levels*(a1: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_num_levels", dynlib: librocksdb.} +proc rocksdb_options_set_level0_file_num_compaction_trigger*( + a1: ptr rocksdb_options_t; a2: cint) {.cdecl, importc: "rocksdb_options_set_level0_file_num_compaction_trigger", + dynlib: librocksdb.} +proc rocksdb_options_get_level0_file_num_compaction_trigger*( + a1: ptr rocksdb_options_t): cint {.cdecl, importc: "rocksdb_options_get_level0_file_num_compaction_trigger", + dynlib: librocksdb.} +proc rocksdb_options_set_level0_slowdown_writes_trigger*( + a1: ptr rocksdb_options_t; a2: cint) {.cdecl, importc: "rocksdb_options_set_level0_slowdown_writes_trigger", + dynlib: librocksdb.} +proc rocksdb_options_get_level0_slowdown_writes_trigger*( + a1: ptr rocksdb_options_t): cint {.cdecl, importc: "rocksdb_options_get_level0_slowdown_writes_trigger", + dynlib: librocksdb.} +proc rocksdb_options_set_level0_stop_writes_trigger*(a1: ptr rocksdb_options_t; + a2: cint) {.cdecl, importc: "rocksdb_options_set_level0_stop_writes_trigger", + dynlib: librocksdb.} +proc rocksdb_options_get_level0_stop_writes_trigger*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_level0_stop_writes_trigger", + dynlib: librocksdb.} +proc rocksdb_options_set_target_file_size_base*(a1: ptr rocksdb_options_t; + a2: uint64) {.cdecl, importc: "rocksdb_options_set_target_file_size_base", + dynlib: librocksdb.} +proc rocksdb_options_get_target_file_size_base*(a1: ptr rocksdb_options_t): uint64 {. + cdecl, importc: "rocksdb_options_get_target_file_size_base", dynlib: librocksdb.} +proc rocksdb_options_set_target_file_size_multiplier*(a1: ptr rocksdb_options_t; + a2: cint) {.cdecl, importc: "rocksdb_options_set_target_file_size_multiplier", + dynlib: librocksdb.} +proc rocksdb_options_get_target_file_size_multiplier*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_target_file_size_multiplier", + dynlib: librocksdb.} +proc rocksdb_options_set_max_bytes_for_level_base*(a1: ptr rocksdb_options_t; + a2: uint64) {.cdecl, importc: "rocksdb_options_set_max_bytes_for_level_base", + dynlib: librocksdb.} +proc rocksdb_options_get_max_bytes_for_level_base*(a1: ptr rocksdb_options_t): uint64 {. + cdecl, importc: "rocksdb_options_get_max_bytes_for_level_base", + dynlib: librocksdb.} +proc rocksdb_options_set_level_compaction_dynamic_level_bytes*( + a1: ptr rocksdb_options_t; a2: uint8) {.cdecl, importc: "rocksdb_options_set_level_compaction_dynamic_level_bytes", + dynlib: librocksdb.} +proc rocksdb_options_get_level_compaction_dynamic_level_bytes*( + a1: ptr rocksdb_options_t): uint8 {.cdecl, importc: "rocksdb_options_get_level_compaction_dynamic_level_bytes", + dynlib: librocksdb.} +proc rocksdb_options_set_max_bytes_for_level_multiplier*( + a1: ptr rocksdb_options_t; a2: cdouble) {.cdecl, + importc: "rocksdb_options_set_max_bytes_for_level_multiplier", + dynlib: librocksdb.} +proc rocksdb_options_get_max_bytes_for_level_multiplier*( + a1: ptr rocksdb_options_t): cdouble {.cdecl, importc: "rocksdb_options_get_max_bytes_for_level_multiplier", + dynlib: librocksdb.} +proc rocksdb_options_set_max_bytes_for_level_multiplier_additional*( + a1: ptr rocksdb_options_t; level_values: ptr cint; num_levels: csize_t) {.cdecl, + importc: "rocksdb_options_set_max_bytes_for_level_multiplier_additional", + dynlib: librocksdb.} +proc rocksdb_options_enable_statistics*(a1: ptr rocksdb_options_t) {.cdecl, + importc: "rocksdb_options_enable_statistics", dynlib: librocksdb.} +proc rocksdb_options_set_periodic_compaction_seconds*(a1: ptr rocksdb_options_t; + a2: uint64) {.cdecl, + importc: "rocksdb_options_set_periodic_compaction_seconds", + dynlib: librocksdb.} +proc rocksdb_options_get_periodic_compaction_seconds*(a1: ptr rocksdb_options_t): uint64 {. + cdecl, importc: "rocksdb_options_get_periodic_compaction_seconds", + dynlib: librocksdb.} +const + rocksdb_statistics_level_disable_all* = 0 + rocksdb_statistics_level_except_tickers* = rocksdb_statistics_level_disable_all + rocksdb_statistics_level_except_histogram_or_timers* = 1 + rocksdb_statistics_level_except_timers* = 2 + rocksdb_statistics_level_except_detailed_timers* = 3 + rocksdb_statistics_level_except_time_for_mutex* = 4 + rocksdb_statistics_level_all* = 5 + +proc rocksdb_options_set_statistics_level*(a1: ptr rocksdb_options_t; level: cint) {. + cdecl, importc: "rocksdb_options_set_statistics_level", dynlib: librocksdb.} +proc rocksdb_options_get_statistics_level*(a1: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_statistics_level", dynlib: librocksdb.} +proc rocksdb_options_set_skip_stats_update_on_db_open*( + opt: ptr rocksdb_options_t; val: uint8) {.cdecl, + importc: "rocksdb_options_set_skip_stats_update_on_db_open", + dynlib: librocksdb.} +proc rocksdb_options_get_skip_stats_update_on_db_open*(opt: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_skip_stats_update_on_db_open", + dynlib: librocksdb.} +proc rocksdb_options_set_skip_checking_sst_file_sizes_on_db_open*( + opt: ptr rocksdb_options_t; val: uint8) {.cdecl, + importc: "rocksdb_options_set_skip_checking_sst_file_sizes_on_db_open", + dynlib: librocksdb.} +proc rocksdb_options_get_skip_checking_sst_file_sizes_on_db_open*( + opt: ptr rocksdb_options_t): uint8 {.cdecl, importc: "rocksdb_options_get_skip_checking_sst_file_sizes_on_db_open", + dynlib: librocksdb.} +## Blob Options Settings + +proc rocksdb_options_set_enable_blob_files*(opt: ptr rocksdb_options_t; val: uint8) {. + cdecl, importc: "rocksdb_options_set_enable_blob_files", dynlib: librocksdb.} +proc rocksdb_options_get_enable_blob_files*(opt: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_enable_blob_files", dynlib: librocksdb.} +proc rocksdb_options_set_min_blob_size*(opt: ptr rocksdb_options_t; val: uint64) {. + cdecl, importc: "rocksdb_options_set_min_blob_size", dynlib: librocksdb.} +proc rocksdb_options_get_min_blob_size*(opt: ptr rocksdb_options_t): uint64 {.cdecl, + importc: "rocksdb_options_get_min_blob_size", dynlib: librocksdb.} +proc rocksdb_options_set_blob_file_size*(opt: ptr rocksdb_options_t; val: uint64) {. + cdecl, importc: "rocksdb_options_set_blob_file_size", dynlib: librocksdb.} +proc rocksdb_options_get_blob_file_size*(opt: ptr rocksdb_options_t): uint64 {.cdecl, + importc: "rocksdb_options_get_blob_file_size", dynlib: librocksdb.} +proc rocksdb_options_set_blob_compression_type*(opt: ptr rocksdb_options_t; + val: cint) {.cdecl, importc: "rocksdb_options_set_blob_compression_type", + dynlib: librocksdb.} +proc rocksdb_options_get_blob_compression_type*(opt: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_blob_compression_type", dynlib: librocksdb.} +proc rocksdb_options_set_enable_blob_gc*(opt: ptr rocksdb_options_t; val: uint8) {. + cdecl, importc: "rocksdb_options_set_enable_blob_gc", dynlib: librocksdb.} +proc rocksdb_options_get_enable_blob_gc*(opt: ptr rocksdb_options_t): uint8 {.cdecl, + importc: "rocksdb_options_get_enable_blob_gc", dynlib: librocksdb.} +proc rocksdb_options_set_blob_gc_age_cutoff*(opt: ptr rocksdb_options_t; + val: cdouble) {.cdecl, importc: "rocksdb_options_set_blob_gc_age_cutoff", + dynlib: librocksdb.} +proc rocksdb_options_get_blob_gc_age_cutoff*(opt: ptr rocksdb_options_t): cdouble {. + cdecl, importc: "rocksdb_options_get_blob_gc_age_cutoff", dynlib: librocksdb.} +proc rocksdb_options_set_blob_gc_force_threshold*(opt: ptr rocksdb_options_t; + val: cdouble) {.cdecl, importc: "rocksdb_options_set_blob_gc_force_threshold", + dynlib: librocksdb.} +proc rocksdb_options_get_blob_gc_force_threshold*(opt: ptr rocksdb_options_t): cdouble {. + cdecl, importc: "rocksdb_options_get_blob_gc_force_threshold", + dynlib: librocksdb.} +proc rocksdb_options_set_blob_compaction_readahead_size*( + opt: ptr rocksdb_options_t; val: uint64) {.cdecl, + importc: "rocksdb_options_set_blob_compaction_readahead_size", + dynlib: librocksdb.} +proc rocksdb_options_get_blob_compaction_readahead_size*( + opt: ptr rocksdb_options_t): uint64 {.cdecl, importc: "rocksdb_options_get_blob_compaction_readahead_size", + dynlib: librocksdb.} +proc rocksdb_options_set_blob_file_starting_level*(opt: ptr rocksdb_options_t; + val: cint) {.cdecl, importc: "rocksdb_options_set_blob_file_starting_level", + dynlib: librocksdb.} +proc rocksdb_options_get_blob_file_starting_level*(opt: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_blob_file_starting_level", + dynlib: librocksdb.} +proc rocksdb_options_set_blob_cache*(opt: ptr rocksdb_options_t; + blob_cache: ptr rocksdb_cache_t) {.cdecl, + importc: "rocksdb_options_set_blob_cache", dynlib: librocksdb.} +const + rocksdb_prepopulate_blob_disable* = 0 + rocksdb_prepopulate_blob_flush_only* = 1 + +proc rocksdb_options_set_prepopulate_blob_cache*(opt: ptr rocksdb_options_t; + val: cint) {.cdecl, importc: "rocksdb_options_set_prepopulate_blob_cache", + dynlib: librocksdb.} +proc rocksdb_options_get_prepopulate_blob_cache*(opt: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_prepopulate_blob_cache", + dynlib: librocksdb.} +## returns a pointer to a malloc()-ed, null terminated string + +proc rocksdb_options_statistics_get_string*(opt: ptr rocksdb_options_t): cstring {. + cdecl, importc: "rocksdb_options_statistics_get_string", dynlib: librocksdb.} +proc rocksdb_options_statistics_get_ticker_count*(opt: ptr rocksdb_options_t; + ticker_type: uint32): uint64 {.cdecl, importc: "rocksdb_options_statistics_get_ticker_count", + dynlib: librocksdb.} +proc rocksdb_options_statistics_get_histogram_data*(opt: ptr rocksdb_options_t; + histogram_type: uint32; data: ptr rocksdb_statistics_histogram_data_t) {.cdecl, + importc: "rocksdb_options_statistics_get_histogram_data", dynlib: librocksdb.} +proc rocksdb_options_set_max_write_buffer_number*(a1: ptr rocksdb_options_t; + a2: cint) {.cdecl, importc: "rocksdb_options_set_max_write_buffer_number", + dynlib: librocksdb.} +proc rocksdb_options_get_max_write_buffer_number*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_max_write_buffer_number", + dynlib: librocksdb.} +proc rocksdb_options_set_min_write_buffer_number_to_merge*( + a1: ptr rocksdb_options_t; a2: cint) {.cdecl, importc: "rocksdb_options_set_min_write_buffer_number_to_merge", + dynlib: librocksdb.} +proc rocksdb_options_get_min_write_buffer_number_to_merge*( + a1: ptr rocksdb_options_t): cint {.cdecl, importc: "rocksdb_options_get_min_write_buffer_number_to_merge", + dynlib: librocksdb.} +proc rocksdb_options_set_max_write_buffer_number_to_maintain*( + a1: ptr rocksdb_options_t; a2: cint) {.cdecl, importc: "rocksdb_options_set_max_write_buffer_number_to_maintain", + dynlib: librocksdb.} +proc rocksdb_options_get_max_write_buffer_number_to_maintain*( + a1: ptr rocksdb_options_t): cint {.cdecl, importc: "rocksdb_options_get_max_write_buffer_number_to_maintain", + dynlib: librocksdb.} +proc rocksdb_options_set_max_write_buffer_size_to_maintain*( + a1: ptr rocksdb_options_t; a2: int64) {.cdecl, importc: "rocksdb_options_set_max_write_buffer_size_to_maintain", + dynlib: librocksdb.} +proc rocksdb_options_get_max_write_buffer_size_to_maintain*( + a1: ptr rocksdb_options_t): int64 {.cdecl, importc: "rocksdb_options_get_max_write_buffer_size_to_maintain", + dynlib: librocksdb.} +proc rocksdb_options_set_enable_pipelined_write*(a1: ptr rocksdb_options_t; + a2: uint8) {.cdecl, importc: "rocksdb_options_set_enable_pipelined_write", + dynlib: librocksdb.} +proc rocksdb_options_get_enable_pipelined_write*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_enable_pipelined_write", + dynlib: librocksdb.} +proc rocksdb_options_set_unordered_write*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_unordered_write", dynlib: librocksdb.} +proc rocksdb_options_get_unordered_write*(a1: ptr rocksdb_options_t): uint8 {.cdecl, + importc: "rocksdb_options_get_unordered_write", dynlib: librocksdb.} +proc rocksdb_options_set_max_subcompactions*(a1: ptr rocksdb_options_t; a2: uint32) {. + cdecl, importc: "rocksdb_options_set_max_subcompactions", dynlib: librocksdb.} +proc rocksdb_options_get_max_subcompactions*(a1: ptr rocksdb_options_t): uint32 {. + cdecl, importc: "rocksdb_options_get_max_subcompactions", dynlib: librocksdb.} +proc rocksdb_options_set_max_background_jobs*(a1: ptr rocksdb_options_t; a2: cint) {. + cdecl, importc: "rocksdb_options_set_max_background_jobs", dynlib: librocksdb.} +proc rocksdb_options_get_max_background_jobs*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_max_background_jobs", dynlib: librocksdb.} +proc rocksdb_options_set_max_background_compactions*(a1: ptr rocksdb_options_t; + a2: cint) {.cdecl, importc: "rocksdb_options_set_max_background_compactions", + dynlib: librocksdb.} +proc rocksdb_options_get_max_background_compactions*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_max_background_compactions", + dynlib: librocksdb.} +proc rocksdb_options_set_max_background_flushes*(a1: ptr rocksdb_options_t; a2: cint) {. + cdecl, importc: "rocksdb_options_set_max_background_flushes", + dynlib: librocksdb.} +proc rocksdb_options_get_max_background_flushes*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_max_background_flushes", + dynlib: librocksdb.} +proc rocksdb_options_set_max_log_file_size*(a1: ptr rocksdb_options_t; a2: csize_t) {. + cdecl, importc: "rocksdb_options_set_max_log_file_size", dynlib: librocksdb.} +proc rocksdb_options_get_max_log_file_size*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_max_log_file_size", dynlib: librocksdb.} +proc rocksdb_options_set_log_file_time_to_roll*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_options_set_log_file_time_to_roll", + dynlib: librocksdb.} +proc rocksdb_options_get_log_file_time_to_roll*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_log_file_time_to_roll", dynlib: librocksdb.} +proc rocksdb_options_set_keep_log_file_num*(a1: ptr rocksdb_options_t; a2: csize_t) {. + cdecl, importc: "rocksdb_options_set_keep_log_file_num", dynlib: librocksdb.} +proc rocksdb_options_get_keep_log_file_num*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_keep_log_file_num", dynlib: librocksdb.} +proc rocksdb_options_set_recycle_log_file_num*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_options_set_recycle_log_file_num", + dynlib: librocksdb.} +proc rocksdb_options_get_recycle_log_file_num*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_recycle_log_file_num", dynlib: librocksdb.} +proc rocksdb_options_set_soft_pending_compaction_bytes_limit*( + opt: ptr rocksdb_options_t; v: csize_t) {.cdecl, + importc: "rocksdb_options_set_soft_pending_compaction_bytes_limit", + dynlib: librocksdb.} +proc rocksdb_options_get_soft_pending_compaction_bytes_limit*( + opt: ptr rocksdb_options_t): csize_t {.cdecl, importc: "rocksdb_options_get_soft_pending_compaction_bytes_limit", + dynlib: librocksdb.} +proc rocksdb_options_set_hard_pending_compaction_bytes_limit*( + opt: ptr rocksdb_options_t; v: csize_t) {.cdecl, + importc: "rocksdb_options_set_hard_pending_compaction_bytes_limit", + dynlib: librocksdb.} +proc rocksdb_options_get_hard_pending_compaction_bytes_limit*( + opt: ptr rocksdb_options_t): csize_t {.cdecl, importc: "rocksdb_options_get_hard_pending_compaction_bytes_limit", + dynlib: librocksdb.} +proc rocksdb_options_set_max_manifest_file_size*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_options_set_max_manifest_file_size", + dynlib: librocksdb.} +proc rocksdb_options_get_max_manifest_file_size*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_max_manifest_file_size", + dynlib: librocksdb.} +proc rocksdb_options_set_table_cache_numshardbits*(a1: ptr rocksdb_options_t; + a2: cint) {.cdecl, importc: "rocksdb_options_set_table_cache_numshardbits", + dynlib: librocksdb.} +proc rocksdb_options_get_table_cache_numshardbits*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_table_cache_numshardbits", + dynlib: librocksdb.} +proc rocksdb_options_set_arena_block_size*(a1: ptr rocksdb_options_t; a2: csize_t) {. + cdecl, importc: "rocksdb_options_set_arena_block_size", dynlib: librocksdb.} +proc rocksdb_options_get_arena_block_size*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_arena_block_size", dynlib: librocksdb.} +proc rocksdb_options_set_use_fsync*(a1: ptr rocksdb_options_t; a2: cint) {.cdecl, + importc: "rocksdb_options_set_use_fsync", dynlib: librocksdb.} +proc rocksdb_options_get_use_fsync*(a1: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_use_fsync", dynlib: librocksdb.} +proc rocksdb_options_set_db_log_dir*(a1: ptr rocksdb_options_t; a2: cstring) {.cdecl, + importc: "rocksdb_options_set_db_log_dir", dynlib: librocksdb.} +proc rocksdb_options_set_wal_dir*(a1: ptr rocksdb_options_t; a2: cstring) {.cdecl, + importc: "rocksdb_options_set_wal_dir", dynlib: librocksdb.} +proc rocksdb_options_set_WAL_ttl_seconds*(a1: ptr rocksdb_options_t; a2: uint64) {. + cdecl, importc: "rocksdb_options_set_WAL_ttl_seconds", dynlib: librocksdb.} +proc rocksdb_options_get_WAL_ttl_seconds*(a1: ptr rocksdb_options_t): uint64 {.cdecl, + importc: "rocksdb_options_get_WAL_ttl_seconds", dynlib: librocksdb.} +proc rocksdb_options_set_WAL_size_limit_MB*(a1: ptr rocksdb_options_t; a2: uint64) {. + cdecl, importc: "rocksdb_options_set_WAL_size_limit_MB", dynlib: librocksdb.} +proc rocksdb_options_get_WAL_size_limit_MB*(a1: ptr rocksdb_options_t): uint64 {. + cdecl, importc: "rocksdb_options_get_WAL_size_limit_MB", dynlib: librocksdb.} +proc rocksdb_options_set_manifest_preallocation_size*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, + importc: "rocksdb_options_set_manifest_preallocation_size", + dynlib: librocksdb.} +proc rocksdb_options_get_manifest_preallocation_size*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_manifest_preallocation_size", + dynlib: librocksdb.} +proc rocksdb_options_set_allow_mmap_reads*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_allow_mmap_reads", dynlib: librocksdb.} +proc rocksdb_options_get_allow_mmap_reads*(a1: ptr rocksdb_options_t): uint8 {.cdecl, + importc: "rocksdb_options_get_allow_mmap_reads", dynlib: librocksdb.} +proc rocksdb_options_set_allow_mmap_writes*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_allow_mmap_writes", dynlib: librocksdb.} +proc rocksdb_options_get_allow_mmap_writes*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_allow_mmap_writes", dynlib: librocksdb.} +proc rocksdb_options_set_use_direct_reads*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_use_direct_reads", dynlib: librocksdb.} +proc rocksdb_options_get_use_direct_reads*(a1: ptr rocksdb_options_t): uint8 {.cdecl, + importc: "rocksdb_options_get_use_direct_reads", dynlib: librocksdb.} +proc rocksdb_options_set_use_direct_io_for_flush_and_compaction*( + a1: ptr rocksdb_options_t; a2: uint8) {.cdecl, importc: "rocksdb_options_set_use_direct_io_for_flush_and_compaction", + dynlib: librocksdb.} +proc rocksdb_options_get_use_direct_io_for_flush_and_compaction*( + a1: ptr rocksdb_options_t): uint8 {.cdecl, importc: "rocksdb_options_get_use_direct_io_for_flush_and_compaction", + dynlib: librocksdb.} +proc rocksdb_options_set_is_fd_close_on_exec*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_is_fd_close_on_exec", dynlib: librocksdb.} +proc rocksdb_options_get_is_fd_close_on_exec*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_is_fd_close_on_exec", dynlib: librocksdb.} +proc rocksdb_options_set_stats_dump_period_sec*(a1: ptr rocksdb_options_t; a2: cuint) {. + cdecl, importc: "rocksdb_options_set_stats_dump_period_sec", dynlib: librocksdb.} +proc rocksdb_options_get_stats_dump_period_sec*(a1: ptr rocksdb_options_t): cuint {. + cdecl, importc: "rocksdb_options_get_stats_dump_period_sec", dynlib: librocksdb.} +proc rocksdb_options_set_stats_persist_period_sec*(a1: ptr rocksdb_options_t; + a2: cuint) {.cdecl, importc: "rocksdb_options_set_stats_persist_period_sec", + dynlib: librocksdb.} +proc rocksdb_options_get_stats_persist_period_sec*(a1: ptr rocksdb_options_t): cuint {. + cdecl, importc: "rocksdb_options_get_stats_persist_period_sec", + dynlib: librocksdb.} +proc rocksdb_options_set_advise_random_on_open*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_advise_random_on_open", dynlib: librocksdb.} +proc rocksdb_options_get_advise_random_on_open*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_advise_random_on_open", dynlib: librocksdb.} +proc rocksdb_options_set_access_hint_on_compaction_start*( + a1: ptr rocksdb_options_t; a2: cint) {.cdecl, importc: "rocksdb_options_set_access_hint_on_compaction_start", + dynlib: librocksdb.} +proc rocksdb_options_get_access_hint_on_compaction_start*( + a1: ptr rocksdb_options_t): cint {.cdecl, importc: "rocksdb_options_get_access_hint_on_compaction_start", + dynlib: librocksdb.} +proc rocksdb_options_set_use_adaptive_mutex*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_use_adaptive_mutex", dynlib: librocksdb.} +proc rocksdb_options_get_use_adaptive_mutex*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_use_adaptive_mutex", dynlib: librocksdb.} +proc rocksdb_options_set_bytes_per_sync*(a1: ptr rocksdb_options_t; a2: uint64) {. + cdecl, importc: "rocksdb_options_set_bytes_per_sync", dynlib: librocksdb.} +proc rocksdb_options_get_bytes_per_sync*(a1: ptr rocksdb_options_t): uint64 {.cdecl, + importc: "rocksdb_options_get_bytes_per_sync", dynlib: librocksdb.} +proc rocksdb_options_set_wal_bytes_per_sync*(a1: ptr rocksdb_options_t; a2: uint64) {. + cdecl, importc: "rocksdb_options_set_wal_bytes_per_sync", dynlib: librocksdb.} +proc rocksdb_options_get_wal_bytes_per_sync*(a1: ptr rocksdb_options_t): uint64 {. + cdecl, importc: "rocksdb_options_get_wal_bytes_per_sync", dynlib: librocksdb.} +proc rocksdb_options_set_writable_file_max_buffer_size*( + a1: ptr rocksdb_options_t; a2: uint64) {.cdecl, importc: "rocksdb_options_set_writable_file_max_buffer_size", + dynlib: librocksdb.} +proc rocksdb_options_get_writable_file_max_buffer_size*(a1: ptr rocksdb_options_t): uint64 {. + cdecl, importc: "rocksdb_options_get_writable_file_max_buffer_size", + dynlib: librocksdb.} +proc rocksdb_options_set_allow_concurrent_memtable_write*( + a1: ptr rocksdb_options_t; a2: uint8) {.cdecl, importc: "rocksdb_options_set_allow_concurrent_memtable_write", + dynlib: librocksdb.} +proc rocksdb_options_get_allow_concurrent_memtable_write*( + a1: ptr rocksdb_options_t): uint8 {.cdecl, importc: "rocksdb_options_get_allow_concurrent_memtable_write", + dynlib: librocksdb.} +proc rocksdb_options_set_enable_write_thread_adaptive_yield*( + a1: ptr rocksdb_options_t; a2: uint8) {.cdecl, importc: "rocksdb_options_set_enable_write_thread_adaptive_yield", + dynlib: librocksdb.} +proc rocksdb_options_get_enable_write_thread_adaptive_yield*( + a1: ptr rocksdb_options_t): uint8 {.cdecl, importc: "rocksdb_options_get_enable_write_thread_adaptive_yield", + dynlib: librocksdb.} +proc rocksdb_options_set_max_sequential_skip_in_iterations*( + a1: ptr rocksdb_options_t; a2: uint64) {.cdecl, importc: "rocksdb_options_set_max_sequential_skip_in_iterations", + dynlib: librocksdb.} +proc rocksdb_options_get_max_sequential_skip_in_iterations*( + a1: ptr rocksdb_options_t): uint64 {.cdecl, importc: "rocksdb_options_get_max_sequential_skip_in_iterations", + dynlib: librocksdb.} +proc rocksdb_options_set_disable_auto_compactions*(a1: ptr rocksdb_options_t; + a2: cint) {.cdecl, importc: "rocksdb_options_set_disable_auto_compactions", + dynlib: librocksdb.} +proc rocksdb_options_get_disable_auto_compactions*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_disable_auto_compactions", + dynlib: librocksdb.} +proc rocksdb_options_set_optimize_filters_for_hits*(a1: ptr rocksdb_options_t; + a2: cint) {.cdecl, importc: "rocksdb_options_set_optimize_filters_for_hits", + dynlib: librocksdb.} +proc rocksdb_options_get_optimize_filters_for_hits*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_optimize_filters_for_hits", + dynlib: librocksdb.} +proc rocksdb_options_set_delete_obsolete_files_period_micros*( + a1: ptr rocksdb_options_t; a2: uint64) {.cdecl, importc: "rocksdb_options_set_delete_obsolete_files_period_micros", + dynlib: librocksdb.} +proc rocksdb_options_get_delete_obsolete_files_period_micros*( + a1: ptr rocksdb_options_t): uint64 {.cdecl, importc: "rocksdb_options_get_delete_obsolete_files_period_micros", + dynlib: librocksdb.} +proc rocksdb_options_prepare_for_bulk_load*(a1: ptr rocksdb_options_t) {.cdecl, + importc: "rocksdb_options_prepare_for_bulk_load", dynlib: librocksdb.} +proc rocksdb_options_set_memtable_vector_rep*(a1: ptr rocksdb_options_t) {.cdecl, + importc: "rocksdb_options_set_memtable_vector_rep", dynlib: librocksdb.} +proc rocksdb_options_set_memtable_prefix_bloom_size_ratio*( + a1: ptr rocksdb_options_t; a2: cdouble) {.cdecl, + importc: "rocksdb_options_set_memtable_prefix_bloom_size_ratio", + dynlib: librocksdb.} +proc rocksdb_options_get_memtable_prefix_bloom_size_ratio*( + a1: ptr rocksdb_options_t): cdouble {.cdecl, importc: "rocksdb_options_get_memtable_prefix_bloom_size_ratio", + dynlib: librocksdb.} +proc rocksdb_options_set_max_compaction_bytes*(a1: ptr rocksdb_options_t; a2: uint64) {. + cdecl, importc: "rocksdb_options_set_max_compaction_bytes", dynlib: librocksdb.} +proc rocksdb_options_get_max_compaction_bytes*(a1: ptr rocksdb_options_t): uint64 {. + cdecl, importc: "rocksdb_options_get_max_compaction_bytes", dynlib: librocksdb.} +proc rocksdb_options_set_hash_skip_list_rep*(a1: ptr rocksdb_options_t; a2: csize_t; + a3: int32; a4: int32) {.cdecl, importc: "rocksdb_options_set_hash_skip_list_rep", + dynlib: librocksdb.} +proc rocksdb_options_set_hash_link_list_rep*(a1: ptr rocksdb_options_t; a2: csize_t) {. + cdecl, importc: "rocksdb_options_set_hash_link_list_rep", dynlib: librocksdb.} +proc rocksdb_options_set_plain_table_factory*(a1: ptr rocksdb_options_t; a2: uint32; + a3: cint; a4: cdouble; a5: csize_t; a6: csize_t; a7: char; a8: uint8; a9: uint8) {.cdecl, + importc: "rocksdb_options_set_plain_table_factory", dynlib: librocksdb.} +proc rocksdb_options_set_min_level_to_compress*(opt: ptr rocksdb_options_t; + level: cint) {.cdecl, importc: "rocksdb_options_set_min_level_to_compress", + dynlib: librocksdb.} +proc rocksdb_options_set_memtable_huge_page_size*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_options_set_memtable_huge_page_size", + dynlib: librocksdb.} +proc rocksdb_options_get_memtable_huge_page_size*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_memtable_huge_page_size", + dynlib: librocksdb.} +proc rocksdb_options_set_max_successive_merges*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_options_set_max_successive_merges", + dynlib: librocksdb.} +proc rocksdb_options_get_max_successive_merges*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_max_successive_merges", dynlib: librocksdb.} +proc rocksdb_options_set_bloom_locality*(a1: ptr rocksdb_options_t; a2: uint32) {. + cdecl, importc: "rocksdb_options_set_bloom_locality", dynlib: librocksdb.} +proc rocksdb_options_get_bloom_locality*(a1: ptr rocksdb_options_t): uint32 {.cdecl, + importc: "rocksdb_options_get_bloom_locality", dynlib: librocksdb.} +proc rocksdb_options_set_inplace_update_support*(a1: ptr rocksdb_options_t; + a2: uint8) {.cdecl, importc: "rocksdb_options_set_inplace_update_support", + dynlib: librocksdb.} +proc rocksdb_options_get_inplace_update_support*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_inplace_update_support", + dynlib: librocksdb.} +proc rocksdb_options_set_inplace_update_num_locks*(a1: ptr rocksdb_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_options_set_inplace_update_num_locks", + dynlib: librocksdb.} +proc rocksdb_options_get_inplace_update_num_locks*(a1: ptr rocksdb_options_t): csize_t {. + cdecl, importc: "rocksdb_options_get_inplace_update_num_locks", + dynlib: librocksdb.} +proc rocksdb_options_set_report_bg_io_stats*(a1: ptr rocksdb_options_t; a2: cint) {. + cdecl, importc: "rocksdb_options_set_report_bg_io_stats", dynlib: librocksdb.} +proc rocksdb_options_get_report_bg_io_stats*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_report_bg_io_stats", dynlib: librocksdb.} +proc rocksdb_options_set_avoid_unnecessary_blocking_io*( + a1: ptr rocksdb_options_t; a2: uint8) {.cdecl, importc: "rocksdb_options_set_avoid_unnecessary_blocking_io", + dynlib: librocksdb.} +proc rocksdb_options_get_avoid_unnecessary_blocking_io*(a1: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_avoid_unnecessary_blocking_io", + dynlib: librocksdb.} +proc rocksdb_options_set_experimental_mempurge_threshold*( + a1: ptr rocksdb_options_t; a2: cdouble) {.cdecl, + importc: "rocksdb_options_set_experimental_mempurge_threshold", + dynlib: librocksdb.} +proc rocksdb_options_get_experimental_mempurge_threshold*( + a1: ptr rocksdb_options_t): cdouble {.cdecl, importc: "rocksdb_options_get_experimental_mempurge_threshold", + dynlib: librocksdb.} +const + rocksdb_tolerate_corrupted_tail_records_recovery* = 0 + rocksdb_absolute_consistency_recovery* = 1 + rocksdb_point_in_time_recovery* = 2 + rocksdb_skip_any_corrupted_records_recovery* = 3 + +proc rocksdb_options_set_wal_recovery_mode*(a1: ptr rocksdb_options_t; a2: cint) {. + cdecl, importc: "rocksdb_options_set_wal_recovery_mode", dynlib: librocksdb.} +proc rocksdb_options_get_wal_recovery_mode*(a1: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_wal_recovery_mode", dynlib: librocksdb.} +const + rocksdb_no_compression* = 0 + rocksdb_snappy_compression* = 1 + rocksdb_zlib_compression* = 2 + rocksdb_bz2_compression* = 3 + rocksdb_lz4_compression* = 4 + rocksdb_lz4hc_compression* = 5 + rocksdb_xpress_compression* = 6 + rocksdb_zstd_compression* = 7 + +proc rocksdb_options_set_compression*(a1: ptr rocksdb_options_t; a2: cint) {.cdecl, + importc: "rocksdb_options_set_compression", dynlib: librocksdb.} +proc rocksdb_options_get_compression*(a1: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_compression", dynlib: librocksdb.} +proc rocksdb_options_set_bottommost_compression*(a1: ptr rocksdb_options_t; a2: cint) {. + cdecl, importc: "rocksdb_options_set_bottommost_compression", + dynlib: librocksdb.} +proc rocksdb_options_get_bottommost_compression*(a1: ptr rocksdb_options_t): cint {. + cdecl, importc: "rocksdb_options_get_bottommost_compression", + dynlib: librocksdb.} +const + rocksdb_level_compaction* = 0 + rocksdb_universal_compaction* = 1 + rocksdb_fifo_compaction* = 2 + +proc rocksdb_options_set_compaction_style*(a1: ptr rocksdb_options_t; a2: cint) {. + cdecl, importc: "rocksdb_options_set_compaction_style", dynlib: librocksdb.} +proc rocksdb_options_get_compaction_style*(a1: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_compaction_style", dynlib: librocksdb.} +proc rocksdb_options_set_universal_compaction_options*(a1: ptr rocksdb_options_t; + a2: ptr rocksdb_universal_compaction_options_t) {.cdecl, + importc: "rocksdb_options_set_universal_compaction_options", + dynlib: librocksdb.} +proc rocksdb_options_set_fifo_compaction_options*(opt: ptr rocksdb_options_t; + fifo: ptr rocksdb_fifo_compaction_options_t) {.cdecl, + importc: "rocksdb_options_set_fifo_compaction_options", dynlib: librocksdb.} +proc rocksdb_options_set_ratelimiter*(opt: ptr rocksdb_options_t; + limiter: ptr rocksdb_ratelimiter_t) {.cdecl, + importc: "rocksdb_options_set_ratelimiter", dynlib: librocksdb.} +proc rocksdb_options_set_atomic_flush*(opt: ptr rocksdb_options_t; a2: uint8) {.cdecl, + importc: "rocksdb_options_set_atomic_flush", dynlib: librocksdb.} +proc rocksdb_options_get_atomic_flush*(opt: ptr rocksdb_options_t): uint8 {.cdecl, + importc: "rocksdb_options_get_atomic_flush", dynlib: librocksdb.} +proc rocksdb_options_set_row_cache*(opt: ptr rocksdb_options_t; + cache: ptr rocksdb_cache_t) {.cdecl, + importc: "rocksdb_options_set_row_cache", dynlib: librocksdb.} +proc rocksdb_options_add_compact_on_deletion_collector_factory*( + a1: ptr rocksdb_options_t; window_size: csize_t; num_dels_trigger: csize_t) {. + cdecl, importc: "rocksdb_options_add_compact_on_deletion_collector_factory", + dynlib: librocksdb.} +proc rocksdb_options_add_compact_on_deletion_collector_factory_del_ratio*( + a1: ptr rocksdb_options_t; window_size: csize_t; num_dels_trigger: csize_t; + deletion_ratio: cdouble) {.cdecl, importc: "rocksdb_options_add_compact_on_deletion_collector_factory_del_ratio", + dynlib: librocksdb.} +proc rocksdb_options_set_manual_wal_flush*(opt: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_manual_wal_flush", dynlib: librocksdb.} +proc rocksdb_options_get_manual_wal_flush*(opt: ptr rocksdb_options_t): uint8 {. + cdecl, importc: "rocksdb_options_get_manual_wal_flush", dynlib: librocksdb.} +proc rocksdb_options_set_wal_compression*(opt: ptr rocksdb_options_t; a2: cint) {. + cdecl, importc: "rocksdb_options_set_wal_compression", dynlib: librocksdb.} +proc rocksdb_options_get_wal_compression*(opt: ptr rocksdb_options_t): cint {.cdecl, + importc: "rocksdb_options_get_wal_compression", dynlib: librocksdb.} +## RateLimiter + +proc rocksdb_ratelimiter_create*(rate_bytes_per_sec: int64; + refill_period_us: int64; fairness: int32): ptr rocksdb_ratelimiter_t {. + cdecl, importc: "rocksdb_ratelimiter_create", dynlib: librocksdb.} +proc rocksdb_ratelimiter_create_auto_tuned*(rate_bytes_per_sec: int64; + refill_period_us: int64; fairness: int32): ptr rocksdb_ratelimiter_t {.cdecl, + importc: "rocksdb_ratelimiter_create_auto_tuned", dynlib: librocksdb.} +proc rocksdb_ratelimiter_destroy*(a1: ptr rocksdb_ratelimiter_t) {.cdecl, + importc: "rocksdb_ratelimiter_destroy", dynlib: librocksdb.} +## PerfContext + +const + rocksdb_uninitialized* = 0 + rocksdb_disable* = 1 + rocksdb_enable_count* = 2 + rocksdb_enable_time_except_for_mutex* = 3 + rocksdb_enable_time* = 4 + rocksdb_out_of_bounds* = 5 + +const + rocksdb_user_key_comparison_count* = 0 + rocksdb_block_cache_hit_count* = 1 + rocksdb_block_read_count* = 2 + rocksdb_block_read_byte* = 3 + rocksdb_block_read_time* = 4 + rocksdb_block_checksum_time* = 5 + rocksdb_block_decompress_time* = 6 + rocksdb_get_read_bytes* = 7 + rocksdb_multiget_read_bytes* = 8 + rocksdb_iter_read_bytes* = 9 + rocksdb_internal_key_skipped_count* = 10 + rocksdb_internal_delete_skipped_count* = 11 + rocksdb_internal_recent_skipped_count* = 12 + rocksdb_internal_merge_count* = 13 + rocksdb_get_snapshot_time* = 14 + rocksdb_get_from_memtable_time* = 15 + rocksdb_get_from_memtable_count* = 16 + rocksdb_get_post_process_time* = 17 + rocksdb_get_from_output_files_time* = 18 + rocksdb_seek_on_memtable_time* = 19 + rocksdb_seek_on_memtable_count* = 20 + rocksdb_next_on_memtable_count* = 21 + rocksdb_prev_on_memtable_count* = 22 + rocksdb_seek_child_seek_time* = 23 + rocksdb_seek_child_seek_count* = 24 + rocksdb_seek_min_heap_time* = 25 + rocksdb_seek_max_heap_time* = 26 + rocksdb_seek_internal_seek_time* = 27 + rocksdb_find_next_user_entry_time* = 28 + rocksdb_write_wal_time* = 29 + rocksdb_write_memtable_time* = 30 + rocksdb_write_delay_time* = 31 + rocksdb_write_pre_and_post_process_time* = 32 + rocksdb_db_mutex_lock_nanos* = 33 + rocksdb_db_condition_wait_nanos* = 34 + rocksdb_merge_operator_time_nanos* = 35 + rocksdb_read_index_block_nanos* = 36 + rocksdb_read_filter_block_nanos* = 37 + rocksdb_new_table_block_iter_nanos* = 38 + rocksdb_new_table_iterator_nanos* = 39 + rocksdb_block_seek_nanos* = 40 + rocksdb_find_table_nanos* = 41 + rocksdb_bloom_memtable_hit_count* = 42 + rocksdb_bloom_memtable_miss_count* = 43 + rocksdb_bloom_sst_hit_count* = 44 + rocksdb_bloom_sst_miss_count* = 45 + rocksdb_key_lock_wait_time* = 46 + rocksdb_key_lock_wait_count* = 47 + rocksdb_env_new_sequential_file_nanos* = 48 + rocksdb_env_new_random_access_file_nanos* = 49 + rocksdb_env_new_writable_file_nanos* = 50 + rocksdb_env_reuse_writable_file_nanos* = 51 + rocksdb_env_new_random_rw_file_nanos* = 52 + rocksdb_env_new_directory_nanos* = 53 + rocksdb_env_file_exists_nanos* = 54 + rocksdb_env_get_children_nanos* = 55 + rocksdb_env_get_children_file_attributes_nanos* = 56 + rocksdb_env_delete_file_nanos* = 57 + rocksdb_env_create_dir_nanos* = 58 + rocksdb_env_create_dir_if_missing_nanos* = 59 + rocksdb_env_delete_dir_nanos* = 60 + rocksdb_env_get_file_size_nanos* = 61 + rocksdb_env_get_file_modification_time_nanos* = 62 + rocksdb_env_rename_file_nanos* = 63 + rocksdb_env_link_file_nanos* = 64 + rocksdb_env_lock_file_nanos* = 65 + rocksdb_env_unlock_file_nanos* = 66 + rocksdb_env_new_logger_nanos* = 67 + rocksdb_number_async_seek* = 68 + rocksdb_blob_cache_hit_count* = 69 + rocksdb_blob_read_count* = 70 + rocksdb_blob_read_byte* = 71 + rocksdb_blob_read_time* = 72 + rocksdb_blob_checksum_time* = 73 + rocksdb_blob_decompress_time* = 74 + rocksdb_internal_range_del_reseek_count* = 75 + rocksdb_block_read_cpu_time* = 76 + rocksdb_total_metric_count* = 79 + +proc rocksdb_set_perf_level*(a1: cint) {.cdecl, importc: "rocksdb_set_perf_level", + dynlib: librocksdb.} +proc rocksdb_perfcontext_create*(): ptr rocksdb_perfcontext_t {.cdecl, + importc: "rocksdb_perfcontext_create", dynlib: librocksdb.} +proc rocksdb_perfcontext_reset*(context: ptr rocksdb_perfcontext_t) {.cdecl, + importc: "rocksdb_perfcontext_reset", dynlib: librocksdb.} +proc rocksdb_perfcontext_report*(context: ptr rocksdb_perfcontext_t; + exclude_zero_counters: uint8): cstring {.cdecl, + importc: "rocksdb_perfcontext_report", dynlib: librocksdb.} +proc rocksdb_perfcontext_metric*(context: ptr rocksdb_perfcontext_t; metric: cint): uint64 {. + cdecl, importc: "rocksdb_perfcontext_metric", dynlib: librocksdb.} +proc rocksdb_perfcontext_destroy*(context: ptr rocksdb_perfcontext_t) {.cdecl, + importc: "rocksdb_perfcontext_destroy", dynlib: librocksdb.} +## Compaction Filter + +proc rocksdb_compactionfilter_create*(state: pointer; + destructor: proc (a1: pointer) {.cdecl.}; filter: proc ( + a1: pointer; level: cint; key: cstring; key_length: csize_t; + existing_value: cstring; value_length: csize_t; new_value: cstringArray; + new_value_length: ptr csize_t; value_changed: ptr uint8): uint8 {.cdecl.}; + name: proc (a1: pointer): cstring {.cdecl.}): ptr rocksdb_compactionfilter_t {. + cdecl, importc: "rocksdb_compactionfilter_create", dynlib: librocksdb.} +proc rocksdb_compactionfilter_set_ignore_snapshots*( + a1: ptr rocksdb_compactionfilter_t; a2: uint8) {.cdecl, + importc: "rocksdb_compactionfilter_set_ignore_snapshots", dynlib: librocksdb.} +proc rocksdb_compactionfilter_destroy*(a1: ptr rocksdb_compactionfilter_t) {.cdecl, + importc: "rocksdb_compactionfilter_destroy", dynlib: librocksdb.} +## Compaction Filter Context + +proc rocksdb_compactionfiltercontext_is_full_compaction*( + context: ptr rocksdb_compactionfiltercontext_t): uint8 {.cdecl, + importc: "rocksdb_compactionfiltercontext_is_full_compaction", + dynlib: librocksdb.} +proc rocksdb_compactionfiltercontext_is_manual_compaction*( + context: ptr rocksdb_compactionfiltercontext_t): uint8 {.cdecl, + importc: "rocksdb_compactionfiltercontext_is_manual_compaction", + dynlib: librocksdb.} +## Compaction Filter Factory + +proc rocksdb_compactionfilterfactory_create*(state: pointer; + destructor: proc (a1: pointer) {.cdecl.}; create_compaction_filter: proc ( + a1: pointer; context: ptr rocksdb_compactionfiltercontext_t): ptr rocksdb_compactionfilter_t {. + cdecl.}; name: proc (a1: pointer): cstring {.cdecl.}): ptr rocksdb_compactionfilterfactory_t {. + cdecl, importc: "rocksdb_compactionfilterfactory_create", dynlib: librocksdb.} +proc rocksdb_compactionfilterfactory_destroy*( + a1: ptr rocksdb_compactionfilterfactory_t) {.cdecl, + importc: "rocksdb_compactionfilterfactory_destroy", dynlib: librocksdb.} +## Comparator + +proc rocksdb_comparator_create*(state: pointer; + destructor: proc (a1: pointer) {.cdecl.}; compare: proc ( + a1: pointer; a: cstring; alen: csize_t; b: cstring; blen: csize_t): cint {.cdecl.}; + name: proc (a1: pointer): cstring {.cdecl.}): ptr rocksdb_comparator_t {. + cdecl, importc: "rocksdb_comparator_create", dynlib: librocksdb.} +proc rocksdb_comparator_destroy*(a1: ptr rocksdb_comparator_t) {.cdecl, + importc: "rocksdb_comparator_destroy", dynlib: librocksdb.} +proc rocksdb_comparator_with_ts_create*(state: pointer; + destructor: proc (a1: pointer) {.cdecl.}; + compare: proc (a1: pointer; a: cstring; alen: csize_t; b: cstring; blen: csize_t): cint {. + cdecl.}; compare_ts: proc (a1: pointer; a_ts: cstring; a_tslen: csize_t; + b_ts: cstring; b_tslen: csize_t): cint {.cdecl.}; + compare_without_ts: proc (a1: pointer; a: cstring; alen: csize_t; a_has_ts: uint8; + b: cstring; blen: csize_t; b_has_ts: uint8): cint {.cdecl.}; + name: proc (a1: pointer): cstring {.cdecl.}; timestamp_size: csize_t): ptr rocksdb_comparator_t {. + cdecl, importc: "rocksdb_comparator_with_ts_create", dynlib: librocksdb.} +## Filter policy + +proc rocksdb_filterpolicy_destroy*(a1: ptr rocksdb_filterpolicy_t) {.cdecl, + importc: "rocksdb_filterpolicy_destroy", dynlib: librocksdb.} +proc rocksdb_filterpolicy_create_bloom*(bits_per_key: cdouble): ptr rocksdb_filterpolicy_t {. + cdecl, importc: "rocksdb_filterpolicy_create_bloom", dynlib: librocksdb.} +proc rocksdb_filterpolicy_create_bloom_full*(bits_per_key: cdouble): ptr rocksdb_filterpolicy_t {. + cdecl, importc: "rocksdb_filterpolicy_create_bloom_full", dynlib: librocksdb.} +proc rocksdb_filterpolicy_create_ribbon*(bloom_equivalent_bits_per_key: cdouble): ptr rocksdb_filterpolicy_t {. + cdecl, importc: "rocksdb_filterpolicy_create_ribbon", dynlib: librocksdb.} +proc rocksdb_filterpolicy_create_ribbon_hybrid*( + bloom_equivalent_bits_per_key: cdouble; bloom_before_level: cint): ptr rocksdb_filterpolicy_t {. + cdecl, importc: "rocksdb_filterpolicy_create_ribbon_hybrid", dynlib: librocksdb.} +## Merge Operator + +proc rocksdb_mergeoperator_create*(state: pointer; + destructor: proc (a1: pointer) {.cdecl.}; + full_merge: proc (a1: pointer; key: cstring; key_length: csize_t; + existing_value: cstring; existing_value_length: csize_t; + operands_list: cstringArray; + operands_list_length: ptr csize_t; num_operands: cint; + success: ptr uint8; new_value_length: ptr csize_t): cstring {.cdecl.}; + partial_merge: proc (a1: pointer; key: cstring; key_length: csize_t; + operands_list: cstringArray; + operands_list_length: ptr csize_t; num_operands: cint; + success: ptr uint8; new_value_length: ptr csize_t): cstring {. + cdecl.}; delete_value: proc (a1: pointer; value: cstring; value_length: csize_t) {. + cdecl.}; name: proc (a1: pointer): cstring {.cdecl.}): ptr rocksdb_mergeoperator_t {. + cdecl, importc: "rocksdb_mergeoperator_create", dynlib: librocksdb.} +proc rocksdb_mergeoperator_destroy*(a1: ptr rocksdb_mergeoperator_t) {.cdecl, + importc: "rocksdb_mergeoperator_destroy", dynlib: librocksdb.} +## Read options + +proc rocksdb_readoptions_create*(): ptr rocksdb_readoptions_t {.cdecl, + importc: "rocksdb_readoptions_create", dynlib: librocksdb.} +proc rocksdb_readoptions_destroy*(a1: ptr rocksdb_readoptions_t) {.cdecl, + importc: "rocksdb_readoptions_destroy", dynlib: librocksdb.} +proc rocksdb_readoptions_set_verify_checksums*(a1: ptr rocksdb_readoptions_t; + a2: uint8) {.cdecl, importc: "rocksdb_readoptions_set_verify_checksums", + dynlib: librocksdb.} +proc rocksdb_readoptions_get_verify_checksums*(a1: ptr rocksdb_readoptions_t): uint8 {. + cdecl, importc: "rocksdb_readoptions_get_verify_checksums", dynlib: librocksdb.} +proc rocksdb_readoptions_set_fill_cache*(a1: ptr rocksdb_readoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_readoptions_set_fill_cache", dynlib: librocksdb.} +proc rocksdb_readoptions_get_fill_cache*(a1: ptr rocksdb_readoptions_t): uint8 {. + cdecl, importc: "rocksdb_readoptions_get_fill_cache", dynlib: librocksdb.} +proc rocksdb_readoptions_set_snapshot*(a1: ptr rocksdb_readoptions_t; + a2: ptr rocksdb_snapshot_t) {.cdecl, + importc: "rocksdb_readoptions_set_snapshot", dynlib: librocksdb.} +proc rocksdb_readoptions_set_iterate_upper_bound*(a1: ptr rocksdb_readoptions_t; + key: cstring; keylen: csize_t) {.cdecl, importc: "rocksdb_readoptions_set_iterate_upper_bound", + dynlib: librocksdb.} +proc rocksdb_readoptions_set_iterate_lower_bound*(a1: ptr rocksdb_readoptions_t; + key: cstring; keylen: csize_t) {.cdecl, importc: "rocksdb_readoptions_set_iterate_lower_bound", + dynlib: librocksdb.} +proc rocksdb_readoptions_set_read_tier*(a1: ptr rocksdb_readoptions_t; a2: cint) {. + cdecl, importc: "rocksdb_readoptions_set_read_tier", dynlib: librocksdb.} +proc rocksdb_readoptions_get_read_tier*(a1: ptr rocksdb_readoptions_t): cint {.cdecl, + importc: "rocksdb_readoptions_get_read_tier", dynlib: librocksdb.} +proc rocksdb_readoptions_set_tailing*(a1: ptr rocksdb_readoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_readoptions_set_tailing", dynlib: librocksdb.} +proc rocksdb_readoptions_get_tailing*(a1: ptr rocksdb_readoptions_t): uint8 {.cdecl, + importc: "rocksdb_readoptions_get_tailing", dynlib: librocksdb.} +## The functionality that this option controlled has been removed. + +proc rocksdb_readoptions_set_managed*(a1: ptr rocksdb_readoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_readoptions_set_managed", dynlib: librocksdb.} +proc rocksdb_readoptions_set_readahead_size*(a1: ptr rocksdb_readoptions_t; + a2: csize_t) {.cdecl, importc: "rocksdb_readoptions_set_readahead_size", + dynlib: librocksdb.} +proc rocksdb_readoptions_get_readahead_size*(a1: ptr rocksdb_readoptions_t): csize_t {. + cdecl, importc: "rocksdb_readoptions_get_readahead_size", dynlib: librocksdb.} +proc rocksdb_readoptions_set_prefix_same_as_start*(a1: ptr rocksdb_readoptions_t; + a2: uint8) {.cdecl, importc: "rocksdb_readoptions_set_prefix_same_as_start", + dynlib: librocksdb.} +proc rocksdb_readoptions_get_prefix_same_as_start*(a1: ptr rocksdb_readoptions_t): uint8 {. + cdecl, importc: "rocksdb_readoptions_get_prefix_same_as_start", + dynlib: librocksdb.} +proc rocksdb_readoptions_set_pin_data*(a1: ptr rocksdb_readoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_readoptions_set_pin_data", dynlib: librocksdb.} +proc rocksdb_readoptions_get_pin_data*(a1: ptr rocksdb_readoptions_t): uint8 {.cdecl, + importc: "rocksdb_readoptions_get_pin_data", dynlib: librocksdb.} +proc rocksdb_readoptions_set_total_order_seek*(a1: ptr rocksdb_readoptions_t; + a2: uint8) {.cdecl, importc: "rocksdb_readoptions_set_total_order_seek", + dynlib: librocksdb.} +proc rocksdb_readoptions_get_total_order_seek*(a1: ptr rocksdb_readoptions_t): uint8 {. + cdecl, importc: "rocksdb_readoptions_get_total_order_seek", dynlib: librocksdb.} +proc rocksdb_readoptions_set_max_skippable_internal_keys*( + a1: ptr rocksdb_readoptions_t; a2: uint64) {.cdecl, + importc: "rocksdb_readoptions_set_max_skippable_internal_keys", + dynlib: librocksdb.} +proc rocksdb_readoptions_get_max_skippable_internal_keys*( + a1: ptr rocksdb_readoptions_t): uint64 {.cdecl, + importc: "rocksdb_readoptions_get_max_skippable_internal_keys", + dynlib: librocksdb.} +proc rocksdb_readoptions_set_background_purge_on_iterator_cleanup*( + a1: ptr rocksdb_readoptions_t; a2: uint8) {.cdecl, + importc: "rocksdb_readoptions_set_background_purge_on_iterator_cleanup", + dynlib: librocksdb.} +proc rocksdb_readoptions_get_background_purge_on_iterator_cleanup*( + a1: ptr rocksdb_readoptions_t): uint8 {.cdecl, importc: "rocksdb_readoptions_get_background_purge_on_iterator_cleanup", + dynlib: librocksdb.} +proc rocksdb_readoptions_set_ignore_range_deletions*( + a1: ptr rocksdb_readoptions_t; a2: uint8) {.cdecl, + importc: "rocksdb_readoptions_set_ignore_range_deletions", dynlib: librocksdb.} +proc rocksdb_readoptions_get_ignore_range_deletions*( + a1: ptr rocksdb_readoptions_t): uint8 {.cdecl, importc: "rocksdb_readoptions_get_ignore_range_deletions", + dynlib: librocksdb.} +proc rocksdb_readoptions_set_deadline*(a1: ptr rocksdb_readoptions_t; + microseconds: uint64) {.cdecl, + importc: "rocksdb_readoptions_set_deadline", dynlib: librocksdb.} +proc rocksdb_readoptions_get_deadline*(a1: ptr rocksdb_readoptions_t): uint64 {. + cdecl, importc: "rocksdb_readoptions_get_deadline", dynlib: librocksdb.} +proc rocksdb_readoptions_set_io_timeout*(a1: ptr rocksdb_readoptions_t; + microseconds: uint64) {.cdecl, + importc: "rocksdb_readoptions_set_io_timeout", dynlib: librocksdb.} +proc rocksdb_readoptions_get_io_timeout*(a1: ptr rocksdb_readoptions_t): uint64 {. + cdecl, importc: "rocksdb_readoptions_get_io_timeout", dynlib: librocksdb.} +proc rocksdb_readoptions_set_async_io*(a1: ptr rocksdb_readoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_readoptions_set_async_io", dynlib: librocksdb.} +proc rocksdb_readoptions_get_async_io*(a1: ptr rocksdb_readoptions_t): uint8 {.cdecl, + importc: "rocksdb_readoptions_get_async_io", dynlib: librocksdb.} +proc rocksdb_readoptions_set_timestamp*(a1: ptr rocksdb_readoptions_t; ts: cstring; + tslen: csize_t) {.cdecl, + importc: "rocksdb_readoptions_set_timestamp", dynlib: librocksdb.} +proc rocksdb_readoptions_set_iter_start_ts*(a1: ptr rocksdb_readoptions_t; + ts: cstring; tslen: csize_t) {.cdecl, importc: "rocksdb_readoptions_set_iter_start_ts", + dynlib: librocksdb.} +proc rocksdb_readoptions_set_auto_readahead_size*(a1: ptr rocksdb_readoptions_t; + a2: uint8) {.cdecl, importc: "rocksdb_readoptions_set_auto_readahead_size", + dynlib: librocksdb.} +## Write options + +proc rocksdb_writeoptions_create*(): ptr rocksdb_writeoptions_t {.cdecl, + importc: "rocksdb_writeoptions_create", dynlib: librocksdb.} +proc rocksdb_writeoptions_destroy*(a1: ptr rocksdb_writeoptions_t) {.cdecl, + importc: "rocksdb_writeoptions_destroy", dynlib: librocksdb.} +proc rocksdb_writeoptions_set_sync*(a1: ptr rocksdb_writeoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_writeoptions_set_sync", dynlib: librocksdb.} +proc rocksdb_writeoptions_get_sync*(a1: ptr rocksdb_writeoptions_t): uint8 {.cdecl, + importc: "rocksdb_writeoptions_get_sync", dynlib: librocksdb.} +proc rocksdb_writeoptions_disable_WAL*(opt: ptr rocksdb_writeoptions_t; + disable: cint) {.cdecl, + importc: "rocksdb_writeoptions_disable_WAL", dynlib: librocksdb.} +proc rocksdb_writeoptions_get_disable_WAL*(opt: ptr rocksdb_writeoptions_t): uint8 {. + cdecl, importc: "rocksdb_writeoptions_get_disable_WAL", dynlib: librocksdb.} +proc rocksdb_writeoptions_set_ignore_missing_column_families*( + a1: ptr rocksdb_writeoptions_t; a2: uint8) {.cdecl, + importc: "rocksdb_writeoptions_set_ignore_missing_column_families", + dynlib: librocksdb.} +proc rocksdb_writeoptions_get_ignore_missing_column_families*( + a1: ptr rocksdb_writeoptions_t): uint8 {.cdecl, + importc: "rocksdb_writeoptions_get_ignore_missing_column_families", + dynlib: librocksdb.} +proc rocksdb_writeoptions_set_no_slowdown*(a1: ptr rocksdb_writeoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_writeoptions_set_no_slowdown", dynlib: librocksdb.} +proc rocksdb_writeoptions_get_no_slowdown*(a1: ptr rocksdb_writeoptions_t): uint8 {. + cdecl, importc: "rocksdb_writeoptions_get_no_slowdown", dynlib: librocksdb.} +proc rocksdb_writeoptions_set_low_pri*(a1: ptr rocksdb_writeoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_writeoptions_set_low_pri", dynlib: librocksdb.} +proc rocksdb_writeoptions_get_low_pri*(a1: ptr rocksdb_writeoptions_t): uint8 {. + cdecl, importc: "rocksdb_writeoptions_get_low_pri", dynlib: librocksdb.} +proc rocksdb_writeoptions_set_memtable_insert_hint_per_batch*( + a1: ptr rocksdb_writeoptions_t; a2: uint8) {.cdecl, + importc: "rocksdb_writeoptions_set_memtable_insert_hint_per_batch", + dynlib: librocksdb.} +proc rocksdb_writeoptions_get_memtable_insert_hint_per_batch*( + a1: ptr rocksdb_writeoptions_t): uint8 {.cdecl, + importc: "rocksdb_writeoptions_get_memtable_insert_hint_per_batch", + dynlib: librocksdb.} +## Compact range options + +proc rocksdb_compactoptions_create*(): ptr rocksdb_compactoptions_t {.cdecl, + importc: "rocksdb_compactoptions_create", dynlib: librocksdb.} +proc rocksdb_compactoptions_destroy*(a1: ptr rocksdb_compactoptions_t) {.cdecl, + importc: "rocksdb_compactoptions_destroy", dynlib: librocksdb.} +proc rocksdb_compactoptions_set_exclusive_manual_compaction*( + a1: ptr rocksdb_compactoptions_t; a2: uint8) {.cdecl, + importc: "rocksdb_compactoptions_set_exclusive_manual_compaction", + dynlib: librocksdb.} +proc rocksdb_compactoptions_get_exclusive_manual_compaction*( + a1: ptr rocksdb_compactoptions_t): uint8 {.cdecl, + importc: "rocksdb_compactoptions_get_exclusive_manual_compaction", + dynlib: librocksdb.} +proc rocksdb_compactoptions_set_bottommost_level_compaction*( + a1: ptr rocksdb_compactoptions_t; a2: uint8) {.cdecl, + importc: "rocksdb_compactoptions_set_bottommost_level_compaction", + dynlib: librocksdb.} +proc rocksdb_compactoptions_get_bottommost_level_compaction*( + a1: ptr rocksdb_compactoptions_t): uint8 {.cdecl, + importc: "rocksdb_compactoptions_get_bottommost_level_compaction", + dynlib: librocksdb.} +proc rocksdb_compactoptions_set_change_level*(a1: ptr rocksdb_compactoptions_t; + a2: uint8) {.cdecl, importc: "rocksdb_compactoptions_set_change_level", + dynlib: librocksdb.} +proc rocksdb_compactoptions_get_change_level*(a1: ptr rocksdb_compactoptions_t): uint8 {. + cdecl, importc: "rocksdb_compactoptions_get_change_level", dynlib: librocksdb.} +proc rocksdb_compactoptions_set_target_level*(a1: ptr rocksdb_compactoptions_t; + a2: cint) {.cdecl, importc: "rocksdb_compactoptions_set_target_level", + dynlib: librocksdb.} +proc rocksdb_compactoptions_get_target_level*(a1: ptr rocksdb_compactoptions_t): cint {. + cdecl, importc: "rocksdb_compactoptions_get_target_level", dynlib: librocksdb.} +proc rocksdb_compactoptions_set_full_history_ts_low*( + a1: ptr rocksdb_compactoptions_t; ts: cstring; tslen: csize_t) {.cdecl, + importc: "rocksdb_compactoptions_set_full_history_ts_low", dynlib: librocksdb.} +## Flush options + +proc rocksdb_flushoptions_create*(): ptr rocksdb_flushoptions_t {.cdecl, + importc: "rocksdb_flushoptions_create", dynlib: librocksdb.} +proc rocksdb_flushoptions_destroy*(a1: ptr rocksdb_flushoptions_t) {.cdecl, + importc: "rocksdb_flushoptions_destroy", dynlib: librocksdb.} +proc rocksdb_flushoptions_set_wait*(a1: ptr rocksdb_flushoptions_t; a2: uint8) {. + cdecl, importc: "rocksdb_flushoptions_set_wait", dynlib: librocksdb.} +proc rocksdb_flushoptions_get_wait*(a1: ptr rocksdb_flushoptions_t): uint8 {.cdecl, + importc: "rocksdb_flushoptions_get_wait", dynlib: librocksdb.} +## Memory allocator + +proc rocksdb_jemalloc_nodump_allocator_create*(errptr: cstringArray): ptr rocksdb_memory_allocator_t {. + cdecl, importc: "rocksdb_jemalloc_nodump_allocator_create", dynlib: librocksdb.} +proc rocksdb_memory_allocator_destroy*(a1: ptr rocksdb_memory_allocator_t) {.cdecl, + importc: "rocksdb_memory_allocator_destroy", dynlib: librocksdb.} +## Cache + +proc rocksdb_lru_cache_options_create*(): ptr rocksdb_lru_cache_options_t {.cdecl, + importc: "rocksdb_lru_cache_options_create", dynlib: librocksdb.} +proc rocksdb_lru_cache_options_destroy*(a1: ptr rocksdb_lru_cache_options_t) {. + cdecl, importc: "rocksdb_lru_cache_options_destroy", dynlib: librocksdb.} +proc rocksdb_lru_cache_options_set_capacity*(a1: ptr rocksdb_lru_cache_options_t; + a2: csize_t) {.cdecl, importc: "rocksdb_lru_cache_options_set_capacity", + dynlib: librocksdb.} +proc rocksdb_lru_cache_options_set_num_shard_bits*( + a1: ptr rocksdb_lru_cache_options_t; a2: cint) {.cdecl, + importc: "rocksdb_lru_cache_options_set_num_shard_bits", dynlib: librocksdb.} +proc rocksdb_lru_cache_options_set_memory_allocator*( + a1: ptr rocksdb_lru_cache_options_t; a2: ptr rocksdb_memory_allocator_t) {.cdecl, + importc: "rocksdb_lru_cache_options_set_memory_allocator", dynlib: librocksdb.} +proc rocksdb_cache_create_lru*(capacity: csize_t): ptr rocksdb_cache_t {.cdecl, + importc: "rocksdb_cache_create_lru", dynlib: librocksdb.} +proc rocksdb_cache_create_lru_with_strict_capacity_limit*(capacity: csize_t): ptr rocksdb_cache_t {. + cdecl, importc: "rocksdb_cache_create_lru_with_strict_capacity_limit", + dynlib: librocksdb.} +proc rocksdb_cache_create_lru_opts*(a1: ptr rocksdb_lru_cache_options_t): ptr rocksdb_cache_t {. + cdecl, importc: "rocksdb_cache_create_lru_opts", dynlib: librocksdb.} +proc rocksdb_cache_destroy*(cache: ptr rocksdb_cache_t) {.cdecl, + importc: "rocksdb_cache_destroy", dynlib: librocksdb.} +proc rocksdb_cache_disown_data*(cache: ptr rocksdb_cache_t) {.cdecl, + importc: "rocksdb_cache_disown_data", dynlib: librocksdb.} +proc rocksdb_cache_set_capacity*(cache: ptr rocksdb_cache_t; capacity: csize_t) {. + cdecl, importc: "rocksdb_cache_set_capacity", dynlib: librocksdb.} +proc rocksdb_cache_get_capacity*(cache: ptr rocksdb_cache_t): csize_t {.cdecl, + importc: "rocksdb_cache_get_capacity", dynlib: librocksdb.} +proc rocksdb_cache_get_usage*(cache: ptr rocksdb_cache_t): csize_t {.cdecl, + importc: "rocksdb_cache_get_usage", dynlib: librocksdb.} +proc rocksdb_cache_get_pinned_usage*(cache: ptr rocksdb_cache_t): csize_t {.cdecl, + importc: "rocksdb_cache_get_pinned_usage", dynlib: librocksdb.} +proc rocksdb_cache_get_table_address_count*(cache: ptr rocksdb_cache_t): csize_t {. + cdecl, importc: "rocksdb_cache_get_table_address_count", dynlib: librocksdb.} +proc rocksdb_cache_get_occupancy_count*(cache: ptr rocksdb_cache_t): csize_t {.cdecl, + importc: "rocksdb_cache_get_occupancy_count", dynlib: librocksdb.} +## WriteBufferManager + +proc rocksdb_write_buffer_manager_create*(buffer_size: csize_t; allow_stall: bool): ptr rocksdb_write_buffer_manager_t {. + cdecl, importc: "rocksdb_write_buffer_manager_create", dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_create_with_cache*(buffer_size: csize_t; + cache: ptr rocksdb_cache_t; allow_stall: bool): ptr rocksdb_write_buffer_manager_t {. + cdecl, importc: "rocksdb_write_buffer_manager_create_with_cache", + dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_destroy*( + wbm: ptr rocksdb_write_buffer_manager_t) {.cdecl, + importc: "rocksdb_write_buffer_manager_destroy", dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_enabled*( + wbm: ptr rocksdb_write_buffer_manager_t): bool {.cdecl, + importc: "rocksdb_write_buffer_manager_enabled", dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_cost_to_cache*( + wbm: ptr rocksdb_write_buffer_manager_t): bool {.cdecl, + importc: "rocksdb_write_buffer_manager_cost_to_cache", dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_memory_usage*( + wbm: ptr rocksdb_write_buffer_manager_t): csize_t {.cdecl, + importc: "rocksdb_write_buffer_manager_memory_usage", dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_mutable_memtable_memory_usage*( + wbm: ptr rocksdb_write_buffer_manager_t): csize_t {.cdecl, + importc: "rocksdb_write_buffer_manager_mutable_memtable_memory_usage", + dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_dummy_entries_in_cache_usage*( + wbm: ptr rocksdb_write_buffer_manager_t): csize_t {.cdecl, + importc: "rocksdb_write_buffer_manager_dummy_entries_in_cache_usage", + dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_buffer_size*( + wbm: ptr rocksdb_write_buffer_manager_t): csize_t {.cdecl, + importc: "rocksdb_write_buffer_manager_buffer_size", dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_set_buffer_size*( + wbm: ptr rocksdb_write_buffer_manager_t; new_size: csize_t) {.cdecl, + importc: "rocksdb_write_buffer_manager_set_buffer_size", dynlib: librocksdb.} +proc rocksdb_write_buffer_manager_set_allow_stall*( + wbm: ptr rocksdb_write_buffer_manager_t; new_allow_stall: bool) {.cdecl, + importc: "rocksdb_write_buffer_manager_set_allow_stall", dynlib: librocksdb.} +## HyperClockCache + +proc rocksdb_hyper_clock_cache_options_create*(capacity: csize_t; + estimated_entry_charge: csize_t): ptr rocksdb_hyper_clock_cache_options_t {. + cdecl, importc: "rocksdb_hyper_clock_cache_options_create", dynlib: librocksdb.} +proc rocksdb_hyper_clock_cache_options_destroy*( + a1: ptr rocksdb_hyper_clock_cache_options_t) {.cdecl, + importc: "rocksdb_hyper_clock_cache_options_destroy", dynlib: librocksdb.} +proc rocksdb_hyper_clock_cache_options_set_capacity*( + a1: ptr rocksdb_hyper_clock_cache_options_t; a2: csize_t) {.cdecl, + importc: "rocksdb_hyper_clock_cache_options_set_capacity", dynlib: librocksdb.} +proc rocksdb_hyper_clock_cache_options_set_estimated_entry_charge*( + a1: ptr rocksdb_hyper_clock_cache_options_t; a2: csize_t) {.cdecl, + importc: "rocksdb_hyper_clock_cache_options_set_estimated_entry_charge", + dynlib: librocksdb.} +proc rocksdb_hyper_clock_cache_options_set_num_shard_bits*( + a1: ptr rocksdb_hyper_clock_cache_options_t; a2: cint) {.cdecl, + importc: "rocksdb_hyper_clock_cache_options_set_num_shard_bits", + dynlib: librocksdb.} +proc rocksdb_hyper_clock_cache_options_set_memory_allocator*( + a1: ptr rocksdb_hyper_clock_cache_options_t; a2: ptr rocksdb_memory_allocator_t) {. + cdecl, importc: "rocksdb_hyper_clock_cache_options_set_memory_allocator", + dynlib: librocksdb.} +proc rocksdb_cache_create_hyper_clock*(capacity: csize_t; + estimated_entry_charge: csize_t): ptr rocksdb_cache_t {. + cdecl, importc: "rocksdb_cache_create_hyper_clock", dynlib: librocksdb.} +proc rocksdb_cache_create_hyper_clock_opts*( + a1: ptr rocksdb_hyper_clock_cache_options_t): ptr rocksdb_cache_t {.cdecl, + importc: "rocksdb_cache_create_hyper_clock_opts", dynlib: librocksdb.} +## DBPath + +proc rocksdb_dbpath_create*(path: cstring; target_size: uint64): ptr rocksdb_dbpath_t {. + cdecl, importc: "rocksdb_dbpath_create", dynlib: librocksdb.} +proc rocksdb_dbpath_destroy*(a1: ptr rocksdb_dbpath_t) {.cdecl, + importc: "rocksdb_dbpath_destroy", dynlib: librocksdb.} +## Env + +proc rocksdb_create_default_env*(): ptr rocksdb_env_t {.cdecl, + importc: "rocksdb_create_default_env", dynlib: librocksdb.} +proc rocksdb_create_mem_env*(): ptr rocksdb_env_t {.cdecl, + importc: "rocksdb_create_mem_env", dynlib: librocksdb.} +proc rocksdb_env_set_background_threads*(env: ptr rocksdb_env_t; n: cint) {.cdecl, + importc: "rocksdb_env_set_background_threads", dynlib: librocksdb.} +proc rocksdb_env_get_background_threads*(env: ptr rocksdb_env_t): cint {.cdecl, + importc: "rocksdb_env_get_background_threads", dynlib: librocksdb.} +proc rocksdb_env_set_high_priority_background_threads*(env: ptr rocksdb_env_t; + n: cint) {.cdecl, importc: "rocksdb_env_set_high_priority_background_threads", + dynlib: librocksdb.} +proc rocksdb_env_get_high_priority_background_threads*(env: ptr rocksdb_env_t): cint {. + cdecl, importc: "rocksdb_env_get_high_priority_background_threads", + dynlib: librocksdb.} +proc rocksdb_env_set_low_priority_background_threads*(env: ptr rocksdb_env_t; + n: cint) {.cdecl, importc: "rocksdb_env_set_low_priority_background_threads", + dynlib: librocksdb.} +proc rocksdb_env_get_low_priority_background_threads*(env: ptr rocksdb_env_t): cint {. + cdecl, importc: "rocksdb_env_get_low_priority_background_threads", + dynlib: librocksdb.} +proc rocksdb_env_set_bottom_priority_background_threads*(env: ptr rocksdb_env_t; + n: cint) {.cdecl, + importc: "rocksdb_env_set_bottom_priority_background_threads", + dynlib: librocksdb.} +proc rocksdb_env_get_bottom_priority_background_threads*(env: ptr rocksdb_env_t): cint {. + cdecl, importc: "rocksdb_env_get_bottom_priority_background_threads", + dynlib: librocksdb.} +proc rocksdb_env_join_all_threads*(env: ptr rocksdb_env_t) {.cdecl, + importc: "rocksdb_env_join_all_threads", dynlib: librocksdb.} +proc rocksdb_env_lower_thread_pool_io_priority*(env: ptr rocksdb_env_t) {.cdecl, + importc: "rocksdb_env_lower_thread_pool_io_priority", dynlib: librocksdb.} +proc rocksdb_env_lower_high_priority_thread_pool_io_priority*( + env: ptr rocksdb_env_t) {.cdecl, importc: "rocksdb_env_lower_high_priority_thread_pool_io_priority", + dynlib: librocksdb.} +proc rocksdb_env_lower_thread_pool_cpu_priority*(env: ptr rocksdb_env_t) {.cdecl, + importc: "rocksdb_env_lower_thread_pool_cpu_priority", dynlib: librocksdb.} +proc rocksdb_env_lower_high_priority_thread_pool_cpu_priority*( + env: ptr rocksdb_env_t) {.cdecl, importc: "rocksdb_env_lower_high_priority_thread_pool_cpu_priority", + dynlib: librocksdb.} +proc rocksdb_env_destroy*(a1: ptr rocksdb_env_t) {.cdecl, + importc: "rocksdb_env_destroy", dynlib: librocksdb.} +proc rocksdb_envoptions_create*(): ptr rocksdb_envoptions_t {.cdecl, + importc: "rocksdb_envoptions_create", dynlib: librocksdb.} +proc rocksdb_envoptions_destroy*(opt: ptr rocksdb_envoptions_t) {.cdecl, + importc: "rocksdb_envoptions_destroy", dynlib: librocksdb.} +proc rocksdb_create_dir_if_missing*(env: ptr rocksdb_env_t; path: cstring; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_create_dir_if_missing", dynlib: librocksdb.} +## SstFile + +proc rocksdb_sstfilewriter_create*(env: ptr rocksdb_envoptions_t; + io_options: ptr rocksdb_options_t): ptr rocksdb_sstfilewriter_t {. + cdecl, importc: "rocksdb_sstfilewriter_create", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_create_with_comparator*(env: ptr rocksdb_envoptions_t; + io_options: ptr rocksdb_options_t; comparator: ptr rocksdb_comparator_t): ptr rocksdb_sstfilewriter_t {. + cdecl, importc: "rocksdb_sstfilewriter_create_with_comparator", + dynlib: librocksdb.} +proc rocksdb_sstfilewriter_open*(writer: ptr rocksdb_sstfilewriter_t; name: cstring; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_sstfilewriter_open", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_add*(writer: ptr rocksdb_sstfilewriter_t; key: cstring; + keylen: csize_t; val: cstring; vallen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_sstfilewriter_add", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_put*(writer: ptr rocksdb_sstfilewriter_t; key: cstring; + keylen: csize_t; val: cstring; vallen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_sstfilewriter_put", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_put_with_ts*(writer: ptr rocksdb_sstfilewriter_t; + key: cstring; keylen: csize_t; ts: cstring; + tslen: csize_t; val: cstring; + vallen: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_sstfilewriter_put_with_ts", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_merge*(writer: ptr rocksdb_sstfilewriter_t; key: cstring; + keylen: csize_t; val: cstring; vallen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_sstfilewriter_merge", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_delete*(writer: ptr rocksdb_sstfilewriter_t; + key: cstring; keylen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_sstfilewriter_delete", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_delete_with_ts*(writer: ptr rocksdb_sstfilewriter_t; + key: cstring; keylen: csize_t; ts: cstring; tslen: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_sstfilewriter_delete_with_ts", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_delete_range*(writer: ptr rocksdb_sstfilewriter_t; + begin_key: cstring; begin_keylen: csize_t; + end_key: cstring; end_keylen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_sstfilewriter_delete_range", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_finish*(writer: ptr rocksdb_sstfilewriter_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_sstfilewriter_finish", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_file_size*(writer: ptr rocksdb_sstfilewriter_t; + file_size: ptr uint64) {.cdecl, + importc: "rocksdb_sstfilewriter_file_size", dynlib: librocksdb.} +proc rocksdb_sstfilewriter_destroy*(writer: ptr rocksdb_sstfilewriter_t) {.cdecl, + importc: "rocksdb_sstfilewriter_destroy", dynlib: librocksdb.} +proc rocksdb_ingestexternalfileoptions_create*(): ptr rocksdb_ingestexternalfileoptions_t {. + cdecl, importc: "rocksdb_ingestexternalfileoptions_create", dynlib: librocksdb.} +proc rocksdb_ingestexternalfileoptions_set_move_files*( + opt: ptr rocksdb_ingestexternalfileoptions_t; move_files: uint8) {.cdecl, + importc: "rocksdb_ingestexternalfileoptions_set_move_files", + dynlib: librocksdb.} +proc rocksdb_ingestexternalfileoptions_set_snapshot_consistency*( + opt: ptr rocksdb_ingestexternalfileoptions_t; snapshot_consistency: uint8) {. + cdecl, importc: "rocksdb_ingestexternalfileoptions_set_snapshot_consistency", + dynlib: librocksdb.} +proc rocksdb_ingestexternalfileoptions_set_allow_global_seqno*( + opt: ptr rocksdb_ingestexternalfileoptions_t; allow_global_seqno: uint8) {.cdecl, + importc: "rocksdb_ingestexternalfileoptions_set_allow_global_seqno", + dynlib: librocksdb.} +proc rocksdb_ingestexternalfileoptions_set_allow_blocking_flush*( + opt: ptr rocksdb_ingestexternalfileoptions_t; allow_blocking_flush: uint8) {. + cdecl, importc: "rocksdb_ingestexternalfileoptions_set_allow_blocking_flush", + dynlib: librocksdb.} +proc rocksdb_ingestexternalfileoptions_set_ingest_behind*( + opt: ptr rocksdb_ingestexternalfileoptions_t; ingest_behind: uint8) {.cdecl, + importc: "rocksdb_ingestexternalfileoptions_set_ingest_behind", + dynlib: librocksdb.} +proc rocksdb_ingestexternalfileoptions_set_fail_if_not_bottommost_level*( + opt: ptr rocksdb_ingestexternalfileoptions_t; + fail_if_not_bottommost_level: uint8) {.cdecl, importc: "rocksdb_ingestexternalfileoptions_set_fail_if_not_bottommost_level", + dynlib: librocksdb.} +proc rocksdb_ingestexternalfileoptions_destroy*( + opt: ptr rocksdb_ingestexternalfileoptions_t) {.cdecl, + importc: "rocksdb_ingestexternalfileoptions_destroy", dynlib: librocksdb.} +proc rocksdb_ingest_external_file*(db: ptr rocksdb_t; file_list: cstringArray; + list_len: csize_t; + opt: ptr rocksdb_ingestexternalfileoptions_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_ingest_external_file", dynlib: librocksdb.} +proc rocksdb_ingest_external_file_cf*(db: ptr rocksdb_t; handle: ptr rocksdb_column_family_handle_t; + file_list: cstringArray; list_len: csize_t; opt: ptr rocksdb_ingestexternalfileoptions_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_ingest_external_file_cf", dynlib: librocksdb.} +proc rocksdb_try_catch_up_with_primary*(db: ptr rocksdb_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_try_catch_up_with_primary", dynlib: librocksdb.} +## SliceTransform + +proc rocksdb_slicetransform_create*(state: pointer; + destructor: proc (a1: pointer) {.cdecl.}; + transform: proc (a1: pointer; key: cstring; length: csize_t; dst_length: ptr csize_t): cstring {. + cdecl.}; in_domain: proc (a1: pointer; key: cstring; length: csize_t): uint8 {.cdecl.}; + in_range: proc (a1: pointer; key: cstring; length: csize_t): uint8 {.cdecl.}; + name: proc (a1: pointer): cstring {.cdecl.}): ptr rocksdb_slicetransform_t {. + cdecl, importc: "rocksdb_slicetransform_create", dynlib: librocksdb.} +proc rocksdb_slicetransform_create_fixed_prefix*(a1: csize_t): ptr rocksdb_slicetransform_t {. + cdecl, importc: "rocksdb_slicetransform_create_fixed_prefix", + dynlib: librocksdb.} +proc rocksdb_slicetransform_create_noop*(): ptr rocksdb_slicetransform_t {.cdecl, + importc: "rocksdb_slicetransform_create_noop", dynlib: librocksdb.} +proc rocksdb_slicetransform_destroy*(a1: ptr rocksdb_slicetransform_t) {.cdecl, + importc: "rocksdb_slicetransform_destroy", dynlib: librocksdb.} +## Universal Compaction options + +const + rocksdb_similar_size_compaction_stop_style* = 0 + rocksdb_total_size_compaction_stop_style* = 1 + +proc rocksdb_universal_compaction_options_create*(): ptr rocksdb_universal_compaction_options_t {. + cdecl, importc: "rocksdb_universal_compaction_options_create", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_set_size_ratio*( + a1: ptr rocksdb_universal_compaction_options_t; a2: cint) {.cdecl, + importc: "rocksdb_universal_compaction_options_set_size_ratio", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_get_size_ratio*( + a1: ptr rocksdb_universal_compaction_options_t): cint {.cdecl, + importc: "rocksdb_universal_compaction_options_get_size_ratio", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_set_min_merge_width*( + a1: ptr rocksdb_universal_compaction_options_t; a2: cint) {.cdecl, + importc: "rocksdb_universal_compaction_options_set_min_merge_width", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_get_min_merge_width*( + a1: ptr rocksdb_universal_compaction_options_t): cint {.cdecl, + importc: "rocksdb_universal_compaction_options_get_min_merge_width", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_set_max_merge_width*( + a1: ptr rocksdb_universal_compaction_options_t; a2: cint) {.cdecl, + importc: "rocksdb_universal_compaction_options_set_max_merge_width", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_get_max_merge_width*( + a1: ptr rocksdb_universal_compaction_options_t): cint {.cdecl, + importc: "rocksdb_universal_compaction_options_get_max_merge_width", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_set_max_size_amplification_percent*( + a1: ptr rocksdb_universal_compaction_options_t; a2: cint) {.cdecl, importc: "rocksdb_universal_compaction_options_set_max_size_amplification_percent", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_get_max_size_amplification_percent*( + a1: ptr rocksdb_universal_compaction_options_t): cint {.cdecl, importc: "rocksdb_universal_compaction_options_get_max_size_amplification_percent", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_set_compression_size_percent*( + a1: ptr rocksdb_universal_compaction_options_t; a2: cint) {.cdecl, importc: "rocksdb_universal_compaction_options_set_compression_size_percent", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_get_compression_size_percent*( + a1: ptr rocksdb_universal_compaction_options_t): cint {.cdecl, importc: "rocksdb_universal_compaction_options_get_compression_size_percent", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_set_stop_style*( + a1: ptr rocksdb_universal_compaction_options_t; a2: cint) {.cdecl, + importc: "rocksdb_universal_compaction_options_set_stop_style", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_get_stop_style*( + a1: ptr rocksdb_universal_compaction_options_t): cint {.cdecl, + importc: "rocksdb_universal_compaction_options_get_stop_style", + dynlib: librocksdb.} +proc rocksdb_universal_compaction_options_destroy*( + a1: ptr rocksdb_universal_compaction_options_t) {.cdecl, + importc: "rocksdb_universal_compaction_options_destroy", dynlib: librocksdb.} +proc rocksdb_fifo_compaction_options_create*(): ptr rocksdb_fifo_compaction_options_t {. + cdecl, importc: "rocksdb_fifo_compaction_options_create", dynlib: librocksdb.} +proc rocksdb_fifo_compaction_options_set_allow_compaction*( + fifo_opts: ptr rocksdb_fifo_compaction_options_t; allow_compaction: uint8) {. + cdecl, importc: "rocksdb_fifo_compaction_options_set_allow_compaction", + dynlib: librocksdb.} +proc rocksdb_fifo_compaction_options_get_allow_compaction*( + fifo_opts: ptr rocksdb_fifo_compaction_options_t): uint8 {.cdecl, + importc: "rocksdb_fifo_compaction_options_get_allow_compaction", + dynlib: librocksdb.} +proc rocksdb_fifo_compaction_options_set_max_table_files_size*( + fifo_opts: ptr rocksdb_fifo_compaction_options_t; size: uint64) {.cdecl, + importc: "rocksdb_fifo_compaction_options_set_max_table_files_size", + dynlib: librocksdb.} +proc rocksdb_fifo_compaction_options_get_max_table_files_size*( + fifo_opts: ptr rocksdb_fifo_compaction_options_t): uint64 {.cdecl, + importc: "rocksdb_fifo_compaction_options_get_max_table_files_size", + dynlib: librocksdb.} +proc rocksdb_fifo_compaction_options_destroy*( + fifo_opts: ptr rocksdb_fifo_compaction_options_t) {.cdecl, + importc: "rocksdb_fifo_compaction_options_destroy", dynlib: librocksdb.} +proc rocksdb_livefiles_count*(a1: ptr rocksdb_livefiles_t): cint {.cdecl, + importc: "rocksdb_livefiles_count", dynlib: librocksdb.} +proc rocksdb_livefiles_column_family_name*(a1: ptr rocksdb_livefiles_t; index: cint): cstring {. + cdecl, importc: "rocksdb_livefiles_column_family_name", dynlib: librocksdb.} +proc rocksdb_livefiles_name*(a1: ptr rocksdb_livefiles_t; index: cint): cstring {. + cdecl, importc: "rocksdb_livefiles_name", dynlib: librocksdb.} +proc rocksdb_livefiles_level*(a1: ptr rocksdb_livefiles_t; index: cint): cint {.cdecl, + importc: "rocksdb_livefiles_level", dynlib: librocksdb.} +proc rocksdb_livefiles_size*(a1: ptr rocksdb_livefiles_t; index: cint): csize_t {. + cdecl, importc: "rocksdb_livefiles_size", dynlib: librocksdb.} +proc rocksdb_livefiles_smallestkey*(a1: ptr rocksdb_livefiles_t; index: cint; + size: ptr csize_t): cstring {.cdecl, + importc: "rocksdb_livefiles_smallestkey", dynlib: librocksdb.} +proc rocksdb_livefiles_largestkey*(a1: ptr rocksdb_livefiles_t; index: cint; + size: ptr csize_t): cstring {.cdecl, + importc: "rocksdb_livefiles_largestkey", dynlib: librocksdb.} +proc rocksdb_livefiles_entries*(a1: ptr rocksdb_livefiles_t; index: cint): uint64 {. + cdecl, importc: "rocksdb_livefiles_entries", dynlib: librocksdb.} +proc rocksdb_livefiles_deletions*(a1: ptr rocksdb_livefiles_t; index: cint): uint64 {. + cdecl, importc: "rocksdb_livefiles_deletions", dynlib: librocksdb.} +proc rocksdb_livefiles_destroy*(a1: ptr rocksdb_livefiles_t) {.cdecl, + importc: "rocksdb_livefiles_destroy", dynlib: librocksdb.} +## Utility Helpers + +proc rocksdb_get_options_from_string*(base_options: ptr rocksdb_options_t; + opts_str: cstring; + new_options: ptr rocksdb_options_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_get_options_from_string", dynlib: librocksdb.} +proc rocksdb_delete_file_in_range*(db: ptr rocksdb_t; start_key: cstring; + start_key_len: csize_t; limit_key: cstring; + limit_key_len: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_delete_file_in_range", dynlib: librocksdb.} +proc rocksdb_delete_file_in_range_cf*(db: ptr rocksdb_t; column_family: ptr rocksdb_column_family_handle_t; + start_key: cstring; start_key_len: csize_t; + limit_key: cstring; limit_key_len: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_delete_file_in_range_cf", dynlib: librocksdb.} +## MetaData + +proc rocksdb_get_column_family_metadata*(db: ptr rocksdb_t): ptr rocksdb_column_family_metadata_t {. + cdecl, importc: "rocksdb_get_column_family_metadata", dynlib: librocksdb.} +## +## Returns the rocksdb_column_family_metadata_t of the specified +## column family. +## +## Note that the caller is responsible to release the returned memory +## using rocksdb_column_family_metadata_destroy. +## + +proc rocksdb_get_column_family_metadata_cf*(db: ptr rocksdb_t; + column_family: ptr rocksdb_column_family_handle_t): ptr rocksdb_column_family_metadata_t {. + cdecl, importc: "rocksdb_get_column_family_metadata_cf", dynlib: librocksdb.} +proc rocksdb_column_family_metadata_destroy*( + cf_meta: ptr rocksdb_column_family_metadata_t) {.cdecl, + importc: "rocksdb_column_family_metadata_destroy", dynlib: librocksdb.} +proc rocksdb_column_family_metadata_get_size*( + cf_meta: ptr rocksdb_column_family_metadata_t): uint64 {.cdecl, + importc: "rocksdb_column_family_metadata_get_size", dynlib: librocksdb.} +proc rocksdb_column_family_metadata_get_file_count*( + cf_meta: ptr rocksdb_column_family_metadata_t): csize_t {.cdecl, + importc: "rocksdb_column_family_metadata_get_file_count", dynlib: librocksdb.} +proc rocksdb_column_family_metadata_get_name*( + cf_meta: ptr rocksdb_column_family_metadata_t): cstring {.cdecl, + importc: "rocksdb_column_family_metadata_get_name", dynlib: librocksdb.} +proc rocksdb_column_family_metadata_get_level_count*( + cf_meta: ptr rocksdb_column_family_metadata_t): csize_t {.cdecl, + importc: "rocksdb_column_family_metadata_get_level_count", dynlib: librocksdb.} +## +## Returns the rocksdb_level_metadata_t of the ith level from the specified +## column family metadata. +## +## If the specified i is greater than or equal to the number of levels +## in the specified column family, then NULL will be returned. +## +## Note that the caller is responsible to release the returned memory +## using rocksdb_level_metadata_destroy before releasing its parent +## rocksdb_column_family_metadata_t. +## + +proc rocksdb_column_family_metadata_get_level_metadata*( + cf_meta: ptr rocksdb_column_family_metadata_t; i: csize_t): ptr rocksdb_level_metadata_t {. + cdecl, importc: "rocksdb_column_family_metadata_get_level_metadata", + dynlib: librocksdb.} +## +## Releases the specified rocksdb_level_metadata_t. +## +## Note that the specified rocksdb_level_metadata_t must be released +## before the release of its parent rocksdb_column_family_metadata_t. +## + +proc rocksdb_level_metadata_destroy*(level_meta: ptr rocksdb_level_metadata_t) {. + cdecl, importc: "rocksdb_level_metadata_destroy", dynlib: librocksdb.} +proc rocksdb_level_metadata_get_level*(level_meta: ptr rocksdb_level_metadata_t): cint {. + cdecl, importc: "rocksdb_level_metadata_get_level", dynlib: librocksdb.} +proc rocksdb_level_metadata_get_size*(level_meta: ptr rocksdb_level_metadata_t): uint64 {. + cdecl, importc: "rocksdb_level_metadata_get_size", dynlib: librocksdb.} +proc rocksdb_level_metadata_get_file_count*( + level_meta: ptr rocksdb_level_metadata_t): csize_t {.cdecl, + importc: "rocksdb_level_metadata_get_file_count", dynlib: librocksdb.} +## +## Returns the sst_file_metadata_t of the ith file from the specified level +## metadata. +## +## If the specified i is greater than or equal to the number of files +## in the specified level, then NULL will be returned. +## +## Note that the caller is responsible to release the returned memory +## using rocksdb_sst_file_metadata_destroy before releasing its +## parent rocksdb_level_metadata_t. +## + +proc rocksdb_level_metadata_get_sst_file_metadata*( + level_meta: ptr rocksdb_level_metadata_t; i: csize_t): ptr rocksdb_sst_file_metadata_t {. + cdecl, importc: "rocksdb_level_metadata_get_sst_file_metadata", + dynlib: librocksdb.} +## +## Releases the specified rocksdb_sst_file_metadata_t. +## +## Note that the specified rocksdb_sst_file_metadata_t must be released +## before the release of its parent rocksdb_level_metadata_t. +## + +proc rocksdb_sst_file_metadata_destroy*(file_meta: ptr rocksdb_sst_file_metadata_t) {. + cdecl, importc: "rocksdb_sst_file_metadata_destroy", dynlib: librocksdb.} +proc rocksdb_sst_file_metadata_get_relative_filename*( + file_meta: ptr rocksdb_sst_file_metadata_t): cstring {.cdecl, + importc: "rocksdb_sst_file_metadata_get_relative_filename", dynlib: librocksdb.} +proc rocksdb_sst_file_metadata_get_directory*( + file_meta: ptr rocksdb_sst_file_metadata_t): cstring {.cdecl, + importc: "rocksdb_sst_file_metadata_get_directory", dynlib: librocksdb.} +proc rocksdb_sst_file_metadata_get_size*(file_meta: ptr rocksdb_sst_file_metadata_t): uint64 {. + cdecl, importc: "rocksdb_sst_file_metadata_get_size", dynlib: librocksdb.} +## +## Returns the smallest key of the specified sst file. +## The caller is responsible for releasing the returned memory. +## +## @param file_meta the metadata of an SST file to obtain its smallest key. +## @param len the out value which will contain the length of the returned key +## after the function call. +## + +proc rocksdb_sst_file_metadata_get_smallestkey*( + file_meta: ptr rocksdb_sst_file_metadata_t; len: ptr csize_t): cstring {.cdecl, + importc: "rocksdb_sst_file_metadata_get_smallestkey", dynlib: librocksdb.} +## +## Returns the smallest key of the specified sst file. +## The caller is responsible for releasing the returned memory. +## +## @param file_meta the metadata of an SST file to obtain its smallest key. +## @param len the out value which will contain the length of the returned key +## after the function call. +## + +proc rocksdb_sst_file_metadata_get_largestkey*( + file_meta: ptr rocksdb_sst_file_metadata_t; len: ptr csize_t): cstring {.cdecl, + importc: "rocksdb_sst_file_metadata_get_largestkey", dynlib: librocksdb.} +## Transactions + +proc rocksdb_transactiondb_create_column_family*( + txn_db: ptr rocksdb_transactiondb_t; + column_family_options: ptr rocksdb_options_t; column_family_name: cstring; + errptr: cstringArray): ptr rocksdb_column_family_handle_t {.cdecl, + importc: "rocksdb_transactiondb_create_column_family", dynlib: librocksdb.} +proc rocksdb_transactiondb_open*(options: ptr rocksdb_options_t; txn_db_options: ptr rocksdb_transactiondb_options_t; + name: cstring; errptr: cstringArray): ptr rocksdb_transactiondb_t {. + cdecl, importc: "rocksdb_transactiondb_open", dynlib: librocksdb.} +proc rocksdb_transactiondb_open_column_families*(options: ptr rocksdb_options_t; + txn_db_options: ptr rocksdb_transactiondb_options_t; name: cstring; + num_column_families: cint; column_family_names: cstringArray; + column_family_options: ptr ptr rocksdb_options_t; + column_family_handles: ptr ptr rocksdb_column_family_handle_t; + errptr: cstringArray): ptr rocksdb_transactiondb_t {.cdecl, + importc: "rocksdb_transactiondb_open_column_families", dynlib: librocksdb.} +proc rocksdb_transactiondb_create_snapshot*(txn_db: ptr rocksdb_transactiondb_t): ptr rocksdb_snapshot_t {. + cdecl, importc: "rocksdb_transactiondb_create_snapshot", dynlib: librocksdb.} +proc rocksdb_transactiondb_release_snapshot*(txn_db: ptr rocksdb_transactiondb_t; + snapshot: ptr rocksdb_snapshot_t) {.cdecl, importc: "rocksdb_transactiondb_release_snapshot", + dynlib: librocksdb.} +proc rocksdb_transactiondb_property_value*(db: ptr rocksdb_transactiondb_t; + propname: cstring): cstring {.cdecl, + importc: "rocksdb_transactiondb_property_value", + dynlib: librocksdb.} +proc rocksdb_transactiondb_property_int*(db: ptr rocksdb_transactiondb_t; + propname: cstring; out_val: ptr uint64): cint {. + cdecl, importc: "rocksdb_transactiondb_property_int", dynlib: librocksdb.} +proc rocksdb_transactiondb_get_base_db*(txn_db: ptr rocksdb_transactiondb_t): ptr rocksdb_t {. + cdecl, importc: "rocksdb_transactiondb_get_base_db", dynlib: librocksdb.} +proc rocksdb_transactiondb_close_base_db*(base_db: ptr rocksdb_t) {.cdecl, + importc: "rocksdb_transactiondb_close_base_db", dynlib: librocksdb.} +proc rocksdb_transaction_begin*(txn_db: ptr rocksdb_transactiondb_t; + write_options: ptr rocksdb_writeoptions_t; + txn_options: ptr rocksdb_transaction_options_t; + old_txn: ptr rocksdb_transaction_t): ptr rocksdb_transaction_t {. + cdecl, importc: "rocksdb_transaction_begin", dynlib: librocksdb.} +proc rocksdb_transactiondb_get_prepared_transactions*( + txn_db: ptr rocksdb_transactiondb_t; cnt: ptr csize_t): ptr ptr rocksdb_transaction_t {. + cdecl, importc: "rocksdb_transactiondb_get_prepared_transactions", + dynlib: librocksdb.} +proc rocksdb_transaction_set_name*(txn: ptr rocksdb_transaction_t; name: cstring; + name_len: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_set_name", dynlib: librocksdb.} +proc rocksdb_transaction_get_name*(txn: ptr rocksdb_transaction_t; + name_len: ptr csize_t): cstring {.cdecl, + importc: "rocksdb_transaction_get_name", dynlib: librocksdb.} +proc rocksdb_transaction_prepare*(txn: ptr rocksdb_transaction_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_prepare", dynlib: librocksdb.} +proc rocksdb_transaction_commit*(txn: ptr rocksdb_transaction_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_commit", dynlib: librocksdb.} +proc rocksdb_transaction_rollback*(txn: ptr rocksdb_transaction_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_rollback", dynlib: librocksdb.} +proc rocksdb_transaction_set_savepoint*(txn: ptr rocksdb_transaction_t) {.cdecl, + importc: "rocksdb_transaction_set_savepoint", dynlib: librocksdb.} +proc rocksdb_transaction_rollback_to_savepoint*(txn: ptr rocksdb_transaction_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_rollback_to_savepoint", + dynlib: librocksdb.} +proc rocksdb_transaction_destroy*(txn: ptr rocksdb_transaction_t) {.cdecl, + importc: "rocksdb_transaction_destroy", dynlib: librocksdb.} +proc rocksdb_transaction_get_writebatch_wi*(txn: ptr rocksdb_transaction_t): ptr rocksdb_writebatch_wi_t {. + cdecl, importc: "rocksdb_transaction_get_writebatch_wi", dynlib: librocksdb.} +proc rocksdb_transaction_rebuild_from_writebatch*(txn: ptr rocksdb_transaction_t; + writebatch: ptr rocksdb_writebatch_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_rebuild_from_writebatch", dynlib: librocksdb.} +## This rocksdb_writebatch_wi_t should be freed with rocksdb_free + +proc rocksdb_transaction_rebuild_from_writebatch_wi*( + txn: ptr rocksdb_transaction_t; wi: ptr rocksdb_writebatch_wi_t; + errptr: cstringArray) {.cdecl, importc: "rocksdb_transaction_rebuild_from_writebatch_wi", + dynlib: librocksdb.} +proc rocksdb_transaction_set_commit_timestamp*(txn: ptr rocksdb_transaction_t; + commit_timestamp: uint64) {.cdecl, importc: "rocksdb_transaction_set_commit_timestamp", + dynlib: librocksdb.} +proc rocksdb_transaction_set_read_timestamp_for_validation*( + txn: ptr rocksdb_transaction_t; read_timestamp: uint64) {.cdecl, + importc: "rocksdb_transaction_set_read_timestamp_for_validation", + dynlib: librocksdb.} +## This snapshot should be freed using rocksdb_free + +proc rocksdb_transaction_get_snapshot*(txn: ptr rocksdb_transaction_t): ptr rocksdb_snapshot_t {. + cdecl, importc: "rocksdb_transaction_get_snapshot", dynlib: librocksdb.} +proc rocksdb_transaction_get*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; key: cstring; + klen: csize_t; vlen: ptr csize_t; errptr: cstringArray): cstring {. + cdecl, importc: "rocksdb_transaction_get", dynlib: librocksdb.} +proc rocksdb_transaction_get_pinned*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; + key: cstring; klen: csize_t; + errptr: cstringArray): ptr rocksdb_pinnableslice_t {. + cdecl, importc: "rocksdb_transaction_get_pinned", dynlib: librocksdb.} +proc rocksdb_transaction_get_cf*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; vlen: ptr csize_t; + errptr: cstringArray): cstring {.cdecl, + importc: "rocksdb_transaction_get_cf", dynlib: librocksdb.} +proc rocksdb_transaction_get_pinned_cf*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; klen: csize_t; + errptr: cstringArray): ptr rocksdb_pinnableslice_t {. + cdecl, importc: "rocksdb_transaction_get_pinned_cf", dynlib: librocksdb.} +proc rocksdb_transaction_get_for_update*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; + key: cstring; klen: csize_t; + vlen: ptr csize_t; exclusive: uint8; + errptr: cstringArray): cstring {.cdecl, + importc: "rocksdb_transaction_get_for_update", dynlib: librocksdb.} +proc rocksdb_transaction_get_pinned_for_update*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; key: cstring; klen: csize_t; exclusive: uint8; + errptr: cstringArray): ptr rocksdb_pinnableslice_t {.cdecl, + importc: "rocksdb_transaction_get_pinned_for_update", dynlib: librocksdb.} +proc rocksdb_transaction_get_for_update_cf*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; klen: csize_t; + vlen: ptr csize_t; exclusive: uint8; errptr: cstringArray): cstring {.cdecl, + importc: "rocksdb_transaction_get_for_update_cf", dynlib: librocksdb.} +proc rocksdb_transaction_get_pinned_for_update_cf*( + txn: ptr rocksdb_transaction_t; options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; klen: csize_t; + exclusive: uint8; errptr: cstringArray): ptr rocksdb_pinnableslice_t {.cdecl, + importc: "rocksdb_transaction_get_pinned_for_update_cf", dynlib: librocksdb.} +proc rocksdb_transaction_multi_get*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; + num_keys: csize_t; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; + values_list: cstringArray; + values_list_sizes: ptr csize_t; + errs: cstringArray) {.cdecl, + importc: "rocksdb_transaction_multi_get", dynlib: librocksdb.} +proc rocksdb_transaction_multi_get_for_update*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; num_keys: csize_t; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; values_list: cstringArray; + values_list_sizes: ptr csize_t; errs: cstringArray) {.cdecl, + importc: "rocksdb_transaction_multi_get_for_update", dynlib: librocksdb.} +proc rocksdb_transaction_multi_get_cf*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; + column_families: ptr ptr rocksdb_column_family_handle_t; num_keys: csize_t; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t; + values_list: cstringArray; + values_list_sizes: ptr csize_t; + errs: cstringArray) {.cdecl, + importc: "rocksdb_transaction_multi_get_cf", dynlib: librocksdb.} +proc rocksdb_transaction_multi_get_for_update_cf*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; + column_families: ptr ptr rocksdb_column_family_handle_t; num_keys: csize_t; + keys_list: cstringArray; keys_list_sizes: ptr csize_t; values_list: cstringArray; + values_list_sizes: ptr csize_t; errs: cstringArray) {.cdecl, + importc: "rocksdb_transaction_multi_get_for_update_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_get*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_readoptions_t; key: cstring; + klen: csize_t; vlen: ptr csize_t; errptr: cstringArray): cstring {. + cdecl, importc: "rocksdb_transactiondb_get", dynlib: librocksdb.} +proc rocksdb_transactiondb_get_pinned*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_readoptions_t; + key: cstring; klen: csize_t; + errptr: cstringArray): ptr rocksdb_pinnableslice_t {. + cdecl, importc: "rocksdb_transactiondb_get_pinned", dynlib: librocksdb.} +proc rocksdb_transactiondb_get_cf*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_readoptions_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; + vallen: ptr csize_t; errptr: cstringArray): cstring {. + cdecl, importc: "rocksdb_transactiondb_get_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_get_pinned_cf*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; + errptr: cstringArray): ptr rocksdb_pinnableslice_t {.cdecl, + importc: "rocksdb_transactiondb_get_pinned_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_multi_get*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_readoptions_t; + num_keys: csize_t; keys_list: cstringArray; + keys_list_sizes: ptr csize_t; + values_list: cstringArray; + values_list_sizes: ptr csize_t; + errs: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_multi_get", dynlib: librocksdb.} +proc rocksdb_transactiondb_multi_get_cf*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_readoptions_t; + column_families: ptr ptr rocksdb_column_family_handle_t; num_keys: csize_t; + keys_list: cstringArray; + keys_list_sizes: ptr csize_t; + values_list: cstringArray; + values_list_sizes: ptr csize_t; + errs: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_multi_get_cf", dynlib: librocksdb.} +proc rocksdb_transaction_put*(txn: ptr rocksdb_transaction_t; key: cstring; + klen: csize_t; val: cstring; vlen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_put", dynlib: librocksdb.} +proc rocksdb_transaction_put_cf*(txn: ptr rocksdb_transaction_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; val: cstring; + vlen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_put_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_put*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_writeoptions_t; key: cstring; + klen: csize_t; val: cstring; vlen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_put", dynlib: librocksdb.} +proc rocksdb_transactiondb_put_cf*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; + val: cstring; vallen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_put_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_write*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_writeoptions_t; + batch: ptr rocksdb_writebatch_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_write", dynlib: librocksdb.} +proc rocksdb_transaction_merge*(txn: ptr rocksdb_transaction_t; key: cstring; + klen: csize_t; val: cstring; vlen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_merge", dynlib: librocksdb.} +proc rocksdb_transaction_merge_cf*(txn: ptr rocksdb_transaction_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; val: cstring; + vlen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_merge_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_merge*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_writeoptions_t; key: cstring; + klen: csize_t; val: cstring; vlen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_merge", dynlib: librocksdb.} +proc rocksdb_transactiondb_merge_cf*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; klen: csize_t; + val: cstring; vlen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_merge_cf", dynlib: librocksdb.} +proc rocksdb_transaction_delete*(txn: ptr rocksdb_transaction_t; key: cstring; + klen: csize_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_transaction_delete", dynlib: librocksdb.} +proc rocksdb_transaction_delete_cf*(txn: ptr rocksdb_transaction_t; column_family: ptr rocksdb_column_family_handle_t; + key: cstring; klen: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_transaction_delete_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_delete*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_writeoptions_t; + key: cstring; klen: csize_t; errptr: cstringArray) {. + cdecl, importc: "rocksdb_transactiondb_delete", dynlib: librocksdb.} +proc rocksdb_transactiondb_delete_cf*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_writeoptions_t; + column_family: ptr rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_delete_cf", dynlib: librocksdb.} +proc rocksdb_transaction_create_iterator*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t): ptr rocksdb_iterator_t {.cdecl, + importc: "rocksdb_transaction_create_iterator", dynlib: librocksdb.} +proc rocksdb_transaction_create_iterator_cf*(txn: ptr rocksdb_transaction_t; + options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t): ptr rocksdb_iterator_t {. + cdecl, importc: "rocksdb_transaction_create_iterator_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_create_iterator*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_readoptions_t): ptr rocksdb_iterator_t {.cdecl, + importc: "rocksdb_transactiondb_create_iterator", dynlib: librocksdb.} +proc rocksdb_transactiondb_create_iterator_cf*( + txn_db: ptr rocksdb_transactiondb_t; options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t): ptr rocksdb_iterator_t {. + cdecl, importc: "rocksdb_transactiondb_create_iterator_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_close*(txn_db: ptr rocksdb_transactiondb_t) {.cdecl, + importc: "rocksdb_transactiondb_close", dynlib: librocksdb.} +proc rocksdb_transactiondb_flush*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_flushoptions_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_flush", dynlib: librocksdb.} +proc rocksdb_transactiondb_flush_cf*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_flushoptions_t; + column_family: ptr rocksdb_column_family_handle_t; errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_flush_cf", dynlib: librocksdb.} +proc rocksdb_transactiondb_flush_cfs*(txn_db: ptr rocksdb_transactiondb_t; + options: ptr rocksdb_flushoptions_t; + column_families: ptr ptr rocksdb_column_family_handle_t; + num_column_families: cint; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_flush_cfs", dynlib: librocksdb.} +proc rocksdb_transactiondb_flush_wal*(txn_db: ptr rocksdb_transactiondb_t; + sync: uint8; errptr: cstringArray) {.cdecl, + importc: "rocksdb_transactiondb_flush_wal", dynlib: librocksdb.} +proc rocksdb_transactiondb_checkpoint_object_create*( + txn_db: ptr rocksdb_transactiondb_t; errptr: cstringArray): ptr rocksdb_checkpoint_t {. + cdecl, importc: "rocksdb_transactiondb_checkpoint_object_create", + dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_open*(options: ptr rocksdb_options_t; + name: cstring; errptr: cstringArray): ptr rocksdb_optimistictransactiondb_t {. + cdecl, importc: "rocksdb_optimistictransactiondb_open", dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_open_column_families*( + options: ptr rocksdb_options_t; name: cstring; num_column_families: cint; + column_family_names: cstringArray; + column_family_options: ptr ptr rocksdb_options_t; + column_family_handles: ptr ptr rocksdb_column_family_handle_t; + errptr: cstringArray): ptr rocksdb_optimistictransactiondb_t {.cdecl, + importc: "rocksdb_optimistictransactiondb_open_column_families", + dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_get_base_db*( + otxn_db: ptr rocksdb_optimistictransactiondb_t): ptr rocksdb_t {.cdecl, + importc: "rocksdb_optimistictransactiondb_get_base_db", dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_close_base_db*(base_db: ptr rocksdb_t) {.cdecl, + importc: "rocksdb_optimistictransactiondb_close_base_db", dynlib: librocksdb.} +proc rocksdb_optimistictransaction_begin*( + otxn_db: ptr rocksdb_optimistictransactiondb_t; + write_options: ptr rocksdb_writeoptions_t; + otxn_options: ptr rocksdb_optimistictransaction_options_t; + old_txn: ptr rocksdb_transaction_t): ptr rocksdb_transaction_t {.cdecl, + importc: "rocksdb_optimistictransaction_begin", dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_write*( + otxn_db: ptr rocksdb_optimistictransactiondb_t; + options: ptr rocksdb_writeoptions_t; batch: ptr rocksdb_writebatch_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_optimistictransactiondb_write", + dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_close*( + otxn_db: ptr rocksdb_optimistictransactiondb_t) {.cdecl, + importc: "rocksdb_optimistictransactiondb_close", dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_checkpoint_object_create*( + otxn_db: ptr rocksdb_optimistictransactiondb_t; errptr: cstringArray): ptr rocksdb_checkpoint_t {. + cdecl, importc: "rocksdb_optimistictransactiondb_checkpoint_object_create", + dynlib: librocksdb.} +## Transaction Options + +proc rocksdb_transactiondb_options_create*(): ptr rocksdb_transactiondb_options_t {. + cdecl, importc: "rocksdb_transactiondb_options_create", dynlib: librocksdb.} +proc rocksdb_transactiondb_options_destroy*( + opt: ptr rocksdb_transactiondb_options_t) {.cdecl, + importc: "rocksdb_transactiondb_options_destroy", dynlib: librocksdb.} +proc rocksdb_transactiondb_options_set_max_num_locks*( + opt: ptr rocksdb_transactiondb_options_t; max_num_locks: int64) {.cdecl, + importc: "rocksdb_transactiondb_options_set_max_num_locks", dynlib: librocksdb.} +proc rocksdb_transactiondb_options_set_num_stripes*( + opt: ptr rocksdb_transactiondb_options_t; num_stripes: csize_t) {.cdecl, + importc: "rocksdb_transactiondb_options_set_num_stripes", dynlib: librocksdb.} +proc rocksdb_transactiondb_options_set_transaction_lock_timeout*( + opt: ptr rocksdb_transactiondb_options_t; txn_lock_timeout: int64) {.cdecl, + importc: "rocksdb_transactiondb_options_set_transaction_lock_timeout", + dynlib: librocksdb.} +proc rocksdb_transactiondb_options_set_default_lock_timeout*( + opt: ptr rocksdb_transactiondb_options_t; default_lock_timeout: int64) {.cdecl, + importc: "rocksdb_transactiondb_options_set_default_lock_timeout", + dynlib: librocksdb.} +proc rocksdb_transaction_options_create*(): ptr rocksdb_transaction_options_t {. + cdecl, importc: "rocksdb_transaction_options_create", dynlib: librocksdb.} +proc rocksdb_transaction_options_destroy*(opt: ptr rocksdb_transaction_options_t) {. + cdecl, importc: "rocksdb_transaction_options_destroy", dynlib: librocksdb.} +proc rocksdb_transaction_options_set_set_snapshot*( + opt: ptr rocksdb_transaction_options_t; v: uint8) {.cdecl, + importc: "rocksdb_transaction_options_set_set_snapshot", dynlib: librocksdb.} +proc rocksdb_transaction_options_set_deadlock_detect*( + opt: ptr rocksdb_transaction_options_t; v: uint8) {.cdecl, + importc: "rocksdb_transaction_options_set_deadlock_detect", dynlib: librocksdb.} +proc rocksdb_transaction_options_set_lock_timeout*( + opt: ptr rocksdb_transaction_options_t; lock_timeout: int64) {.cdecl, + importc: "rocksdb_transaction_options_set_lock_timeout", dynlib: librocksdb.} +proc rocksdb_transaction_options_set_expiration*( + opt: ptr rocksdb_transaction_options_t; expiration: int64) {.cdecl, + importc: "rocksdb_transaction_options_set_expiration", dynlib: librocksdb.} +proc rocksdb_transaction_options_set_deadlock_detect_depth*( + opt: ptr rocksdb_transaction_options_t; depth: int64) {.cdecl, + importc: "rocksdb_transaction_options_set_deadlock_detect_depth", + dynlib: librocksdb.} +proc rocksdb_transaction_options_set_max_write_batch_size*( + opt: ptr rocksdb_transaction_options_t; size: csize_t) {.cdecl, + importc: "rocksdb_transaction_options_set_max_write_batch_size", + dynlib: librocksdb.} +proc rocksdb_transaction_options_set_skip_prepare*( + opt: ptr rocksdb_transaction_options_t; v: uint8) {.cdecl, + importc: "rocksdb_transaction_options_set_skip_prepare", dynlib: librocksdb.} +proc rocksdb_optimistictransaction_options_create*(): ptr rocksdb_optimistictransaction_options_t {. + cdecl, importc: "rocksdb_optimistictransaction_options_create", + dynlib: librocksdb.} +proc rocksdb_optimistictransaction_options_destroy*( + opt: ptr rocksdb_optimistictransaction_options_t) {.cdecl, + importc: "rocksdb_optimistictransaction_options_destroy", dynlib: librocksdb.} +proc rocksdb_optimistictransaction_options_set_set_snapshot*( + opt: ptr rocksdb_optimistictransaction_options_t; v: uint8) {.cdecl, + importc: "rocksdb_optimistictransaction_options_set_set_snapshot", + dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_property_value*( + db: ptr rocksdb_optimistictransactiondb_t; propname: cstring): cstring {.cdecl, + importc: "rocksdb_optimistictransactiondb_property_value", dynlib: librocksdb.} +proc rocksdb_optimistictransactiondb_property_int*( + db: ptr rocksdb_optimistictransactiondb_t; propname: cstring; out_val: ptr uint64): cint {. + cdecl, importc: "rocksdb_optimistictransactiondb_property_int", + dynlib: librocksdb.} +## referring to convention (3), this should be used by client +## to free memory that was malloc()ed + +proc rocksdb_free*(`ptr`: pointer) {.cdecl, importc: "rocksdb_free", + dynlib: librocksdb.} +proc rocksdb_get_pinned*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; + key: cstring; keylen: csize_t; errptr: cstringArray): ptr rocksdb_pinnableslice_t {. + cdecl, importc: "rocksdb_get_pinned", dynlib: librocksdb.} +proc rocksdb_get_pinned_cf*(db: ptr rocksdb_t; options: ptr rocksdb_readoptions_t; + column_family: ptr rocksdb_column_family_handle_t; + key: cstring; keylen: csize_t; errptr: cstringArray): ptr rocksdb_pinnableslice_t {. + cdecl, importc: "rocksdb_get_pinned_cf", dynlib: librocksdb.} +proc rocksdb_pinnableslice_destroy*(v: ptr rocksdb_pinnableslice_t) {.cdecl, + importc: "rocksdb_pinnableslice_destroy", dynlib: librocksdb.} +proc rocksdb_pinnableslice_value*(t: ptr rocksdb_pinnableslice_t; vlen: ptr csize_t): cstring {. + cdecl, importc: "rocksdb_pinnableslice_value", dynlib: librocksdb.} +proc rocksdb_memory_consumers_create*(): ptr rocksdb_memory_consumers_t {.cdecl, + importc: "rocksdb_memory_consumers_create", dynlib: librocksdb.} +proc rocksdb_memory_consumers_add_db*(consumers: ptr rocksdb_memory_consumers_t; + db: ptr rocksdb_t) {.cdecl, + importc: "rocksdb_memory_consumers_add_db", dynlib: librocksdb.} +proc rocksdb_memory_consumers_add_cache*(consumers: ptr rocksdb_memory_consumers_t; + cache: ptr rocksdb_cache_t) {.cdecl, + importc: "rocksdb_memory_consumers_add_cache", dynlib: librocksdb.} +proc rocksdb_memory_consumers_destroy*(consumers: ptr rocksdb_memory_consumers_t) {. + cdecl, importc: "rocksdb_memory_consumers_destroy", dynlib: librocksdb.} +proc rocksdb_approximate_memory_usage_create*( + consumers: ptr rocksdb_memory_consumers_t; errptr: cstringArray): ptr rocksdb_memory_usage_t {. + cdecl, importc: "rocksdb_approximate_memory_usage_create", dynlib: librocksdb.} +proc rocksdb_approximate_memory_usage_destroy*(usage: ptr rocksdb_memory_usage_t) {. + cdecl, importc: "rocksdb_approximate_memory_usage_destroy", dynlib: librocksdb.} +proc rocksdb_approximate_memory_usage_get_mem_table_total*( + memory_usage: ptr rocksdb_memory_usage_t): uint64 {.cdecl, + importc: "rocksdb_approximate_memory_usage_get_mem_table_total", + dynlib: librocksdb.} +proc rocksdb_approximate_memory_usage_get_mem_table_unflushed*( + memory_usage: ptr rocksdb_memory_usage_t): uint64 {.cdecl, + importc: "rocksdb_approximate_memory_usage_get_mem_table_unflushed", + dynlib: librocksdb.} +proc rocksdb_approximate_memory_usage_get_mem_table_readers_total*( + memory_usage: ptr rocksdb_memory_usage_t): uint64 {.cdecl, + importc: "rocksdb_approximate_memory_usage_get_mem_table_readers_total", + dynlib: librocksdb.} +proc rocksdb_approximate_memory_usage_get_cache_total*( + memory_usage: ptr rocksdb_memory_usage_t): uint64 {.cdecl, + importc: "rocksdb_approximate_memory_usage_get_cache_total", + dynlib: librocksdb.} +proc rocksdb_options_set_dump_malloc_stats*(a1: ptr rocksdb_options_t; a2: uint8) {. + cdecl, importc: "rocksdb_options_set_dump_malloc_stats", dynlib: librocksdb.} +proc rocksdb_options_set_memtable_whole_key_filtering*(a1: ptr rocksdb_options_t; + a2: uint8) {.cdecl, + importc: "rocksdb_options_set_memtable_whole_key_filtering", + dynlib: librocksdb.} +proc rocksdb_cancel_all_background_work*(db: ptr rocksdb_t; wait: uint8) {.cdecl, + importc: "rocksdb_cancel_all_background_work", dynlib: librocksdb.} +proc rocksdb_disable_manual_compaction*(db: ptr rocksdb_t) {.cdecl, + importc: "rocksdb_disable_manual_compaction", dynlib: librocksdb.} +proc rocksdb_enable_manual_compaction*(db: ptr rocksdb_t) {.cdecl, + importc: "rocksdb_enable_manual_compaction", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_create*(): ptr rocksdb_statistics_histogram_data_t {. + cdecl, importc: "rocksdb_statistics_histogram_data_create", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_destroy*( + data: ptr rocksdb_statistics_histogram_data_t) {.cdecl, + importc: "rocksdb_statistics_histogram_data_destroy", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_median*( + data: ptr rocksdb_statistics_histogram_data_t): cdouble {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_median", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_p95*( + data: ptr rocksdb_statistics_histogram_data_t): cdouble {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_p95", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_p99*( + data: ptr rocksdb_statistics_histogram_data_t): cdouble {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_p99", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_average*( + data: ptr rocksdb_statistics_histogram_data_t): cdouble {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_average", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_std_dev*( + data: ptr rocksdb_statistics_histogram_data_t): cdouble {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_std_dev", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_max*( + data: ptr rocksdb_statistics_histogram_data_t): cdouble {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_max", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_count*( + data: ptr rocksdb_statistics_histogram_data_t): uint64 {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_count", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_sum*( + data: ptr rocksdb_statistics_histogram_data_t): uint64 {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_sum", dynlib: librocksdb.} +proc rocksdb_statistics_histogram_data_get_min*( + data: ptr rocksdb_statistics_histogram_data_t): cdouble {.cdecl, + importc: "rocksdb_statistics_histogram_data_get_min", dynlib: librocksdb.} +proc rocksdb_wait_for_compact*(db: ptr rocksdb_t; + options: ptr rocksdb_wait_for_compact_options_t; + errptr: cstringArray) {.cdecl, + importc: "rocksdb_wait_for_compact", dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_create*(): ptr rocksdb_wait_for_compact_options_t {. + cdecl, importc: "rocksdb_wait_for_compact_options_create", dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_destroy*( + opt: ptr rocksdb_wait_for_compact_options_t) {.cdecl, + importc: "rocksdb_wait_for_compact_options_destroy", dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_set_abort_on_pause*( + opt: ptr rocksdb_wait_for_compact_options_t; v: uint8) {.cdecl, + importc: "rocksdb_wait_for_compact_options_set_abort_on_pause", + dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_get_abort_on_pause*( + opt: ptr rocksdb_wait_for_compact_options_t): uint8 {.cdecl, + importc: "rocksdb_wait_for_compact_options_get_abort_on_pause", + dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_set_flush*( + opt: ptr rocksdb_wait_for_compact_options_t; v: uint8) {.cdecl, + importc: "rocksdb_wait_for_compact_options_set_flush", dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_get_flush*( + opt: ptr rocksdb_wait_for_compact_options_t): uint8 {.cdecl, + importc: "rocksdb_wait_for_compact_options_get_flush", dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_set_close_db*( + opt: ptr rocksdb_wait_for_compact_options_t; v: uint8) {.cdecl, + importc: "rocksdb_wait_for_compact_options_set_close_db", dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_get_close_db*( + opt: ptr rocksdb_wait_for_compact_options_t): uint8 {.cdecl, + importc: "rocksdb_wait_for_compact_options_get_close_db", dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_set_timeout*( + opt: ptr rocksdb_wait_for_compact_options_t; microseconds: uint64) {.cdecl, + importc: "rocksdb_wait_for_compact_options_set_timeout", dynlib: librocksdb.} +proc rocksdb_wait_for_compact_options_get_timeout*( + opt: ptr rocksdb_wait_for_compact_options_t): uint64 {.cdecl, + importc: "rocksdb_wait_for_compact_options_get_timeout", dynlib: librocksdb.} \ No newline at end of file diff --git a/rocksdb/librocksdb.nim b/rocksdb/librocksdb.nim deleted file mode 100644 index f087784..0000000 --- a/rocksdb/librocksdb.nim +++ /dev/null @@ -1,1111 +0,0 @@ -# Copyright 2018-2022 Status Research & Development GmbH -# Licensed under either of -# -# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) -# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) -# -# at your option. This file may not be copied, modified, or distributed except according to those terms. - -# Nim-RocksDB is a wrapper for Facebook's RocksDB -# RocksDB License -# Copyright (c) 2011-present, Facebook, Inc. All rights reserved. -# Source code can be found at https://github.com/facebook/rocksdb -# under both the GPLv2 (found in the COPYING file in the RocksDB root directory) and Apache 2.0 License -# (found in the LICENSE.Apache file in the RocksDB root directory). - -# RocksDB is derived work of LevelDB -# LevelDB License -# Copyright (c) 2011 The LevelDB Authors. All rights reserved. -# Source code can be found at https://github.com/google/leveldb -# Use of this source code is governed by a BSD-style license that can be -# found in the LevelDB LICENSE file. See the AUTHORS file for names of contributors. - -## This file exposes the low-level C API of RocksDB - -{.push raises: [].} - -when defined(windows): - const librocksdb = "librocksdb(|_lite).dll" -elif defined(macosx): - const librocksdb = "librocksdb(|_lite).dylib" -else: - # TODO linking to just the .so file here is wrong: - # * soname of library is librocksdb.so.X.Y, indicating that ABI compatibility - # is kept for patches only, and may break for minor versions - # * linking like this makes the wrapper swallow any ABI version that the user - # happens to have installed when running the application - notably this may - # be completely different from what the developer used when writing the - # wrapper - # * with good luck, the above will lead to crashes that are hard to diagnose - # with bad luck, it will be exploited as a security hole - # * Fedora28 for example ships with soname librocksdb.so.5.7 while Ubuntu - # 14.04 (what travis uses at the time of writing) comes with 4.5! - const librocksdb = "librocksdb(|_lite).so" -## Exported types - -proc shouldUseNativeLinking(): bool {.compileTime.} = - when defined(linux): - return true - -const LibrocksbStaticArgs {.strdefine.}: string = "" - -template rocksType(T) = - type T* = distinct pointer - proc isNil*(v: T): bool {.borrow, gcsafe.} - -rocksType rocksdb_t -rocksType rocksdb_backup_engine_t -rocksType rocksdb_backup_engine_info_t -rocksType rocksdb_restore_options_t -rocksType rocksdb_cache_t -rocksType rocksdb_compactionfilter_t -rocksType rocksdb_compactionfiltercontext_t -rocksType rocksdb_compactionfilterfactory_t -rocksType rocksdb_comparator_t -rocksType rocksdb_dbpath_t -rocksType rocksdb_env_t -rocksType rocksdb_fifo_compaction_options_t -rocksType rocksdb_filelock_t -rocksType rocksdb_filterpolicy_t -rocksType rocksdb_flushoptions_t -rocksType rocksdb_iterator_t -rocksType rocksdb_logger_t -rocksType rocksdb_mergeoperator_t -rocksType rocksdb_options_t -rocksType rocksdb_compactoptions_t -rocksType rocksdb_block_based_table_options_t -rocksType rocksdb_cuckoo_table_options_t -rocksType rocksdb_randomfile_t -rocksType rocksdb_readoptions_t -rocksType rocksdb_seqfile_t -rocksType rocksdb_slicetransform_t -rocksType rocksdb_snapshot_t -rocksType rocksdb_writablefile_t -rocksType rocksdb_writebatch_t -rocksType rocksdb_writebatch_wi_t -rocksType rocksdb_writeoptions_t -rocksType rocksdb_universal_compaction_options_t -rocksType rocksdb_livefiles_t -rocksType rocksdb_column_family_handle_t -rocksType rocksdb_envoptions_t -rocksType rocksdb_ingestexternalfileoptions_t -rocksType rocksdb_sstfilewriter_t -rocksType rocksdb_ratelimiter_t -rocksType rocksdb_pinnableslice_t -rocksType rocksdb_transactiondb_options_t -rocksType rocksdb_transactiondb_t -rocksType rocksdb_transaction_options_t -rocksType rocksdb_optimistictransactiondb_t -rocksType rocksdb_optimistictransaction_options_t -rocksType rocksdb_transaction_t -rocksType rocksdb_checkpoint_t - -## DB operations -when LibrocksbStaticArgs != "": - {.pragma: importrocks, importc, cdecl.} - {.passL: LibrocksbStaticArgs.} - when defined(windows): - {.passL: "-lshlwapi -lrpcrt4".} -else: - when shouldUseNativeLinking(): - {.pragma: importrocks, importc, cdecl.} - {.passL: "-lrocksdb".} - else: - {.pragma: importrocks, importc, cdecl, dynlib: librocksdb.} - -proc rocksdb_open*(options: rocksdb_options_t; name: cstring; errptr: ptr cstring): rocksdb_t {.importrocks.} -proc rocksdb_open_for_read_only*(options: rocksdb_options_t; name: cstring; - error_if_log_file_exist: uint8; - errptr: ptr cstring): rocksdb_t {.importrocks.} -proc rocksdb_backup_engine_open*(options: rocksdb_options_t; path: cstring; - errptr: ptr cstring): rocksdb_backup_engine_t {.importrocks.} -proc rocksdb_backup_engine_create_new_backup*(be: rocksdb_backup_engine_t; - db: rocksdb_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_backup_engine_purge_old_backups*(be: rocksdb_backup_engine_t; - num_backups_to_keep: uint32; errptr: ptr cstring) {.importrocks.} -proc rocksdb_restore_options_create*(): rocksdb_restore_options_t {.importrocks.} -proc rocksdb_restore_options_destroy*(opt: rocksdb_restore_options_t) {.importrocks.} -proc rocksdb_restore_options_set_keep_log_files*( - opt: rocksdb_restore_options_t; v: cint) {.importrocks.} -proc rocksdb_backup_engine_restore_db_from_latest_backup*( - be: rocksdb_backup_engine_t; db_dir: cstring; wal_dir: cstring; - restore_options: rocksdb_restore_options_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_backup_engine_get_backup_info*(be: rocksdb_backup_engine_t): rocksdb_backup_engine_info_t {.importrocks.} -proc rocksdb_backup_engine_info_count*(info: rocksdb_backup_engine_info_t): cint {.importrocks.} -proc rocksdb_backup_engine_info_timestamp*( - info: rocksdb_backup_engine_info_t; index: cint): int64 {.importrocks.} -proc rocksdb_backup_engine_info_backup_id*( - info: rocksdb_backup_engine_info_t; index: cint): uint32 {.importrocks.} -proc rocksdb_backup_engine_info_size*(info: rocksdb_backup_engine_info_t; - index: cint): uint64 {.importrocks.} -proc rocksdb_backup_engine_info_number_files*( - info: rocksdb_backup_engine_info_t; index: cint): uint32 {.importrocks.} -proc rocksdb_backup_engine_info_destroy*(info: rocksdb_backup_engine_info_t) {.importrocks.} -proc rocksdb_backup_engine_close*(be: rocksdb_backup_engine_t) {.importrocks.} -proc rocksdb_checkpoint_object_create*(db: rocksdb_t; errptr: ptr cstring): rocksdb_checkpoint_t {.importrocks.} -proc rocksdb_checkpoint_create*(checkpoint: rocksdb_checkpoint_t; - checkpoint_dir: cstring; - log_size_for_flush: uint64; errptr: ptr cstring) {.importrocks.} -proc rocksdb_checkpoint_object_destroy*(checkpoint: rocksdb_checkpoint_t) {.importrocks.} -proc rocksdb_open_column_families*(options: rocksdb_options_t; name: cstring; - num_column_families: cint; - column_family_names: cstringArray; - column_family_options: ptr rocksdb_options_t; column_family_handles: ptr rocksdb_column_family_handle_t; - errptr: ptr cstring): rocksdb_t {.importrocks.} -proc rocksdb_open_for_read_only_column_families*(options: rocksdb_options_t; - name: cstring; num_column_families: cint; column_family_names: cstringArray; - column_family_options: ptr rocksdb_options_t; - column_family_handles: ptr rocksdb_column_family_handle_t; - error_if_log_file_exist: uint8; errptr: ptr cstring): rocksdb_t {.importrocks.} -proc rocksdb_list_column_families*(options: rocksdb_options_t; name: cstring; - lencf: ptr csize_t; errptr: ptr cstring): cstringArray {.importrocks.} -proc rocksdb_list_column_families_destroy*(list: cstringArray; len: csize_t) {.importrocks.} -proc rocksdb_create_column_family*(db: rocksdb_t; - column_family_options: rocksdb_options_t; - column_family_name: cstring; - errptr: ptr cstring): rocksdb_column_family_handle_t {.importrocks.} -proc rocksdb_drop_column_family*(db: rocksdb_t; - handle: rocksdb_column_family_handle_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_column_family_handle_destroy*(a2: rocksdb_column_family_handle_t) {.importrocks.} -proc rocksdb_close*(db: rocksdb_t) {.importrocks.} -proc rocksdb_put*(db: rocksdb_t; options: rocksdb_writeoptions_t; key: cstring; - keylen: csize_t; val: cstring; vallen: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_put_cf*(db: rocksdb_t; options: rocksdb_writeoptions_t; - column_family: rocksdb_column_family_handle_t; - key: cstring; keylen: csize_t; val: cstring; vallen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_delete*(db: rocksdb_t; options: rocksdb_writeoptions_t; - key: cstring; keylen: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_delete_cf*(db: rocksdb_t; options: rocksdb_writeoptions_t; - column_family: rocksdb_column_family_handle_t; - key: cstring; keylen: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_merge*(db: rocksdb_t; options: rocksdb_writeoptions_t; - key: cstring; keylen: csize_t; val: cstring; vallen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_merge_cf*(db: rocksdb_t; options: rocksdb_writeoptions_t; - column_family: rocksdb_column_family_handle_t; - key: cstring; keylen: csize_t; val: cstring; vallen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_write*(db: rocksdb_t; options: rocksdb_writeoptions_t; - batch: rocksdb_writebatch_t; errptr: ptr cstring) {.importrocks.} -## Returns NULL if not found. A malloc()ed array otherwise. -## Stores the length of the array in *vallen. - -proc rocksdb_get*(db: rocksdb_t; options: rocksdb_readoptions_t; key: cstring; - keylen: csize_t; vallen: ptr csize_t; errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_get_cf*(db: rocksdb_t; options: rocksdb_readoptions_t; - column_family: rocksdb_column_family_handle_t; - key: cstring; keylen: csize_t; vallen: ptr csize_t; - errptr: ptr cstring): cstring {.importrocks.} -## if values_list[i] == NULL and errs[i] == NULL, -## then we got status.IsNotFound(), which we will not return. -## all errors except status status.ok() and status.IsNotFound() are returned. -## -## errs, values_list and values_list_sizes must be num_keys in length, -## allocated by the caller. -## errs is a list of strings as opposed to the conventional one error, -## where errs[i] is the status for retrieval of keys_list[i]. -## each non-NULL errs entry is a malloc()ed, null terminated string. -## each non-NULL values_list entry is a malloc()ed array, with -## the length for each stored in values_list_sizes[i]. - -proc rocksdb_multi_get*(db: rocksdb_t; options: rocksdb_readoptions_t; - num_keys: csize_t; keys_list: cstringArray; - keys_list_sizes: ptr csize_t; values_list: cstringArray; - values_list_sizes: ptr csize_t; errs: cstringArray) {.importrocks.} -proc rocksdb_multi_get_cf*(db: rocksdb_t; options: rocksdb_readoptions_t; - column_families: ptr rocksdb_column_family_handle_t; num_keys: csize_t; - keys_list: cstringArray; keys_list_sizes: ptr csize_t; - values_list: cstringArray; values_list_sizes: ptr csize_t; - errs: cstringArray) {.importrocks.} -proc rocksdb_create_iterator*(db: rocksdb_t; options: rocksdb_readoptions_t): rocksdb_iterator_t {.importrocks.} -proc rocksdb_create_iterator_cf*(db: rocksdb_t; - options: rocksdb_readoptions_t; column_family: rocksdb_column_family_handle_t): rocksdb_iterator_t {.importrocks.} -proc rocksdb_create_iterators*(db: rocksdb_t; opts: rocksdb_readoptions_t; - column_families: ptr rocksdb_column_family_handle_t; - iterators: ptr rocksdb_iterator_t; size: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_create_snapshot*(db: rocksdb_t): rocksdb_snapshot_t {.importrocks.} -proc rocksdb_release_snapshot*(db: rocksdb_t; snapshot: rocksdb_snapshot_t) {.importrocks.} -## Returns NULL if property name is unknown. -## Else returns a pointer to a malloc()-ed null-terminated value. - -proc rocksdb_property_value*(db: rocksdb_t; propname: cstring): cstring {.importrocks.} -## returns 0 on success, -1 otherwise - -proc rocksdb_property_int*(db: rocksdb_t; propname: cstring; out_val: ptr uint64): cint {.importrocks.} -proc rocksdb_property_value_cf*(db: rocksdb_t; column_family: rocksdb_column_family_handle_t; - propname: cstring): cstring {.importrocks.} -proc rocksdb_approximate_sizes*(db: rocksdb_t; num_ranges: cint; - range_start_key: cstringArray; - range_start_key_len: ptr csize_t; - range_limit_key: cstringArray; - range_limit_key_len: ptr csize_t; sizes: ptr uint64) {.importrocks.} -proc rocksdb_approximate_sizes_cf*(db: rocksdb_t; column_family: rocksdb_column_family_handle_t; - num_ranges: cint; range_start_key: cstringArray; - range_start_key_len: ptr csize_t; - range_limit_key: cstringArray; - range_limit_key_len: ptr csize_t; sizes: ptr uint64) {.importrocks.} -proc rocksdb_compact_range*(db: rocksdb_t; start_key: cstring; - start_key_len: csize_t; limit_key: cstring; - limit_key_len: csize_t) {.importrocks.} -proc rocksdb_compact_range_cf*(db: rocksdb_t; column_family: rocksdb_column_family_handle_t; - start_key: cstring; start_key_len: csize_t; - limit_key: cstring; limit_key_len: csize_t) {.importrocks.} -proc rocksdb_compact_range_opt*(db: rocksdb_t; - opt: rocksdb_compactoptions_t; - start_key: cstring; start_key_len: csize_t; - limit_key: cstring; limit_key_len: csize_t) {.importrocks.} -proc rocksdb_compact_range_cf_opt*(db: rocksdb_t; column_family: rocksdb_column_family_handle_t; - opt: rocksdb_compactoptions_t; - start_key: cstring; start_key_len: csize_t; - limit_key: cstring; limit_key_len: csize_t) {.importrocks.} -proc rocksdb_delete_file*(db: rocksdb_t; name: cstring) {.importrocks.} -proc rocksdb_livefiles*(db: rocksdb_t): rocksdb_livefiles_t {.importrocks.} -proc rocksdb_flush*(db: rocksdb_t; options: rocksdb_flushoptions_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_disable_file_deletions*(db: rocksdb_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_enable_file_deletions*(db: rocksdb_t; force: uint8; - errptr: ptr cstring) {.importrocks.} -## Management operations - -proc rocksdb_destroy_db*(options: rocksdb_options_t; name: cstring; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_repair_db*(options: rocksdb_options_t; name: cstring; - errptr: ptr cstring) {.importrocks.} -## Iterator - -proc rocksdb_iter_destroy*(a2: rocksdb_iterator_t) {.importrocks.} -proc rocksdb_iter_valid*(a2: rocksdb_iterator_t): uint8 {.importrocks.} -proc rocksdb_iter_seek_to_first*(a2: rocksdb_iterator_t) {.importrocks.} -proc rocksdb_iter_seek_to_last*(a2: rocksdb_iterator_t) {.importrocks.} -proc rocksdb_iter_seek*(a2: rocksdb_iterator_t; k: cstring; klen: csize_t) {.importrocks.} -proc rocksdb_iter_seek_for_prev*(a2: rocksdb_iterator_t; k: cstring; klen: csize_t) {.importrocks.} -proc rocksdb_iter_next*(a2: rocksdb_iterator_t) {.importrocks.} -proc rocksdb_iter_prev*(a2: rocksdb_iterator_t) {.importrocks.} -proc rocksdb_iter_key*(a2: rocksdb_iterator_t; klen: ptr csize_t): cstring {.importrocks.} -proc rocksdb_iter_value*(a2: rocksdb_iterator_t; vlen: ptr csize_t): cstring {.importrocks.} -proc rocksdb_iter_get_error*(a2: rocksdb_iterator_t; errptr: ptr cstring) {.importrocks.} -## Write batch - -proc rocksdb_writebatch_create*(): rocksdb_writebatch_t {.importrocks.} -proc rocksdb_writebatch_create_from*(rep: cstring; size: csize_t): rocksdb_writebatch_t {.importrocks.} -proc rocksdb_writebatch_destroy*(a2: rocksdb_writebatch_t) {.importrocks.} -proc rocksdb_writebatch_clear*(a2: rocksdb_writebatch_t) {.importrocks.} -proc rocksdb_writebatch_count*(a2: rocksdb_writebatch_t): cint {.importrocks.} -proc rocksdb_writebatch_put*(a2: rocksdb_writebatch_t; key: cstring; klen: csize_t; - val: cstring; vlen: csize_t) {.importrocks.} -proc rocksdb_writebatch_put_cf*(a2: rocksdb_writebatch_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t; val: cstring; vlen: csize_t) {.importrocks.} -proc rocksdb_writebatch_putv*(b: rocksdb_writebatch_t; num_keys: cint; - keys_list: cstringArray; keys_list_sizes: ptr csize_t; - num_values: cint; values_list: cstringArray; - values_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_putv_cf*(b: rocksdb_writebatch_t; column_family: rocksdb_column_family_handle_t; - num_keys: cint; keys_list: cstringArray; - keys_list_sizes: ptr csize_t; num_values: cint; - values_list: cstringArray; - values_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_merge*(a2: rocksdb_writebatch_t; key: cstring; - klen: csize_t; val: cstring; vlen: csize_t) {.importrocks.} -proc rocksdb_writebatch_merge_cf*(a2: rocksdb_writebatch_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t; val: cstring; vlen: csize_t) {.importrocks.} -proc rocksdb_writebatch_mergev*(b: rocksdb_writebatch_t; num_keys: cint; - keys_list: cstringArray; - keys_list_sizes: ptr csize_t; num_values: cint; - values_list: cstringArray; - values_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_mergev_cf*(b: rocksdb_writebatch_t; column_family: rocksdb_column_family_handle_t; - num_keys: cint; keys_list: cstringArray; - keys_list_sizes: ptr csize_t; num_values: cint; - values_list: cstringArray; - values_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_delete*(a2: rocksdb_writebatch_t; key: cstring; - klen: csize_t) {.importrocks.} -proc rocksdb_writebatch_delete_cf*(a2: rocksdb_writebatch_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t) {.importrocks.} -proc rocksdb_writebatch_deletev*(b: rocksdb_writebatch_t; num_keys: cint; - keys_list: cstringArray; - keys_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_deletev_cf*(b: rocksdb_writebatch_t; column_family: rocksdb_column_family_handle_t; - num_keys: cint; keys_list: cstringArray; - keys_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_delete_range*(b: rocksdb_writebatch_t; - start_key: cstring; start_key_len: csize_t; - end_key: cstring; end_key_len: csize_t) {.importrocks.} -proc rocksdb_writebatch_delete_range_cf*(b: rocksdb_writebatch_t; column_family: rocksdb_column_family_handle_t; - start_key: cstring; start_key_len: csize_t; - end_key: cstring; end_key_len: csize_t) {.importrocks.} -proc rocksdb_writebatch_delete_rangev*(b: rocksdb_writebatch_t; num_keys: cint; - start_keys_list: cstringArray; - start_keys_list_sizes: ptr csize_t; - end_keys_list: cstringArray; - end_keys_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_delete_rangev_cf*(b: rocksdb_writebatch_t; - column_family: rocksdb_column_family_handle_t; num_keys: cint; - start_keys_list: cstringArray; start_keys_list_sizes: ptr csize_t; - end_keys_list: cstringArray; end_keys_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_put_log_data*(a2: rocksdb_writebatch_t; blob: cstring; - len: csize_t) {.importrocks.} -proc rocksdb_writebatch_iterate*(a2: rocksdb_writebatch_t; state: pointer; put: proc ( - a2: pointer; k: cstring; klen: csize_t; v: cstring; vlen: csize_t) {.cdecl.}; deleted: proc ( - a2: pointer; k: cstring; klen: csize_t) {.cdecl.}) {.importrocks.} -proc rocksdb_writebatch_data*(a2: rocksdb_writebatch_t; size: ptr csize_t): cstring {.importrocks.} -proc rocksdb_writebatch_set_save_point*(a2: rocksdb_writebatch_t) {.importrocks.} -proc rocksdb_writebatch_rollback_to_save_point*(a2: rocksdb_writebatch_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_writebatch_pop_save_point*(a2: rocksdb_writebatch_t; - errptr: ptr cstring) {.importrocks.} -## Write batch with index - -proc rocksdb_writebatch_wi_create*(reserved_bytes: csize_t; overwrite_keys: uint8): rocksdb_writebatch_wi_t {.importrocks.} -proc rocksdb_writebatch_wi_create_from*(rep: cstring; size: csize_t): rocksdb_writebatch_wi_t {.importrocks.} -proc rocksdb_writebatch_wi_destroy*(a2: rocksdb_writebatch_wi_t) {.importrocks.} -proc rocksdb_writebatch_wi_clear*(a2: rocksdb_writebatch_wi_t) {.importrocks.} -proc rocksdb_writebatch_wi_count*(b: rocksdb_writebatch_wi_t): cint {.importrocks.} -proc rocksdb_writebatch_wi_put*(a2: rocksdb_writebatch_wi_t; key: cstring; - klen: csize_t; val: cstring; vlen: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_put_cf*(a2: rocksdb_writebatch_wi_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t; val: cstring; vlen: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_putv*(b: rocksdb_writebatch_wi_t; num_keys: cint; - keys_list: cstringArray; - keys_list_sizes: ptr csize_t; num_values: cint; - values_list: cstringArray; - values_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_putv_cf*(b: rocksdb_writebatch_wi_t; column_family: rocksdb_column_family_handle_t; - num_keys: cint; keys_list: cstringArray; - keys_list_sizes: ptr csize_t; num_values: cint; - values_list: cstringArray; - values_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_merge*(a2: rocksdb_writebatch_wi_t; key: cstring; - klen: csize_t; val: cstring; vlen: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_merge_cf*(a2: rocksdb_writebatch_wi_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t; val: cstring; - vlen: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_mergev*(b: rocksdb_writebatch_wi_t; num_keys: cint; - keys_list: cstringArray; - keys_list_sizes: ptr csize_t; num_values: cint; - values_list: cstringArray; - values_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_mergev_cf*(b: rocksdb_writebatch_wi_t; column_family: rocksdb_column_family_handle_t; - num_keys: cint; keys_list: cstringArray; - keys_list_sizes: ptr csize_t; num_values: cint; - values_list: cstringArray; - values_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_delete*(a2: rocksdb_writebatch_wi_t; key: cstring; - klen: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_delete_cf*(a2: rocksdb_writebatch_wi_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_deletev*(b: rocksdb_writebatch_wi_t; num_keys: cint; - keys_list: cstringArray; - keys_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_deletev_cf*(b: rocksdb_writebatch_wi_t; column_family: rocksdb_column_family_handle_t; - num_keys: cint; keys_list: cstringArray; - keys_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_delete_range*(b: rocksdb_writebatch_wi_t; - start_key: cstring; start_key_len: csize_t; - end_key: cstring; end_key_len: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_delete_range_cf*(b: rocksdb_writebatch_wi_t; - column_family: rocksdb_column_family_handle_t; start_key: cstring; - start_key_len: csize_t; end_key: cstring; end_key_len: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_delete_rangev*(b: rocksdb_writebatch_wi_t; - num_keys: cint; start_keys_list: cstringArray; start_keys_list_sizes: ptr csize_t; - end_keys_list: cstringArray; end_keys_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_delete_rangev_cf*(b: rocksdb_writebatch_wi_t; - column_family: rocksdb_column_family_handle_t; num_keys: cint; - start_keys_list: cstringArray; start_keys_list_sizes: ptr csize_t; - end_keys_list: cstringArray; end_keys_list_sizes: ptr csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_put_log_data*(a2: rocksdb_writebatch_wi_t; - blob: cstring; len: csize_t) {.importrocks.} -proc rocksdb_writebatch_wi_iterate*(b: rocksdb_writebatch_wi_t; state: pointer; - put: proc (a2: pointer; k: cstring; klen: csize_t; v: cstring; vlen: csize_t) {.cdecl.}; - deleted: proc (a2: pointer; k: cstring; klen: csize_t) {.cdecl.}) {.importrocks.} -proc rocksdb_writebatch_wi_data*(b: rocksdb_writebatch_wi_t; size: ptr csize_t): cstring {.importrocks.} -proc rocksdb_writebatch_wi_set_save_point*(a2: rocksdb_writebatch_wi_t) {.importrocks.} -proc rocksdb_writebatch_wi_rollback_to_save_point*( - a2: rocksdb_writebatch_wi_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_writebatch_wi_get_from_batch*(wbwi: rocksdb_writebatch_wi_t; - options: rocksdb_options_t; key: cstring; keylen: csize_t; vallen: ptr csize_t; - errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_writebatch_wi_get_from_batch_cf*(wbwi: rocksdb_writebatch_wi_t; - options: rocksdb_options_t; - column_family: rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; - vallen: ptr csize_t; errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_writebatch_wi_get_from_batch_and_db*( - wbwi: rocksdb_writebatch_wi_t; db: rocksdb_t; - options: rocksdb_readoptions_t; key: cstring; keylen: csize_t; vallen: ptr csize_t; - errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_writebatch_wi_get_from_batch_and_db_cf*( - wbwi: rocksdb_writebatch_wi_t; db: rocksdb_t; - options: rocksdb_readoptions_t; - column_family: rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; - vallen: ptr csize_t; errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_write_writebatch_wi*(db: rocksdb_t; - options: rocksdb_writeoptions_t; - wbwi: rocksdb_writebatch_wi_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_writebatch_wi_create_iterator_with_base*( - wbwi: rocksdb_writebatch_wi_t; base_iterator: rocksdb_iterator_t): rocksdb_iterator_t {.importrocks.} -proc rocksdb_writebatch_wi_create_iterator_with_base_cf*( - wbwi: rocksdb_writebatch_wi_t; base_iterator: rocksdb_iterator_t; - cf: rocksdb_column_family_handle_t): rocksdb_iterator_t {.importrocks.} -## Block based table options - -proc rocksdb_block_based_options_create*(): rocksdb_block_based_table_options_t {.importrocks.} -proc rocksdb_block_based_options_destroy*( - options: rocksdb_block_based_table_options_t) {.importrocks.} -proc rocksdb_block_based_options_set_block_size*( - options: rocksdb_block_based_table_options_t; block_size: csize_t) {.importrocks.} -proc rocksdb_block_based_options_set_block_size_deviation*( - options: rocksdb_block_based_table_options_t; block_size_deviation: cint) {.importrocks.} -proc rocksdb_block_based_options_set_block_restart_interval*( - options: rocksdb_block_based_table_options_t; block_restart_interval: cint) {.importrocks.} -proc rocksdb_block_based_options_set_index_block_restart_interval*( - options: rocksdb_block_based_table_options_t; - index_block_restart_interval: cint) {.importrocks.} -proc rocksdb_block_based_options_set_metadata_block_size*( - options: rocksdb_block_based_table_options_t; metadata_block_size: uint64) {.importrocks.} -proc rocksdb_block_based_options_set_partition_filters*( - options: rocksdb_block_based_table_options_t; partition_filters: uint8) {.importrocks.} -proc rocksdb_block_based_options_set_use_delta_encoding*( - options: rocksdb_block_based_table_options_t; use_delta_encoding: uint8) {.importrocks.} -proc rocksdb_block_based_options_set_filter_policy*( - options: rocksdb_block_based_table_options_t; - filter_policy: rocksdb_filterpolicy_t) {.importrocks.} -proc rocksdb_block_based_options_set_no_block_cache*( - options: rocksdb_block_based_table_options_t; no_block_cache: uint8) {.importrocks.} -proc rocksdb_block_based_options_set_block_cache*( - options: rocksdb_block_based_table_options_t; - block_cache: rocksdb_cache_t) {.importrocks.} -proc rocksdb_block_based_options_set_block_cache_compressed*( - options: rocksdb_block_based_table_options_t; - block_cache_compressed: rocksdb_cache_t) {.importrocks.} -proc rocksdb_block_based_options_set_whole_key_filtering*( - a2: rocksdb_block_based_table_options_t; a3: uint8) {.importrocks.} -proc rocksdb_block_based_options_set_format_version*( - a2: rocksdb_block_based_table_options_t; a3: cint) {.importrocks.} -const - rocksdb_block_based_table_index_type_binary_search* = 0 - rocksdb_block_based_table_index_type_hash_search* = 1 - rocksdb_block_based_table_index_type_two_level_index_search* = 2 - -proc rocksdb_block_based_options_set_index_type*( - a2: rocksdb_block_based_table_options_t; a3: cint) {.importrocks.} -## uses one of the above enums - -proc rocksdb_block_based_options_set_hash_index_allow_collision*( - a2: rocksdb_block_based_table_options_t; a3: uint8) {.importrocks.} -proc rocksdb_block_based_options_set_cache_index_and_filter_blocks*( - a2: rocksdb_block_based_table_options_t; a3: uint8) {.importrocks.} -proc rocksdb_block_based_options_set_cache_index_and_filter_blocks_with_high_priority*( - a2: rocksdb_block_based_table_options_t; a3: uint8) {.importrocks.} -proc rocksdb_block_based_options_set_pin_l0_filter_and_index_blocks_in_cache*( - a2: rocksdb_block_based_table_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_block_based_table_factory*(opt: rocksdb_options_t; - table_options: rocksdb_block_based_table_options_t) {.importrocks.} -## Cuckoo table options - -proc rocksdb_cuckoo_options_create*(): rocksdb_cuckoo_table_options_t {.importrocks.} -proc rocksdb_cuckoo_options_destroy*(options: rocksdb_cuckoo_table_options_t) {.importrocks.} -proc rocksdb_cuckoo_options_set_hash_ratio*( - options: rocksdb_cuckoo_table_options_t; v: cdouble) {.importrocks.} -proc rocksdb_cuckoo_options_set_max_search_depth*( - options: rocksdb_cuckoo_table_options_t; v: uint32) {.importrocks.} -proc rocksdb_cuckoo_options_set_cuckoo_block_size*( - options: rocksdb_cuckoo_table_options_t; v: uint32) {.importrocks.} -proc rocksdb_cuckoo_options_set_identity_as_first_hash*( - options: rocksdb_cuckoo_table_options_t; v: uint8) {.importrocks.} -proc rocksdb_cuckoo_options_set_use_module_hash*( - options: rocksdb_cuckoo_table_options_t; v: uint8) {.importrocks.} -proc rocksdb_options_set_cuckoo_table_factory*(opt: rocksdb_options_t; - table_options: rocksdb_cuckoo_table_options_t) {.importrocks.} -## Options - -proc rocksdb_set_options*(db: rocksdb_t; count: cint; keys: ptr cstring; - values: ptr cstring; errptr: ptr cstring) {.importrocks.} -proc rocksdb_options_create*(): rocksdb_options_t {.importrocks.} -proc rocksdb_options_destroy*(a2: rocksdb_options_t) {.importrocks.} -proc rocksdb_options_increase_parallelism*(opt: rocksdb_options_t; - total_threads: cint) {.importrocks.} -proc rocksdb_options_optimize_for_point_lookup*(opt: rocksdb_options_t; - block_cache_size_mb: uint64) {.importrocks.} -proc rocksdb_options_optimize_level_style_compaction*(opt: rocksdb_options_t; - memtable_memory_budget: uint64) {.importrocks.} -proc rocksdb_options_optimize_universal_style_compaction*( - opt: rocksdb_options_t; memtable_memory_budget: uint64) {.importrocks.} -proc rocksdb_options_set_allow_ingest_behind*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_compaction_filter*(a2: rocksdb_options_t; - a3: rocksdb_compactionfilter_t) {.importrocks.} -proc rocksdb_options_set_compaction_filter_factory*(a2: rocksdb_options_t; - a3: rocksdb_compactionfilterfactory_t) {.importrocks.} -proc rocksdb_options_compaction_readahead_size*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_comparator*(a2: rocksdb_options_t; - a3: rocksdb_comparator_t) {.importrocks.} -proc rocksdb_options_set_merge_operator*(a2: rocksdb_options_t; - a3: rocksdb_mergeoperator_t) {.importrocks.} -proc rocksdb_options_set_uint64add_merge_operator*(a2: rocksdb_options_t) {.importrocks.} -proc rocksdb_options_set_compression_per_level*(opt: rocksdb_options_t; - level_values: ptr cint; num_levels: csize_t) {.importrocks.} -proc rocksdb_options_set_create_if_missing*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_create_missing_column_families*( - a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_error_if_exists*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_paranoid_checks*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_db_paths*(a2: rocksdb_options_t; - path_values: ptr rocksdb_dbpath_t; - num_paths: csize_t) {.importrocks.} -proc rocksdb_options_set_env*(a2: rocksdb_options_t; a3: rocksdb_env_t) {.importrocks.} -proc rocksdb_options_set_info_log*(a2: rocksdb_options_t; - a3: rocksdb_logger_t) {.importrocks.} -proc rocksdb_options_set_info_log_level*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_write_buffer_size*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_db_write_buffer_size*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_max_open_files*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_max_file_opening_threads*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_max_total_wal_size*(opt: rocksdb_options_t; n: uint64) {.importrocks.} -proc rocksdb_options_set_compression_options*(a2: rocksdb_options_t; a3: cint; - a4: cint; a5: cint; a6: cint) {.importrocks.} -proc rocksdb_options_set_prefix_extractor*(a2: rocksdb_options_t; - a3: rocksdb_slicetransform_t) {.importrocks.} -proc rocksdb_options_set_num_levels*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_level0_file_num_compaction_trigger*( - a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_level0_slowdown_writes_trigger*( - a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_level0_stop_writes_trigger*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_max_mem_compaction_level*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_target_file_size_base*(a2: rocksdb_options_t; - a3: uint64) {.importrocks.} -proc rocksdb_options_set_target_file_size_multiplier*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_max_bytes_for_level_base*(a2: rocksdb_options_t; - a3: uint64) {.importrocks.} -proc rocksdb_options_set_level_compaction_dynamic_level_bytes*( - a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_max_bytes_for_level_multiplier*( - a2: rocksdb_options_t; a3: cdouble) {.importrocks.} -proc rocksdb_options_set_max_bytes_for_level_multiplier_additional*( - a2: rocksdb_options_t; level_values: ptr cint; num_levels: csize_t) {.importrocks.} -proc rocksdb_options_enable_statistics*(a2: rocksdb_options_t) {.importrocks.} -proc rocksdb_options_set_skip_stats_update_on_db_open*( - opt: rocksdb_options_t; val: uint8) {.importrocks.} -## returns a pointer to a malloc()-ed, null terminated string - -proc rocksdb_options_statistics_get_string*(opt: rocksdb_options_t): cstring {.importrocks.} -proc rocksdb_options_set_max_write_buffer_number*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_min_write_buffer_number_to_merge*( - a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_max_write_buffer_number_to_maintain*( - a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_max_background_compactions*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_base_background_compactions*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_max_background_flushes*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_max_log_file_size*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_log_file_time_to_roll*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_keep_log_file_num*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_recycle_log_file_num*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_soft_rate_limit*(a2: rocksdb_options_t; a3: cdouble) {.importrocks.} -proc rocksdb_options_set_hard_rate_limit*(a2: rocksdb_options_t; a3: cdouble) {.importrocks.} -proc rocksdb_options_set_soft_pending_compaction_bytes_limit*( - opt: rocksdb_options_t; v: csize_t) {.importrocks.} -proc rocksdb_options_set_hard_pending_compaction_bytes_limit*( - opt: rocksdb_options_t; v: csize_t) {.importrocks.} -proc rocksdb_options_set_rate_limit_delay_max_milliseconds*( - a2: rocksdb_options_t; a3: cuint) {.importrocks.} -proc rocksdb_options_set_max_manifest_file_size*(a2: rocksdb_options_t; - a3: csize_t) {.importrocks.} -proc rocksdb_options_set_table_cache_numshardbits*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_table_cache_remove_scan_count_limit*( - a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_arena_block_size*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_use_fsync*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_db_log_dir*(a2: rocksdb_options_t; a3: cstring) {.importrocks.} -proc rocksdb_options_set_wal_dir*(a2: rocksdb_options_t; a3: cstring) {.importrocks.} -proc rocksdb_options_set_WAL_ttl_seconds*(a2: rocksdb_options_t; a3: uint64) {.importrocks.} -proc rocksdb_options_set_WAL_size_limit_MB*(a2: rocksdb_options_t; a3: uint64) {.importrocks.} -proc rocksdb_options_set_manifest_preallocation_size*(a2: rocksdb_options_t; - a3: csize_t) {.importrocks.} -proc rocksdb_options_set_purge_redundant_kvs_while_flush*( - a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_allow_mmap_reads*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_allow_mmap_writes*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_use_direct_reads*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_use_direct_io_for_flush_and_compaction*( - a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_is_fd_close_on_exec*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_skip_log_error_on_recovery*(a2: rocksdb_options_t; - a3: uint8) {.importrocks.} -proc rocksdb_options_set_stats_dump_period_sec*(a2: rocksdb_options_t; a3: cuint) {.importrocks.} -proc rocksdb_options_set_advise_random_on_open*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_access_hint_on_compaction_start*( - a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_use_adaptive_mutex*(a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_bytes_per_sync*(a2: rocksdb_options_t; a3: uint64) {.importrocks.} -proc rocksdb_options_set_wal_bytes_per_sync*(a2: rocksdb_options_t; a3: uint64) {.importrocks.} -proc rocksdb_options_set_writable_file_max_buffer_size*( - a2: rocksdb_options_t; a3: uint64) {.importrocks.} -proc rocksdb_options_set_allow_concurrent_memtable_write*( - a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_enable_write_thread_adaptive_yield*( - a2: rocksdb_options_t; a3: uint8) {.importrocks.} -proc rocksdb_options_set_max_sequential_skip_in_iterations*( - a2: rocksdb_options_t; a3: uint64) {.importrocks.} -proc rocksdb_options_set_disable_auto_compactions*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_optimize_filters_for_hits*(a2: rocksdb_options_t; - a3: cint) {.importrocks.} -proc rocksdb_options_set_delete_obsolete_files_period_micros*( - a2: rocksdb_options_t; a3: uint64) {.importrocks.} -proc rocksdb_options_prepare_for_bulk_load*(a2: rocksdb_options_t) {.importrocks.} -proc rocksdb_options_set_memtable_vector_rep*(a2: rocksdb_options_t) {.importrocks.} -proc rocksdb_options_set_memtable_prefix_bloom_size_ratio*( - a2: rocksdb_options_t; a3: cdouble) {.importrocks.} -proc rocksdb_options_set_max_compaction_bytes*(a2: rocksdb_options_t; a3: uint64) {.importrocks.} -proc rocksdb_options_set_hash_skip_list_rep*(a2: rocksdb_options_t; a3: csize_t; - a4: int32; a5: int32) {.importrocks.} -proc rocksdb_options_set_hash_link_list_rep*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_plain_table_factory*(a2: rocksdb_options_t; a3: uint32; - a4: cint; a5: cdouble; a6: csize_t) {.importrocks.} -proc rocksdb_options_set_min_level_to_compress*(opt: rocksdb_options_t; - level: cint) {.importrocks.} -proc rocksdb_options_set_memtable_huge_page_size*(a2: rocksdb_options_t; - a3: csize_t) {.importrocks.} -proc rocksdb_options_set_max_successive_merges*(a2: rocksdb_options_t; a3: csize_t) {.importrocks.} -proc rocksdb_options_set_bloom_locality*(a2: rocksdb_options_t; a3: uint32) {.importrocks.} -proc rocksdb_options_set_inplace_update_support*(a2: rocksdb_options_t; - a3: uint8) {.importrocks.} -proc rocksdb_options_set_inplace_update_num_locks*(a2: rocksdb_options_t; - a3: csize_t) {.importrocks.} -proc rocksdb_options_set_report_bg_io_stats*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -const - rocksdb_tolerate_corrupted_tail_records_recovery* = 0 - rocksdb_absolute_consistency_recovery* = 1 - rocksdb_point_in_time_recovery* = 2 - rocksdb_skip_any_corrupted_records_recovery* = 3 - -proc rocksdb_options_set_wal_recovery_mode*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -const - rocksdb_no_compression* = 0 - rocksdb_snappy_compression* = 1 - rocksdb_zlib_compression* = 2 - rocksdb_bz2_compression* = 3 - rocksdb_lz4_compression* = 4 - rocksdb_lz4hc_compression* = 5 - rocksdb_xpress_compression* = 6 - rocksdb_zstd_compression* = 7 - -proc rocksdb_options_set_compression*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -const - rocksdb_level_compaction* = 0 - rocksdb_universal_compaction* = 1 - rocksdb_fifo_compaction* = 2 - -proc rocksdb_options_set_compaction_style*(a2: rocksdb_options_t; a3: cint) {.importrocks.} -proc rocksdb_options_set_universal_compaction_options*(a2: rocksdb_options_t; - a3: rocksdb_universal_compaction_options_t) {.importrocks.} -proc rocksdb_options_set_fifo_compaction_options*(opt: rocksdb_options_t; - fifo: rocksdb_fifo_compaction_options_t) {.importrocks.} -proc rocksdb_options_set_ratelimiter*(opt: rocksdb_options_t; - limiter: rocksdb_ratelimiter_t) {.importrocks.} -## RateLimiter - -proc rocksdb_ratelimiter_create*(rate_bytes_per_sec: int64; - refill_period_us: int64; fairness: int32): rocksdb_ratelimiter_t {.importrocks.} -proc rocksdb_ratelimiter_destroy*(a2: rocksdb_ratelimiter_t) {.importrocks.} -## Compaction Filter - -proc rocksdb_compactionfilter_create*(state: pointer; - destructor: proc (a2: pointer) {.cdecl.}; filter: proc ( - a2: pointer; level: cint; key: cstring; key_length: csize_t; existing_value: cstring; - value_length: csize_t; new_value: cstringArray; new_value_length: ptr csize_t; - value_changed: ptr uint8): uint8 {.cdecl.}; - name: proc (a2: pointer): cstring {.cdecl.}): rocksdb_compactionfilter_t {.importrocks.} -proc rocksdb_compactionfilter_set_ignore_snapshots*( - a2: rocksdb_compactionfilter_t; a3: uint8) {.importrocks.} -proc rocksdb_compactionfilter_destroy*(a2: rocksdb_compactionfilter_t) {.importrocks.} -## Compaction Filter Context - -proc rocksdb_compactionfiltercontext_is_full_compaction*( - context: rocksdb_compactionfiltercontext_t): uint8 {.importrocks.} -proc rocksdb_compactionfiltercontext_is_manual_compaction*( - context: rocksdb_compactionfiltercontext_t): uint8 {.importrocks.} -## Compaction Filter Factory - -proc rocksdb_compactionfilterfactory_create*(state: pointer; - destructor: proc (a2: pointer) {.cdecl.}; create_compaction_filter: proc ( - a2: pointer; context: rocksdb_compactionfiltercontext_t): rocksdb_compactionfilter_t {. - cdecl.}; name: proc (a2: pointer): cstring {.cdecl.}): rocksdb_compactionfilterfactory_t {.importrocks.} -proc rocksdb_compactionfilterfactory_destroy*( - a2: rocksdb_compactionfilterfactory_t) {.importrocks.} -## Comparator - -proc rocksdb_comparator_create*(state: pointer; - destructor: proc (a2: pointer) {.cdecl.}; compare: proc ( - a2: pointer; a: cstring; alen: csize_t; b: cstring; blen: csize_t): cint {.cdecl.}; - name: proc (a2: pointer): cstring {.cdecl.}): rocksdb_comparator_t {.importrocks.} -proc rocksdb_comparator_destroy*(a2: rocksdb_comparator_t) {.importrocks.} -## Filter policy - -proc rocksdb_filterpolicy_create*(state: pointer; - destructor: proc (a2: pointer) {.cdecl.}; - create_filter: proc (a2: pointer; key_array: cstringArray; - key_length_array: ptr csize_t; num_keys: cint; - filter_length: ptr csize_t): cstring {.cdecl.}; key_may_match: proc ( - a2: pointer; key: cstring; length: csize_t; filter: cstring; filter_length: csize_t): uint8 {. - cdecl.}; delete_filter: proc (a2: pointer; filter: cstring; filter_length: csize_t) {. - cdecl.}; name: proc (a2: pointer): cstring {.cdecl.}): rocksdb_filterpolicy_t {.importrocks.} -proc rocksdb_filterpolicy_destroy*(a2: rocksdb_filterpolicy_t) {.importrocks.} -proc rocksdb_filterpolicy_create_bloom*(bits_per_key: cint): rocksdb_filterpolicy_t {.importrocks.} -proc rocksdb_filterpolicy_create_bloom_full*(bits_per_key: cint): rocksdb_filterpolicy_t {.importrocks.} -## Merge Operator - -proc rocksdb_mergeoperator_create*(state: pointer; - destructor: proc (a2: pointer) {.cdecl.}; - full_merge: proc (a2: pointer; key: cstring; key_length: csize_t; - existing_value: cstring; existing_value_length: csize_t; - operands_list: cstringArray; operands_list_length: ptr csize_t; - num_operands: cint; success: ptr uint8; - new_value_length: ptr csize_t): cstring {.cdecl.}; partial_merge: proc ( - a2: pointer; key: cstring; key_length: csize_t; operands_list: cstringArray; - operands_list_length: ptr csize_t; num_operands: cint; success: ptr uint8; - new_value_length: ptr csize_t): cstring {.cdecl.}; delete_value: proc (a2: pointer; - value: cstring; value_length: csize_t) {.cdecl.}; - name: proc (a2: pointer): cstring {.cdecl.}): rocksdb_mergeoperator_t {.importrocks.} -proc rocksdb_mergeoperator_destroy*(a2: rocksdb_mergeoperator_t) {.importrocks.} -## Read options - -proc rocksdb_readoptions_create*(): rocksdb_readoptions_t {.importrocks.} -proc rocksdb_readoptions_destroy*(a2: rocksdb_readoptions_t) {.importrocks.} -proc rocksdb_readoptions_set_verify_checksums*(a2: rocksdb_readoptions_t; - a3: uint8) {.importrocks.} -proc rocksdb_readoptions_set_fill_cache*(a2: rocksdb_readoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_readoptions_set_snapshot*(a2: rocksdb_readoptions_t; - a3: rocksdb_snapshot_t) {.importrocks.} -proc rocksdb_readoptions_set_iterate_upper_bound*(a2: rocksdb_readoptions_t; - key: cstring; keylen: csize_t) {.importrocks.} -proc rocksdb_readoptions_set_iterate_lower_bound*(a2: rocksdb_readoptions_t; - key: cstring; keylen: csize_t) {.importrocks.} -proc rocksdb_readoptions_set_read_tier*(a2: rocksdb_readoptions_t; a3: cint) {.importrocks.} -proc rocksdb_readoptions_set_tailing*(a2: rocksdb_readoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_readoptions_set_managed*(a2: rocksdb_readoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_readoptions_set_readahead_size*(a2: rocksdb_readoptions_t; - a3: csize_t) {.importrocks.} -proc rocksdb_readoptions_set_prefix_same_as_start*(a2: rocksdb_readoptions_t; - a3: uint8) {.importrocks.} -proc rocksdb_readoptions_set_pin_data*(a2: rocksdb_readoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_readoptions_set_total_order_seek*(a2: rocksdb_readoptions_t; - a3: uint8) {.importrocks.} -proc rocksdb_readoptions_set_max_skippable_internal_keys*( - a2: rocksdb_readoptions_t; a3: uint64) {.importrocks.} -proc rocksdb_readoptions_set_background_purge_on_iterator_cleanup*( - a2: rocksdb_readoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_readoptions_set_ignore_range_deletions*( - a2: rocksdb_readoptions_t; a3: uint8) {.importrocks.} -## Write options - -proc rocksdb_writeoptions_create*(): rocksdb_writeoptions_t {.importrocks.} -proc rocksdb_writeoptions_destroy*(a2: rocksdb_writeoptions_t) {.importrocks.} -proc rocksdb_writeoptions_set_sync*(a2: rocksdb_writeoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_writeoptions_disable_WAL*(opt: rocksdb_writeoptions_t; - disable: cint) {.importrocks.} -proc rocksdb_writeoptions_set_ignore_missing_column_families*( - a2: rocksdb_writeoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_writeoptions_set_no_slowdown*(a2: rocksdb_writeoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_writeoptions_set_low_pri*(a2: rocksdb_writeoptions_t; a3: uint8) {.importrocks.} -## Compact range options - -proc rocksdb_compactoptions_create*(): rocksdb_compactoptions_t {.importrocks.} -proc rocksdb_compactoptions_destroy*(a2: rocksdb_compactoptions_t) {.importrocks.} -proc rocksdb_compactoptions_set_exclusive_manual_compaction*( - a2: rocksdb_compactoptions_t; a3: uint8) {.importrocks.} -proc rocksdb_compactoptions_set_change_level*(a2: rocksdb_compactoptions_t; - a3: uint8) {.importrocks.} -proc rocksdb_compactoptions_set_target_level*(a2: rocksdb_compactoptions_t; - a3: cint) {.importrocks.} -## Flush options - -proc rocksdb_flushoptions_create*(): rocksdb_flushoptions_t {.importrocks.} -proc rocksdb_flushoptions_destroy*(a2: rocksdb_flushoptions_t) {.importrocks.} -proc rocksdb_flushoptions_set_wait*(a2: rocksdb_flushoptions_t; a3: uint8) {.importrocks.} -## Cache - -proc rocksdb_cache_create_lru*(capacity: csize_t): rocksdb_cache_t {.importrocks.} -proc rocksdb_cache_destroy*(cache: rocksdb_cache_t) {.importrocks.} -proc rocksdb_cache_set_capacity*(cache: rocksdb_cache_t; capacity: csize_t) {.importrocks.} -proc rocksdb_cache_get_usage*(cache: rocksdb_cache_t): csize_t {.importrocks.} -proc rocksdb_cache_get_pinned_usage*(cache: rocksdb_cache_t): csize_t {.importrocks.} -## DBPath - -proc rocksdb_dbpath_create*(path: cstring; target_size: uint64): rocksdb_dbpath_t {.importrocks.} -proc rocksdb_dbpath_destroy*(a2: rocksdb_dbpath_t) {.importrocks.} -## Env - -proc rocksdb_create_default_env*(): rocksdb_env_t {.importrocks.} -proc rocksdb_create_mem_env*(): rocksdb_env_t {.importrocks.} -proc rocksdb_env_set_background_threads*(env: rocksdb_env_t; n: cint) {.importrocks.} -proc rocksdb_env_set_high_priority_background_threads*(env: rocksdb_env_t; - n: cint) {.importrocks.} -proc rocksdb_env_join_all_threads*(env: rocksdb_env_t) {.importrocks.} -proc rocksdb_env_destroy*(a2: rocksdb_env_t) {.importrocks.} -proc rocksdb_envoptions_create*(): rocksdb_envoptions_t {.importrocks.} -proc rocksdb_envoptions_destroy*(opt: rocksdb_envoptions_t) {.importrocks.} -## SstFile - -proc rocksdb_sstfilewriter_create*(env: rocksdb_envoptions_t; - io_options: rocksdb_options_t): rocksdb_sstfilewriter_t {.importrocks.} -proc rocksdb_sstfilewriter_create_with_comparator*(env: rocksdb_envoptions_t; - io_options: rocksdb_options_t; comparator: rocksdb_comparator_t): rocksdb_sstfilewriter_t {.importrocks.} -proc rocksdb_sstfilewriter_open*(writer: rocksdb_sstfilewriter_t; name: cstring; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_sstfilewriter_add*(writer: rocksdb_sstfilewriter_t; key: cstring; - keylen: csize_t; val: cstring; vallen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_sstfilewriter_put*(writer: rocksdb_sstfilewriter_t; key: cstring; - keylen: csize_t; val: cstring; vallen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_sstfilewriter_merge*(writer: rocksdb_sstfilewriter_t; key: cstring; - keylen: csize_t; val: cstring; vallen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_sstfilewriter_delete*(writer: rocksdb_sstfilewriter_t; - key: cstring; keylen: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_sstfilewriter_finish*(writer: rocksdb_sstfilewriter_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_sstfilewriter_destroy*(writer: rocksdb_sstfilewriter_t) {.importrocks.} -proc rocksdb_ingestexternalfileoptions_create*(): rocksdb_ingestexternalfileoptions_t {.importrocks.} -proc rocksdb_ingestexternalfileoptions_set_move_files*( - opt: rocksdb_ingestexternalfileoptions_t; move_files: uint8) {.importrocks.} -proc rocksdb_ingestexternalfileoptions_set_snapshot_consistency*( - opt: rocksdb_ingestexternalfileoptions_t; snapshot_consistency: uint8) {.importrocks.} -proc rocksdb_ingestexternalfileoptions_set_allow_global_seqno*( - opt: rocksdb_ingestexternalfileoptions_t; allow_global_seqno: uint8) {.importrocks.} -proc rocksdb_ingestexternalfileoptions_set_allow_blocking_flush*( - opt: rocksdb_ingestexternalfileoptions_t; allow_blocking_flush: uint8) {.importrocks.} -proc rocksdb_ingestexternalfileoptions_set_ingest_behind*( - opt: rocksdb_ingestexternalfileoptions_t; ingest_behind: uint8) {.importrocks.} -proc rocksdb_ingestexternalfileoptions_destroy*( - opt: rocksdb_ingestexternalfileoptions_t) {.importrocks.} -proc rocksdb_ingest_external_file*(db: rocksdb_t; file_list: cstringArray; - list_len: csize_t; - opt: rocksdb_ingestexternalfileoptions_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_ingest_external_file_cf*(db: rocksdb_t; handle: rocksdb_column_family_handle_t; - file_list: cstringArray; list_len: csize_t; opt: rocksdb_ingestexternalfileoptions_t; - errptr: ptr cstring) {.importrocks.} -## SliceTransform - -proc rocksdb_slicetransform_create*(state: pointer; - destructor: proc (a2: pointer) {.cdecl.}; - transform: proc (a2: pointer; key: cstring; length: csize_t; dst_length: ptr csize_t): cstring {. - cdecl.}; in_domain: proc (a2: pointer; key: cstring; length: csize_t): uint8 {.cdecl.}; - in_range: proc (a2: pointer; key: cstring; length: csize_t): uint8 {.cdecl.}; - name: proc (a2: pointer): cstring {.cdecl.}): rocksdb_slicetransform_t {.importrocks.} -proc rocksdb_slicetransform_create_fixed_prefix*(a2: csize_t): rocksdb_slicetransform_t {.importrocks.} -proc rocksdb_slicetransform_create_noop*(): rocksdb_slicetransform_t {.importrocks.} -proc rocksdb_slicetransform_destroy*(a2: rocksdb_slicetransform_t) {.importrocks.} -## Universal Compaction options - -const - rocksdb_similar_size_compaction_stop_style* = 0 - rocksdb_total_size_compaction_stop_style* = 1 - -proc rocksdb_universal_compaction_options_create*(): rocksdb_universal_compaction_options_t {.importrocks.} -proc rocksdb_universal_compaction_options_set_size_ratio*( - a2: rocksdb_universal_compaction_options_t; a3: cint) {.importrocks.} -proc rocksdb_universal_compaction_options_set_min_merge_width*( - a2: rocksdb_universal_compaction_options_t; a3: cint) {.importrocks.} -proc rocksdb_universal_compaction_options_set_max_merge_width*( - a2: rocksdb_universal_compaction_options_t; a3: cint) {.importrocks.} -proc rocksdb_universal_compaction_options_set_max_size_amplification_percent*( - a2: rocksdb_universal_compaction_options_t; a3: cint) {.importrocks.} -proc rocksdb_universal_compaction_options_set_compression_size_percent*( - a2: rocksdb_universal_compaction_options_t; a3: cint) {.importrocks.} -proc rocksdb_universal_compaction_options_set_stop_style*( - a2: rocksdb_universal_compaction_options_t; a3: cint) {.importrocks.} -proc rocksdb_universal_compaction_options_destroy*( - a2: rocksdb_universal_compaction_options_t) {.importrocks.} -proc rocksdb_fifo_compaction_options_create*(): rocksdb_fifo_compaction_options_t {.importrocks.} -proc rocksdb_fifo_compaction_options_set_max_table_files_size*( - fifo_opts: rocksdb_fifo_compaction_options_t; size: uint64) {.importrocks.} -proc rocksdb_fifo_compaction_options_destroy*( - fifo_opts: rocksdb_fifo_compaction_options_t) {.importrocks.} -proc rocksdb_livefiles_count*(a2: rocksdb_livefiles_t): cint {.importrocks.} -proc rocksdb_livefiles_name*(a2: rocksdb_livefiles_t; index: cint): cstring {.importrocks.} -proc rocksdb_livefiles_level*(a2: rocksdb_livefiles_t; index: cint): cint {.importrocks.} -proc rocksdb_livefiles_size*(a2: rocksdb_livefiles_t; index: cint): csize_t {.importrocks.} -proc rocksdb_livefiles_smallestkey*(a2: rocksdb_livefiles_t; index: cint; - size: ptr csize_t): cstring {.importrocks.} -proc rocksdb_livefiles_largestkey*(a2: rocksdb_livefiles_t; index: cint; - size: ptr csize_t): cstring {.importrocks.} -proc rocksdb_livefiles_destroy*(a2: rocksdb_livefiles_t) {.importrocks.} -## Utility Helpers - -proc rocksdb_get_options_from_string*(base_options: rocksdb_options_t; - opts_str: cstring; - new_options: rocksdb_options_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_delete_file_in_range*(db: rocksdb_t; start_key: cstring; - start_key_len: csize_t; limit_key: cstring; - limit_key_len: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_delete_file_in_range_cf*(db: rocksdb_t; column_family: rocksdb_column_family_handle_t; - start_key: cstring; start_key_len: csize_t; - limit_key: cstring; limit_key_len: csize_t; - errptr: ptr cstring) {.importrocks.} -## Transactions - -proc rocksdb_transactiondb_create_column_family*( - txn_db: rocksdb_transactiondb_t; - column_family_options: rocksdb_options_t; column_family_name: cstring; - errptr: ptr cstring): rocksdb_column_family_handle_t {.importrocks.} -proc rocksdb_transactiondb_open*(options: rocksdb_options_t; txn_db_options: rocksdb_transactiondb_options_t; - name: cstring; errptr: ptr cstring): rocksdb_transactiondb_t {.importrocks.} -proc rocksdb_transactiondb_create_snapshot*(txn_db: rocksdb_transactiondb_t): rocksdb_snapshot_t {.importrocks.} -proc rocksdb_transactiondb_release_snapshot*(txn_db: rocksdb_transactiondb_t; - snapshot: rocksdb_snapshot_t) {.importrocks.} -proc rocksdb_transaction_begin*(txn_db: rocksdb_transactiondb_t; - write_options: rocksdb_writeoptions_t; - txn_options: rocksdb_transaction_options_t; - old_txn: rocksdb_transaction_t): rocksdb_transaction_t {.importrocks.} -proc rocksdb_transaction_commit*(txn: rocksdb_transaction_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transaction_rollback*(txn: rocksdb_transaction_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transaction_set_savepoint*(txn: rocksdb_transaction_t) {.importrocks.} -proc rocksdb_transaction_rollback_to_savepoint*(txn: rocksdb_transaction_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transaction_destroy*(txn: rocksdb_transaction_t) {.importrocks.} -## This snapshot should be freed using rocksdb_free - -proc rocksdb_transaction_get_snapshot*(txn: rocksdb_transaction_t): rocksdb_snapshot_t {.importrocks.} -proc rocksdb_transaction_get*(txn: rocksdb_transaction_t; - options: rocksdb_readoptions_t; key: cstring; - klen: csize_t; vlen: ptr csize_t; errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_transaction_get_cf*(txn: rocksdb_transaction_t; - options: rocksdb_readoptions_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t; vlen: ptr csize_t; - errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_transaction_get_for_update*(txn: rocksdb_transaction_t; - options: rocksdb_readoptions_t; - key: cstring; klen: csize_t; vlen: ptr csize_t; - exclusive: uint8; errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_transactiondb_get*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_readoptions_t; key: cstring; - klen: csize_t; vlen: ptr csize_t; errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_transactiondb_get_cf*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_readoptions_t; column_family: rocksdb_column_family_handle_t; - key: cstring; keylen: csize_t; vallen: ptr csize_t; - errptr: ptr cstring): cstring {.importrocks.} -proc rocksdb_transaction_put*(txn: rocksdb_transaction_t; key: cstring; - klen: csize_t; val: cstring; vlen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transaction_put_cf*(txn: rocksdb_transaction_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t; val: cstring; vlen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transactiondb_put*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_writeoptions_t; key: cstring; - klen: csize_t; val: cstring; vlen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transactiondb_put_cf*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_writeoptions_t; - column_family: rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; - val: cstring; vallen: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_transactiondb_write*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_writeoptions_t; - batch: rocksdb_writebatch_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transaction_merge*(txn: rocksdb_transaction_t; key: cstring; - klen: csize_t; val: cstring; vlen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transactiondb_merge*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_writeoptions_t; key: cstring; - klen: csize_t; val: cstring; vlen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transaction_delete*(txn: rocksdb_transaction_t; key: cstring; - klen: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_transaction_delete_cf*(txn: rocksdb_transaction_t; column_family: rocksdb_column_family_handle_t; - key: cstring; klen: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_transactiondb_delete*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_writeoptions_t; - key: cstring; klen: csize_t; errptr: ptr cstring) {.importrocks.} -proc rocksdb_transactiondb_delete_cf*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_writeoptions_t; - column_family: rocksdb_column_family_handle_t; key: cstring; keylen: csize_t; - errptr: ptr cstring) {.importrocks.} -proc rocksdb_transaction_create_iterator*(txn: rocksdb_transaction_t; - options: rocksdb_readoptions_t): rocksdb_iterator_t {.importrocks.} -proc rocksdb_transaction_create_iterator_cf*(txn: rocksdb_transaction_t; - options: rocksdb_readoptions_t; - column_family: rocksdb_column_family_handle_t): rocksdb_iterator_t {.importrocks.} -proc rocksdb_transactiondb_create_iterator*(txn_db: rocksdb_transactiondb_t; - options: rocksdb_readoptions_t): rocksdb_iterator_t {.importrocks.} -proc rocksdb_transactiondb_close*(txn_db: rocksdb_transactiondb_t) {.importrocks.} -proc rocksdb_transactiondb_checkpoint_object_create*( - txn_db: rocksdb_transactiondb_t; errptr: ptr cstring): rocksdb_checkpoint_t {.importrocks.} -proc rocksdb_optimistictransactiondb_open*(options: rocksdb_options_t; - name: cstring; errptr: ptr cstring): rocksdb_optimistictransactiondb_t {.importrocks.} -proc rocksdb_optimistictransactiondb_open_column_families*( - options: rocksdb_options_t; name: cstring; num_column_families: cint; - column_family_names: cstringArray; - column_family_options: ptr rocksdb_options_t; - column_family_handles: ptr rocksdb_column_family_handle_t; - errptr: ptr cstring): rocksdb_optimistictransactiondb_t {.importrocks.} -proc rocksdb_optimistictransactiondb_get_base_db*( - otxn_db: rocksdb_optimistictransactiondb_t): rocksdb_t {.importrocks.} -proc rocksdb_optimistictransactiondb_close_base_db*(base_db: rocksdb_t) {.importrocks.} -proc rocksdb_optimistictransaction_begin*( - otxn_db: rocksdb_optimistictransactiondb_t; - write_options: rocksdb_writeoptions_t; - otxn_options: rocksdb_optimistictransaction_options_t; - old_txn: rocksdb_transaction_t): rocksdb_transaction_t {.importrocks.} -proc rocksdb_optimistictransactiondb_close*( - otxn_db: rocksdb_optimistictransactiondb_t) {.importrocks.} -## Transaction Options - -proc rocksdb_transactiondb_options_create*(): rocksdb_transactiondb_options_t {.importrocks.} -proc rocksdb_transactiondb_options_destroy*( - opt: rocksdb_transactiondb_options_t) {.importrocks.} -proc rocksdb_transactiondb_options_set_max_num_locks*( - opt: rocksdb_transactiondb_options_t; max_num_locks: int64) {.importrocks.} -proc rocksdb_transactiondb_options_set_num_stripes*( - opt: rocksdb_transactiondb_options_t; num_stripes: csize_t) {.importrocks.} -proc rocksdb_transactiondb_options_set_transaction_lock_timeout*( - opt: rocksdb_transactiondb_options_t; txn_lock_timeout: int64) {.importrocks.} -proc rocksdb_transactiondb_options_set_default_lock_timeout*( - opt: rocksdb_transactiondb_options_t; default_lock_timeout: int64) {.importrocks.} -proc rocksdb_transaction_options_create*(): rocksdb_transaction_options_t {.importrocks.} -proc rocksdb_transaction_options_destroy*(opt: rocksdb_transaction_options_t) {.importrocks.} -proc rocksdb_transaction_options_set_set_snapshot*( - opt: rocksdb_transaction_options_t; v: uint8) {.importrocks.} -proc rocksdb_transaction_options_set_deadlock_detect*( - opt: rocksdb_transaction_options_t; v: uint8) {.importrocks.} -proc rocksdb_transaction_options_set_lock_timeout*( - opt: rocksdb_transaction_options_t; lock_timeout: int64) {.importrocks.} -proc rocksdb_transaction_options_set_expiration*( - opt: rocksdb_transaction_options_t; expiration: int64) {.importrocks.} -proc rocksdb_transaction_options_set_deadlock_detect_depth*( - opt: rocksdb_transaction_options_t; depth: int64) {.importrocks.} -proc rocksdb_transaction_options_set_max_write_batch_size*( - opt: rocksdb_transaction_options_t; size: csize_t) {.importrocks.} -proc rocksdb_optimistictransaction_options_create*(): rocksdb_optimistictransaction_options_t {.importrocks.} -proc rocksdb_optimistictransaction_options_destroy*( - opt: rocksdb_optimistictransaction_options_t) {.importrocks.} -proc rocksdb_optimistictransaction_options_set_set_snapshot*( - opt: rocksdb_optimistictransaction_options_t; v: uint8) {.importrocks.} -## referring to convention (3), this should be used by client -## to free memory that was malloc()ed - -proc rocksdb_free*(`ptr`: pointer) {.importrocks.} -proc rocksdb_get_pinned*(db: rocksdb_t; options: rocksdb_readoptions_t; - key: cstring; keylen: csize_t; errptr: ptr cstring): rocksdb_pinnableslice_t {.importrocks.} -proc rocksdb_get_pinned_cf*(db: rocksdb_t; options: rocksdb_readoptions_t; - column_family: rocksdb_column_family_handle_t; - key: cstring; keylen: csize_t; errptr: ptr cstring): rocksdb_pinnableslice_t {.importrocks.} -proc rocksdb_pinnableslice_destroy*(v: rocksdb_pinnableslice_t) {.importrocks.} -proc rocksdb_pinnableslice_value*(t: rocksdb_pinnableslice_t; vlen: ptr csize_t): cstring {.importrocks.} diff --git a/rocksdb/options/backupopts.nim b/rocksdb/options/backupopts.nim new file mode 100644 index 0000000..c7815fa --- /dev/null +++ b/rocksdb/options/backupopts.nim @@ -0,0 +1,41 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + ../lib/librocksdb + +type + BackupEngineOptionsPtr* = ptr rocksdb_options_t + + BackupEngineOptionsRef* = ref object + cPtr: BackupEngineOptionsPtr + +proc newBackupEngineOptions*(): BackupEngineOptionsRef = + BackupEngineOptionsRef(cPtr: rocksdb_options_create()) + +template isClosed*(engineOpts: BackupEngineOptionsRef): bool = + engineOpts.cPtr.isNil() + +proc cPtr*(engineOpts: BackupEngineOptionsRef): BackupEngineOptionsPtr = + doAssert not engineOpts.isClosed() + engineOpts.cPtr + +# TODO: Add setters and getters for backup options properties. + +template defaultBackupEngineOptions*(): BackupEngineOptionsRef = + newBackupEngineOptions() + # TODO: set prefered defaults + +proc close*(engineOpts: var BackupEngineOptionsRef) = + if not engineOpts.isClosed(): + rocksdb_options_destroy(engineOpts.cPtr) + engineOpts.cPtr = nil + diff --git a/rocksdb/options/dbopts.nim b/rocksdb/options/dbopts.nim new file mode 100644 index 0000000..e99e120 --- /dev/null +++ b/rocksdb/options/dbopts.nim @@ -0,0 +1,85 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + std/cpuinfo, + ../lib/librocksdb + +type + DbOptionsPtr* = ptr rocksdb_options_t + + DbOptionsRef* = ref object + cPtr: DbOptionsPtr + +proc newDbOptions*(): DbOptionsRef = + DbOptionsRef(cPtr: rocksdb_options_create()) + +template isClosed*(dbOpts: DbOptionsRef): bool = + dbOpts.cPtr.isNil() + +proc cPtr*(dbOpts: DbOptionsRef): DbOptionsPtr = + doAssert not dbOpts.isClosed() + dbOpts.cPtr + +proc setIncreaseParallelism*(dbOpts: var DbOptionsRef, totalThreads: int) = + doAssert totalThreads > 0 + doAssert not dbOpts.isClosed() + rocksdb_options_increase_parallelism(dbOpts.cPtr, totalThreads.cint) + +proc setCreateIfMissing*(dbOpts: var DbOptionsRef, flag: bool) = + doAssert not dbOpts.isClosed() + rocksdb_options_set_create_if_missing(dbOpts.cPtr, flag.uint8) + +proc setMaxOpenFiles*(dbOpts: var DbOptionsRef, maxOpenFiles: int) = + doAssert maxOpenFiles >= -1 + doAssert not dbOpts.isClosed() + rocksdb_options_set_max_open_files(dbOpts.cPtr, maxOpenFiles.cint) + +proc setCreateMissingColumnFamilies*(dbOpts: var DbOptionsRef, flag: bool) = + doAssert not dbOpts.isClosed() + rocksdb_options_set_create_missing_column_families(dbOpts.cPtr, flag.uint8) + +proc defaultDbOptions*(): DbOptionsRef = + var opts = newDbOptions() + # Optimize RocksDB. This is the easiest way to get RocksDB to perform well: + opts.setIncreaseParallelism(countProcessors()) + # This requires snappy - disabled because rocksdb is not always compiled with + # snappy support (for example Fedora 28, certain Ubuntu versions) + # rocksdb_options_optimize_level_style_compaction(options, 0); + opts.setCreateIfMissing(true) + # 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. + opts.setMaxOpenFiles(-1) + # Enable creating column families if they do not exist + opts.setCreateMissingColumnFamilies(true) + return opts + +# 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 getCreateIfMissing*(dbOpts: DbOptionsRef): bool = +# doAssert not dbOpts.isClosed() +# rocksdb_options_get_create_if_missing(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(): + rocksdb_options_destroy(dbOpts.cPtr) + dbOpts.cPtr = nil + diff --git a/rocksdb/options/readopts.nim b/rocksdb/options/readopts.nim new file mode 100644 index 0000000..8cc86b9 --- /dev/null +++ b/rocksdb/options/readopts.nim @@ -0,0 +1,41 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + ../lib/librocksdb + +type + ReadOptionsPtr* = ptr rocksdb_readoptions_t + + ReadOptionsRef* = ref object + cPtr: ReadOptionsPtr + +proc newReadOptions*(): ReadOptionsRef = + ReadOptionsRef(cPtr: rocksdb_readoptions_create()) + +template isClosed*(readOpts: ReadOptionsRef): bool = + readOpts.cPtr.isNil() + +proc cPtr*(readOpts: ReadOptionsRef): ReadOptionsPtr = + doAssert not readOpts.isClosed() + readOpts.cPtr + +# TODO: Add setters and getters for read options properties. + +template defaultReadOptions*(): ReadOptionsRef = + newReadOptions() + # TODO: set prefered defaults + +proc close*(readOpts: var ReadOptionsRef) = + if not readOpts.isClosed(): + rocksdb_readoptions_destroy(readOpts.cPtr) + readOpts.cPtr = nil + diff --git a/rocksdb/options/writeopts.nim b/rocksdb/options/writeopts.nim new file mode 100644 index 0000000..5a635f9 --- /dev/null +++ b/rocksdb/options/writeopts.nim @@ -0,0 +1,41 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + ../lib/librocksdb + +type + WriteOptionsPtr* = ptr rocksdb_writeoptions_t + + WriteOptionsRef* = ref object + cPtr: WriteOptionsPtr + +proc newWriteOptions*(): WriteOptionsRef = + WriteOptionsRef(cPtr: rocksdb_writeoptions_create()) + +template isClosed*(writeOpts: WriteOptionsRef): bool = + writeOpts.cPtr.isNil() + +proc cPtr*(writeOpts: WriteOptionsRef): WriteOptionsPtr = + doAssert not writeOpts.isClosed() + writeOpts.cPtr + +# TODO: Add setters and getters for write options properties. + +template defaultWriteOptions*(): WriteOptionsRef = + newWriteOptions() + # TODO: set prefered defaults + +proc close*(writeOpts: var WriteOptionsRef) = + if not writeOpts.isClosed(): + rocksdb_writeoptions_destroy(writeOpts.cPtr) + writeOpts.cPtr = nil + diff --git a/rocksdb/rocksdb.nim b/rocksdb/rocksdb.nim new file mode 100644 index 0000000..946b719 --- /dev/null +++ b/rocksdb/rocksdb.nim @@ -0,0 +1,251 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.push raises: [].} + +import + std/sequtils, + results, + ./lib/librocksdb, + ./options/[dbopts, readopts, writeopts], + ./columnfamily/[cfopts, cfdescriptor, cfhandle], + ./internal/[cftable, utils] + +export + results, + dbopts, + readopts, + writeopts, + cfdescriptor + +type + RocksDBResult*[T] = Result[T, string] + + RocksDbPtr = ptr rocksdb_t + + RocksDbRef* = ref object of RootObj + cPtr: RocksDbPtr + path: string + dbOpts: DbOptionsRef + readOpts: ReadOptionsRef + cfTable: ColFamilyTableRef + + RocksDbReadOnlyRef* = ref object of RocksDbRef + + RocksDbReadWriteRef* = ref object of RocksDbRef + writeOpts: WriteOptionsRef + + DataProc* = proc(val: openArray[byte]) {.gcsafe, raises: [].} + +proc openRocksDb*( + path: string, + dbOpts = defaultDbOptions(), + readOpts = defaultReadOptions(), + writeOpts = defaultWriteOptions(), + columnFamilies = @[defaultColFamilyDescriptor()]): RocksDBResult[RocksDbReadWriteRef] = + + if columnFamilies.len == 0: + return err("rocksdb: no column families") + + var + cfNames = columnFamilies.mapIt(it.name().cstring) + cfOpts = columnFamilies.mapIt(it.options.cPtr) + columnFamilyHandles = newSeq[ColFamilyHandlePtr](columnFamilies.len) + errors: cstring + + let rocksDbPtr = rocksdb_open_column_families( + dbOpts.cPtr, + path.cstring, + cfNames.len().cint, + cast[cstringArray](cfNames[0].addr), + cfOpts[0].addr, + columnFamilyHandles[0].addr, + cast[cstringArray](errors.addr)) + bailOnErrors(errors) + + var cfTable = newColFamilyTable() + for i, cf in columnFamilies: + cfTable.put(cf.name(), columnFamilyHandles[i]) + + let db = RocksDbReadWriteRef( + cPtr: rocksDbPtr, + path: path, + dbOpts: dbOpts, + readOpts: readOpts, + writeOpts: writeOpts, + cfTable: cfTable) + ok(db) + +proc openRocksDbReadOnly*( + path: string, + dbOpts = defaultDbOptions(), + readOpts = defaultReadOptions(), + columnFamilies = @[defaultColFamilyDescriptor()], + errorIfWalFileExists = false): RocksDBResult[RocksDbReadOnlyRef] = + + if columnFamilies.len == 0: + return err("rocksdb: no column families") + + var + cfNames = columnFamilies.mapIt(it.name().cstring) + cfOpts = columnFamilies.mapIt(it.options.cPtr) + columnFamilyHandles = newSeq[ColFamilyHandlePtr](columnFamilies.len) + errors: cstring + + let rocksDbPtr = rocksdb_open_for_read_only_column_families( + dbOpts.cPtr, + path.cstring, + cfNames.len().cint, + cast[cstringArray](cfNames[0].addr), + cfOpts[0].addr, + columnFamilyHandles[0].addr, + errorIfWalFileExists.uint8, + cast[cstringArray](errors.addr)) + bailOnErrors(errors) + + var cfTable = newColFamilyTable() + for i, cf in columnFamilies: + cfTable.put(cf.name(), columnFamilyHandles[i]) + + let db = RocksDbReadOnlyRef( + cPtr: rocksDbPtr, + path: path, + dbOpts: dbOpts, + readOpts: readOpts, + cfTable: cfTable) + ok(db) + +template isClosed*(db: RocksDbRef): bool = + db.cPtr.isNil() + +proc cPtr*(db: RocksDbRef): RocksDbPtr = + doAssert not db.isClosed() + db.cPtr + +proc get*( + db: RocksDbRef, + key: openArray[byte], + onData: DataProc, + columnFamily = "default"): RocksDBResult[bool] = + + if key.len() == 0: + return err("rocksdb: key is empty") + + let cfHandle = db.cfTable.get(columnFamily) + if cfHandle.isNil: + return err("rocksdb: unknown column family") + + var + len: csize_t + errors: cstring + let data = rocksdb_get_cf( + db.cPtr, + db.readOpts.cPtr, + cfHandle.cPtr, + cast[cstring](unsafeAddr key[0]), + csize_t(key.len), + len.addr, + cast[cstringArray](errors.addr)) + bailOnErrors(errors) + + if data.isNil: + doAssert len == 0 + ok(false) + else: + onData(toOpenArrayByte(data, 0, len.int - 1)) + rocksdb_free(data) + ok(true) + +proc get*( + db: RocksDbRef, + key: openArray[byte], + columnFamily = "default"): RocksDBResult[seq[byte]] = + + var dataRes: RocksDBResult[seq[byte]] + proc onData(data: openArray[byte]) = + dataRes.ok(@data) + + let res = db.get(key, onData, columnFamily) + if res.isOk(): + return dataRes + + dataRes.err(res.error()) + +proc put*( + db: RocksDbReadWriteRef, + key, val: openArray[byte], + columnFamily = "default"): RocksDBResult[void] = + + if key.len() == 0: + return err("rocksdb: key is empty") + + let cfHandle = db.cfTable.get(columnFamily) + if cfHandle.isNil(): + return err("rocksdb: unknown column family") + + var + errors: cstring + rocksdb_put_cf( + db.cPtr, + db.writeOpts.cPtr, + cfHandle.cPtr, + cast[cstring](unsafeAddr key[0]), + csize_t(key.len), + cast[cstring](if val.len > 0: unsafeAddr val[0] else: nil), + csize_t(val.len), + cast[cstringArray](errors.addr)) + bailOnErrors(errors) + + ok() + +proc keyExists*( + db: RocksDbRef, + key: openArray[byte], + columnFamily = "default"): RocksDBResult[bool] = + + # TODO: Call rocksdb_key_may_exist_cf to improve performance for the case + # when the key does not exist + + db.get(key, proc(data: openArray[byte]) = discard, columnFamily) + +proc delete*( + db: RocksDbReadWriteRef, + key: openArray[byte], + columnFamily = "default"): RocksDBResult[void] = + + if key.len() == 0: + return err("rocksdb: key is empty") + + let cfHandle = db.cfTable.get(columnFamily) + if cfHandle.isNil: + return err("rocksdb: unknown column family") + + var errors: cstring + rocksdb_delete_cf( + db.cPtr, + db.writeOpts.cPtr, + cfHandle.cPtr, + cast[cstring](unsafeAddr key[0]), + csize_t(key.len), + cast[cstringArray](errors.addr)) + bailOnErrors(errors) + + ok() + +proc close*(db: RocksDbRef) = + if not db.isClosed(): + db.dbOpts.close() + db.readOpts.close() + db.cfTable.close() + + if db of RocksDbReadWriteRef: + db.RocksDbReadWriteRef.writeOpts.close() + + rocksdb_close(db.cPtr) + db.cPtr = nil \ No newline at end of file diff --git a/tests/columnfamily/test_cfdescriptor.nim b/tests/columnfamily/test_cfdescriptor.nim new file mode 100644 index 0000000..af1c0c1 --- /dev/null +++ b/tests/columnfamily/test_cfdescriptor.nim @@ -0,0 +1,59 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + unittest2, + ../../rocksdb/internal/utils, + ../../rocksdb/columnfamily/cfdescriptor + +suite "ColFamilyDescriptor Tests": + + const TEST_CF_NAME = "test" + + test "Test initColFamilyDescriptor": + var descriptor = initColFamilyDescriptor(TEST_CF_NAME) + + check: + descriptor.name() == TEST_CF_NAME + not descriptor.options().isNil() + not descriptor.isDefault() + + descriptor.close() + + test "Test initColFamilyDescriptor with options": + var descriptor = initColFamilyDescriptor(TEST_CF_NAME, defaultColFamilyOptions()) + + check: + descriptor.name() == TEST_CF_NAME + not descriptor.options().isNil() + not descriptor.isDefault() + + descriptor.close() + + test "Test defaultColFamilyDescriptor": + var descriptor = defaultColFamilyDescriptor() + + check: + descriptor.name() == DEFAULT_COLUMN_FAMILY_NAME + not descriptor.options().isNil() + descriptor.isDefault() + + descriptor.close() + + test "Test close": + var descriptor = defaultColFamilyDescriptor() + + check not descriptor.isClosed() + descriptor.close() + check descriptor.isClosed() + descriptor.close() + check descriptor.isClosed() + diff --git a/tests/columnfamily/test_cfhandle.nim b/tests/columnfamily/test_cfhandle.nim new file mode 100644 index 0000000..151addf --- /dev/null +++ b/tests/columnfamily/test_cfhandle.nim @@ -0,0 +1,67 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + std/os, + tempfile, + unittest2, + ../../rocksdb/lib/librocksdb, + ../../rocksdb/columnfamily/cfhandle + +suite "ColFamilyHandleRef Tests": + + const TEST_CF_NAME = "test" + + setup: + let + dbPath = mkdtemp() / "data" + dbOpts = rocksdb_options_create() + cfOpts = rocksdb_options_create() + + var + errors: cstring + + rocksdb_options_set_create_if_missing(dbOpts, 1); + + let db = rocksdb_open(dbOpts, dbPath.cstring, cast[cstringArray](errors.addr)) + doAssert errors.isNil() + doAssert not db.isNil() + + let cfHandlePtr = rocksdb_create_column_family( + db, + cfOpts, + TEST_CF_NAME.cstring, + cast[cstringArray](errors.addr)) + doAssert errors.isNil() + doAssert not cfHandlePtr.isNil() + + teardown: + rocksdb_close(db) + removeDir($dbPath) + + test "Test newColFamilyHandle": + var cfHandle = newColFamilyHandle(cfHandlePtr) + + check: + not cfHandle.cPtr.isNil() + cfHandle.cPtr == cfHandlePtr + + cfHandle.close() + + test "Test close": + var cfHandle = newColFamilyHandle(cfHandlePtr) + + check not cfHandle.isClosed() + cfHandle.close() + check cfHandle.isClosed() + cfHandle.close() + check cfHandle.isClosed() + diff --git a/tests/columnfamily/test_cfopts.nim b/tests/columnfamily/test_cfopts.nim new file mode 100644 index 0000000..20ca91d --- /dev/null +++ b/tests/columnfamily/test_cfopts.nim @@ -0,0 +1,47 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + unittest2, + ../../rocksdb/columnfamily/cfopts + +suite "ColFamilyOptionsRef Tests": + + test "Test newColFamilyOptions": + var cfOpts = newColFamilyOptions() + + check not cfOpts.cPtr.isNil() + # check not cfOpts.getCreateMissingColumnFamilies() + + cfOpts.setCreateMissingColumnFamilies(true) + # check cfOpts.getCreateMissingColumnFamilies() + + cfOpts.close() + + test "Test defaultColFamilyOptions": + var cfOpts = defaultColFamilyOptions() + + check not cfOpts.cPtr.isNil() + # check cfOpts.getCreateMissingColumnFamilies() + + cfOpts.setCreateMissingColumnFamilies(false) + # check not cfOpts.getCreateMissingColumnFamilies() + + cfOpts.close() + + test "Test close": + var cfOpts = defaultColFamilyOptions() + + check not cfOpts.isClosed() + cfOpts.close() + check cfOpts.isClosed() + cfOpts.close() + check cfOpts.isClosed() \ No newline at end of file diff --git a/tests/internal/test_cftable.nim b/tests/internal/test_cftable.nim new file mode 100644 index 0000000..1add0b9 --- /dev/null +++ b/tests/internal/test_cftable.nim @@ -0,0 +1,82 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + std/os, + tempfile, + unittest2, + ../../rocksdb/lib/librocksdb, + ../../rocksdb/columnfamily/cfhandle, + ../../rocksdb/internal/cftable + +suite "ColFamilyTableRef Tests": + + const TEST_CF_NAME = "test" + + setup: + let + dbPath = mkdtemp() / "data" + dbOpts = rocksdb_options_create() + cfOpts = rocksdb_options_create() + + var + errors: cstring + + rocksdb_options_set_create_if_missing(dbOpts, 1); + + let db = rocksdb_open(dbOpts, dbPath.cstring, cast[cstringArray](errors.addr)) + doAssert errors.isNil() + doAssert not db.isNil() + + let cfHandlePtr = rocksdb_create_column_family( + db, + cfOpts, + TEST_CF_NAME.cstring, + cast[cstringArray](errors.addr)) + doAssert errors.isNil() + doAssert not cfHandlePtr.isNil() + + teardown: + rocksdb_close(db) + removeDir($dbPath) + + + test "Test newColFamilyTable": + var cfTable = newColFamilyTable() + + cfTable.put(TEST_CF_NAME, cfHandlePtr) + check cfTable.get(TEST_CF_NAME).cPtr() == cfHandlePtr + check not cfTable.isClosed() + + # second put, same result + cfTable.put(TEST_CF_NAME, cfHandlePtr) + check cfTable.get(TEST_CF_NAME).cPtr() == cfHandlePtr + check not cfTable.isClosed() + + # doesn't exist + check cfTable.get("other").isNil() + check not cfTable.isClosed() + + cfTable.close() + + test "Test close": + var cfTable = newColFamilyTable() + cfTable.put(TEST_CF_NAME, cfHandlePtr) + + let cfHandle = cfTable.get(TEST_CF_NAME) + + check not cfHandle.isClosed() + check not cfTable.isClosed() + cfTable.close() + check cfHandle.isClosed() + check cfTable.isClosed() + cfTable.close() + check cfTable.isClosed() diff --git a/tests/test_rocksdb_c.nim b/tests/lib/test_librocksdb.nim similarity index 77% rename from tests/test_rocksdb_c.nim rename to tests/lib/test_librocksdb.nim index 63703cd..3a053ad 100644 --- a/tests/test_rocksdb_c.nim +++ b/tests/lib/test_librocksdb.nim @@ -10,15 +10,16 @@ {.used.} import - cpuinfo, os, unittest, + std/[cpuinfo, os], tempfile, - ../rocksdb + unittest2, + ../../rocksdb/lib/librocksdb -suite "RocksDB C wrapper tests": +suite "librocksdb C wrapper Tests": setup: let - dbPath: cstring = mkdtemp() - dbBackupPath: cstring = mkdtemp() + dbPath = mkdtemp().cstring + dbBackupPath = mkdtemp().cstring teardown: removeDir($dbPath) @@ -26,8 +27,8 @@ suite "RocksDB C wrapper tests": test "Simple create-update-close example": var - db: rocksdb_t - be: rocksdb_backup_engine_t + db: ptr rocksdb_t + be: ptr rocksdb_backup_engine_t options = rocksdb_options_create() let cpus = countProcessors() @@ -39,12 +40,12 @@ suite "RocksDB C wrapper tests": rocksdb_options_set_create_if_missing(options, 1); # open DB - var err: cstring # memory leak: example code does not free error string! - db = rocksdb_open(options, dbPath, err.addr) + var err: cstringArray # memory leak: example code does not free error string! + db = rocksdb_open(options, dbPath, err) check: err.isNil # open Backup Engine that we will use for backing up our database - be = rocksdb_backup_engine_open(options, dbBackupPath, err.addr) + be = rocksdb_backup_engine_open(options, dbBackupPath, err) check: err.isNil # Put key-value @@ -53,14 +54,14 @@ suite "RocksDB C wrapper tests": let put_value = "value" rocksdb_put( db, writeOptions, key.cstring, csize_t(key.len), - put_value.cstring, csize_t(put_value.len), err.addr) + put_value.cstring, csize_t(put_value.len), err) check: err.isNil # Get value var readOptions = rocksdb_readoptions_create() var len: csize_t let raw_value = rocksdb_get( - db, readOptions, key, csize_t(key.len), addr len, err.addr) # Important: rocksdb_get is not null-terminated + db, readOptions, key.cstring, csize_t(key.len), addr len, err) # Important: rocksdb_get is not null-terminated check: err.isNil # Copy it to a regular Nim string (copyMem workaround because non-null terminated) @@ -70,7 +71,7 @@ suite "RocksDB C wrapper tests": check: $get_value == $put_value # create new backup in a directory specified by DBBackupPath - rocksdb_backup_engine_create_new_backup(be, db, err.addr) + rocksdb_backup_engine_create_new_backup(be, db, err) check: err.isNil rocksdb_close(db) @@ -78,11 +79,11 @@ suite "RocksDB C wrapper tests": # If something is wrong, you might want to restore data from last backup var restoreOptions = rocksdb_restore_options_create() rocksdb_backup_engine_restore_db_from_latest_backup(be, dbPath, dbPath, - restoreOptions, err.addr) + restoreOptions, err) check: err.isNil rocksdb_restore_options_destroy(restore_options) - db = rocksdb_open(options, dbPath, err.addr) + db = rocksdb_open(options, dbPath, err) check: err.isNil # cleanup diff --git a/tests/options/test_backupopts.nim b/tests/options/test_backupopts.nim new file mode 100644 index 0000000..8215b6a --- /dev/null +++ b/tests/options/test_backupopts.nim @@ -0,0 +1,39 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + unittest2, + ../../rocksdb/options/backupopts + +suite "BackupEngineOptionsRef Tests": + + test "Test newBackupEngineOptions": + var backupOpts = newBackupEngineOptions() + + check not backupOpts.cPtr.isNil() + + backupOpts.close() + + test "Test defaultBackupEngineOptions": + var backupOpts = defaultBackupEngineOptions() + + check not backupOpts.cPtr.isNil() + + backupOpts.close() + + test "Test close": + var backupOpts = defaultBackupEngineOptions() + + check not backupOpts.isClosed() + backupOpts.close() + check backupOpts.isClosed() + backupOpts.close() + check backupOpts.isClosed() \ No newline at end of file diff --git a/tests/options/test_dbopts.nim b/tests/options/test_dbopts.nim new file mode 100644 index 0000000..aa4a9b8 --- /dev/null +++ b/tests/options/test_dbopts.nim @@ -0,0 +1,61 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + unittest2, + ../../rocksdb/options/dbopts + +suite "DbOptionsRef Tests": + + test "Test newDbOptions": + var dbOpts = newDbOptions() + + check not dbOpts.cPtr.isNil() + + dbOpts.setCreateIfMissing(true) + dbOpts.setMaxOpenFiles(10) + dbOpts.setCreateMissingColumnFamilies(false) + + # check: + # dbOpts.getCreateIfMissing() + # dbOpts.getMaxOpenFiles() == 10 + # not dbOpts.getCreateMissingColumnFamilies() + + dbOpts.close() + + test "Test defaultDbOptions": + var dbOpts = defaultDbOptions() + + check: + not dbOpts.cPtr.isNil() + # 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() + + dbOpts.close() + + test "Test close": + var dbOpts = defaultDbOptions() + + check not dbOpts.isClosed() + dbOpts.close() + check dbOpts.isClosed() + dbOpts.close() + check dbOpts.isClosed() \ No newline at end of file diff --git a/tests/options/test_readopts.nim b/tests/options/test_readopts.nim new file mode 100644 index 0000000..9d72b36 --- /dev/null +++ b/tests/options/test_readopts.nim @@ -0,0 +1,39 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + unittest2, + ../../rocksdb/options/readopts + +suite "ReadOptionsRef Tests": + + test "Test newReadOptions": + var readOpts = newReadOptions() + + check not readOpts.cPtr.isNil() + + readOpts.close() + + test "Test defaultReadOptions": + var readOpts = defaultReadOptions() + + check not readOpts.cPtr.isNil() + + readOpts.close() + + test "Test close": + var readOpts = defaultReadOptions() + + check not readOpts.isClosed() + readOpts.close() + check readOpts.isClosed() + readOpts.close() + check readOpts.isClosed() \ No newline at end of file diff --git a/tests/options/test_writeopts.nim b/tests/options/test_writeopts.nim new file mode 100644 index 0000000..c94021e --- /dev/null +++ b/tests/options/test_writeopts.nim @@ -0,0 +1,39 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + unittest2, + ../../rocksdb/options/writeopts + +suite "WriteOptionsRef Tests": + + test "Test newWriteOptions": + var writeOpts = newWriteOptions() + + check not writeOpts.cPtr.isNil() + + writeOpts.close() + + test "Test defaultWriteOptions": + var writeOpts = defaultWriteOptions() + + check not writeOpts.cPtr.isNil() + + writeOpts.close() + + test "Test close": + var writeOpts = defaultWriteOptions() + + check not writeOpts.isClosed() + writeOpts.close() + check writeOpts.isClosed() + writeOpts.close() + check writeOpts.isClosed() \ No newline at end of file diff --git a/tests/all.nim b/tests/test_all.nim similarity index 63% rename from tests/all.nim rename to tests/test_all.nim index d7011f0..9fe6733 100644 --- a/tests/all.nim +++ b/tests/test_all.nim @@ -8,5 +8,14 @@ # at your option. This file may not be copied, modified, or distributed except according to those terms. import - ./test_rocksdb_c, + ./columnfamily/test_cfdescriptor, + ./columnfamily/test_cfhandle, + ./columnfamily/test_cfopts, + ./internal/test_cftable, + ./lib/test_librocksdb, + ./options/test_backupopts, + ./options/test_dbopts, + ./options/test_readopts, + ./options/test_writeopts, + ./test_backup, ./test_rocksdb diff --git a/tests/test_backup.nim b/tests/test_backup.nim new file mode 100644 index 0000000..f8b9f9f --- /dev/null +++ b/tests/test_backup.nim @@ -0,0 +1,70 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + std/os, + tempfile, + unittest2, + ../rocksdb/backup, + ./test_helper + +suite "BackupEngineRef Tests": + + let + key = @[byte(1), 2, 3, 4, 5] + val = @[byte(1), 2, 3, 4, 5] + + setup: + let + dbPath = mkdtemp() / "data" + dbBackupPath = mkdtemp() / "backup" + dbRestorePath = mkdtemp() / "restore" + + var + db = initReadWriteDb(dbPath) + + teardown: + + db.close() + removeDir($dbPath) + removeDir($dbBackupPath) + + + test "Test backup": + var engine = initBackupEngine(dbBackupPath) + + check: + db.put(key, val).isOk() + db.keyExists(key).value() + + check engine.createNewBackup(db).isOk() + + check: + db.delete(key).isOk() + not db.keyExists(key).value() + + check engine.restoreDbFromLatestBackup(dbRestorePath).isOk() + + let db2 = initReadWriteDb(dbRestorePath) + check db2.keyExists(key).value() + + engine.close() + + test "Test close": + let res = openBackupEngine(dbPath) + doAssert res.isOk() + var engine = res.get() + + check not engine.isClosed() + engine.close() + check engine.isClosed() + engine.close() + check engine.isClosed() \ No newline at end of file diff --git a/tests/test_helper.nim b/tests/test_helper.nim new file mode 100644 index 0000000..4493950 --- /dev/null +++ b/tests/test_helper.nim @@ -0,0 +1,46 @@ +# Nim-RocksDB +# Copyright 2024 Status Research & Development GmbH +# Licensed under either of +# +# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) +# * GPL license, version 2.0, ([LICENSE-GPLv2](LICENSE-GPLv2) or https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) +# +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +{.used.} + +import + std/sequtils, + ../rocksdb/backup, + ../rocksdb/rocksdb + + +proc initReadWriteDb*( + path: string, + columnFamilyNames = @["default"]): RocksDbReadWriteRef = + + let res = openRocksDb( + path, + columnFamilies = columnFamilyNames.mapIt(initColFamilyDescriptor(it))) + if res.isErr(): + echo res.error() + doAssert res.isOk() + res.value() + +proc initReadOnlyDb*( + path: string, + columnFamilyNames = @["default"]): RocksDbReadOnlyRef = + + let res = openRocksDbReadOnly( + path, + columnFamilies = columnFamilyNames.mapIt(initColFamilyDescriptor(it))) + if res.isErr(): + echo res.error() + doAssert res.isOk() + res.value() + +proc initBackupEngine*(path: string): BackupEngineRef = + + let res = openBackupEngine(path) + doAssert res.isOk() + res.value() \ No newline at end of file diff --git a/tests/test_rocksdb.nim b/tests/test_rocksdb.nim index cc53458..beb4208 100644 --- a/tests/test_rocksdb.nim +++ b/tests/test_rocksdb.nim @@ -1,5 +1,5 @@ # Nim-RocksDB -# Copyright 2018-2019 Status Research & Development GmbH +# Copyright 2018-2024 Status Research & Development GmbH # Licensed under either of # # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) @@ -10,68 +10,228 @@ {.used.} import - os, unittest, + std/os, tempfile, - ../rocksdb + unittest2, + ../rocksdb/rocksdb, + ./test_helper -type - MyDB = object - rocksdb: RocksDBInstance +suite "RocksDbRef Tests": + const + CF_DEFAULT = "default" + CF_OTHER = "other" -# TODO no tests for failures / error reporting - -proc initMyDb(path: string): MyDB = let - dataDir = path / "data" - backupsDir = path / "backups" + key = @[byte(1), 2, 3, 4, 5] + otherKey = @[byte(1), 2, 3, 4, 5, 6] + val = @[byte(1), 2, 3, 4, 5] + + test "Basic operations": + var + dbDir = mkdtemp() + db = initReadWriteDb(dbDir) + + var s = db.put(key, val) + check s.isOk() + + var bytes: seq[byte] + check db.get(key, proc(data: openArray[byte]) = bytes = @data)[] + check not db.get(otherkey, proc(data: openArray[byte]) = bytes = @data)[] + + var r1 = db.get(key) + check r1.isOk() and r1.value == val + + var r2 = db.get(otherKey) + # there's no error string for missing keys + check r2.isOk() == false and r2.error.len == 0 + + var e1 = db.keyExists(key) + check e1.isOk() and e1.value == true + + var e2 = db.keyExists(otherKey) + check e2.isOk() and e2.value == false + + var d = db.delete(key) + check d.isOk() + + e1 = db.keyExists(key) + check e1.isOk() and e1.value == false + + d = db.delete(otherKey) + check d.isOk() + + close(db) + check db.isClosed() + + # Open database in read only mode + block: + + var + readOnlyDb = initReadOnlyDb(dbDir) + r = readOnlyDb.keyExists(key) + check r.isOk() and r.value == false + + # This won't compile as designed: + # var r2 = readOnlyDb.put(key, @[123.byte]) + # check r2.isErr() + + readOnlyDb.close() + check readOnlyDb.isClosed() + + removeDir(dbDir) + + test "Basic operations - default column family": + var + dbDir = mkdtemp() + db = initReadWriteDb(dbDir, columnFamilyNames = @[CF_DEFAULT]) + + var s = db.put(key, val, CF_DEFAULT) + check s.isOk() + + var bytes: seq[byte] + check db.get(key, proc(data: openArray[byte]) = bytes = @data, CF_DEFAULT)[] + check not db.get(otherkey, proc(data: openArray[byte]) = bytes = @data, CF_DEFAULT)[] + + var r1 = db.get(key) + check r1.isOk() and r1.value == val + + var r2 = db.get(otherKey) + # there's no error string for missing keys + check r2.isOk() == false and r2.error.len == 0 + + var e1 = db.keyExists(key, CF_DEFAULT) + check e1.isOk() and e1.value == true + + var e2 = db.keyExists(otherKey, CF_DEFAULT) + check e2.isOk() and e2.value == false + + var d = db.delete(key, CF_DEFAULT) + check d.isOk() + + e1 = db.keyExists(key, CF_DEFAULT) + check e1.isOk() and e1.value == false + + d = db.delete(otherKey, CF_DEFAULT) + check d.isOk() - createDir(dataDir) - createDir(backupsDir) + close(db) + check db.isClosed() - var s = result.rocksdb.init(dataDir, backupsDir) - doAssert s.isOk, $s + # Open database in read only mode + block: + var + readOnlyDb = initReadOnlyDb(dbDir, columnFamilyNames = @[CF_DEFAULT]) + r = readOnlyDb.keyExists(key, CF_DEFAULT) + check r.isOk() and r.value == false -suite "Nim API tests": - setup: + # Won't compile as designed: + # var r2 = readOnlyDb.put(key, @[123.byte], CF_DEFAULT) + # check r2.isErr() + + readOnlyDb.close() + check readOnlyDb.isClosed() + + removeDir(dbDir) + + test "Basic operations - multiple column families": var dbDir = mkdtemp() - db = initMyDb(dbDir) + db = initReadWriteDb(dbDir, columnFamilyNames = @[CF_DEFAULT, CF_OTHER]) + + var s = db.put(key, val, CF_DEFAULT) + check s.isOk() + + var s2 = db.put(otherKey, val, CF_OTHER) + check s2.isOk() + + var bytes: seq[byte] + check db.get(key, proc(data: openArray[byte]) = bytes = @data, CF_DEFAULT)[] + check not db.get(otherkey, proc(data: openArray[byte]) = bytes = @data, CF_DEFAULT)[] + + var bytes2: seq[byte] + check db.get(otherKey, proc(data: openArray[byte]) = bytes2 = @data, CF_OTHER)[] + check not db.get(key, proc(data: openArray[byte]) = bytes2 = @data, CF_OTHER)[] + + var e1 = db.keyExists(key, CF_DEFAULT) + check e1.isOk() and e1.value == true + var e2 = db.keyExists(otherKey, CF_DEFAULT) + check e2.isOk() and e2.value == false + + var e3 = db.keyExists(key, CF_OTHER) + check e3.isOk() and e3.value == false + var e4 = db.keyExists(otherKey, CF_OTHER) + check e4.isOk() and e4.value == true + + var d = db.delete(key, CF_DEFAULT) + check d.isOk() + e1 = db.keyExists(key, CF_DEFAULT) + check e1.isOk() and e1.value == false + d = db.delete(otherKey, CF_DEFAULT) + check d.isOk() + + var d2 = db.delete(key, CF_OTHER) + check d2.isOk() + e3 = db.keyExists(key, CF_OTHER) + check e3.isOk() and e3.value == false + d2 = db.delete(otherKey, CF_OTHER) + check d2.isOk() + d2 = db.delete(otherKey, CF_OTHER) + check d2.isOk() + + db.close() + check db.isClosed() + + # Open database in read only mode + block: + var + readOnlyDb = initReadOnlyDb(dbDir, columnFamilyNames = @[CF_DEFAULT, CF_OTHER]) + + var r = readOnlyDb.keyExists(key, CF_OTHER) + check r.isOk() and r.value == false + + # Does not compile as designed: + # var r2 = readOnlyDb.put(key, @[123.byte], CF_OTHER) + # check r2.isErr() + + readOnlyDb.close() + check readOnlyDb.isClosed() - teardown: - close(db.rocksdb) removeDir(dbDir) - test "Basic operations": - proc test() = - let key = @[byte(1), 2, 3, 4, 5] - let otherKey = @[byte(1), 2, 3, 4, 5, 6] - let val = @[byte(1), 2, 3, 4, 5] + test "Close multiple times": + var + dbDir = mkdtemp() + db = initReadWriteDb(dbDir) + check not db.isClosed() + + db.close() + check db.isClosed() - var s = db.rocksdb.put(key, val) - check s.isok + db.close() + check db.isClosed() - var bytes: seq[byte] - check db.rocksdb.get(key, proc(data: openArray[byte]) = bytes = @data)[] - check not db.rocksdb.get( - otherkey, proc(data: openArray[byte]) = bytes = @data)[] + removeDir(dbDir) - var r1 = db.rocksdb.getBytes(key) - check r1.isok and r1.value == val + test "Unknown column family": + const CF_UNKNOWN = "unknown" - var r2 = db.rocksdb.getBytes(otherKey) - # there's no error string for missing keys - check r2.isok == false and r2.error.len == 0 + var + dbDir = mkdtemp() + db = initReadWriteDb(dbDir, columnFamilyNames = @[CF_DEFAULT, CF_OTHER]) - var e1 = db.rocksdb.contains(key) - check e1.isok and e1.value == true + let r = db.put(key, val, CF_UNKNOWN) + check r.isErr() and r.error() == "rocksdb: unknown column family" - var e2 = db.rocksdb.contains(otherKey) - check e2.isok and e2.value == false + var bytes: seq[byte] + let r2 = db.get(key, proc(data: openArray[byte]) = bytes = @data, CF_UNKNOWN) + check r2.isErr() and r2.error() == "rocksdb: unknown column family" - var d = db.rocksdb.del(key) - check d.isok and d.value == true + let r3 = db.keyExists(key, CF_UNKNOWN) + check r3.isErr() and r3.error() == "rocksdb: unknown column family" - e1 = db.rocksdb.contains(key) - check e1.isok and e1.value == false + let r4 = db.delete(key, CF_UNKNOWN) + check r4.isErr() and r4.error() == "rocksdb: unknown column family" - test() + db.close() + check db.isClosed() + removeDir(dbDir) \ No newline at end of file