isomorfeus-data 2.2.10 → 2.3.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: ac14fede053fd257ce57f22eccb8a83c3f1f563e95969d72e5c8fdc269b81ebc
4
- data.tar.gz: 232a02ed01f77d627f9bf91726b53973d3becc8e2e6d9705c196e8e77d825c6f
3
+ metadata.gz: ecada7abb58b35e74c7f0443286a473e9c8662118068258b8752d671fe73bd6a
4
+ data.tar.gz: bd60bdcceec9379fadd760deef48a5b81718d07020fb5384836b584c869dc384
5
5
  SHA512:
6
- metadata.gz: a8042dfbc75120886f39f550ccae76050017cdd7d62ef1ede12dc63739ee706839d86856f122cef7bceede7ee08c2816646f5902f713f0d57f05e3159f3a03e6
7
- data.tar.gz: 7fe8c3031d9c71a5709559a4a83445015da3ea0f48b228e35b910cb9ea0506636f3babcfff772ecdf133480cd2685f9be5f1992c6c3315a8877ceaeb3010598d
6
+ metadata.gz: 5ae0594cefae1ac6773387a21de8fc696d84e3b24816d09828b1130684b07dc15729eede6d4dbf33a377438b9ffa1c23289594e12e0acddbbd553010fc2bf963
7
+ data.tar.gz: a4f43cb48a4ce2143ec73632ce4d1acca57a7c0f464650be8539148ea3f561a54a90d35a5d982867e71b5f414a769beb1e1e24ac7205b5094b6d4ae98ca9a1a1
@@ -79,7 +79,7 @@ module Isomorfeus
79
79
 
80
80
  # objects, nodes and edges
81
81
  self.hamster_path = File.expand_path(File.join(self.storage_path, 'hamster'))
82
- self.hamster_mapsize = 4294967296
82
+ self.hamster_mapsize = 4_294_967_296
83
83
  self.data_object_envs_path = File.expand_path(File.join(self.hamster_path, 'object_envs'))
84
84
  self.data_object_idxs_path = File.expand_path(File.join(self.hamster_path, 'object_idxs'))
85
85
  end
@@ -50,11 +50,11 @@ module Isomorfeus
50
50
  end
51
51
 
52
52
  def index_put(key, val)
53
- @index_db.put(key, val)
53
+ environment.transaction { @index_db.put(key, val) }
54
54
  end
55
55
 
56
- def each(&block)
57
- @db.each do |key, obj|
56
+ def each(readonly: true, &block)
57
+ @db.each(readonly: readonly) do |key, obj|
58
58
  block.call(Isomorfeus::Hamster::Marshal.unserialize(obj, class_cache: @use_class_cache))
59
59
  end
60
60
  end
@@ -67,7 +67,12 @@ module Isomorfeus
67
67
 
68
68
  def open_environment
69
69
  FileUtils.mkdir_p(@env_path) unless Dir.exist?(@env_path)
70
- self.environment = Isomorfeus::Hamster.new(@env_path, mapsize: Isomorfeus.hamster_mapsize)
70
+ begin
71
+ self.environment = Isomorfeus::Hamster.new(@env_path, mapsize: Isomorfeus.hamster_mapsize)
72
+ rescue RangeError
73
+ self.environment = Isomorfeus::Hamster.new(@env_path, mapsize: 2_147_483_647)
74
+ STDERR.puts "Isomorfeus::Data Warning: Hamster Object Store limited to 2Gb because of platform restrictions."
75
+ end
71
76
  end
72
77
  end
73
78
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Data
3
- VERSION = '2.2.10'
3
+ VERSION = '2.3.1'
4
4
  end
5
5
  end
@@ -106,6 +106,16 @@ module LucidDocument
106
106
  end
107
107
  end
108
108
 
109
+ def each(&block)
110
+ self.ferret_accelerator.each do |id|
111
+ doc = self.ferret_accelerator.index.doc(id)&.load
112
+ if doc
113
+ key = doc.delete(:key)
114
+ block.call(self.new(key: key, fields: doc))
115
+ end
116
+ end
117
+ end
118
+
109
119
  def search(query, options = {})
110
120
  top_docs = []
111
121
  self.ferret_accelerator.search_each(query, options) do |id|
@@ -18,72 +18,6 @@ module LucidFile
18
18
  result
19
19
  end
20
20
 
21
- def content_type
22
- _reload
23
- return @_data_uri_object.content_type if @_data_uri_object
24
- nil
25
- end
26
-
27
- def content_type=(c)
28
- changed!
29
- _content_type(c)
30
- end
31
-
32
- def _content_type(c)
33
- _reload
34
- @_data_uri_string = _format_data_uri(c, @_data_uri_object.data)
35
- @_data_uri_object = URI::Data.new(@_data_uri_string)
36
- c
37
- end
38
-
39
- def data
40
- _reload
41
- @_data_uri_object.data
42
- end
43
-
44
- def data=(d)
45
- changed!
46
- _data(d)
47
- end
48
-
49
- def _data(d)
50
- _reload
51
- @_data_uri_string = _format_data_uri(self.content_type, d)
52
- @_data_uri_object = URI::Data.new(@_data_uri_string)
53
- d
54
- end
55
-
56
- def data_uri
57
- _reload
58
- @_data_uri_string
59
- end
60
-
61
- def data_uri=(d)
62
- changed!
63
- _data_uri(d)
64
- end
65
-
66
- def _data_uri(d)
67
- _reload
68
- if d.class == URI::Data
69
- @_data_uri_string = _format_data_uri(d.content_type, d.data)
70
- @_data_uri_object = d
71
- else
72
- @_data_uri_string = d
73
- @_data_uri_object = URI::Data.new(d)
74
- end
75
- @_data_uri_string
76
- end
77
-
78
- def data_uri_object
79
- _reload
80
- @_data_uri_object
81
- end
82
-
83
- def _format_data_uri(c, d)
84
- "data:#{c};base64,#{Base64.encode64(d).chop}"
85
- end
86
-
87
21
  if RUBY_ENGINE == 'opal'
88
22
  base.instance_exec do
89
23
  def files_path
@@ -130,6 +64,72 @@ module LucidFile
130
64
  def _update_paths
131
65
  @_store_path = [:data_state, @class_name, @key, :data_uri]
132
66
  end
67
+
68
+ def content_type
69
+ _reload
70
+ return @_data_uri_object.content_type if @_data_uri_object
71
+ nil
72
+ end
73
+
74
+ def content_type=(c)
75
+ changed!
76
+ _content_type(c)
77
+ end
78
+
79
+ def _content_type(c)
80
+ _reload
81
+ @_data_uri_string = _format_data_uri(c, @_data_uri_object.data)
82
+ @_data_uri_object = URI::Data.new(@_data_uri_string)
83
+ c
84
+ end
85
+
86
+ def data
87
+ _reload
88
+ @_data_uri_object.data
89
+ end
90
+
91
+ def data=(d)
92
+ changed!
93
+ _data(d)
94
+ end
95
+
96
+ def _data(d)
97
+ _reload
98
+ @_data_uri_string = _format_data_uri(self.content_type, d)
99
+ @_data_uri_object = URI::Data.new(@_data_uri_string)
100
+ d
101
+ end
102
+
103
+ def data_uri
104
+ _reload
105
+ @_data_uri_string
106
+ end
107
+
108
+ def data_uri=(d)
109
+ changed!
110
+ _data_uri(d)
111
+ end
112
+
113
+ def _data_uri(d)
114
+ _reload
115
+ if d.class == URI::Data
116
+ @_data_uri_string = _format_data_uri(d.content_type, d.data)
117
+ @_data_uri_object = d
118
+ else
119
+ @_data_uri_string = d
120
+ @_data_uri_object = URI::Data.new(d)
121
+ end
122
+ @_data_uri_string
123
+ end
124
+
125
+ def data_uri_object
126
+ _reload
127
+ @_data_uri_object
128
+ end
129
+
130
+ def _format_data_uri(c, d)
131
+ "data:#{c};base64,#{Base64.encode64(d).chop}"
132
+ end
133
133
  else # RUBY_ENGINE
134
134
  Isomorfeus.add_valid_file_class(base) unless base == LucidFile::Base
135
135
 
@@ -163,7 +163,7 @@ module LucidFile
163
163
  file = elements.pop
164
164
  if elements.size > 0
165
165
  dir_path = ::File.expand_path(::File.join(files_path, *elements))
166
- FileUtils.mkdir_p(path) unless Dir.exist?(dir_path)
166
+ FileUtils.mkdir_p(dir_path) unless Dir.exist?(dir_path)
167
167
  ::File.join(dir_path, file)
168
168
  else
169
169
  FileUtils.mkdir_p(files_path) unless Dir.exist?(files_path)
@@ -183,15 +183,18 @@ module LucidFile
183
183
 
184
184
  execute_load do |key:|
185
185
  file = check_and_prepare_path(key: key)
186
- d = ::File.read(file)
187
- instance = self.new(key: key)
188
- instance.data = d
189
- instance
186
+ if File.exist?(file)
187
+ d = ::File.binread(file)
188
+ instance = self.new(key: key, data: d)
189
+ instance
190
+ else
191
+ nil
192
+ end
190
193
  end
191
194
 
192
195
  execute_save do
193
196
  file = self.class.check_and_prepare_path(key: self.key)
194
- ::File.write(file, self.data)
197
+ ::File.binwrite(file, self.data)
195
198
  self
196
199
  end
197
200
  end
@@ -201,24 +204,77 @@ module LucidFile
201
204
  @class_name = self.class.name
202
205
  @class_name = @class_name.split('>::').last if @class_name.start_with?('#<')
203
206
  @_revision = revision
204
- @_data_uri_object = nil
205
- @_data_uri_string = nil
206
207
  if data_uri
207
208
  self._data_uri(data_uri)
208
209
  else
209
- self._data(data ? data : '')
210
- self._content_type(content_type) if content_type
210
+ @_data = data
211
+ @_content_type = content_type
211
212
  end
212
213
  @_changed = false
213
214
  end
214
215
 
215
- def _reload
216
- end
217
-
218
216
  def _unchange!
219
- @_data_uri = @_changed_data_uri if @_changed
220
217
  @_changed = false
221
218
  end
219
+
220
+ def content_type
221
+ @_content_type = @_data_uri_object.content_type if !@_content_type && @_data_uri_object
222
+ @_content_type
223
+ end
224
+
225
+ def content_type=(c)
226
+ changed!
227
+ _content_type(c)
228
+ end
229
+
230
+ def _content_type(c)
231
+ if @_data_uri_string
232
+ @_data_uri_string = _format_data_uri(c, @_data_uri_object.data)
233
+ @_data_uri_object = URI::Data.new(@_data_uri_string)
234
+ end
235
+ @_content_type = c
236
+ end
237
+
238
+ def data
239
+ @_data = @_data_uri_object.data if !@_data && @_data_uri_object
240
+ @_data
241
+ end
242
+
243
+ def data=(d)
244
+ changed!
245
+ @_data = d
246
+ end
247
+
248
+ def data_uri
249
+ _data_uri(_format_data_uri(content_type, @_data)) if !@_data_uri_string && @_data
250
+ @_data_uri_string
251
+ end
252
+
253
+ def data_uri=(d)
254
+ changed!
255
+ _data_uri(d)
256
+ end
257
+
258
+ def _data_uri(d)
259
+ if d.class == URI::Data
260
+ d = '' if d.nil?
261
+ @_data_uri_string = _format_data_uri(d.content_type, d.data)
262
+ @_data_uri_object = d
263
+ else
264
+ @_data_uri_string = d
265
+ @_data_uri_object = URI::Data.new(d)
266
+ end
267
+ @_data_uri_string
268
+ end
269
+
270
+ def data_uri_object
271
+ _data_uri(@_data) if !@_data_uri_object && @_data
272
+ @_data_uri_object
273
+ end
274
+
275
+ def _format_data_uri(c, d)
276
+ "data:#{c};base64,#{Base64.encode64(d).chop}"
277
+ end
222
278
  end # RUBY_ENGINE
223
279
  end
224
280
  end
@@ -125,6 +125,12 @@ module LucidObject
125
125
  end
126
126
  end
127
127
 
128
+ def each(readonly: true, &block)
129
+ self.object_expander.each(readonly: readonly) do |obj|
130
+ block.call(obj) if obj.class == self
131
+ end
132
+ end
133
+
128
134
  def search(attr, val, options = {})
129
135
  idx_type = self.indexed_attributes[attr]
130
136
  raise "Can only search indexed attributes, but attribute :#{attr} is not indexed!" unless idx_type
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-data
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.10
4
+ version: 2.3.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: 2022-02-26 00:00:00.000000000 Z
11
+ date: 2022-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.14.17
75
+ version: 0.14.21
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.14.17
82
+ version: 0.14.21
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: isomorfeus-ferret
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,56 +100,56 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.6.6
103
+ version: 0.6.7
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.6.6
110
+ version: 0.6.7
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: isomorfeus-i18n
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 2.2.10
117
+ version: 2.3.1
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 2.2.10
124
+ version: 2.3.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: isomorfeus-policy
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 2.2.10
131
+ version: 2.3.1
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 2.2.10
138
+ version: 2.3.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: isomorfeus-preact
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 10.6.54
145
+ version: 10.6.61
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 10.6.54
152
+ version: 10.6.61
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: isomorfeus-redux
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,28 +170,28 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 2.2.10
173
+ version: 2.3.1
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 2.2.10
180
+ version: 2.3.1
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: isomorfeus
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - '='
186
186
  - !ruby/object:Gem::Version
187
- version: 2.2.10
187
+ version: 2.3.1
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - '='
193
193
  - !ruby/object:Gem::Version
194
- version: 2.2.10
194
+ version: 2.3.1
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rake
197
197
  requirement: !ruby/object:Gem::Requirement