perobs 4.2.0 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -16
- data/lib/perobs/BTree.rb +2 -2
- data/lib/perobs/BTreeNode.rb +46 -29
- data/lib/perobs/BigArrayNode.rb +11 -9
- data/lib/perobs/Cache.rb +32 -6
- data/lib/perobs/EquiBlobsFile.rb +2 -0
- data/lib/perobs/FlatFile.rb +40 -60
- data/lib/perobs/FuzzyStringMatcher.rb +32 -49
- data/lib/perobs/Hash.rb +68 -23
- data/lib/perobs/IDListPageFile.rb +2 -1
- data/lib/perobs/IDListPageRecord.rb +1 -1
- data/lib/perobs/Log.rb +5 -0
- data/lib/perobs/ObjectBase.rb +7 -0
- data/lib/perobs/SpaceTree.rb +1 -1
- data/lib/perobs/Store.rb +177 -125
- data/lib/perobs/version.rb +1 -1
- data/lib/perobs.rb +1 -0
- data/perobs.gemspec +1 -1
- data/test/FlatFileDB_spec.rb +30 -0
- data/test/FuzzyStringMatcher_spec.rb +94 -4
- data/test/Hash_spec.rb +12 -1
- data/test/Store_spec.rb +14 -0
- metadata +8 -10
- data/lib/perobs/BTreeNodeCache.rb +0 -109
data/test/Hash_spec.rb
CHANGED
@@ -31,7 +31,6 @@ require 'spec_helper'
|
|
31
31
|
|
32
32
|
require 'perobs'
|
33
33
|
|
34
|
-
|
35
34
|
class PO < PEROBS::Object
|
36
35
|
|
37
36
|
attr_persist :name
|
@@ -68,9 +67,13 @@ describe PEROBS::Hash do
|
|
68
67
|
h['po'] = po = @store.new(PO)
|
69
68
|
po.name = 'foobar'
|
70
69
|
h['b'] = 'B'
|
70
|
+
@store['po_key'] = po_key = @store.new(PO)
|
71
|
+
po_key.name = 'po key'
|
72
|
+
h[po_key] = 'PO Key'
|
71
73
|
|
72
74
|
expect(h['a']).to eq('A')
|
73
75
|
expect(h['b']).to eq('B')
|
76
|
+
expect(h[@store['po_key']]).to eq('PO Key')
|
74
77
|
@store.exit
|
75
78
|
|
76
79
|
@store = PEROBS::Store.new(@db_name)
|
@@ -78,6 +81,14 @@ describe PEROBS::Hash do
|
|
78
81
|
expect(h['a']).to eq('A')
|
79
82
|
expect(h['b']).to eq('B')
|
80
83
|
expect(h['po'].name).to eq('foobar')
|
84
|
+
po_key = @store['po_key']
|
85
|
+
expect(po_key.name).to eq('po key')
|
86
|
+
expect(h[po_key]).to eq('PO Key')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should not allow hash keys that conflict with internal notations' do
|
90
|
+
@store['h'] = h = @store.new(PEROBS::Hash)
|
91
|
+
expect { h['#<PEROBS::POReference id=1234>'] = 'foo'; @store.sync }.to raise_error(ArgumentError)
|
81
92
|
end
|
82
93
|
|
83
94
|
it 'should have an each method to iterate' do
|
data/test/Store_spec.rb
CHANGED
@@ -251,6 +251,20 @@ describe PEROBS::Store do
|
|
251
251
|
end
|
252
252
|
expect(i).to eq(6)
|
253
253
|
|
254
|
+
capture_io { store.gc }
|
255
|
+
capture_io { expect { store.check }.to_not raise_error }
|
256
|
+
capture_io { store.exit }
|
257
|
+
|
258
|
+
store = PEROBS::Store.new(@db_file)
|
259
|
+
capture_io { expect { store.check }.to_not raise_error }
|
260
|
+
|
261
|
+
person = store['person1']
|
262
|
+
i = 0
|
263
|
+
while (person = person.related) do
|
264
|
+
i += 1
|
265
|
+
end
|
266
|
+
expect(i).to eq(6)
|
267
|
+
|
254
268
|
capture_io { store.gc }
|
255
269
|
capture_io { expect { store.check }.to_not raise_error }
|
256
270
|
expect { store.delete_store }.to_not raise_error
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schlaeger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 13.0.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 13.0.3
|
55
55
|
description: Library to provide a persistent object store
|
56
56
|
email:
|
57
57
|
- chris@linux.com
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- lib/perobs/BTreeBlob.rb
|
71
71
|
- lib/perobs/BTreeDB.rb
|
72
72
|
- lib/perobs/BTreeNode.rb
|
73
|
-
- lib/perobs/BTreeNodeCache.rb
|
74
73
|
- lib/perobs/BTreeNodeLink.rb
|
75
74
|
- lib/perobs/BigArray.rb
|
76
75
|
- lib/perobs/BigArrayNode.rb
|
@@ -147,7 +146,7 @@ homepage: https://github.com/scrapper/perobs
|
|
147
146
|
licenses:
|
148
147
|
- MIT
|
149
148
|
metadata: {}
|
150
|
-
post_install_message:
|
149
|
+
post_install_message:
|
151
150
|
rdoc_options: []
|
152
151
|
require_paths:
|
153
152
|
- lib
|
@@ -162,9 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
161
|
- !ruby/object:Gem::Version
|
163
162
|
version: '0'
|
164
163
|
requirements: []
|
165
|
-
|
166
|
-
|
167
|
-
signing_key:
|
164
|
+
rubygems_version: 3.2.32
|
165
|
+
signing_key:
|
168
166
|
specification_version: 4
|
169
167
|
summary: Persistent Ruby Object Store
|
170
168
|
test_files:
|
@@ -1,109 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# = BTree.rb -- Persistent Ruby Object Store
|
4
|
-
#
|
5
|
-
# Copyright (c) 2016, 2017 by Chris Schlaeger <chris@taskjuggler.org>
|
6
|
-
#
|
7
|
-
# MIT License
|
8
|
-
#
|
9
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
10
|
-
# a copy of this software and associated documentation files (the
|
11
|
-
# "Software"), to deal in the Software without restriction, including
|
12
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
13
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
14
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
15
|
-
# the following conditions:
|
16
|
-
#
|
17
|
-
# The above copyright notice and this permission notice shall be
|
18
|
-
# included in all copies or substantial portions of the Software.
|
19
|
-
#
|
20
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
21
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
23
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
24
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
25
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
26
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27
|
-
|
28
|
-
require 'perobs/BTreeNode'
|
29
|
-
|
30
|
-
module PEROBS
|
31
|
-
|
32
|
-
class BTreeNodeCache
|
33
|
-
|
34
|
-
def initialize(tree)
|
35
|
-
@tree = tree
|
36
|
-
clear
|
37
|
-
end
|
38
|
-
|
39
|
-
def get(address)
|
40
|
-
if (node = @modified_nodes[address])
|
41
|
-
return node
|
42
|
-
end
|
43
|
-
|
44
|
-
if (node = @top_nodes[address])
|
45
|
-
return node
|
46
|
-
end
|
47
|
-
|
48
|
-
if (node = @ephemeral_nodes[address])
|
49
|
-
return node
|
50
|
-
end
|
51
|
-
|
52
|
-
BTreeNode::load(@tree, address)
|
53
|
-
end
|
54
|
-
|
55
|
-
def set_root(node)
|
56
|
-
node = node.get_node if node.is_a?(BTreeNodeLink)
|
57
|
-
|
58
|
-
@top_nodes = {}
|
59
|
-
@top_nodes[node.node_address] = node
|
60
|
-
end
|
61
|
-
|
62
|
-
def insert(node, modified = true)
|
63
|
-
unless node
|
64
|
-
PEROBS.log.fatal "nil cannot be cached"
|
65
|
-
end
|
66
|
-
node = node.get_node if node.is_a?(BTreeNodeLink)
|
67
|
-
|
68
|
-
if modified
|
69
|
-
@modified_nodes[node.node_address] = node
|
70
|
-
end
|
71
|
-
@ephemeral_nodes[node.node_address] = node
|
72
|
-
|
73
|
-
if !@top_nodes.include?(node) && node.is_top?
|
74
|
-
@top_nodes[node.node_address] = node
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def _collect(address, ruby_object_id)
|
79
|
-
# Just a dummy for now
|
80
|
-
end
|
81
|
-
|
82
|
-
# Remove a node from the cache.
|
83
|
-
# @param address [Integer] address of node to remove.
|
84
|
-
def delete(address)
|
85
|
-
@ephemeral_nodes.delete(address)
|
86
|
-
@top_nodes.delete(address)
|
87
|
-
@modified_nodes.delete(address)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Flush all dirty nodes into the backing store.
|
91
|
-
def flush(now = false)
|
92
|
-
if now || @modified_nodes.size > 1024
|
93
|
-
@modified_nodes.each_value { |node| node.write_node }
|
94
|
-
@modified_nodes = {}
|
95
|
-
end
|
96
|
-
@ephemeral_nodes = {}
|
97
|
-
end
|
98
|
-
|
99
|
-
# Remove all nodes from the cache.
|
100
|
-
def clear
|
101
|
-
@top_nodes = {}
|
102
|
-
@ephemeral_nodes = {}
|
103
|
-
@modified_nodes = {}
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|