factbase 0.14.5 → 0.14.6

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: fdee6a1a98e26f25786c6f9bffbaf201d39639b52bf8933beaa4a8053860dfde
4
- data.tar.gz: ca5ccea23c49c9ffc45d4cebf77b798bb42a527d599533d854836bf47276a532
3
+ metadata.gz: a74a73e5bfec2f7ff39d41428d6c1cbacaaf374d7b2d4b987df0833a0864f0d3
4
+ data.tar.gz: 684f79dcdae19e8fe5a2b3deb6b21d786e5f9b75e81624a08a5a28f9af3e8597
5
5
  SHA512:
6
- metadata.gz: 37a08deb9fba4cc348861fe67dd680328b635f10366f193baf9e4f955118e60a1439562416d2e7bd5e5e140243250a6daec6ce72049ad40132b987c55c16ff88
7
- data.tar.gz: c4dd0a22cfa88b3c2b4d5c87c672fe0cbbd81959dc0c96e6d8e3b4bdacec3c5ef3448b5832b9b91378d4fe4629cae72ec6af71de05ad029052478068fe6626cd
6
+ metadata.gz: 29ebcc501c156e5d84d216224918df28df4dfb114e438139b90276a297bdefa373bc848d0d93919035444a40f29c77e83aa22a2e29e5c04e10aa3d5db71068a0
7
+ data.tar.gz: 8741e804d14332085756fe5c15edb1efa28d0db8357e445f42a097d96d6f63fe87bb48ca2f9b7239e7ed87ca87d7722001be6bf8564824384033b1bb86bb543f
data/README.md CHANGED
@@ -210,35 +210,35 @@ This is the result of the benchmark:
210
210
  <!-- benchmark_begin -->
211
211
  ```text
212
212
  user
213
- insert 20000 facts 0.658630
214
- export 20000 facts 0.025967
215
- import 411020 bytes (20000 facts) 0.024282
216
- insert 10 facts 0.050191
217
- query 10 times w/txn 2.063964
218
- query 10 times w/o txn 0.044326
219
- modify 10 attrs w/txn 1.745367
220
- delete 10 facts w/txn 1.023205
221
- (and (eq what 'issue-was-closed') (exists... -> 200 2.043080
222
- (and (eq what 'issue-was-closed') (exists... -> 200/txn 1.019861
223
- (and (eq what 'issue-was-closed') (exists... -> zero 2.350912
224
- (and (eq what 'issue-was-closed') (exists... -> zero/txn 1.187649
225
- (gt time '2024-03-23T03:21:43Z') 0.304861
226
- (gt cost 50) 0.234136
227
- (eq title 'Object Thinking 5000') 0.091766
228
- (and (eq foo 42.998) (or (gt bar 200) (absent z... 0.049974
229
- (and (exists foo) (not (exists blue))) 0.926298
230
- (eq id (agg (always) (max id))) 0.606111
231
- (join "c<=cost,b<=bar" (eq id (agg (always) (ma... 1.276007
232
- (and (eq what "foo") (join "w<=what" (and (eq i... 6.827440
233
- delete! 0.218373
234
- Taped.append() x50000 0.023564
235
- Taped.each() x125 1.348705
236
- Taped.delete_if() x375 0.812740
213
+ insert 20000 facts 0.638553
214
+ export 20000 facts 0.027273
215
+ import 410717 bytes (20000 facts) 0.021643
216
+ insert 10 facts 0.042390
217
+ query 10 times w/txn 2.278994
218
+ query 10 times w/o txn 0.037285
219
+ modify 10 attrs w/txn 2.261902
220
+ delete 10 facts w/txn 1.205367
221
+ (and (eq what 'issue-was-closed') (exists... -> 200 2.092734
222
+ (and (eq what 'issue-was-closed') (exists... -> 200/txn 1.032410
223
+ (and (eq what 'issue-was-closed') (exists... -> zero 2.385969
224
+ (and (eq what 'issue-was-closed') (exists... -> zero/txn 1.190590
225
+ (gt time '2024-03-23T03:21:43Z') 0.321057
226
+ (gt cost 50) 0.210374
227
+ (eq title 'Object Thinking 5000') 0.055549
228
+ (and (eq foo 42.998) (or (gt bar 200) (absent z... 0.049508
229
+ (and (exists foo) (not (exists blue))) 0.999753
230
+ (eq id (agg (always) (max id))) 0.627528
231
+ (join "c<=cost,b<=bar" (eq id (agg (always) (ma... 1.246746
232
+ (and (eq what "foo") (join "w<=what" (and (eq i... 6.881145
233
+ delete! 0.174194
234
+ Taped.append() x50000 0.023669
235
+ Taped.each() x125 1.423781
236
+ Taped.delete_if() x375 0.843940
237
237
  ```
238
238
 
239
239
  The results were calculated in [this GHA job][benchmark-gha]
240
- on 2025-07-28 at 17:02,
240
+ on 2025-08-09 at 06:42,
241
241
  on Linux with 4 CPUs.
242
242
  <!-- benchmark_end -->
243
243
 
244
- [benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/16575338618
244
+ [benchmark-gha]: https://github.com/yegor256/factbase/actions/runs/16846550540
@@ -40,8 +40,8 @@ class Factbase::Rules
40
40
  Fact.new(@fb.insert, @check, @fb)
41
41
  end
42
42
 
43
- def query(query, maps = nil)
44
- Query.new(@fb.query(query, maps), @check, self)
43
+ def query(term, maps = nil)
44
+ Query.new(@fb.query(term, maps), @check, self)
45
45
  end
46
46
 
47
47
  def txn
@@ -78,7 +78,7 @@ class Factbase::Rules
78
78
 
79
79
  others do |*args|
80
80
  r = @fact.method_missing(*args)
81
- k = args[0].to_s
81
+ k = args.first.to_s
82
82
  @check.it(@fact, @fb) if k.end_with?('=')
83
83
  r
84
84
  end
@@ -132,14 +132,16 @@ class Factbase::Rules
132
132
  return if @uid.nil?
133
133
  a = fact[@uid]
134
134
  return if a.nil?
135
- @facts << a[0]
135
+ raise "More than one #{@uid.inspect} in the fact: #{a}" if a.size > 1
136
+ @facts << a.first
136
137
  end
137
138
 
138
139
  def include?(fact)
139
140
  return true if @uid.nil?
140
141
  a = fact[@uid]
141
142
  return true if a.nil?
142
- @facts.include?(a[0])
143
+ raise "More than one #{@uid.inspect} in the fact: #{a}" if a.size > 1
144
+ @facts.include?(a.first)
143
145
  end
144
146
  end
145
147
  end
@@ -9,5 +9,5 @@
9
9
  # License:: MIT
10
10
  class Factbase
11
11
  # Current version of the gem (changed by .rultor.yml on every release)
12
- VERSION = '0.14.5' unless const_defined?(:VERSION)
12
+ VERSION = '0.14.6' unless const_defined?(:VERSION)
13
13
  end
@@ -336,8 +336,21 @@ class TestQuery < Factbase::Test
336
336
  )
337
337
  ),
338
338
  'logged+plain' => Factbase::Logged.new(Factbase.new(maps), Loog::NULL),
339
- 'indexed+cached+plain' => Factbase::IndexedFactbase.new(Factbase::CachedFactbase.new(Factbase.new(maps))),
340
- 'cached+indexed+plain' => Factbase::CachedFactbase.new(Factbase::IndexedFactbase.new(Factbase.new(maps))),
339
+ 'indexed+cached+plain' => Factbase::IndexedFactbase.new(
340
+ Factbase::CachedFactbase.new(Factbase.new(maps))
341
+ ),
342
+ 'indexed+cached+rules+plain' => Factbase::IndexedFactbase.new(
343
+ Factbase::CachedFactbase.new(
344
+ Factbase::Rules.new(
345
+ Factbase.new(maps),
346
+ '(always)',
347
+ uid: '_id'
348
+ )
349
+ )
350
+ ),
351
+ 'cached+indexed+plain' => Factbase::CachedFactbase.new(
352
+ Factbase::IndexedFactbase.new(Factbase.new(maps))
353
+ ),
341
354
  'indexed+indexed+plain' => Factbase::IndexedFactbase.new(
342
355
  Factbase::IndexedFactbase.new(Factbase.new(maps))
343
356
  ),
@@ -80,6 +80,18 @@ class TestRules < Factbase::Test
80
80
  assert_equal(0, fb.size)
81
81
  end
82
82
 
83
+ def test_defends_against_id_duplicates
84
+ fb = Factbase::Rules.new(Factbase.new, '(always)', uid: 'id')
85
+ assert_raises(StandardError) do
86
+ fb.txn do |fbt|
87
+ fbt.insert.then do |f|
88
+ f.id = 1
89
+ f.id = 2
90
+ end
91
+ end
92
+ end
93
+ end
94
+
83
95
  def test_in_combination_with_pre
84
96
  fb = Factbase::Rules.new(Factbase.new, '(when (exists a) (exists b))')
85
97
  fb =
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.5
4
+ version: 0.14.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko