-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
691 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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 | ||
OptionsPtr = ptr rocksdb_options_t | ||
|
||
ColFamilyOptionsRef* = ref object | ||
optionsPtr: OptionsPtr | ||
|
||
proc newColFamilyOptions*(): ColFamilyOptionsRef = | ||
ColFamilyOptionsRef(optionsPtr: rocksdb_options_create()) | ||
|
||
template isClosed(dbOpts: ColFamilyOptionsRef): bool = | ||
dbOpts.optionsPtr.isNil() | ||
|
||
proc setCreateMissingColumnFamilies*(cfOpts: var ColFamilyOptionsRef, flag: bool) = | ||
doAssert not cfOpts.isClosed() | ||
rocksdb_options_set_create_missing_column_families(cfOpts.optionsPtr, flag.uint8) | ||
|
||
proc defaultColFamilyOptions*(): ColFamilyOptionsRef = | ||
var opts = newColFamilyOptions() | ||
# Enable creating column families if they do not exist | ||
opts.setCreateMissingColumnFamilies(true) | ||
return opts | ||
|
||
proc getCreateMissingColumnFamilies*(cfOpts: ColFamilyOptionsRef): bool = | ||
doAssert not cfOpts.isClosed() | ||
rocksdb_options_get_create_missing_column_families(cfOpts.optionsPtr).bool | ||
|
||
proc close*(cfOpts: var ColFamilyOptionsRef) = | ||
if not cfOpts.isClosed(): | ||
rocksdb_options_destroy(cfOpts.optionsPtr) | ||
cfOpts.optionsPtr = nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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 | ||
./cfopts | ||
|
||
const DEFAULT_COLUMN_FAMILY* = "default" | ||
|
||
type | ||
ColFamilyDescriptor* = object | ||
name: string | ||
options: ColFamilyOptionsRef | ||
|
||
proc initColFamilyDescriptor*( | ||
name: string, | ||
options = defaultColFamilyOptions()): ColFamilyDescriptor = | ||
ColFamilyDescriptor(name: name, options: options) | ||
|
||
proc name*(descriptor: ColFamilyDescriptor): string = | ||
descriptor.name | ||
|
||
proc options*(descriptor: ColFamilyDescriptor): ColFamilyOptionsRef = | ||
descriptor.options | ||
|
||
proc defaultColFamilyDescriptor*(): ColFamilyDescriptor = | ||
initColFamilyDescriptor(DEFAULT_COLUMN_FAMILY) | ||
|
||
template close*(descriptor: var ColFamilyDescriptor) = | ||
descriptor.options.close() |
Oops, something went wrong.