Class: Alf::Engine::Semi::Hash
- Inherits:
-
Object
- Object
- Alf::Engine::Semi::Hash
- Includes:
- Cog, Alf::Engine::Semi
- Defined in:
- lib/alf/engine/semi/hash.rb
Overview
Filters tuples from left that match or do not match tuples from right.
Constant Summary
Constants included from Cog
Cog::EMPTY_CHILDREN, Cog::EMPTY_OPTIONS
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.
Attributes included from Compiler::Cog
Instance Method Summary collapse
- #_each ⇒ Object
- #arguments ⇒ Object
-
#initialize(left, right, predicate, expr = nil, compiler = nil) ⇒ Hash
constructor
Creates a Semi::Hash instance.
-
#operands ⇒ Object
Returns left and right operands in an array.
Methods included from Cog
#children, #each, #options, #to_s
Methods included from Compiler::Cog
#cog_orders, #orderedby?, #relation_type, #to_ascii_tree, #to_cog, #to_relation
Constructor Details
#initialize(left, right, predicate, expr = nil, compiler = nil) ⇒ Hash
Creates a Semi::Hash instance
20 21 22 23 24 25 |
# File 'lib/alf/engine/semi/hash.rb', line 20 def initialize(left, right, predicate, expr = nil, compiler = nil) super(expr, compiler) @left = left @right = right @predicate = predicate end |
Instance Attribute Details
#left ⇒ Enumerable (readonly)
Returns The left operand.
11 12 13 |
# File 'lib/alf/engine/semi/hash.rb', line 11 def left @left end |
#predicate ⇒ Boolean (readonly)
Returns Match (true) or not match (false)?.
17 18 19 |
# File 'lib/alf/engine/semi/hash.rb', line 17 def predicate @predicate end |
#right ⇒ Enumerable (readonly)
Returns The right operand.
14 15 16 |
# File 'lib/alf/engine/semi/hash.rb', line 14 def right @right end |
Instance Method Details
#_each ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/alf/engine/semi/hash.rb', line 33 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 |
#arguments ⇒ Object
45 46 47 |
# File 'lib/alf/engine/semi/hash.rb', line 45 def arguments [ predicate ] end |
#operands ⇒ Object
Returns left and right operands in an array
28 29 30 |
# File 'lib/alf/engine/semi/hash.rb', line 28 def operands [ left, right ] end |