Module: Bmg::Algebra

Includes:
Shortcuts
Included in:
Relation
Defined in:
lib/bmg/algebra.rb,
lib/bmg/algebra/shortcuts.rb

Defined Under Namespace

Modules: Shortcuts

Instance Method Summary collapse

Methods included from Shortcuts

#cross_product, #exclude, #images, #prefix, #rxmatch, #suffix, #where

Instance Method Details

#allbut(butlist = []) ⇒ Object



4
5
6
7
# File 'lib/bmg/algebra.rb', line 4

def allbut(butlist = [])
  return self if butlist.empty?
  _allbut self.type.allbut(butlist), butlist
end

#autosummarize(by = [], summarization = {}, options = {}) ⇒ Object



24
25
26
# File 'lib/bmg/algebra.rb', line 24

def autosummarize(by = [], summarization = {}, options = {})
  _autosummarize self.type.autosummarize(by, summarization, options), by, summarization, options
end

#autowrap(options = {}) ⇒ Object



14
15
16
17
# File 'lib/bmg/algebra.rb', line 14

def autowrap(options = {})
  return self if self.type.identity_autowrap?(options)
  _autowrap self.type.autowrap(options), options
end

#constants(cs = {}) ⇒ Object



33
34
35
# File 'lib/bmg/algebra.rb', line 33

def constants(cs = {})
  _constants self.type.constants(cs), cs
end

#extend(extension = {}) ⇒ Object



42
43
44
45
# File 'lib/bmg/algebra.rb', line 42

def extend(extension = {})
  return self if extension.empty?
  _extend self.type.extend(extension), extension
end

#group(attrs, as = :group, options = {}) ⇒ Object



52
53
54
# File 'lib/bmg/algebra.rb', line 52

def group(attrs, as = :group, options = {})
  _group self.type.group(attrs, as), attrs, as, options
end

#image(right, as = :image, on = [], options = {}) ⇒ Object



61
62
63
# File 'lib/bmg/algebra.rb', line 61

def image(right, as = :image, on = [], options = {})
  _image self.type.image(right.type, as, on, options), right, as, on, options
end

#join(right, on = []) ⇒ Object



70
71
72
# File 'lib/bmg/algebra.rb', line 70

def join(right, on = [])
  _join self.type.join(right.type, on), right, on
end

#left_join(right, on = [], default_right_tuple = {}) ⇒ Object



84
85
86
87
# File 'lib/bmg/algebra.rb', line 84

def left_join(right, on = [], default_right_tuple = {})
  drt = default_right_tuple
  _left_join self.type.left_join(right.type, on, drt), right, on, drt
end

#matching(right, on = []) ⇒ Object



97
98
99
# File 'lib/bmg/algebra.rb', line 97

def matching(right, on = [])
  _matching self.type.matching(right.type, on), right, on
end

#materializeObject



234
235
236
# File 'lib/bmg/algebra.rb', line 234

def materialize
  Relation::Materialized.new(self)
end

#minus(other) ⇒ Object



206
207
208
209
# File 'lib/bmg/algebra.rb', line 206

def minus(other)
  return self if other.is_a?(Relation::Empty)
  _minus self.type.minus(other.type), other
end

#not_matching(right, on = []) ⇒ Object



106
107
108
# File 'lib/bmg/algebra.rb', line 106

def not_matching(right, on = [])
  _not_matching self.type.not_matching(right.type, on), right, on
end

#page(ordering, page_index, options) ⇒ Object



115
116
117
# File 'lib/bmg/algebra.rb', line 115

def page(ordering, page_index, options)
  _page self.type.page(ordering, page_index, options), ordering, page_index, options
end

#project(attrlist = []) ⇒ Object



124
125
126
# File 'lib/bmg/algebra.rb', line 124

def project(attrlist = [])
  _project self.type.project(attrlist), attrlist
end

#rename(renaming = {}) ⇒ Object



133
134
135
136
137
# File 'lib/bmg/algebra.rb', line 133

def rename(renaming = {})
  renaming = renaming.reject{|k,v| k==v }
  return self if renaming.empty?
  _rename self.type.rename(renaming), renaming
end

#restrict(predicate) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/bmg/algebra.rb', line 144

def restrict(predicate)
  predicate = Predicate.coerce(predicate)
  if predicate.tautology?
    self
  else
    type = self.type.restrict(predicate)
    if predicate.contradiction?
      Relation.empty(type)
    else
      begin
        _restrict type, predicate
      rescue Predicate::NotSupportedError
        Operator::Restrict.new(type, self, predicate)
      end
    end
  end
end

#spied(spy) ⇒ Object



225
226
227
228
# File 'lib/bmg/algebra.rb', line 225

def spied(spy)
  return self if spy.nil?
  Relation::Spied.new(self, spy)
end

#summarize(by, summarization = {}) ⇒ Object



167
168
169
# File 'lib/bmg/algebra.rb', line 167

def summarize(by, summarization = {})
  _summarize self.type.summarize(by, summarization), by, summarization
end

#transform(transformation = nil, options = {}, &proc) ⇒ Object



176
177
178
179
180
# File 'lib/bmg/algebra.rb', line 176

def transform(transformation = nil, options = {}, &proc)
  transformation, options = proc, (transformation || {}) unless proc.nil?
  return self if transformation.is_a?(Hash) && transformation.empty?
  _transform(self.type.transform(transformation, options), transformation, options)
end

#ungroup(attrs) ⇒ Object



187
188
189
# File 'lib/bmg/algebra.rb', line 187

def ungroup(attrs)
  _ungroup self.type.ungroup(attrs), attrs
end

#union(other, options = {}) ⇒ Object



196
197
198
199
# File 'lib/bmg/algebra.rb', line 196

def union(other, options = {})
  return self if other.is_a?(Relation::Empty)
  _union self.type.union(other.type), other, options
end

#unspiedObject



230
231
232
# File 'lib/bmg/algebra.rb', line 230

def unspied
  self
end

#unwrap(attrs) ⇒ Object



216
217
218
# File 'lib/bmg/algebra.rb', line 216

def unwrap(attrs)
  _unwrap self.type.unwrap(attrs), attrs
end