Initial layout/commit.
FossilOrigin-Name: 5ccedce83232d9c4f5341866293f884fde8bcc9c1df2ea7407740d2d984fae9b
This commit is contained in:
commit
6a7bfb722f
17 changed files with 305 additions and 0 deletions
13
.hgignore
Normal file
13
.hgignore
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
docs/
|
||||||
|
tmp/
|
||||||
|
\.bundle$
|
||||||
|
\.lock$
|
||||||
|
\.gemspec$
|
||||||
|
\.so$
|
||||||
|
spec/\.status
|
||||||
|
coverage/
|
||||||
|
vendor/
|
||||||
|
pkg/
|
||||||
|
^Session.vim$
|
||||||
|
^Makefile$
|
||||||
|
|
||||||
14
.pryrc
Normal file
14
.pryrc
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# -*- ruby -*-
|
||||||
|
# vim: set nosta noet ts=4 sw=4 ft=ruby:
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
$LOAD_PATH.unshift( 'lib' )
|
||||||
|
|
||||||
|
begin
|
||||||
|
require 'mdbx'
|
||||||
|
rescue Exception => e
|
||||||
|
$stderr.puts "Ack! Libraries failed to load: #{e.message}\n\t" +
|
||||||
|
e.backtrace.join( "\n\t" )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
1
.rspec
Normal file
1
.rspec
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
-fd -c
|
||||||
1
.ruby-gemset
Normal file
1
.ruby-gemset
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdbx
|
||||||
1
.ruby-version
Normal file
1
.ruby-version
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
2.7.1
|
||||||
0
History.md
Normal file
0
History.md
Normal file
0
LICENSE.txt
Normal file
0
LICENSE.txt
Normal file
3
Manifest.txt
Normal file
3
Manifest.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
History.md
|
||||||
|
LICENSE.txt
|
||||||
|
README.md
|
||||||
128
README.md
Normal file
128
README.md
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
# Ruby MDBX
|
||||||
|
|
||||||
|
home
|
||||||
|
: https://gitlab.com/mahlon/ruby-mdbx
|
||||||
|
|
||||||
|
code
|
||||||
|
: https://code.martini.nu/ruby-mdbx
|
||||||
|
|
||||||
|
github
|
||||||
|
: https://github.com/mahlon/ruby-mdbx
|
||||||
|
|
||||||
|
gitlab
|
||||||
|
: https://gitlab.com/mahlon/ruby-mdbx/-/tree-master
|
||||||
|
|
||||||
|
|
||||||
|
docs
|
||||||
|
: https://martini.nu/docs/ruby-mdbx
|
||||||
|
#FIXME: ....... somewhere on martini
|
||||||
|
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This is a Ruby (MRI) binding for the libmdbx database library.
|
||||||
|
|
||||||
|
libmdbx is an extremely fast, compact, powerful, embedded, transactional
|
||||||
|
key-value database, with permissive license. libmdbx has a specific set
|
||||||
|
of properties and capabilities, focused on creating unique lightweight
|
||||||
|
solutions.
|
||||||
|
|
||||||
|
- Allows a swarm of multi-threaded processes to ACIDly read and update
|
||||||
|
several key-value maps and multimaps in a locally-shared database.
|
||||||
|
|
||||||
|
- Provides extraordinary performance, minimal overhead through
|
||||||
|
Memory-Mapping and Olog(N) operations costs by virtue of B+ tree.
|
||||||
|
|
||||||
|
- Requires no maintenance and no crash recovery since it doesn't use
|
||||||
|
WAL, but that might be a caveat for write-intensive workloads with
|
||||||
|
durability requirements.
|
||||||
|
|
||||||
|
- Compact and friendly for fully embedding. Only ≈25KLOC of C11,
|
||||||
|
≈64K x86 binary code of core, no internal threads neither server
|
||||||
|
process(es), but implements a simplified variant of the Berkeley DB
|
||||||
|
and dbm API.
|
||||||
|
|
||||||
|
- Enforces serializability for writers just by single mutex and
|
||||||
|
affords wait-free for parallel readers without atomic/interlocked
|
||||||
|
operations, while writing and reading transactions do not block each
|
||||||
|
other.
|
||||||
|
|
||||||
|
- Guarantee data integrity after crash unless this was explicitly
|
||||||
|
neglected in favour of write performance.
|
||||||
|
|
||||||
|
- Supports Linux, Windows, MacOS, Android, iOS, FreeBSD, DragonFly,
|
||||||
|
Solaris, OpenSolaris, OpenIndiana, NetBSD, OpenBSD and other systems
|
||||||
|
compliant with POSIX.1-2008.
|
||||||
|
|
||||||
|
- Historically, libmdbx is a deeply revised and extended descendant
|
||||||
|
of the amazing Lightning Memory-Mapped Database. libmdbx inherits
|
||||||
|
all benefits from LMDB, but resolves some issues and adds a set of
|
||||||
|
improvements.
|
||||||
|
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
[forthcoming]
|
||||||
|
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
* Ruby 2.6+
|
||||||
|
* libmdbx (https://github.com/erthink/libmdbx)
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
$ gem install mdbx
|
||||||
|
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
You can check out the current development source with Mercurial via its
|
||||||
|
[home repo](https://code.martini.nu/ruby-mdbx), or with Git at its
|
||||||
|
[project page](https://gitlab.com/mahlon/ruby-mdbx).
|
||||||
|
|
||||||
|
After checking out the source, run:
|
||||||
|
|
||||||
|
$ gem install -Ng
|
||||||
|
$ rake setup
|
||||||
|
|
||||||
|
This will install dependencies, and do any other necessary setup for
|
||||||
|
development.
|
||||||
|
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
- Mahlon E. Smith <mahlon@martini.nu>
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright (c) 2020, Mahlon E. Smith
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the author/s, nor the names of the project's
|
||||||
|
contributors may be used to endorse or promote products derived from this
|
||||||
|
software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
22
Rakefile
Normal file
22
Rakefile
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# vim: set noet sta sw=4 ts=4 :
|
||||||
|
# -*- ruby -*-
|
||||||
|
|
||||||
|
require 'rake/deveiate'
|
||||||
|
|
||||||
|
Rake::DevEiate.setup( 'mdbx' ) do |project|
|
||||||
|
project.summary = <<~END_SUM
|
||||||
|
A ruby binding to libmdbx, an improved version
|
||||||
|
of the Lightning Memory Mapped Database.
|
||||||
|
END_SUM
|
||||||
|
project.description = <<~END_DESC
|
||||||
|
This is a native ruby binding to libmdbx, an improved version
|
||||||
|
of the Lightning Memory Mapped Database.
|
||||||
|
|
||||||
|
libmdbx is an extremely fast, compact, powerful, embedded,
|
||||||
|
transactional key-value database, with permissive license.
|
||||||
|
libmdbx has a specific set of properties and capabilities,
|
||||||
|
focused on creating unique lightweight solutions.
|
||||||
|
END_DESC
|
||||||
|
project.authors = [ 'Mahlon E. Smith <mahlon@martini.nu>' ]
|
||||||
|
end
|
||||||
|
|
||||||
11
ext/mdbx_ext/extconf.rb
Executable file
11
ext/mdbx_ext/extconf.rb
Executable file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# vim: set noet sta sw=4 ts=4 :
|
||||||
|
|
||||||
|
require 'mkmf'
|
||||||
|
|
||||||
|
have_library( 'mdbx' ) or abort "No mdbx library!"
|
||||||
|
have_header( 'mdbx.h' ) or abort "No mdbx.h header!"
|
||||||
|
|
||||||
|
create_header()
|
||||||
|
create_makefile( 'mdbx_ext' )
|
||||||
|
|
||||||
15
ext/mdbx_ext/mdbx_ext.c
Normal file
15
ext/mdbx_ext/mdbx_ext.c
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
/* vim: set noet sta sw=4 ts=4 : */
|
||||||
|
|
||||||
|
#include "mdbx_ext.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MDBX initialization
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Init_mdbx_ext()
|
||||||
|
{
|
||||||
|
mdbx_mMDBX = rb_define_module( "MDBX" );
|
||||||
|
rb_define_const( mdbx_mMDBX, "LIBRARY_VERSION", rb_str_new_cstr(mdbx_version.git.describe) );
|
||||||
|
}
|
||||||
|
|
||||||
13
ext/mdbx_ext/mdbx_ext.h
Normal file
13
ext/mdbx_ext/mdbx_ext.h
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
#include <ruby.h>
|
||||||
|
#include "extconf.h"
|
||||||
|
|
||||||
|
#include "mdbx.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------
|
||||||
|
Globals
|
||||||
|
------------------------------------------------------------ */
|
||||||
|
|
||||||
|
VALUE mdbx_mMDBX;
|
||||||
|
|
||||||
13
gem.deps.rb
Normal file
13
gem.deps.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
source "https://rubygems.org/"
|
||||||
|
|
||||||
|
group( :development ) do
|
||||||
|
gem 'pry', '~> 0.13'
|
||||||
|
gem 'rake', '~> 13.0'
|
||||||
|
gem 'rake-compiler', '~> 1.1'
|
||||||
|
gem 'rake-deveiate', '~> 0.15', '>= 0.15.1'
|
||||||
|
gem 'rdoc-generator-fivefish', '~> 0.4'
|
||||||
|
gem 'rspec', '~> 3.9'
|
||||||
|
gem 'rubocop', '~> 0.93'
|
||||||
|
gem 'simplecov', '~> 0.12'
|
||||||
|
end
|
||||||
|
|
||||||
18
lib/mdbx.rb
Normal file
18
lib/mdbx.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# -*- ruby -*-
|
||||||
|
# vim: set nosta noet ts=4 sw=4 ft=ruby:
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
require 'mdbx_ext'
|
||||||
|
|
||||||
|
|
||||||
|
# Top level namespace for MDBX.
|
||||||
|
#
|
||||||
|
module MDBX
|
||||||
|
|
||||||
|
# The version of this gem.
|
||||||
|
# Note: the MDBX library version can be found in
|
||||||
|
# the 'LIBRARY_VERSION' constant.
|
||||||
|
VERSION = '0.0.1'
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
39
spec/lib/helper.rb
Normal file
39
spec/lib/helper.rb
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
# -*- ruby -*-
|
||||||
|
# vim: set noet sta sw=4 ts=4 :
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
|
||||||
|
if ENV[ 'COVERAGE' ]
|
||||||
|
require 'simplecov'
|
||||||
|
SimpleCov.start
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'rspec'
|
||||||
|
require 'mdbx'
|
||||||
|
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.expect_with :rspec do |expectations|
|
||||||
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||||
|
expectations.syntax = :expect
|
||||||
|
end
|
||||||
|
|
||||||
|
config.mock_with( :rspec ) do |mock|
|
||||||
|
mock.syntax = :expect
|
||||||
|
mock.verify_partial_doubles = true
|
||||||
|
end
|
||||||
|
|
||||||
|
config.disable_monkey_patching!
|
||||||
|
config.example_status_persistence_file_path = "spec/.status"
|
||||||
|
config.filter_run :focus
|
||||||
|
config.filter_run_when_matching :focus
|
||||||
|
config.order = :random
|
||||||
|
config.profile_examples = 5
|
||||||
|
config.run_all_when_everything_filtered = true
|
||||||
|
# config.warnings = true
|
||||||
|
|
||||||
|
# config.include( Zyre::Testing )
|
||||||
|
# config.include( Loggability::SpecHelpers )
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
13
spec/mdbx_spec.rb
Normal file
13
spec/mdbx_spec.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env rspec -cfd
|
||||||
|
|
||||||
|
require_relative './lib/helper'
|
||||||
|
|
||||||
|
|
||||||
|
RSpec.describe( MDBX ) do
|
||||||
|
|
||||||
|
it "can report the MDBX library version" do
|
||||||
|
expect( described_class::LIBRARY_VERSION ).
|
||||||
|
to match( /v\d+\.\d+\.\d+\-\d+\-\w+$/ )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue