perobs 4.5.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +38 -0
- data/.gitignore +0 -1
- data/Gemfile +1 -0
- data/lib/perobs/Array.rb +25 -30
- data/lib/perobs/BigArray.rb +16 -29
- data/lib/perobs/BigArrayNode.rb +82 -96
- data/lib/perobs/BigHash.rb +14 -24
- data/lib/perobs/BigTree.rb +7 -17
- data/lib/perobs/BigTreeNode.rb +101 -122
- data/lib/perobs/ClassMap.rb +6 -0
- data/lib/perobs/DataBase.rb +19 -14
- data/lib/perobs/IDList.rb +2 -2
- data/lib/perobs/Store.rb +1 -1
- data/lib/perobs/version.rb +1 -1
- data/perobs.gemspec +3 -2
- data/test/Array_spec.rb +55 -59
- data/test/BTreeDB_spec.rb +5 -1
- data/test/BigTreeNode_spec.rb +5 -8
- data/test/LegacyDBs/version_4.1/class_map.json +1 -0
- data/test/LegacyDBs/version_4.1/config.json +1 -0
- data/test/LegacyDBs/version_4.1/database.blobs +0 -0
- data/test/LegacyDBs/version_4.1/database_spaces.blobs +0 -0
- data/test/LegacyDBs/version_4.1/index.blobs +0 -0
- data/test/LegacyDBs/version_4.1/log +5 -0
- data/test/LegacyDBs/version_4.1/version +1 -0
- data/test/spec_helper.rb +1 -1
- metadata +38 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab088013ef7d418174d01ec9ca992a8af41740f90e05857b58bb0f6696dcef3a
|
4
|
+
data.tar.gz: 65ec2df5c10d4725e91b8fcbaa8676a921afc11c899f179fc6895a4fb43d18c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83387ebc8c3b6288c54db762aa4ff22be19bbe40368fa5435a51ccefb8231d8afd4d4bdae6bb1e8920f0a89749ab1d25938fd28529e66b84e97604673b34d6e6
|
7
|
+
data.tar.gz: 1de1c7b4e10b19e6a55634980a87839b84cf22f400bb0c5b94e765056f1890f59a8253048127c912e35fc1d21dbfdba03516de24e832a3b4ccf92f6e9fecf540
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "master" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "master" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.2']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
# uses: ruby/setup-ruby@v1
|
33
|
+
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby-version }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/perobs/Array.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# = Array.rb -- Persistent Ruby Object Store
|
4
4
|
#
|
5
5
|
# Copyright (c) 2015, 2016, 2017 by Chris Schlaeger <chris@taskjuggler.org>
|
@@ -25,11 +25,10 @@
|
|
25
25
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
26
26
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
require_relative 'Log'
|
29
|
+
require_relative 'ObjectBase'
|
30
30
|
|
31
31
|
module PEROBS
|
32
|
-
|
33
32
|
# An Array that is transparently persisted onto the back-end storage. It is
|
34
33
|
# very similar to the Ruby built-in Array class but like other PEROBS
|
35
34
|
# object classes it converts direct references to other PEROBS objects into
|
@@ -41,15 +40,14 @@ module PEROBS
|
|
41
40
|
# with BasicObject.initialize_copy. You can use PEROBS::Array.replace()
|
42
41
|
# instead.
|
43
42
|
class Array < ObjectBase
|
44
|
-
|
45
43
|
attr_reader :data
|
46
44
|
|
47
45
|
# These methods do not mutate the Array but create a new PEROBS::Array
|
48
46
|
# object. They only perform read operations.
|
49
|
-
([
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
(%i[
|
48
|
+
| & + - collect compact drop drop_while
|
49
|
+
flatten map reject reverse rotate select shuffle slice
|
50
|
+
sort take take_while uniq values_at
|
53
51
|
] + Enumerable.instance_methods).uniq.each do |method_sym|
|
54
52
|
define_method(method_sym) do |*args, &block|
|
55
53
|
@store.cache.cache_read(self)
|
@@ -59,12 +57,12 @@ module PEROBS
|
|
59
57
|
|
60
58
|
# These methods do not mutate the Array and only perform read operations.
|
61
59
|
# They do not return basic objects types.
|
62
|
-
([
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
(%i[
|
61
|
+
== [] <=> at bsearch bsearch_index count cycle
|
62
|
+
each each_index empty? eql? fetch find_index first
|
63
|
+
frozen? include? index join last length pack
|
64
|
+
pretty_print pretty_print_cycle reverse_each rindex sample
|
65
|
+
size to_a to_ary to_s
|
68
66
|
] + Enumerable.instance_methods).uniq.each do |method_sym|
|
69
67
|
define_method(method_sym) do |*args, &block|
|
70
68
|
@store.cache.cache_read(self)
|
@@ -73,11 +71,11 @@ module PEROBS
|
|
73
71
|
end
|
74
72
|
|
75
73
|
# These methods mutate the Array and return self.
|
76
|
-
[
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
%i[
|
75
|
+
<< clear collect! compact! concat
|
76
|
+
fill flatten! insert keep_if map! push
|
77
|
+
reject! replace select! reverse! rotate! shuffle!
|
78
|
+
slice! sort! sort_by! uniq!
|
81
79
|
].each do |method_sym|
|
82
80
|
define_method(method_sym) do |*args, &block|
|
83
81
|
@store.cache.cache_write(self)
|
@@ -87,8 +85,8 @@ module PEROBS
|
|
87
85
|
end
|
88
86
|
|
89
87
|
# These methods mutate the Array.
|
90
|
-
[
|
91
|
-
|
88
|
+
%i[
|
89
|
+
delete delete_at delete_if shift pop
|
92
90
|
].each do |method_sym|
|
93
91
|
define_method(method_sym) do |*args, &block|
|
94
92
|
@store.cache.cache_write(self)
|
@@ -104,7 +102,7 @@ module PEROBS
|
|
104
102
|
# Array to initialize
|
105
103
|
# @param default [Any] The default value that is returned when no value is
|
106
104
|
# stored for a specific key.
|
107
|
-
def initialize(p, arg1 = 0, default = nil
|
105
|
+
def initialize(p, arg1 = 0, default = nil)
|
108
106
|
super(p)
|
109
107
|
if arg1.is_a?(::Array)
|
110
108
|
arg1.each { |v| _check_assignment_value(v) }
|
@@ -123,7 +121,7 @@ module PEROBS
|
|
123
121
|
|
124
122
|
# Proxy for the assignment method.
|
125
123
|
def []=(*args)
|
126
|
-
if
|
124
|
+
if args.length == 2
|
127
125
|
_check_assignment_value(args[1])
|
128
126
|
else
|
129
127
|
_check_assignment_value(args[2])
|
@@ -144,8 +142,8 @@ module PEROBS
|
|
144
142
|
# @return [Array of Integer] IDs of referenced objects
|
145
143
|
def _referenced_object_ids
|
146
144
|
@data.each.select do |v|
|
147
|
-
v
|
148
|
-
end.map
|
145
|
+
v&.respond_to?(:is_poxreference?)
|
146
|
+
end.map(&:id)
|
149
147
|
end
|
150
148
|
|
151
149
|
# This method should only be used during store repair operations. It will
|
@@ -199,8 +197,5 @@ module PEROBS
|
|
199
197
|
end
|
200
198
|
end
|
201
199
|
end
|
202
|
-
|
203
200
|
end
|
204
|
-
|
205
201
|
end
|
206
|
-
|
data/lib/perobs/BigArray.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# # frozen_string_literal: true
|
2
2
|
#
|
3
3
|
# = BigArray.rb -- Persistent Ruby Object Store
|
4
4
|
#
|
@@ -26,20 +26,16 @@
|
|
26
26
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
27
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
require_relative 'Object'
|
30
|
+
require_relative 'BigArrayNode'
|
31
31
|
|
32
32
|
module PEROBS
|
33
|
-
|
34
33
|
# The BigArray class implements an Array that stores the data in segments. It
|
35
34
|
# only loads the currently needed parts of the Array into memory. To provide
|
36
35
|
# an efficient access to the data by index a B+Tree like data structure is
|
37
36
|
# used. Each segment is stored in a leaf node of the B+Tree.
|
38
37
|
class BigArray < PEROBS::Object
|
39
|
-
|
40
|
-
class Stats < Struct.new(:leaf_nodes, :branch_nodes, :min_depth,
|
41
|
-
:max_depth)
|
42
|
-
end
|
38
|
+
Stats = Struct.new(:leaf_nodes, :branch_nodes, :min_depth, :max_depth)
|
43
39
|
|
44
40
|
attr_persist :node_size, :root, :first_leaf, :last_leaf, :entry_counter
|
45
41
|
|
@@ -53,12 +49,8 @@ module PEROBS
|
|
53
49
|
# range to try.
|
54
50
|
def initialize(p, node_size = 150)
|
55
51
|
super(p)
|
56
|
-
unless node_size > 3
|
57
|
-
|
58
|
-
end
|
59
|
-
unless node_size % 2 == 0
|
60
|
-
PEROBS.log.fatal "Node size (#{node_size}) must be an even number"
|
61
|
-
end
|
52
|
+
PEROBS.log.fatal "Node size (#{node_size}) must be larger than 3" unless node_size > 3
|
53
|
+
PEROBS.log.fatal "Node size (#{node_size}) must be an even number" unless (node_size % 2).zero?
|
62
54
|
|
63
55
|
self.node_size = node_size
|
64
56
|
clear
|
@@ -146,11 +138,9 @@ module PEROBS
|
|
146
138
|
# @param index [Integer] Index in the BigArray
|
147
139
|
# @return [Object] found value or nil
|
148
140
|
def delete_at(index)
|
149
|
-
|
150
|
-
index = @entry_counter + index
|
151
|
-
end
|
141
|
+
index = @entry_counter + index if index.negative?
|
152
142
|
|
153
|
-
return nil if index
|
143
|
+
return nil if index.negative? || index >= @entry_counter
|
154
144
|
|
155
145
|
deleted_value = nil
|
156
146
|
@store.transaction do
|
@@ -176,9 +166,7 @@ module PEROBS
|
|
176
166
|
old_root = @root
|
177
167
|
clear
|
178
168
|
old_root.each do |k, v|
|
179
|
-
|
180
|
-
insert(k, v)
|
181
|
-
end
|
169
|
+
insert(k, v) unless yield(k, v)
|
182
170
|
end
|
183
171
|
end
|
184
172
|
|
@@ -191,7 +179,7 @@ module PEROBS
|
|
191
179
|
|
192
180
|
# Return true if the BigArray has no stored entries.
|
193
181
|
def empty?
|
194
|
-
@entry_counter
|
182
|
+
@entry_counter.zero?
|
195
183
|
end
|
196
184
|
|
197
185
|
# Return the first entry of the Array.
|
@@ -215,6 +203,7 @@ module PEROBS
|
|
215
203
|
node = @first_leaf
|
216
204
|
while node
|
217
205
|
break unless node.each(&block)
|
206
|
+
|
218
207
|
node = node.next_sibling
|
219
208
|
end
|
220
209
|
end
|
@@ -226,6 +215,7 @@ module PEROBS
|
|
226
215
|
node = @last_leaf
|
227
216
|
while node
|
228
217
|
break unless node.reverse_each(&block)
|
218
|
+
|
229
219
|
node = node.prev_sibling
|
230
220
|
end
|
231
221
|
end
|
@@ -236,7 +226,7 @@ module PEROBS
|
|
236
226
|
def to_a
|
237
227
|
ary = []
|
238
228
|
node = @first_leaf
|
239
|
-
while node
|
229
|
+
while node
|
240
230
|
ary += node.values
|
241
231
|
node = node.next_sibling
|
242
232
|
end
|
@@ -267,10 +257,10 @@ module PEROBS
|
|
267
257
|
private
|
268
258
|
|
269
259
|
def validate_index_range(index)
|
270
|
-
if index
|
260
|
+
if index.negative?
|
271
261
|
if -index > @entry_counter
|
272
|
-
raise IndexError, "index #{index} too small for array; "
|
273
|
-
|
262
|
+
raise IndexError, "index #{index} too small for array; " \
|
263
|
+
"minimum #{-@entry_counter}"
|
274
264
|
end
|
275
265
|
|
276
266
|
index = @entry_counter + index
|
@@ -278,8 +268,5 @@ module PEROBS
|
|
278
268
|
|
279
269
|
index
|
280
270
|
end
|
281
|
-
|
282
271
|
end
|
283
|
-
|
284
272
|
end
|
285
|
-
|