lmdb 0.6 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/ext/lmdb_ext/extconf.rb +7 -3
  3. data/ext/lmdb_ext/lmdb_ext.c +120 -110
  4. data/lib/lmdb/version.rb +1 -1
  5. data/lmdb.gemspec +4 -4
  6. data/{ext/lmdb_ext → vendor/libraries}/liblmdb/.gitignore +8 -0
  7. data/{ext/lmdb_ext → vendor/libraries}/liblmdb/COPYRIGHT +1 -1
  8. data/vendor/libraries/liblmdb/Doxyfile +1631 -0
  9. data/{ext/lmdb_ext → vendor/libraries}/liblmdb/LICENSE +0 -0
  10. data/vendor/libraries/liblmdb/Makefile +118 -0
  11. data/vendor/libraries/liblmdb/intro.doc +192 -0
  12. data/{ext/lmdb_ext → vendor/libraries}/liblmdb/lmdb.h +161 -61
  13. data/{ext/lmdb_ext → vendor/libraries}/liblmdb/mdb.c +3244 -1302
  14. data/vendor/libraries/liblmdb/mdb_copy.1 +61 -0
  15. data/vendor/libraries/liblmdb/mdb_copy.c +84 -0
  16. data/vendor/libraries/liblmdb/mdb_drop.1 +40 -0
  17. data/vendor/libraries/liblmdb/mdb_drop.c +135 -0
  18. data/vendor/libraries/liblmdb/mdb_dump.1 +81 -0
  19. data/vendor/libraries/liblmdb/mdb_dump.c +319 -0
  20. data/vendor/libraries/liblmdb/mdb_load.1 +84 -0
  21. data/vendor/libraries/liblmdb/mdb_load.c +492 -0
  22. data/vendor/libraries/liblmdb/mdb_stat.1 +70 -0
  23. data/vendor/libraries/liblmdb/mdb_stat.c +264 -0
  24. data/{ext/lmdb_ext → vendor/libraries}/liblmdb/midl.c +66 -5
  25. data/{ext/lmdb_ext → vendor/libraries}/liblmdb/midl.h +19 -5
  26. data/vendor/libraries/liblmdb/mtest.c +177 -0
  27. data/vendor/libraries/liblmdb/mtest2.c +124 -0
  28. data/vendor/libraries/liblmdb/mtest3.c +133 -0
  29. data/vendor/libraries/liblmdb/mtest4.c +168 -0
  30. data/vendor/libraries/liblmdb/mtest5.c +135 -0
  31. data/vendor/libraries/liblmdb/mtest6.c +141 -0
  32. data/vendor/libraries/liblmdb/sample-bdb.txt +73 -0
  33. data/vendor/libraries/liblmdb/sample-mdb.txt +62 -0
  34. data/vendor/libraries/liblmdb/tooltag +27 -0
  35. metadata +34 -14
  36. data/.gitignore +0 -15
  37. data/.travis.yml +0 -14
  38. data/ext/lmdb_ext/liblmdb/CHANGES +0 -112
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2eac165bb0261c0af6813f16df9b725b2ca2a63f4c5de98734473d9976930735
4
- data.tar.gz: 3aa0562060e4586dd7c7a44e795adc1449f489f57634787ef5e6480abbd49a48
3
+ metadata.gz: d6f0a0943419dca02f5aab8971d28fe32b5771842cbfcb467e6f6c4b368aae4f
4
+ data.tar.gz: 5cd32d2a3b594861d92cfd9dcdd71aed3534b2ea7c4d910b3ce02e07dbb2ba02
5
5
  SHA512:
6
- metadata.gz: 22cc9f78002a05aa25fba212e4d3e3e97566ed7a9bd2e0c84996297398131b5afd57da0e1510a27086ac4b1938401d1369393f9b0515bdd044856109510c6432
7
- data.tar.gz: eea983ccb0638bed2dbcfcd3e2ea76271072ea91d259b95e392d505c26f184c351f89ae6076025b93f47bfec3e42add3ec41055e5edb67bee5bfec2e8e341a80
6
+ metadata.gz: 340922f5163f227adffd8ef78dfd7348ad159f86df16fb469e18d92a1f04b08a5769c867d03fe6610e291375fb8c515e86847f171db2552262338b91327eaa03
7
+ data.tar.gz: c99c4423232109007ac971ec2d268ea4642751f0d4bcda3aa91c69c9348371d88e0612439fd583f07ef3d5165d7fd384ffc85c3674cf2d372d559aa3dfdccabe
@@ -5,10 +5,14 @@ $CFLAGS << ' -fdeclspec' if /darwin/.match? RUBY_PLATFORM
5
5
 
6
6
  # Embed lmdb if we cannot find it
7
7
  if enable_config("bundled-lmdb", false) || !(find_header('lmdb.h') && have_library('lmdb', 'mdb_env_create'))
8
- $INCFLAGS << " -I$(srcdir)/liblmdb"
8
+ lmdbpath = "../../vendor/libraries/liblmdb"
9
+ $INCFLAGS << " -I$(srcdir)/#{lmdbpath}"
9
10
  $VPATH ||= []
10
- $VPATH << "$(srcdir)/liblmdb"
11
- $srcs = Dir.glob("#{$srcdir}/{,liblmdb/}*.c").map {|n| File.basename(n) }
11
+ $VPATH << "$(srcdir)/#{lmdbpath}"
12
+ # XXX this is a sketchy, sketchy way to do this
13
+ $srcs = Dir.glob("#{$srcdir}/{#{lmdbpath}/{mdb,midl}.c,*.c}").map do |n|
14
+ File.basename(n)
15
+ end
12
16
  end
13
17
 
14
18
  have_header 'limits.h'
@@ -38,21 +38,21 @@ static void check(int code) {
38
38
  }
39
39
 
40
40
  static void transaction_free(Transaction* transaction) {
41
- if (transaction->txn && !NIL_P(transaction->txn)) {
42
- //int id = (int)mdb_txn_id(transaction->txn);
43
- //rb_warn(sprintf("Memory leak: Garbage collecting active transaction %d", id));
44
- rb_warn("Memory leak: Garbage collecting active transaction");
45
- // transaction_abort(transaction);
46
- // mdb_txn_abort(transaction->txn);
47
- }
48
- free(transaction);
41
+ if (transaction->txn) {
42
+ //int id = (int)mdb_txn_id(transaction->txn);
43
+ //rb_warn(sprintf("Memory leak: Garbage collecting active transaction %d", id));
44
+ rb_warn("Memory leak: Garbage collecting active transaction");
45
+ // transaction_abort(transaction);
46
+ // mdb_txn_abort(transaction->txn);
47
+ }
48
+ free(transaction);
49
49
  }
50
50
 
51
51
  static void transaction_mark(Transaction* transaction) {
52
- rb_gc_mark(transaction->parent);
53
- rb_gc_mark(transaction->child);
54
- rb_gc_mark(transaction->env);
55
- rb_gc_mark(transaction->cursors);
52
+ rb_gc_mark(transaction->parent);
53
+ rb_gc_mark(transaction->child);
54
+ rb_gc_mark(transaction->env);
55
+ rb_gc_mark(transaction->cursors);
56
56
  }
57
57
 
58
58
  /**
@@ -197,7 +197,8 @@ static void transaction_finish(VALUE self, int commit) {
197
197
  // no more active read-write transaction; unset the registry
198
198
  if (!(transaction->flags & MDB_RDONLY) && !transaction->parent) {
199
199
  ENVIRONMENT(transaction->env, env);
200
- env->rw_txn_thread = NULL;
200
+ // maybe this should be Qnil, i dunno
201
+ env->rw_txn_thread = (VALUE)NULL;
201
202
  }
202
203
 
203
204
  // now set the active transaction to the parent, if there is one
@@ -600,47 +601,50 @@ static int environment_options(VALUE key, VALUE value, EnvironmentOptions* optio
600
601
  * end
601
602
  */
602
603
  static VALUE environment_new(int argc, VALUE *argv, VALUE klass) {
603
- VALUE path, option_hash;
604
+ VALUE path, option_hash;
604
605
 
605
606
  #ifdef RB_SCAN_ARGS_KEYWORDS
606
- rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
607
- argc, argv, "1:", &path, &option_hash);
607
+ rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
608
+ argc, argv, "1:", &path, &option_hash);
608
609
  #else
609
- rb_scan_args(argc, argv, "1:", &path, &option_hash);
610
+ rb_scan_args(argc, argv, "1:", &path, &option_hash);
610
611
  #endif
611
612
 
612
- EnvironmentOptions options = {
613
- .flags = MDB_NOTLS,
614
- .maxreaders = -1,
615
- .maxdbs = 128,
616
- .mapsize = 0,
617
- .mode = 0755,
618
- };
619
- if (!NIL_P(option_hash))
620
- rb_hash_foreach(option_hash, environment_options, (VALUE)&options);
621
-
622
- MDB_env* env;
623
- check(mdb_env_create(&env));
624
-
625
- Environment* environment;
626
- VALUE venv = Data_Make_Struct(cEnvironment, Environment, environment_mark, environment_free, environment);
627
- environment->env = env;
628
- environment->thread_txn_hash = rb_hash_new();
629
- environment->txn_thread_hash = rb_hash_new();
630
-
631
- if (options.maxreaders > 0)
632
- check(mdb_env_set_maxreaders(env, options.maxreaders));
633
- if (options.mapsize > 0)
634
- check(mdb_env_set_mapsize(env, options.mapsize));
635
-
636
- check(mdb_env_set_maxdbs(env, options.maxdbs <= 0 ? 1 : options.maxdbs));
637
- VALUE expanded_path = rb_file_expand_path(path, Qnil);
638
- check(mdb_env_open(env, StringValueCStr(expanded_path), options.flags, options.mode));
613
+ EnvironmentOptions options = {
614
+ .flags = MDB_NOTLS,
615
+ .maxreaders = -1,
616
+ .maxdbs = 128,
617
+ .mapsize = 0,
618
+ .mode = 0755,
619
+ };
620
+ if (!NIL_P(option_hash))
621
+ rb_hash_foreach(option_hash, (int (*)(ANYARGS))environment_options,
622
+ (VALUE)&options);
623
+
624
+ MDB_env* env;
625
+ check(mdb_env_create(&env));
626
+
627
+ Environment* environment;
628
+ VALUE venv = Data_Make_Struct(cEnvironment, Environment, environment_mark,
629
+ environment_free, environment);
630
+ environment->env = env;
631
+ environment->thread_txn_hash = rb_hash_new();
632
+ environment->txn_thread_hash = rb_hash_new();
633
+
634
+ if (options.maxreaders > 0)
635
+ check(mdb_env_set_maxreaders(env, options.maxreaders));
636
+ if (options.mapsize > 0)
637
+ check(mdb_env_set_mapsize(env, options.mapsize));
639
638
 
640
- if (rb_block_given_p())
641
- return rb_ensure(rb_yield, venv, environment_close, venv);
639
+ check(mdb_env_set_maxdbs(env, options.maxdbs <= 0 ? 1 : options.maxdbs));
640
+ VALUE expanded_path = rb_file_expand_path(path, Qnil);
641
+ check(mdb_env_open(env, StringValueCStr(expanded_path), options.flags,
642
+ options.mode));
642
643
 
643
- return venv;
644
+ if (rb_block_given_p())
645
+ return rb_ensure(rb_yield, venv, environment_close, venv);
646
+
647
+ return venv;
644
648
  }
645
649
 
646
650
  /**
@@ -877,32 +881,35 @@ static void database_mark(Database* database) {
877
881
  * transaction or a read-only environment.
878
882
  */
879
883
  static VALUE environment_database(int argc, VALUE *argv, VALUE self) {
880
- ENVIRONMENT(self, environment);
881
- if (!active_txn(self))
882
- return call_with_transaction(self, self, "database", argc, argv, 0);
884
+ ENVIRONMENT(self, environment);
885
+ if (!active_txn(self))
886
+ return call_with_transaction(self, self, "database", argc, argv, 0);
883
887
 
884
- VALUE name, option_hash;
888
+ VALUE name, option_hash;
885
889
  #ifdef RB_SCAN_ARGS_KEYWORDS
886
- rb_scan_args_kw(RB_SCAN_ARGS_KEYWORDS,
887
- argc, argv, "01:", &name, &option_hash);
890
+ rb_scan_args_kw(RB_SCAN_ARGS_KEYWORDS,
891
+ argc, argv, "01:", &name, &option_hash);
888
892
  #else
889
- rb_scan_args(argc, argv, "01:", &name, &option_hash);
893
+ rb_scan_args(argc, argv, "01:", &name, &option_hash);
890
894
  #endif
891
895
 
892
896
 
893
- int flags = 0;
894
- if (!NIL_P(option_hash))
895
- rb_hash_foreach(option_hash, database_flags, (VALUE)&flags);
897
+ int flags = 0;
898
+ if (!NIL_P(option_hash))
899
+ rb_hash_foreach(option_hash, (int (*)(ANYARGS))database_flags,
900
+ (VALUE)&flags);
896
901
 
897
- MDB_dbi dbi;
898
- check(mdb_dbi_open(need_txn(self), NIL_P(name) ? 0 : StringValueCStr(name), flags, &dbi));
902
+ MDB_dbi dbi;
903
+ check(mdb_dbi_open(need_txn(self), NIL_P(name) ? 0 : StringValueCStr(name),
904
+ flags, &dbi));
899
905
 
900
- Database* database;
901
- VALUE vdb = Data_Make_Struct(cDatabase, Database, database_mark, free, database);
902
- database->dbi = dbi;
903
- database->env = self;
906
+ Database* database;
907
+ VALUE vdb = Data_Make_Struct(cDatabase, Database, database_mark, free,
908
+ database);
909
+ database->dbi = dbi;
910
+ database->env = self;
904
911
 
905
- return vdb;
912
+ return vdb;
906
913
  }
907
914
 
908
915
  /**
@@ -1064,33 +1071,34 @@ static VALUE database_get(VALUE self, VALUE vkey) {
1064
1071
  * data.
1065
1072
  */
1066
1073
  static VALUE database_put(int argc, VALUE *argv, VALUE self) {
1067
- DATABASE(self, database);
1068
- if (!active_txn(database->env))
1069
- return call_with_transaction(database->env, self, "put", argc, argv, 0);
1074
+ DATABASE(self, database);
1075
+ if (!active_txn(database->env))
1076
+ return call_with_transaction(database->env, self, "put", argc, argv, 0);
1070
1077
 
1071
- VALUE vkey, vval, option_hash = Qnil;
1078
+ VALUE vkey, vval, option_hash = Qnil;
1072
1079
  #ifdef RB_SCAN_ARGS_KEYWORDS
1073
- rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
1074
- argc, argv, "20:", &vkey, &vval, &option_hash);
1080
+ rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
1081
+ argc, argv, "20:", &vkey, &vval, &option_hash);
1075
1082
  #else
1076
- rb_scan_args(argc, argv, "20:", &vkey, &vval, &option_hash);
1083
+ rb_scan_args(argc, argv, "20:", &vkey, &vval, &option_hash);
1077
1084
  #endif
1078
1085
 
1079
- int flags = 0;
1080
- if (!NIL_P(option_hash))
1081
- rb_hash_foreach(option_hash, database_put_flags, (VALUE)&flags);
1086
+ int flags = 0;
1087
+ if (!NIL_P(option_hash))
1088
+ rb_hash_foreach(option_hash, (int (*)(ANYARGS))database_put_flags,
1089
+ (VALUE)&flags);
1082
1090
 
1083
- vkey = StringValue(vkey);
1084
- vval = StringValue(vval);
1091
+ vkey = StringValue(vkey);
1092
+ vval = StringValue(vval);
1085
1093
 
1086
- MDB_val key, value;
1087
- key.mv_size = RSTRING_LEN(vkey);
1088
- key.mv_data = RSTRING_PTR(vkey);
1089
- value.mv_size = RSTRING_LEN(vval);
1090
- value.mv_data = RSTRING_PTR(vval);
1094
+ MDB_val key, value;
1095
+ key.mv_size = RSTRING_LEN(vkey);
1096
+ key.mv_data = RSTRING_PTR(vkey);
1097
+ value.mv_size = RSTRING_LEN(vval);
1098
+ value.mv_data = RSTRING_PTR(vval);
1091
1099
 
1092
- check(mdb_put(need_txn(database->env), database->dbi, &key, &value, flags));
1093
- return Qnil;
1100
+ check(mdb_put(need_txn(database->env), database->dbi, &key, &value, flags));
1101
+ return Qnil;
1094
1102
  }
1095
1103
 
1096
1104
  /**
@@ -1454,31 +1462,32 @@ static VALUE cursor_get(VALUE self) {
1454
1462
  * data.
1455
1463
  */
1456
1464
  static VALUE cursor_put(int argc, VALUE* argv, VALUE self) {
1457
- CURSOR(self, cursor);
1465
+ CURSOR(self, cursor);
1458
1466
 
1459
- VALUE vkey, vval, option_hash;
1467
+ VALUE vkey, vval, option_hash;
1460
1468
  #ifdef RB_SCAN_ARGS_KEYWORDS
1461
- rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
1462
- argc, argv, "2:", &vkey, &vval, &option_hash);
1469
+ rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
1470
+ argc, argv, "2:", &vkey, &vval, &option_hash);
1463
1471
  #else
1464
- rb_scan_args(argc, argv, "2:", &vkey, &vval, &option_hash);
1472
+ rb_scan_args(argc, argv, "2:", &vkey, &vval, &option_hash);
1465
1473
  #endif
1466
1474
 
1467
- int flags = 0;
1468
- if (!NIL_P(option_hash))
1469
- rb_hash_foreach(option_hash, cursor_put_flags, (VALUE)&flags);
1475
+ int flags = 0;
1476
+ if (!NIL_P(option_hash))
1477
+ rb_hash_foreach(option_hash, (int (*)(ANYARGS))cursor_put_flags,
1478
+ (VALUE)&flags);
1470
1479
 
1471
- vkey = StringValue(vkey);
1472
- vval = StringValue(vval);
1480
+ vkey = StringValue(vkey);
1481
+ vval = StringValue(vval);
1473
1482
 
1474
- MDB_val key, value;
1475
- key.mv_size = RSTRING_LEN(vkey);
1476
- key.mv_data = RSTRING_PTR(vkey);
1477
- value.mv_size = RSTRING_LEN(vval);
1478
- value.mv_data = RSTRING_PTR(vval);
1483
+ MDB_val key, value;
1484
+ key.mv_size = RSTRING_LEN(vkey);
1485
+ key.mv_data = RSTRING_PTR(vkey);
1486
+ value.mv_size = RSTRING_LEN(vval);
1487
+ value.mv_data = RSTRING_PTR(vval);
1479
1488
 
1480
- check(mdb_cursor_put(cursor->cur, &key, &value, flags));
1481
- return Qnil;
1489
+ check(mdb_cursor_put(cursor->cur, &key, &value, flags));
1490
+ return Qnil;
1482
1491
  }
1483
1492
 
1484
1493
  #define METHOD cursor_delete_flags
@@ -1496,22 +1505,23 @@ static VALUE cursor_put(int argc, VALUE* argv, VALUE self) {
1496
1505
  * if the database was opened with +:dupsort+.
1497
1506
  */
1498
1507
  static VALUE cursor_delete(int argc, VALUE *argv, VALUE self) {
1499
- CURSOR(self, cursor);
1508
+ CURSOR(self, cursor);
1500
1509
 
1501
- VALUE option_hash;
1510
+ VALUE option_hash;
1502
1511
  #ifdef RB_SCAN_ARGS_KEYWORDS
1503
- rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
1504
- argc, argv, ":", &option_hash);
1512
+ rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
1513
+ argc, argv, ":", &option_hash);
1505
1514
  #else
1506
- rb_scan_args(argc, argv, ":", &option_hash);
1515
+ rb_scan_args(argc, argv, ":", &option_hash);
1507
1516
  #endif
1508
1517
 
1509
- int flags = 0;
1510
- if (!NIL_P(option_hash))
1511
- rb_hash_foreach(option_hash, cursor_delete_flags, (VALUE)&flags);
1518
+ int flags = 0;
1519
+ if (!NIL_P(option_hash))
1520
+ rb_hash_foreach(option_hash, (int (*)(ANYARGS))cursor_delete_flags,
1521
+ (VALUE)&flags);
1512
1522
 
1513
- check(mdb_cursor_del(cursor->cur, flags));
1514
- return Qnil;
1523
+ check(mdb_cursor_del(cursor->cur, flags));
1524
+ return Qnil;
1515
1525
  }
1516
1526
 
1517
1527
  /**
data/lib/lmdb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LMDB
2
- VERSION = '0.6'.freeze
2
+ VERSION = '0.6.1'.freeze
3
3
  end
data/lmdb.gemspec CHANGED
@@ -9,13 +9,13 @@ Gem::Specification.new do |s|
9
9
  s.date = Date.today.to_s
10
10
  s.licenses = ['MIT']
11
11
  s.summary = 'Ruby bindings to Lightning MDB'
12
- s.email = 'mail@daniel-mendler.de'
13
- s.homepage = 'https://github.com/minad/lmdb'
12
+ s.email = 'code@doriantaylor.com'
13
+ s.homepage = 'https://github.com/doriantaylor/rb-lmdb'
14
14
  s.description = 'lmdb is a Ruby binding to OpenLDAP Lightning MDB.'
15
- s.authors = ['Daniel Mendler']
15
+ s.authors = ['Daniel Mendler', 'Dorian Taylor']
16
16
  s.extensions = Dir['ext/**/extconf.rb']
17
17
 
18
- s.files = `git ls-files`.split("\n")
18
+ s.files = `git ls-files --recurse-submodules -- *`.split("\n")
19
19
  s.test_files = `git ls-files -- spec/*`.split("\n")
20
20
  s.require_paths = ['lib']
21
21
 
@@ -3,12 +3,20 @@ mtest[23456]
3
3
  testdb
4
4
  mdb_copy
5
5
  mdb_stat
6
+ mdb_dump
7
+ mdb_load
8
+ mdb_drop
9
+ *.lo
6
10
  *.[ao]
7
11
  *.so
12
+ *.exe
8
13
  *[~#]
9
14
  *.bak
10
15
  *.orig
11
16
  *.rej
17
+ *.gcov
18
+ *.gcda
19
+ *.gcno
12
20
  core
13
21
  core.*
14
22
  valgrind.*
@@ -1,4 +1,4 @@
1
- Copyright 2011-2014 Howard Chu, Symas Corp.
1
+ Copyright 2011-2021 Howard Chu, Symas Corp.
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without