Expose some mdbx statistics/metadata to ruby.

- Add anonymous structs for settings and state to the internal db
    instance struct.
  - Allow tweaking the max_readers setting on db open.
  - Allow altering database sizing/geometry values.
  - Start sketching out some transaction re-entrancy.
  - Refactor initialization slightly, just use the db struct
    instead of additional unnecessary vars.

FossilOrigin-Name: 513f02946f7dc39001c402c1adf0697bb2852ba867685b35adbccaaaf43c6e15
This commit is contained in:
Mahlon E. Smith 2020-12-23 01:10:19 +00:00
parent 770a931d77
commit ceb92fad16
4 changed files with 397 additions and 111 deletions

View file

@ -18,7 +18,7 @@ class MDBX::Database
### db[ 'key' ] #=> value
### end
###
### FIXME: options!
### FIXME: document all options!
###
def self::open( *args, &block )
db = new( *args )
@ -64,5 +64,31 @@ class MDBX::Database
# Allow for some common nomenclature.
alias_method :namespace, :collection
### Return a hash of various metadata for the current database.
###
def statistics
raw = self.raw_stats
# Place build options in their own hash.
#
build_opts = raw.delete( :build_options ).split.each_with_object( {} ) do |opt, acc|
key, val = opt.split( '=' )
acc[ key.to_sym ] = Integer( val ) rescue val
end
stats = {
build: {
compiler: raw.delete( :build_compiler ),
flags: raw.delete( :build_flags ),
options: build_opts,
target: raw.delete( :build_target )
}
}
stats.merge!( raw )
return stats
end
end # class MDBX::Database