factbase 0.14.4 → 0.14.5

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: 1b99886e9a1cb9ecdefc3a02b7a673fcaa0ffd5f5d43f7099b72ed46f8a73f48
4
- data.tar.gz: ad9e84bd91eb52b2b310f716cd93754acd42d9007e3230f9d2449165a83ff2ba
3
+ metadata.gz: fdee6a1a98e26f25786c6f9bffbaf201d39639b52bf8933beaa4a8053860dfde
4
+ data.tar.gz: ca5ccea23c49c9ffc45d4cebf77b798bb42a527d599533d854836bf47276a532
5
5
  SHA512:
6
- metadata.gz: 98e0a29e89ddf89635488ce7c08dba7cad6ef408c4538ba242d6112d45cebdfa6e8b4229dd3289040f022e1dadb714bb70d3f12133c1b7104b2a83b368dc9dc8
7
- data.tar.gz: 7d57a91ded2d07f78be19ed288b1f4915cdd2fdaae172202da2eb3d584b368113f2adc239075557dd4c7815852339f9350a0ab5e8cb130394e0ab94f5e090c9d
6
+ metadata.gz: 37a08deb9fba4cc348861fe67dd680328b635f10366f193baf9e4f955118e60a1439562416d2e7bd5e5e140243250a6daec6ce72049ad40132b987c55c16ff88
7
+ data.tar.gz: c4dd0a22cfa88b3c2b4d5c87c672fe0cbbd81959dc0c96e6d8e3b4bdacec3c5ef3448b5832b9b91378d4fe4629cae72ec6af71de05ad029052478068fe6626cd
@@ -16,4 +16,4 @@ jobs:
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
18
  - uses: actions/checkout@v4
19
- - uses: crate-ci/typos@v1.35.2
19
+ - uses: crate-ci/typos@v1.35.3
@@ -95,6 +95,27 @@ module Factbase::IndexedTerm
95
95
  result = @idx[cache_key][i..].map { |pair| pair[1] }.uniq
96
96
  (maps & []) | result
97
97
  end
98
+ when :lt
99
+ if @operands.first.is_a?(Symbol) && _scalar?(@operands[1])
100
+ prop = @operands.first.to_s
101
+ cache_key = [maps.object_id, @operands.first, :sorted]
102
+ if @idx[cache_key].nil?
103
+ @idx[cache_key] = []
104
+ maps.to_a.each do |m|
105
+ values = m[prop]
106
+ next if values.nil?
107
+ values.each do |v|
108
+ @idx[cache_key] << [v, m]
109
+ end
110
+ end
111
+ @idx[cache_key].sort_by! { |pair| pair[0] }
112
+ end
113
+ threshold = @operands[1].is_a?(Symbol) ? params[@operands[1].to_s]&.first : @operands[1]
114
+ return nil if threshold.nil?
115
+ i = @idx[cache_key].bsearch_index { |pair| pair[0] >= threshold } || @idx[cache_key].size
116
+ result = @idx[cache_key][0...i].map { |pair| pair[1] }.uniq
117
+ (maps & []) | result
118
+ end
98
119
  when :and
99
120
  r = nil
100
121
  if @operands.all? { |o| o.op == :eq } && @operands.size > 1 \
@@ -30,4 +30,8 @@ class Factbase::Light
30
30
  def query(query, maps = nil)
31
31
  @fb.query(query, maps)
32
32
  end
33
+
34
+ def txn
35
+ raise 'You cannot start a transaction inside another transaction'
36
+ end
33
37
  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.4' unless const_defined?(:VERSION)
12
+ VERSION = '0.14.5' unless const_defined?(:VERSION)
13
13
  end
@@ -120,4 +120,21 @@ class TestIndexedTerm < Factbase::Test
120
120
  assert_equal(3, n.size)
121
121
  assert_kind_of(Factbase::Taped, n)
122
122
  end
123
+
124
+ def test_predicts_on_lt
125
+ term = Factbase::Term.new(:lt, [:foo, 42])
126
+ idx = {}
127
+ term.redress!(Factbase::IndexedTerm, idx:)
128
+ maps = Factbase::Taped.new([
129
+ { 'foo' => [10] },
130
+ { 'foo' => [43] },
131
+ { 'foo' => [42] },
132
+ { 'foo' => [100, 5] },
133
+ { 'bar' => [50] },
134
+ { 'foo' => [41, 42, 43] }
135
+ ])
136
+ n = term.predict(maps, {})
137
+ assert_equal(3, n.size)
138
+ assert_kind_of(Factbase::Taped, n)
139
+ end
123
140
  end
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.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko