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

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

Instance Method Summary collapse

Methods included from Cog

#each, #to_dot, #to_relation

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

#leftEnumerable (readonly)

Returns The left operand.

Returns:

  • (Enumerable)

    The left operand



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

def left
  @left
end

#predicateBoolean (readonly)

Returns Match (true) or not match (false)?.

Returns:

  • (Boolean)

    Match (true) or not match (false)?



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

def predicate
  @predicate
end

#rightEnumerable (readonly)

Returns The right operand.

Returns:

  • (Enumerable)

    The right operand



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

def right
  @right
end

Instance Method Details

#_eachObject



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