Class: Factbase::IndexedExists
- Inherits:
-
Object
- Object
- Factbase::IndexedExists
- Defined in:
- lib/factbase/indexed/indexed_exists.rb
Overview
Indexed term ‘exists’. The @idx structure:
count: Integer (number of facts already processed),
facts: Array (facts found),
Instance Method Summary collapse
-
#initialize(term, idx) ⇒ IndexedExists
constructor
A new instance of IndexedExists.
- #predict(maps, _fb, _params) ⇒ Object
Constructor Details
#initialize(term, idx) ⇒ IndexedExists
Returns a new instance of IndexedExists.
13 14 15 16 |
# File 'lib/factbase/indexed/indexed_exists.rb', line 13 def initialize(term, idx) @term = term @idx = idx end |
Instance Method Details
#predict(maps, _fb, _params) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/factbase/indexed/indexed_exists.rb', line 18 def predict(maps, _fb, _params) operand = @term.operands.first.to_s key = [maps.object_id, operand, @term.op] @idx[key] = { facts: [], count: 0 } if @idx[key].nil? entry = @idx[key] _feed(maps.to_a, entry, operand) maps.respond_to?(:repack) ? maps.repack(entry[:facts]) : entry[:facts] end |