Class: Factbase::IndexedExists
- Inherits:
-
Object
- Object
- Factbase::IndexedExists
- Defined in:
- lib/factbase/indexed/indexed_exists.rb
Overview
Indexed term ‘exists’.
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
8 9 10 11 |
# File 'lib/factbase/indexed/indexed_exists.rb', line 8 def initialize(term, idx) @term = term @idx = idx end |
Instance Method Details
#predict(maps, _fb, _params) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/factbase/indexed/indexed_exists.rb', line 13 def predict(maps, _fb, _params) return nil if @idx.nil? key = [maps.object_id, @term.operands.first, @term.op] if @idx[key].nil? @idx[key] = [] prop = @term.operands.first.to_s maps.to_a.each do |m| @idx[key].append(m) unless m[prop].nil? end end (maps & []) | @idx[key] end |