mdbx 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.md +9 -0
- data/ext/mdbx_ext/database.c +29 -0
- data/ext/mdbx_ext/stats.c +1 -1
- data/lib/mdbx.rb +1 -1
- data/lib/mdbx/database.rb +39 -39
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad20dc19f790a03c428f1d37d082e55934708b11db27bafca68d53ddf47a8e74
|
4
|
+
data.tar.gz: 91425da92a3a2747993800ba2a56d1e6314d886fd4e928e034bd299c35186808
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c450fe97457401622eee77174e0ee77b16d7620c8842fb4045289972cc0f99a52533c790197a54a3e03c05db391cf64bbbb630e92fe64a7d0467de7b70ea079
|
7
|
+
data.tar.gz: b793386005b3fc04659de9fa608b75a5bba56b9257c5b472d570f19a3c4ca93a14b0f8de44b01a4be2ea2aaa8aa2ec2fb8f632eef183acf0421c50e00be9c652
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# Release History for MDBX
|
2
2
|
|
3
3
|
---
|
4
|
+
## v0.2.0 [2021-03-19] Mahlon E. Smith <mahlon@martini.nu>
|
5
|
+
|
6
|
+
Enhancement:
|
7
|
+
|
8
|
+
- Support dup/clone. This has limited use, as there can only
|
9
|
+
be one open handle per process, but implemented in the interests
|
10
|
+
of avoiding unexpected behavior.
|
11
|
+
|
12
|
+
|
4
13
|
## v0.1.1 [2021-03-14] Mahlon E. Smith <mahlon@martini.nu>
|
5
14
|
|
6
15
|
Bugfix:
|
data/ext/mdbx_ext/database.c
CHANGED
@@ -717,6 +717,34 @@ rmdbx_database_initialize( int argc, VALUE *argv, VALUE self )
|
|
717
717
|
}
|
718
718
|
|
719
719
|
|
720
|
+
/*
|
721
|
+
* call-seq:
|
722
|
+
* db.clone => [copy of db]
|
723
|
+
*
|
724
|
+
* Copy the object (clone/dup). The returned copy is closed and needs
|
725
|
+
* to be reopened before use. This function likely has limited use,
|
726
|
+
* considering you can't open two handles within the same process.
|
727
|
+
*/
|
728
|
+
static VALUE rmdbx_init_copy( VALUE copy, VALUE orig )
|
729
|
+
{
|
730
|
+
rmdbx_db_t *orig_db;
|
731
|
+
rmdbx_db_t *copy_db;
|
732
|
+
|
733
|
+
if ( copy == orig ) return copy;
|
734
|
+
|
735
|
+
TypedData_Get_Struct( orig, rmdbx_db_t, &rmdbx_db_data, orig_db );
|
736
|
+
TypedData_Get_Struct( copy, rmdbx_db_t, &rmdbx_db_data, copy_db );
|
737
|
+
|
738
|
+
/* Copy all fields from the original to the copy, and force-close
|
739
|
+
the copy.
|
740
|
+
*/
|
741
|
+
MEMCPY( copy_db, orig_db, rmdbx_db_t, 1 );
|
742
|
+
rmdbx_close_all( copy_db );
|
743
|
+
|
744
|
+
return copy;
|
745
|
+
}
|
746
|
+
|
747
|
+
|
720
748
|
/*
|
721
749
|
* Initialization for the MDBX::Database class.
|
722
750
|
*/
|
@@ -732,6 +760,7 @@ rmdbx_init_database()
|
|
732
760
|
rb_define_alloc_func( rmdbx_cDatabase, rmdbx_alloc );
|
733
761
|
|
734
762
|
rb_define_protected_method( rmdbx_cDatabase, "initialize", rmdbx_database_initialize, -1 );
|
763
|
+
rb_define_protected_method( rmdbx_cDatabase, "initialize_copy", rmdbx_init_copy, 1 );
|
735
764
|
rb_define_method( rmdbx_cDatabase, "collection", rmdbx_set_subdb, -1 );
|
736
765
|
rb_define_method( rmdbx_cDatabase, "close", rmdbx_close, 0 );
|
737
766
|
rb_define_method( rmdbx_cDatabase, "reopen", rmdbx_open_env, 0 );
|
data/ext/mdbx_ext/stats.c
CHANGED
@@ -148,7 +148,7 @@ rmdbx_gather_reader_stats(
|
|
148
148
|
{
|
149
149
|
VALUE readers = rb_ary_new();
|
150
150
|
|
151
|
-
|
151
|
+
mdbx_reader_list( db->env, reader_list_callback, (void*)readers );
|
152
152
|
rb_hash_aset( stat, ID2SYM(rb_intern("readers")), readers );
|
153
153
|
|
154
154
|
return;
|
data/lib/mdbx.rb
CHANGED
data/lib/mdbx/database.rb
CHANGED
@@ -201,24 +201,18 @@ class MDBX::Database
|
|
201
201
|
### pairs.
|
202
202
|
###
|
203
203
|
def to_a
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
return self.each_pair.to_a
|
208
|
-
ensure
|
209
|
-
self.abort unless in_txn
|
204
|
+
return self.conditional_snapshot do
|
205
|
+
self.each_pair.to_a
|
206
|
+
end
|
210
207
|
end
|
211
208
|
|
212
209
|
|
213
210
|
### Return the entirety of database contents as a Hash.
|
214
211
|
###
|
215
212
|
def to_h
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
return self.each_pair.to_h
|
220
|
-
ensure
|
221
|
-
self.abort unless in_txn
|
213
|
+
return self.conditional_snapshot do
|
214
|
+
self.each_pair.to_h
|
215
|
+
end
|
222
216
|
end
|
223
217
|
|
224
218
|
|
@@ -267,12 +261,9 @@ class MDBX::Database
|
|
267
261
|
### Returns a new Array containing all keys in the collection.
|
268
262
|
###
|
269
263
|
def keys
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
return self.each_key.to_a
|
274
|
-
ensure
|
275
|
-
self.abort unless in_txn
|
264
|
+
return self.conditional_snapshot do
|
265
|
+
self.each_key.to_a
|
266
|
+
end
|
276
267
|
end
|
277
268
|
|
278
269
|
|
@@ -280,41 +271,32 @@ class MDBX::Database
|
|
280
271
|
### keys. Any given keys that are not found are ignored.
|
281
272
|
###
|
282
273
|
def slice( *keys )
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
acc[ key ] = val if val
|
274
|
+
return self.conditional_snapshot do
|
275
|
+
keys.each_with_object( {} ) do |key, acc|
|
276
|
+
val = self[ key ]
|
277
|
+
acc[ key ] = val if val
|
278
|
+
end
|
289
279
|
end
|
290
|
-
ensure
|
291
|
-
self.abort unless in_txn
|
292
280
|
end
|
293
281
|
|
294
282
|
|
295
283
|
### Returns a new Array containing all values in the collection.
|
296
284
|
###
|
297
285
|
def values
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
return self.each_value.to_a
|
302
|
-
ensure
|
303
|
-
self.abort unless in_txn
|
286
|
+
return self.conditional_snapshot do
|
287
|
+
self.each_value.to_a
|
288
|
+
end
|
304
289
|
end
|
305
290
|
|
306
291
|
|
307
292
|
### Returns a new Array containing values for the given +keys+.
|
308
293
|
###
|
309
294
|
def values_at( *keys )
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
acc << self[ key ]
|
295
|
+
return self.conditional_snapshot do
|
296
|
+
keys.each_with_object( [] ) do |key, acc|
|
297
|
+
acc << self[ key ]
|
298
|
+
end
|
315
299
|
end
|
316
|
-
ensure
|
317
|
-
self.abort unless in_txn
|
318
300
|
end
|
319
301
|
|
320
302
|
|
@@ -347,5 +329,23 @@ class MDBX::Database
|
|
347
329
|
return stats
|
348
330
|
end
|
349
331
|
|
332
|
+
|
333
|
+
#########
|
334
|
+
protected
|
335
|
+
#########
|
336
|
+
|
337
|
+
### Yield and return the block, opening a snapshot first if
|
338
|
+
### there isn't already a transaction in progress. Closes
|
339
|
+
### the snapshot if this method opened it.
|
340
|
+
###
|
341
|
+
def conditional_snapshot
|
342
|
+
in_txn = self.in_transaction?
|
343
|
+
self.snapshot unless in_txn
|
344
|
+
|
345
|
+
return yield
|
346
|
+
ensure
|
347
|
+
self.abort unless in_txn
|
348
|
+
end
|
349
|
+
|
350
350
|
end # class MDBX::Database
|
351
351
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdbx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mahlon E. Smith
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
49pOzX5KHZLTS9DKeaP/xcGPz6C8MiwQdYrZarr2SHRASX1zFa79rkItO8kE6RDr
|
35
35
|
b6WDF79UvZ55ajtE00TiwqjQL/ZPEtbd
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2021-03-
|
37
|
+
date: 2021-03-19 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: pry
|
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
- !ruby/object:Gem::Version
|
216
216
|
version: '0'
|
217
217
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
218
|
+
rubygems_version: 3.1.4
|
219
219
|
signing_key:
|
220
220
|
specification_version: 4
|
221
221
|
summary: A ruby binding to libmdbx, an improved version of the Lightning Memory Mapped
|
metadata.gz.sig
CHANGED
Binary file
|