Class: Alf::Engine::Semi::Hash
- Inherits:
-
Object
- Object
- Alf::Engine::Semi::Hash
- Includes:
- Cog
- Defined in:
- lib/alf-engine/alf/engine/semi/hash.rb
Overview
Filters tuples from ‘left` that match or do not match tuples from `right`.
Instance Attribute Summary collapse
-
#left ⇒ Enumerable
readonly
The left operand.
-
#predicate ⇒ Boolean
readonly
Match (true) or not match (false)?.
-
#right ⇒ Enumerable
readonly
The right operand.
Instance Method Summary collapse
- #_each ⇒ Object
-
#initialize(left, right, predicate) ⇒ Hash
constructor
Creates a Semi::Hash instance.
Methods included from Cog
Constructor Details
#initialize(left, right, predicate) ⇒ Hash
Creates a Semi::Hash instance
19 20 21 22 23 |
# File 'lib/alf-engine/alf/engine/semi/hash.rb', line 19 def initialize(left, right, predicate) @left = left @right = right @predicate = predicate end |
Instance Attribute Details
#left ⇒ Enumerable (readonly)
Returns The left operand.
10 11 12 |
# File 'lib/alf-engine/alf/engine/semi/hash.rb', line 10 def left @left end |
#predicate ⇒ Boolean (readonly)
Returns Match (true) or not match (false)?.
16 17 18 |
# File 'lib/alf-engine/alf/engine/semi/hash.rb', line 16 def predicate @predicate end |
#right ⇒ Enumerable (readonly)
Returns The right operand.
13 14 15 |
# File 'lib/alf-engine/alf/engine/semi/hash.rb', line 13 def right @right end |
Instance Method Details
#_each ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/alf-engine/alf/engine/semi/hash.rb', line 26 def _each index = nil left.each do |left_tuple| index ||= Materialize::Hash.new(right, lambda{|t| AttrList.new(left_tuple.keys & t.keys) }, false).prepare if index[left_tuple, true].empty? != predicate yield left_tuple end end end |