Sha256: 1b2b187aba8998978d93d1d31f956403f8c1637e89c4f24c2ca63bb2d2c6970c

Contents?: true

Size: 671 Bytes

Versions: 13

Compression:

Stored size: 671 Bytes

Contents

module Alf
  class Aggregator
    #
    # Defines a `count()` aggregation operator.
    #
    # Example:
    #
    #   # direct ruby usage
    #   Alf::Aggregator.count.aggregate(...)
    #
    #   # lispy 
    #   (summarize :supplies, [:sid], :num_orders => count)
    #
    class Count < Aggregator

      # Returns 0 as least value.
      #
      # @see Aggregator::InstanceMethods#least
      def least()
        0
      end

      # Aggregates on a tuple occurence through `memo + 1`
      #
      # @see Aggregator::InstanceMethods#happens
      def happens(memo, tuple) 
        memo + 1
      end

    end # class Count
  end # class Aggregator
end # module Alf

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
alf-core-0.16.3 lib/alf/aggregator/count.rb
alf-core-0.16.2 lib/alf/aggregator/count.rb
alf-core-0.16.1 lib/alf/aggregator/count.rb
alf-core-0.16.0 lib/alf/aggregator/count.rb
alf-core-0.15.0 lib/alf/aggregator/count.rb
alf-core-0.14.0 lib/alf-aggregator/alf/aggregator/count.rb
alf-core-0.13.1 lib/alf-aggregator/alf/aggregator/count.rb
alf-core-0.13.0 lib/alf-aggregator/alf/aggregator/count.rb
alf-0.12.2 lib/alf/aggregator/count.rb
alf-0.12.1 lib/alf/aggregator/count.rb
alf-0.12.0 lib/alf/aggregator/count.rb
alf-0.11.1 lib/alf/aggregator/count.rb
alf-0.11.0 lib/alf/aggregator/count.rb