Sha256: 5d934661abfdbf1415af078c85616ffc518cc88dc738be796158968683624a91

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

module Alf
  module Engine
    class Quota::Cesure
      include Quota
      include Engine::Cesure

      # @return [Enumerable] The operand
      attr_reader :operand

      # @return [AttrList] List of attributes for 'quota by'
      attr_reader :by

      # @return [Summarization] Quota computations as a summarization
      attr_reader :summarization

      # Creates an Quota::Cesure instance
      def initialize(operand, by, summarization, expr = nil, compiler = nil)
        super(expr, compiler)
        @operand = operand
        @by = by.to_attr_list
        @summarization = summarization
      end

      def arguments
        [ by, summarization ]
      end

    protected

      # (see Cesure#project)
      def project(tuple)
        @by.project_tuple(tuple, false)
      end

      # (see Cesure#start_cesure)
      def start_cesure(key, receiver)
        @scope = tuple_scope unless @scope
        @aggs  = @summarization.least
      end

      # (see Cesure#accumulate_cesure)
      def accumulate_cesure(tuple, receiver)
        @aggs = @summarization.happens(@aggs, @scope.__set_tuple(tuple))
        receiver.call tuple.merge(@summarization.finalize(@aggs))
      end

      # (see Cesure#flush_cesure)
      def flush_cesure(key, receiver)
        @scope = nil
      end

    end # class Quota::Cesure
  end # module Engine
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/engine/quota/cesure.rb
alf-core-0.16.2 lib/alf/engine/quota/cesure.rb
alf-core-0.16.1 lib/alf/engine/quota/cesure.rb
alf-core-0.16.0 lib/alf/engine/quota/cesure.rb
alf-core-0.15.0 lib/alf/engine/quota/cesure.rb