Multiple changes.

- Raise an error if invalid options are passed to the constructor.
- Bugfix: Ensure drop() only removes the specified collection.
- Fix initializer double memory allocation.
- Fix key/data object allocation: make garbage collection safe.
- Move common macros to the global header file.

FossilOrigin-Name: 98d3016bd25921dead39d9c5474712766b56519d575bc8cd960932b3fbc16b69
This commit is contained in:
Mahlon E. Smith 2021-06-28 23:39:46 +00:00
parent b7e515d51e
commit e9b476a4d7
10 changed files with 605 additions and 517 deletions

View file

@ -29,10 +29,23 @@ class MDBX::Database
### Unless otherwise mentioned, option keys are symbols, and values
### are boolean.
###
### [:mode]
### Whe creating a new database, set permissions to this 4 digit
### octal number. Defaults to `0644`. Set to `0` to never automatically
### create a new file, only opening existing databases.
### [:coalesce]
### Attempt to coalesce items for the garbage collector,
### potentialy increasing the chance of unallocating storage
### earlier.
###
### [:compatible]
### Skip compatibility checks when opening an in-use database with
### unknown or mismatched flag values.
###
### [:exclusive]
### Access is restricted to the first opening process. Other attempts
### to use this database (even in readonly mode) are denied.
###
### [:lifo_reclaim]
### Recycle garbage collected items via LIFO, instead of FIFO.
### Depending on underlying hardware (disk write-back cache), this
### could increase write performance.
###
### [:max_collections]
### Set the maximum number of "subdatabase" collections allowed. By
@ -45,51 +58,38 @@ class MDBX::Database
### Set an upper boundary (in bytes) for the database map size.
### The default is 10485760 bytes.
###
### [:nosubdir]
### [:mode]
### Whe creating a new database, set permissions to this 4 digit
### octal number. Defaults to `0644`. Set to `0` to never automatically
### create a new file, only opening existing databases.
###
### [:no_memory_init]
### Skip initializing malloc'ed memory to zeroes before writing.
###
### [:no_metasync]
### A system crash may sacrifice the last commit for a potentially
### large write performance increase. Database integrity is
### maintained.
###
### [:no_subdir]
### When creating a new database, don't put the data and lock file
### under a dedicated subdirectory.
###
### [:readonly]
### Reject any write attempts while using this database handle.
###
### [:exclusive]
### Access is restricted to the first opening process. Other attempts
### to use this database (even in readonly mode) are denied.
###
### [:compat]
### Skip compatibility checks when opening an in-use database with
### unknown or mismatched flag values.
###
### [:writemap]
### Trade safety for speed for databases that fit within available
### memory. (See MDBX documentation for details.)
###
### [:no_threadlocal]
### Parallelize read-only transactions across threads. Writes are
### always thread local. (See MDBX documentatoin for details.)
###
### [:no_readahead]
### Disable all use of OS readahead. Potentially useful for
### random reads wunder low memory conditions. Default behavior
### is to dynamically choose when to use or omit readahead.
###
### [:no_memory_init]
### Skip initializing malloc'ed memory to zeroes before writing.
### [:no_threadlocal]
### Parallelize read-only transactions across threads. Writes are
### always thread local. (See MDBX documentatoin for details.)
###
### [:coalesce]
### Attempt to coalesce items for the garbage collector,
### potentialy increasing the chance of unallocating storage
### earlier.
### [:readonly]
### Reject any write attempts while using this database handle.
###
### [:lifo_reclaim]
### Recycle garbage collected items via LIFO, instead of FIFO.
### Depending on underlying hardware (disk write-back cache), this
### could increase write performance.
###
### [:no_metasync]
### A system crash may sacrifice the last commit for a potentially
### large write performance increase. Database integrity is
### maintained.
### [:writemap]
### Trade safety for speed for databases that fit within available
### memory. (See MDBX documentation for details.)
###
def self::open( *args, &block )
db = new( *args )