Class: Alf::Engine::Join::Hash
- Inherits:
-
Object
- Object
- Alf::Engine::Join::Hash
- Includes:
- Cog, Alf::Engine::Join
- 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.
Attributes included from Cog
Instance Method Summary collapse
- #_each(&block) ⇒ Object
-
#initialize(left, right, expr = nil) ⇒ Hash
constructor
Creates a Join::Hash instance.
-
#operands ⇒ Object
Returns left and right operands in an array.
Methods included from Cog
#each, #heading, #keys, #to_cog, #to_dot, #to_relation
Constructor Details
#initialize(left, right, expr = nil) ⇒ Hash
Creates a Join::Hash instance
17 18 19 20 21 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 17 def initialize(left, right, expr = nil) super(expr) @left = left @right = right end |
Instance Attribute Details
#left ⇒ Enumerable (readonly)
Returns The left operand.
11 12 13 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 11 def left @left end |
#right ⇒ Enumerable (readonly)
Returns The right operand.
14 15 16 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 14 def right @right end |
Instance Method Details
#_each(&block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 29 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, expr).prepare index[left_tuple, true].each do |right_tuple| yield left_tuple.merge(right_tuple) end end end |
#operands ⇒ Object
Returns left and right operands in an array
24 25 26 |
# File 'lib/alf-engine/alf/engine/join/hash.rb', line 24 def operands [ left, right ] end |