lmdb 0.6 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/lmdb_ext/extconf.rb +7 -3
- data/ext/lmdb_ext/lmdb_ext.c +120 -110
- data/lib/lmdb/version.rb +1 -1
- data/lmdb.gemspec +4 -4
- data/{ext/lmdb_ext → vendor/libraries}/liblmdb/.gitignore +8 -0
- data/{ext/lmdb_ext → vendor/libraries}/liblmdb/COPYRIGHT +1 -1
- data/vendor/libraries/liblmdb/Doxyfile +1631 -0
- data/{ext/lmdb_ext → vendor/libraries}/liblmdb/LICENSE +0 -0
- data/vendor/libraries/liblmdb/Makefile +118 -0
- data/vendor/libraries/liblmdb/intro.doc +192 -0
- data/{ext/lmdb_ext → vendor/libraries}/liblmdb/lmdb.h +161 -61
- data/{ext/lmdb_ext → vendor/libraries}/liblmdb/mdb.c +3244 -1302
- data/vendor/libraries/liblmdb/mdb_copy.1 +61 -0
- data/vendor/libraries/liblmdb/mdb_copy.c +84 -0
- data/vendor/libraries/liblmdb/mdb_drop.1 +40 -0
- data/vendor/libraries/liblmdb/mdb_drop.c +135 -0
- data/vendor/libraries/liblmdb/mdb_dump.1 +81 -0
- data/vendor/libraries/liblmdb/mdb_dump.c +319 -0
- data/vendor/libraries/liblmdb/mdb_load.1 +84 -0
- data/vendor/libraries/liblmdb/mdb_load.c +492 -0
- data/vendor/libraries/liblmdb/mdb_stat.1 +70 -0
- data/vendor/libraries/liblmdb/mdb_stat.c +264 -0
- data/{ext/lmdb_ext → vendor/libraries}/liblmdb/midl.c +66 -5
- data/{ext/lmdb_ext → vendor/libraries}/liblmdb/midl.h +19 -5
- data/vendor/libraries/liblmdb/mtest.c +177 -0
- data/vendor/libraries/liblmdb/mtest2.c +124 -0
- data/vendor/libraries/liblmdb/mtest3.c +133 -0
- data/vendor/libraries/liblmdb/mtest4.c +168 -0
- data/vendor/libraries/liblmdb/mtest5.c +135 -0
- data/vendor/libraries/liblmdb/mtest6.c +141 -0
- data/vendor/libraries/liblmdb/sample-bdb.txt +73 -0
- data/vendor/libraries/liblmdb/sample-mdb.txt +62 -0
- data/vendor/libraries/liblmdb/tooltag +27 -0
- metadata +34 -14
- data/.gitignore +0 -15
- data/.travis.yml +0 -14
- data/ext/lmdb_ext/liblmdb/CHANGES +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6f0a0943419dca02f5aab8971d28fe32b5771842cbfcb467e6f6c4b368aae4f
|
4
|
+
data.tar.gz: 5cd32d2a3b594861d92cfd9dcdd71aed3534b2ea7c4d910b3ce02e07dbb2ba02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340922f5163f227adffd8ef78dfd7348ad159f86df16fb469e18d92a1f04b08a5769c867d03fe6610e291375fb8c515e86847f171db2552262338b91327eaa03
|
7
|
+
data.tar.gz: c99c4423232109007ac971ec2d268ea4642751f0d4bcda3aa91c69c9348371d88e0612439fd583f07ef3d5165d7fd384ffc85c3674cf2d372d559aa3dfdccabe
|
data/ext/lmdb_ext/extconf.rb
CHANGED
@@ -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
|
-
|
8
|
+
lmdbpath = "../../vendor/libraries/liblmdb"
|
9
|
+
$INCFLAGS << " -I$(srcdir)/#{lmdbpath}"
|
9
10
|
$VPATH ||= []
|
10
|
-
$VPATH << "$(srcdir)
|
11
|
-
|
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'
|
data/ext/lmdb_ext/lmdb_ext.c
CHANGED
@@ -38,21 +38,21 @@ static void check(int code) {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
static void transaction_free(Transaction* transaction) {
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
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
|
-
|
604
|
+
VALUE path, option_hash;
|
604
605
|
|
605
606
|
#ifdef RB_SCAN_ARGS_KEYWORDS
|
606
|
-
|
607
|
-
|
607
|
+
rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
|
608
|
+
argc, argv, "1:", &path, &option_hash);
|
608
609
|
#else
|
609
|
-
|
610
|
+
rb_scan_args(argc, argv, "1:", &path, &option_hash);
|
610
611
|
#endif
|
611
612
|
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
check(
|
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
|
-
|
641
|
-
|
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
|
-
|
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
|
-
|
881
|
-
|
882
|
-
|
884
|
+
ENVIRONMENT(self, environment);
|
885
|
+
if (!active_txn(self))
|
886
|
+
return call_with_transaction(self, self, "database", argc, argv, 0);
|
883
887
|
|
884
|
-
|
888
|
+
VALUE name, option_hash;
|
885
889
|
#ifdef RB_SCAN_ARGS_KEYWORDS
|
886
|
-
|
887
|
-
|
890
|
+
rb_scan_args_kw(RB_SCAN_ARGS_KEYWORDS,
|
891
|
+
argc, argv, "01:", &name, &option_hash);
|
888
892
|
#else
|
889
|
-
|
893
|
+
rb_scan_args(argc, argv, "01:", &name, &option_hash);
|
890
894
|
#endif
|
891
895
|
|
892
896
|
|
893
|
-
|
894
|
-
|
895
|
-
|
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
|
-
|
898
|
-
|
902
|
+
MDB_dbi dbi;
|
903
|
+
check(mdb_dbi_open(need_txn(self), NIL_P(name) ? 0 : StringValueCStr(name),
|
904
|
+
flags, &dbi));
|
899
905
|
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
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
|
-
|
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
|
-
|
1068
|
-
|
1069
|
-
|
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
|
-
|
1078
|
+
VALUE vkey, vval, option_hash = Qnil;
|
1072
1079
|
#ifdef RB_SCAN_ARGS_KEYWORDS
|
1073
|
-
|
1074
|
-
|
1080
|
+
rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
|
1081
|
+
argc, argv, "20:", &vkey, &vval, &option_hash);
|
1075
1082
|
#else
|
1076
|
-
|
1083
|
+
rb_scan_args(argc, argv, "20:", &vkey, &vval, &option_hash);
|
1077
1084
|
#endif
|
1078
1085
|
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
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
|
-
|
1084
|
-
|
1091
|
+
vkey = StringValue(vkey);
|
1092
|
+
vval = StringValue(vval);
|
1085
1093
|
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
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
|
-
|
1093
|
-
|
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
|
-
|
1465
|
+
CURSOR(self, cursor);
|
1458
1466
|
|
1459
|
-
|
1467
|
+
VALUE vkey, vval, option_hash;
|
1460
1468
|
#ifdef RB_SCAN_ARGS_KEYWORDS
|
1461
|
-
|
1462
|
-
|
1469
|
+
rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
|
1470
|
+
argc, argv, "2:", &vkey, &vval, &option_hash);
|
1463
1471
|
#else
|
1464
|
-
|
1472
|
+
rb_scan_args(argc, argv, "2:", &vkey, &vval, &option_hash);
|
1465
1473
|
#endif
|
1466
1474
|
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
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
|
-
|
1472
|
-
|
1480
|
+
vkey = StringValue(vkey);
|
1481
|
+
vval = StringValue(vval);
|
1473
1482
|
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
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
|
-
|
1481
|
-
|
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
|
-
|
1508
|
+
CURSOR(self, cursor);
|
1500
1509
|
|
1501
|
-
|
1510
|
+
VALUE option_hash;
|
1502
1511
|
#ifdef RB_SCAN_ARGS_KEYWORDS
|
1503
|
-
|
1504
|
-
|
1512
|
+
rb_scan_args_kw(RB_SCAN_ARGS_LAST_HASH_KEYWORDS,
|
1513
|
+
argc, argv, ":", &option_hash);
|
1505
1514
|
#else
|
1506
|
-
|
1515
|
+
rb_scan_args(argc, argv, ":", &option_hash);
|
1507
1516
|
#endif
|
1508
1517
|
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
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
|
-
|
1514
|
-
|
1523
|
+
check(mdb_cursor_del(cursor->cur, flags));
|
1524
|
+
return Qnil;
|
1515
1525
|
}
|
1516
1526
|
|
1517
1527
|
/**
|
data/lib/lmdb/version.rb
CHANGED
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 = '
|
13
|
-
s.homepage = 'https://github.com/
|
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
|
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
|
|