Class: Alf::Engine::Join::Hash
- Inherits:
-
Object
- Object
- Alf::Engine::Join::Hash
- Includes:
- Cog
- Defined in:
- lib/alf-engine/alf/engine/join/hash.rb
Overview
Provides hash-based join.
Instance Attribute Summary collapse
-
#left ⇒ Enumerable
readonly
The left operand.
-
#right ⇒ Enumerable
readonly
The right operand.
Instance Method Summary collapse
- #_each(&block) ⇒ Object
-
#initialize(left, right) ⇒ Hash
constructor
Creates a Join::Hash instance.
Methods included from Cog
Constructor Details
#initialize(left, right) ⇒ Hash
Creates a Join::Hash instance
16 17 18 19 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 16 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#left ⇒ Enumerable (readonly)
Returns The left operand.
10 11 12 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 10 def left @left end |
#right ⇒ Enumerable (readonly)
Returns The right operand.
13 14 15 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 13 def right @right end |
Instance Method Details
#_each(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 22 def _each(&block) index = nil left.each do |left_tuple| index ||= Materialize::Hash.new(right, lambda{|t| AttrList.new(left_tuple.keys & t.keys) }, false).prepare index[left_tuple, true].each do |right_tuple| yield left_tuple.merge(right_tuple) end end end |