lmdb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e65d2930d0d2e7812f17f527cec9e28227ff86d3
4
- data.tar.gz: 9b1be0c534d29babf1ecfb665bc0a93f1cadc158
3
+ metadata.gz: c192851303ba3bd76a139142c94322233284d3ed
4
+ data.tar.gz: b9482f90f6599d71f49989246fe9f2c526f47986
5
5
  SHA512:
6
- metadata.gz: 79f1fa24f25e0c3dc0971df47ed6eea2d5f2e388a244f6354586c1a15c0cd9934ff302391a7a51b46f50534ddeb5c1b126e842ffb6e59773967e5e5ef49e35dd
7
- data.tar.gz: 29a36534234f8da14bce75b157add7d4f259e94addf60e32a2faaf2edf4f84d168580e85090803d4eb16bf095a05c5546c6ea172835ba0d2098305d78d02c4cd
6
+ metadata.gz: e8fa0b74c2854ebd13ba07663ee65be141cefe08ae55075f6fd8817c805e21f48d32c886d687f4e85334958bfa1d9f39935a9764d343755dec3adbd7b3d67b08
7
+ data.tar.gz: c760928ef6d4fb1edb6a5a5d5432b9a8823af38e12457efaef74640aef3b7a6e7956bd258cf22b68c54a89136742fc48329c78ac0ce9db2bbfa1b135d8dd3a8a
data/.travis.yml CHANGED
@@ -6,3 +6,9 @@ rvm:
6
6
  - ruby-head
7
7
  - rbx-18mode
8
8
  - rbx-19mode
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
12
+ - rvm: 1.8.7
13
+ - rvm: rbx-18mode
14
+ - rvm: rbx-19mode
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ 0.3.1
2
+
3
+ * Minor fixes
4
+
1
5
  0.3.0
2
6
 
3
7
  * Higher level API improved and stabilized
data/README.md CHANGED
@@ -13,7 +13,27 @@ gem install lmdb
13
13
 
14
14
  ### API
15
15
 
16
- For now take a look at the specs.
16
+ ~~~ ruby
17
+ require 'lmdb'
18
+
19
+ env = LMDB.new(path)
20
+
21
+ maindb = env.database
22
+ subdb = env.database('subdb', create: true)
23
+
24
+ maindb['key'] = 'value'
25
+
26
+ env.transaction do
27
+ maindb['key'] = 'value'
28
+ subdb['key'] = 'value'
29
+ end
30
+
31
+ env.close
32
+ ~~~
33
+
34
+ For details take a look at the specs. If you want to have a simpler interface
35
+ to LMDB databases please consider using [Moneta](https://github.com/minad/moneta).
36
+ The Moneta gem provides an LMDB adapter which uses this gem.
17
37
 
18
38
  ### Licence (MIT)
19
39
 
data/Rakefile CHANGED
@@ -2,13 +2,9 @@
2
2
 
3
3
  require 'bundler/setup'
4
4
  require 'rspec/core/rake_task'
5
- require "rake/extensiontask"
5
+ require 'rake/extensiontask'
6
6
 
7
- # Install spec tasks
8
7
  RSpec::Core::RakeTask.new :spec
8
+ Rake::ExtensionTask.new :lmdb_ext
9
9
 
10
- # Install compile task
11
- Rake::ExtensionTask.new('lmdb_ext')
12
-
13
- desc 'Default: compile & run specs.'
14
- task default: [:compile, :spec]
10
+ task :default => [:compile, :spec]
@@ -3,24 +3,20 @@ require 'mkmf'
3
3
  $CFLAGS = '-std=c99 -Wall -g'
4
4
 
5
5
  # Embed lmdb if we cannot find it
6
- def have_lmbd
7
- find_header('lmdb.h') && have_library('lmdb', 'mdb_env_create')
8
- end
9
-
10
- if enable_config("bundled-lmdb", false) || !have_lmbd
11
- $VPATH << "$(srcdir)/liblmdb"
6
+ if enable_config("bundled-lmdb", false) || !(find_header('lmdb.h') && have_library('lmdb', 'mdb_env_create'))
12
7
  $INCFLAGS << " -I$(srcdir)/liblmdb"
8
+ $VPATH << "$(srcdir)/liblmdb"
13
9
  $srcs = Dir.glob("#{$srcdir}/{,liblmdb/}*.c").map {|n| File.basename(n) }
10
+ end
14
11
 
15
- have_header 'limits.h'
16
- have_header 'string.h'
17
- have_header 'stdlib.h'
18
- have_header 'errno.h'
19
- have_header 'sys/types.h'
20
- have_header 'assert.h'
12
+ have_header 'limits.h'
13
+ have_header 'string.h'
14
+ have_header 'stdlib.h'
15
+ have_header 'errno.h'
16
+ have_header 'sys/types.h'
17
+ have_header 'assert.h'
21
18
 
22
- have_header 'ruby.h'
23
- find_header 'lmdb.h'
24
- end
19
+ have_header 'ruby.h'
20
+ have_func 'rb_funcall_passing_block'
25
21
 
26
22
  create_makefile('lmdb_ext')
@@ -180,7 +180,7 @@ typedef int mdb_filehandle_t;
180
180
  MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
181
181
 
182
182
  /** The release date of this library version */
183
- #define MDB_VERSION_DATE "August 29, 2013"
183
+ #define MDB_VERSION_DATE "September 9, 2013"
184
184
 
185
185
  /** A stringifier for the version info */
186
186
  #define MDB_VERSTR(a,b,c,d) "MDB " #a "." #b "." #c ": (" d ")"
@@ -5231,9 +5231,10 @@ mdb_cursor_set(MDB_cursor *mc, MDB_val *key, MDB_val *data,
5231
5231
  if (!mc->mc_top) {
5232
5232
  /* There are no other pages */
5233
5233
  mc->mc_ki[mc->mc_top] = 0;
5234
- if (op == MDB_SET_RANGE)
5234
+ if (op == MDB_SET_RANGE) {
5235
+ rc = 0;
5235
5236
  goto set1;
5236
- else
5237
+ } else
5237
5238
  return MDB_NOTFOUND;
5238
5239
  }
5239
5240
  }
@@ -5298,6 +5299,7 @@ set1:
5298
5299
  if (rc) {
5299
5300
  if (op == MDB_GET_BOTH || rc > 0)
5300
5301
  return MDB_NOTFOUND;
5302
+ rc = 0;
5301
5303
  }
5302
5304
 
5303
5305
  } else {
@@ -7248,8 +7250,11 @@ mdb_rebalance(MDB_cursor *mc)
7248
7250
  else {
7249
7251
  if (mc->mc_ki[ptop] == 0)
7250
7252
  rc = mdb_page_merge(&mn, mc);
7251
- else
7253
+ else {
7254
+ mn.mc_ki[mn.mc_top] += mc->mc_ki[mn.mc_top] + 1;
7252
7255
  rc = mdb_page_merge(mc, &mn);
7256
+ mdb_cursor_copy(&mn, mc);
7257
+ }
7253
7258
  mc->mc_flags &= ~(C_INITIALIZED|C_EOF);
7254
7259
  }
7255
7260
  return rc;
@@ -84,10 +84,17 @@ static void transaction_finish(VALUE self, int commit) {
84
84
  check(ret);
85
85
  }
86
86
 
87
+ // Ruby 1.8.7 compatibility
88
+ #ifndef HAVE_RB_FUNCALL_PASSING_BLOCK
89
+ static VALUE call_with_transaction_helper(VALUE arg) {
90
+ #error "Not implemented"
91
+ }
92
+ #else
87
93
  static VALUE call_with_transaction_helper(VALUE arg) {
88
94
  HelperArgs* a = (HelperArgs*)arg;
89
95
  return rb_funcall_passing_block(a->self, rb_intern(a->name), a->argc, a->argv);
90
96
  }
97
+ #endif
91
98
 
92
99
  static VALUE call_with_transaction(VALUE venv, VALUE self, const char* name, int argc, const VALUE* argv, int flags) {
93
100
  HelperArgs arg = { self, name, argc, argv };
@@ -4,6 +4,26 @@
4
4
  #include "ruby.h"
5
5
  #include "lmdb.h"
6
6
 
7
+ // Ruby 1.8 compatibility
8
+ #ifndef SIZET2NUM
9
+ # if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
10
+ # define SIZET2NUM(v) ULL2NUM(v)
11
+ # elif SIZEOF_SIZE_T == SIZEOF_LONG
12
+ # define SIZET2NUM(v) ULONG2NUM(v)
13
+ # else
14
+ # define SIZET2NUM(v) UINT2NUM(v)
15
+ # endif
16
+ #endif
17
+
18
+ // Ruby 1.8 compatibility
19
+ #ifndef NUM2SSIZET
20
+ # if defined(HAVE_LONG_LONG) && SIZEOF_SIZE_T > SIZEOF_LONG
21
+ # define NUM2SSIZET(x) ((ssize_t)NUM2LL(x))
22
+ #else
23
+ # define NUM2SSIZET(x) NUM2LONG(x)
24
+ # endif
25
+ #endif
26
+
7
27
  #define ENVIRONMENT(var, var_env) \
8
28
  Environment* var_env; \
9
29
  Data_Get_Struct(var, Environment, var_env); \
@@ -22,8 +42,6 @@
22
42
  Data_Get_Struct(var, Cursor, var_cur); \
23
43
  cursor_check(var_cur)
24
44
 
25
- typedef struct Transaction Transaction;
26
-
27
45
  typedef struct Transaction {
28
46
  VALUE env;
29
47
  VALUE parent;
data/lib/lmdb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LMDB
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
data/lmdb.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.summary = 'Ruby bindings to Lightning MDB'
12
12
  s.email = 'mail@daniel-mendler.de'
13
13
  s.homepage = 'https://github.com/minad/lmdb'
14
- s.description = 'imdb is a Ruby binding to OpenLDAP Lightning MDB.'
14
+ s.description = 'lmdb is a Ruby binding to OpenLDAP Lightning MDB.'
15
15
  s.authors = ['Daniel Mendler']
16
16
  s.extensions = Dir['ext/**/extconf.rb']
17
17
 
@@ -20,6 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ['lib']
21
21
 
22
22
  s.add_development_dependency 'rake'
23
- s.add_development_dependency 'rake-compiler'
23
+ s.add_development_dependency 'rake-compiler', '<=0.8.2'
24
24
  s.add_development_dependency 'rspec'
25
25
  end
data/spec/helper.rb CHANGED
@@ -17,7 +17,7 @@ module LMDB::SpecHelper
17
17
  end
18
18
 
19
19
  def env
20
- @env ||= LMDB::Environment.new path: path
20
+ @env ||= LMDB::Environment.new :path => path
21
21
  end
22
22
  end
23
23
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lmdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Mendler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-08 00:00:00.000000000 Z
11
+ date: 2013-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake-compiler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - <=
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.8.2
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - <=
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.8.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: imdb is a Ruby binding to OpenLDAP Lightning MDB.
55
+ description: lmdb is a Ruby binding to OpenLDAP Lightning MDB.
56
56
  email: mail@daniel-mendler.de
57
57
  executables: []
58
58
  extensions: