isomorfeus-hamster 0.6.0 → 0.6.4

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: c0a62ae4a77a996b8dc257b1f39600f1c90a2903765fb495a8ae47e70ba961c7
4
+ data.tar.gz: 3fd95f68beed49e13b4f2c3dc13ffc97d9ad48beb3b62822e232c1781aee5f59
5
5
  SHA512:
6
- metadata.gz: 8a95b54cd64e1b73953aea2629bb9be0ffe107f9256bcf98ee619801c4a399f9ebacede1a6be9f02a1e99af05245038d8a1950fb2e172f4d87a1c8d7f0ba140b
7
- data.tar.gz: f954296c5e25078c26bfc03e7a2b29df2ea8d71a2140448476eced461e21ab2a68143b876e4a3c01a0a14bd8b70c0098167d9f2b6e014a6a8ae56e0b62a54c26
6
+ metadata.gz: aa0b2b6738eab73e3ceb690ad5fdaa8a90e2046ff6a2429dded499afe78d3286a14ec9a9a7bfae03d78a78f685b9ba24abcb84b4e276b2fb2820b59d573f8405
7
+ data.tar.gz: d59d6b728565ea92591f49eb49f0c8228bcf1423fe052de117dc3b24c5f97dc70f502a7a96b422aa5fc9a8385844add878ff755745f91535fa756e664fdbf16c
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
- # isomorfeus-hamster
1
+ <h1 align="center">
2
+ <img src="https://github.com/isomorfeus/isomorfeus-hamster/blob/master/Logo.png?raw=true" align="center" width="234" height="143" />
3
+ <br/>
4
+ Isomorfeus Hamster<br/>
5
+ </h1>
2
6
 
3
7
  Convenient and well performing key value store and object database.
4
8
 
5
9
  ### Community and Support
6
10
  At the [Isomorfeus Framework Project](http://isomorfeus.com)
7
-
@@ -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);
@@ -2,60 +2,22 @@ module Isomorfeus
2
2
  module Hamster
3
3
  module Marshal
4
4
  class << self
5
- def dump(db, key, obj)
6
- db.env.transaction { db.put(key, Oj.dump(obj)) }
5
+ def dump(db, key, obj, class_cache: true)
6
+ db.env.transaction { db.put(key, ::Oj.dump(obj, mode: :object, class_cache: class_cache)) }
7
7
  end
8
8
 
9
- def load(db, key)
9
+ def load(db, key, class_cache: true)
10
10
  obj_j = db.get(key)
11
11
  return nil unless obj_j
12
- Oj.load(obj_j)
12
+ ::Oj.load(obj_j, mode: :object, class_cache: class_cache)
13
13
  end
14
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
15
+ def serialize(obj, class_cache: true)
16
+ ::Oj.dump(obj, mode: :object, class_cache: class_cache)
29
17
  end
30
18
 
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}"
19
+ def unserialize(obj_j, class_cache: true)
20
+ ::Oj.load(obj_j, mode: :object, class_cache: class_cache)
59
21
  end
60
22
  end
61
23
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Hamster
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.4'
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.4
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: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.13.9
19
+ version: 3.13.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.13.9
26
+ version: 3.13.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +103,7 @@ licenses:
103
103
  - MIT
104
104
  metadata:
105
105
  github_repo: ssh://github.com/isomorfeus/gems
106
+ source_code_uri: https://github.com/isomorfeus/isomorfeus-hamster
106
107
  post_install_message:
107
108
  rdoc_options: []
108
109
  require_paths:
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  - !ruby/object:Gem::Version
119
120
  version: '0'
120
121
  requirements: []
121
- rubygems_version: 3.2.15
122
+ rubygems_version: 3.3.3
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: KV store and ObjectDB for Isomorfeus.