Module: Alf::Algebra::Operator
- Extended by:
- Support::Registry
- Included in:
- Autonum, Clip, Coerce, Compact, Defaults, Extend, Frame, Generator, Group, Hierarchize, Intersect, Join, Matching, Minus, NotMatching, Page, Project, Quota, Rank, Rename, Restrict, Sort, Summarize, Ungroup, Union, Unwrap, Wrap
- Defined in:
- lib/alf/algebra/operator.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
Class Method Summary collapse
-
.included(mod) ⇒ Object
Installs the class methods needed on all operators.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #dup(&bl) ⇒ Object
- #hash ⇒ Object
-
#initialize(*args) ⇒ Object
Create an operator instance.
-
#signature ⇒ Signature
The operator signature.
-
#to_cog(plan = nil) ⇒ Object
-> to_xxx.
- #to_lispy ⇒ Object
- #to_relvar ⇒ Object
- #to_s ⇒ Object
-
#type_check(options = {strict: false}) ⇒ Object
heading, keys, and others.
-
#with_operands(*operands) ⇒ Object
identity and pseudo-mutability.
Methods included from Support::Registry
each, listen, listeners, register, registered
Methods included from TypeCheck
#joinable_headings!, #no_name_clash!, #same_heading!, #type_check_error!, #valid_ordering!
Methods included from Operand
#attr_list, coerce, #heading, #keys, #resulting_type, #to_ascii_tree, #to_relation
Instance Attribute Details
#operands ⇒ Object
45 46 47 |
# File 'lib/alf/algebra/operator.rb', line 45 def operands @operands end |
Class Method Details
.included(mod) ⇒ Object
Installs the class methods needed on all operators
34 35 36 37 38 39 |
# File 'lib/alf/algebra/operator.rb', line 34 def included(mod) super mod.extend(ClassMethods) mod.extend(Classification) register(mod, Operator) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
119 120 121 122 |
# File 'lib/alf/algebra/operator.rb', line 119 def ==(other) super || ((other.class == self.class) && (other.signature.collect_on(other) == self.signature.collect_on(self))) end |
#dup(&bl) ⇒ Object
109 110 111 |
# File 'lib/alf/algebra/operator.rb', line 109 def dup(&bl) bl.nil? ? super : super.tap(&bl) end |
#hash ⇒ Object
113 114 115 116 117 |
# File 'lib/alf/algebra/operator.rb', line 113 def hash @hash ||= [ self.class, operands, signature.collect_on(self) ].hash end |
#initialize(*args) ⇒ Object
Create an operator instance
48 49 50 |
# File 'lib/alf/algebra/operator.rb', line 48 def initialize(*args) signature.parse_args(args, self) end |
#signature ⇒ Signature
Returns the operator signature.
53 54 55 |
# File 'lib/alf/algebra/operator.rb', line 53 def signature self.class.signature end |
#to_cog(plan = nil) ⇒ Object
-> to_xxx
67 68 69 |
# File 'lib/alf/algebra/operator.rb', line 67 def to_cog(plan = nil) plan ? plan.compile(self) : Alf::Compiler::Default.new.call(self) end |
#to_lispy ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/alf/algebra/operator.rb', line 88 def to_lispy cmdname = self.class.rubycase_name oper, args, opts = signature.collect_on(self) args = opts.empty? ? (oper + args) : (oper + args + [ opts ]) args = args.map{|arg| Support.to_lispy(arg) } "#{cmdname}(#{args.join(', ')})" end |
#to_relvar ⇒ Object
96 97 98 |
# File 'lib/alf/algebra/operator.rb', line 96 def to_relvar Relvar::Virtual.new(self) end |
#to_s ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/alf/algebra/operator.rb', line 71 def to_s label = "" label << self.class.rubycase_name.to_s label << "(..." datasets, arguments, = signature.collect_on(self) arguments.each_with_index do |arg,i| label << ", " label << Alf::Support.to_lispy(arg, "[native]") end unless .nil? or .empty? label << ", " label << Alf::Support.to_lispy(, "[native]") end label << ")" label end |
#type_check(options = {strict: false}) ⇒ Object
heading, keys, and others
59 60 61 62 63 |
# File 'lib/alf/algebra/operator.rb', line 59 def type_check( = {strict: false}) operands.each{|op| op.type_check() } _type_check() heading end |
#with_operands(*operands) ⇒ Object
identity and pseudo-mutability
102 103 104 105 106 107 |
# File 'lib/alf/algebra/operator.rb', line 102 def with_operands(*operands) dup{|copy| copy.operands = operands copy.clean_computed_attributes! } end |