Class: Alf::Engine::Semi::Hash

Inherits:
Object
  • Object
show all
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

Attributes included from Compiler::Cog

#compiler, #expr

Instance Method Summary collapse

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

#leftEnumerable (readonly)


11
12
13
# File 'lib/alf/engine/semi/hash.rb', line 11

def left
  @left
end

#predicateBoolean (readonly)


17
18
19
# File 'lib/alf/engine/semi/hash.rb', line 17

def predicate
  @predicate
end

#rightEnumerable (readonly)


14
15
16
# File 'lib/alf/engine/semi/hash.rb', line 14

def right
  @right
end

Instance Method Details

#_eachObject


33
34
35
36
37
38
39
# File 'lib/alf/engine/semi/hash.rb', line 33

def _each
  index = nil
  left.each do |left_tuple|
    index ||= build_index(left_tuple, right)
    yield left_tuple if index[left_tuple, true] == predicate
  end
end

#argumentsObject


41
42
43
# File 'lib/alf/engine/semi/hash.rb', line 41

def arguments
  [ predicate ]
end

#operandsObject

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