lib/alf/operator/relational/quota.rb in alf-0.10.1 vs lib/alf/operator/relational/quota.rb in alf-0.11.0
- old
+ new
@@ -1,51 +1,23 @@
module Alf
- module Operator::Relational
- class Quota < Alf::Operator()
- include Operator::Relational, Operator::Experimental,
- Operator::Shortcut, Operator::Unary
-
- signature do |s|
- s.argument :by, AttrList, []
- s.argument :order, Ordering, []
- s.argument :summarization, Summarization, {}
- end
-
- class SortBased
- include Operator, Operator::Cesure
-
- def initialize(by, order, summarization)
- @by, @order, @summarization = by, order, summarization
+ module Operator
+ module Relational
+ class Quota
+ include Relational, Unary, Experimental
+
+ signature do |s|
+ s.argument :by, AttrList, []
+ s.argument :order, Ordering, []
+ s.argument :summarization, Summarization, {}
end
-
- protected
-
- # (see Operator::Cesure#project)
- def project(tuple)
- @by.project(tuple, false)
+
+ # (see Operator#compile)
+ def compile
+ op = Engine::Sort.new(operand, @by.to_ordering + @order)
+ op = Engine::Quota::Cesure.new(op, @by, summarization)
+ op
end
-
- # (see Operator::Cesure#start_cesure)
- def start_cesure(key, receiver)
- @aggs = @summarization.least
- end
-
- # (see Operator::Cesure#accumulate_cesure)
- def accumulate_cesure(tuple, receiver)
- @aggs = @summarization.happens(@aggs, tuple)
- receiver.call tuple.merge(@summarization.finalize(@aggs))
- end
-
- end # class SortBased
-
- protected
-
- def longexpr
- sort_key = @by.to_ordering + @order
- chain SortBased.new(@by, @order, @summarization),
- Operator::NonRelational::Sort.new(sort_key),
- datasets
- end
-
- end # class Quota
- end # module Operator::Relational
+
+ end # class Quota
+ end # module Relational
+ end # module Operator
end # module Alf