Sha256: 166f37652ca903d98c7de8d8fd1f69cb86ac969257700beb6d3f2dfdb3273c11

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

module Alf
  module Engine
    class Rank::Cesure < Cog
      include Engine::Cesure

      # @return [Enumerable] The operand
      attr_reader :operand

      # @return [AttrList] List of attributes that form the operand ordering
      attr_reader :by

      # @return [AttrName] Name of the introduced attribute
      attr_reader :as

      # Creates an Aggregate instance
      def initialize(operand, by, as)
        @operand = operand
        @by = by.to_attr_list
        @as = as
      end

      protected

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

      # (see Cesure#start_cesure)
      def start_cesure(key, receiver)
        @rank ||= 0
        @last_block = 0
      end

      # (see Cesure#accumulate_cesure)
      def accumulate_cesure(tuple, receiver)
        receiver.call tuple.merge(@as => @rank)
        @last_block += 1
      end

      # (see Cesure#flush_cesure)
      def flush_cesure(key, receiver)
        @rank += @last_block
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 lib/alf-engine/alf/engine/rank/cesure.rb
alf-0.12.1 lib/alf-engine/alf/engine/rank/cesure.rb
alf-0.12.0 lib/alf-engine/alf/engine/rank/cesure.rb
alf-0.11.1 lib/alf-engine/alf/engine/rank/cesure.rb
alf-0.11.0 lib/alf-engine/alf/engine/rank/cesure.rb