class Bmg::Operator::Join
Join
operator.
Natural join, following relational algebra
Constants
- DEFAULT_OPTIONS
Attributes
on[R]
options[R]
Public Class Methods
new(type, left, right, on, options = {})
click to toggle source
# File lib/bmg/operator/join.rb, line 13 def initialize(type, left, right, on, options = {}) @type = type @left = left @right = right @on = on @options = DEFAULT_OPTIONS.merge(options) end
Public Instance Methods
each() { |merge| ... }
click to toggle source
# File lib/bmg/operator/join.rb, line 27 def each return to_enum unless block_given? index = Hash.new right.each_with_object(index) do |t, index| key = tuple_project(t, on) index[key] ||= [] index[key] << t end left.each do |tuple| key = tuple_project(tuple, on) if to_join = index[key] to_join.each do |right| yield right.merge(tuple) end elsif left_join? yield(tuple.merge(default_right_tuple)) end end end
to_ast()
click to toggle source
# File lib/bmg/operator/join.rb, line 47 def to_ast [ :join, left.to_ast, right.to_ast, on, extra_opts ].compact end
Protected Instance Methods
default_right_tuple()
click to toggle source
# File lib/bmg/operator/join.rb, line 57 def default_right_tuple options[:default_right_tuple] end
left_join?()
click to toggle source
# File lib/bmg/operator/join.rb, line 53 def left_join? options[:variant] == :left end