Class: Axiom::Algebra::Join
- Includes:
- Relation::Operation::Combination
- Defined in:
- lib/axiom/algebra/join.rb
Overview
The join between relations
Defined Under Namespace
Modules: Methods
Instance Attribute Summary collapse
-
#join_header ⇒ Header
readonly
private
The common headers between the operands.
Attributes included from Operation::Binary
Attributes inherited from Relation
Instance Method Summary collapse
-
#delete(other) ⇒ Join
Delete a relation from the Join.
-
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set.
-
#initialize(_left, _right) ⇒ undefined
constructor
private
Initialize a Join.
-
#insert(other) ⇒ Join
Insert a relation into the Join.
Methods included from Relation::Operation::Combination
Methods inherited from Relation
#==, #[], #directions, #empty?, #include?, #materialize, #materialized?, new, #replace
Methods included from Visitable
Constructor Details
#initialize(_left, _right) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a Join
25 26 27 28 29 30 |
# File 'lib/axiom/algebra/join.rb', line 25 def initialize(_left, _right) super right_header = right.header @join_header = left.header & right_header @disjoint_header = right_header - join_header end |
Instance Attribute Details
#join_header ⇒ Header (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The common headers between the operands
15 16 17 |
# File 'lib/axiom/algebra/join.rb', line 15 def join_header @join_header end |
Instance Method Details
#delete(other) ⇒ Join
Delete a relation from the Join
84 85 86 87 |
# File 'lib/axiom/algebra/join.rb', line 84 def delete(other) other = coerce(other) delete_left(other).join(delete_right(other)) end |
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/axiom/algebra/join.rb', line 46 def each(&block) return to_enum unless block_given? util = Relation::Operation::Combination index = build_index left.each do |left_tuple| right_tuples = index[join_tuple(left_tuple)] util.combine_tuples(header, left_tuple, right_tuples, &block) end self end |
#insert(other) ⇒ Join
Insert a relation into the Join
69 70 71 72 |
# File 'lib/axiom/algebra/join.rb', line 69 def insert(other) other = coerce(other) insert_left(other).join(insert_right(other)) end |