isomorfeus-hamster 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f2c656886add52a2a6c29ccc906bb62f352472c798a0338a51fd1a292c9d352
4
- data.tar.gz: 96cfa58fae24aaf67e3494c09bea40f9e222dedcc6018336f61f778b1b0c47ae
3
+ metadata.gz: 552d35f21d131aeec9aa8afdcb99997a0b287c9932fc8e2f347c90baa41af9d2
4
+ data.tar.gz: 25eb9e961d3e413fcd8b195ea484ad7a1ea6748443520b54b3157b55970e8978
5
5
  SHA512:
6
- metadata.gz: 8a95b54cd64e1b73953aea2629bb9be0ffe107f9256bcf98ee619801c4a399f9ebacede1a6be9f02a1e99af05245038d8a1950fb2e172f4d87a1c8d7f0ba140b
7
- data.tar.gz: f954296c5e25078c26bfc03e7a2b29df2ea8d71a2140448476eced461e21ab2a68143b876e4a3c01a0a14bd8b70c0098167d9f2b6e014a6a8ae56e0b62a54c26
6
+ metadata.gz: e090d821802de1215d642165fa9c736dbf0a02d16997128836b5264add64d00146ea7b0cf69ec67deb4803c808aadd3a0469ca48781b1abeb62d5ec2064a55f4
7
+ data.tar.gz: a222840275ff93f21fe6e908b6f911f31e4b2da3120aab6818808faa25bd6d0d833c6e7367b62df5ed28b9d300c5043a96c20d63e626b426dacf9713a8852a17
@@ -146,9 +146,10 @@ static void transaction_finish(VALUE self, int commit) {
146
146
  mdb_txn_abort(transaction->txn);
147
147
 
148
148
  long i;
149
+ // mdb_txn_commit and mdb_txn_abort already closed MDB cursors, just clear it
149
150
  for (i=0; i<RARRAY_LEN(transaction->cursors); i++) {
150
151
  VALUE cursor = RARRAY_AREF(transaction->cursors, i);
151
- cursor_close(cursor);
152
+ cursor_clear(cursor);
152
153
  }
153
154
  rb_ary_clear(transaction->cursors);
154
155
 
@@ -1015,6 +1016,15 @@ static void cursor_mark(Cursor* cursor) {
1015
1016
  rb_gc_mark(cursor->db);
1016
1017
  }
1017
1018
 
1019
+ /**
1020
+ * @overload clear
1021
+ * Clear a cursor after the mdb cursor has been closed. The cursor must not be used again after this call.
1022
+ */
1023
+ void cursor_clear(VALUE self) {
1024
+ CURSOR(self, cursor);
1025
+ cursor->cur = 0;
1026
+ }
1027
+
1018
1028
  /**
1019
1029
  * @overload close
1020
1030
  * Close a cursor. The cursor must not be used again after this call.
@@ -108,6 +108,7 @@ static VALUE call_with_transaction(VALUE venv, VALUE self, const char* name, int
108
108
  static VALUE call_with_transaction_helper(VALUE arg);
109
109
  static void check(int code);
110
110
  static void cursor_check(Cursor* cursor);
111
+ static void cursor_clear(VALUE self);
111
112
  static VALUE cursor_close(VALUE self);
112
113
  static VALUE cursor_count(VALUE self);
113
114
  static VALUE cursor_delete(int argc, VALUE *argv, VALUE self);
@@ -3,59 +3,13 @@ module Isomorfeus
3
3
  module Marshal
4
4
  class << self
5
5
  def dump(db, key, obj)
6
- db.env.transaction { db.put(key, Oj.dump(obj)) }
6
+ db.env.transaction { db.put(key, ::Oj.dump(obj)) }
7
7
  end
8
8
 
9
9
  def load(db, key)
10
10
  obj_j = db.get(key)
11
11
  return nil unless obj_j
12
- Oj.load(obj_j)
13
- end
14
-
15
- def structured_dump(db, obj)
16
- kv = []
17
- oc = obj.class.to_s
18
- ky = obj.key
19
- as = obj.attributes
20
- kv << [ats_key(oc, ky), Oj.dump(as)]
21
- as.each do |at|
22
- kv << [at_key(oc, ky, at), Oj.dump(obj.send(at))]
23
- end
24
- db.env.transaction do
25
- kv.each do |k, v|
26
- db.put(k, v)
27
- end
28
- end
29
- end
30
-
31
- def structured_load(db, oc, ky)
32
- if oc.class = String
33
- oC = const_get(oc)
34
- else
35
- oC = oc
36
- oc = oc.to_s
37
- end
38
- ak = ats_key(oc, ky)
39
- oh = {}
40
- db.env.transaction do
41
- as_j = db.get(ak)
42
- as = Oj.load(as_j)
43
- as.each do |at|
44
- v_j = db.get(at_key(oc, ky, at))
45
- oh[at] = Oj.load(v_j)
46
- end
47
- end
48
- oC.instance_from_hash(oh)
49
- end
50
-
51
- private
52
-
53
- def ats_key(oc, ky)
54
- "#{oc}|#{ky}|attributes"
55
- end
56
-
57
- def at_key(oc, ky, at)
58
- "#{oc}|#{ky}|:|#{at}"
12
+ ::Oj.load(obj_j)
59
13
  end
60
14
  end
61
15
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Hamster
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
+ require 'oj'
1
2
  require 'isomorfeus_hamster_ext'
2
3
  require 'isomorfeus/hamster/version'
3
4
  require 'isomorfeus/hamster/database'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-hamster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-02 00:00:00.000000000 Z
11
+ date: 2021-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubygems_version: 3.2.15
121
+ rubygems_version: 3.2.22
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: KV store and ObjectDB for Isomorfeus.