Sha256: b12a0b339a6f0d138b2f59487898a6f5520fb8c3a2544ab76c989f279fda1415

Contents?: true

Size: 687 Bytes

Versions: 26

Compression:

Stored size: 687 Bytes

Contents

module Bmg
  class Summarizer
    #
    # Collect the count of distinct values.
    #
    # Example:
    #
    #   # direct ruby usage
    #   Bmg::Summarizer.distinct_count(:qty).summarize(...)
    #
    class DistinctCount < Summarizer

      # Returns [] as least value.
      def least()
        {}
      end

      # Adds val to the memo array
      def _happens(memo, val)
        memo[val] = true
        memo
      end

      def finalize(memo)
        memo.keys.size
      end

    end # class DistinctCount

    # Factors a distinct count summarizer
    def self.distinct_count(*args, &bl)
      DistinctCount.new(*args, &bl)
    end

  end # class Summarizer
end # module Bmg

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
bmg-0.23.3 lib/bmg/summarizer/distinct_count.rb
bmg-0.23.2 lib/bmg/summarizer/distinct_count.rb
bmg-0.23.1 lib/bmg/summarizer/distinct_count.rb
bmg-0.23.0 lib/bmg/summarizer/distinct_count.rb
bmg-0.21.5 lib/bmg/summarizer/distinct_count.rb
bmg-0.21.4 lib/bmg/summarizer/distinct_count.rb
bmg-0.20.5 lib/bmg/summarizer/distinct_count.rb
bmg-0.19.3 lib/bmg/summarizer/distinct_count.rb
bmg-0.21.3 lib/bmg/summarizer/distinct_count.rb
bmg-0.21.2 lib/bmg/summarizer/distinct_count.rb
bmg-0.21.0 lib/bmg/summarizer/distinct_count.rb
bmg-0.20.4 lib/bmg/summarizer/distinct_count.rb
bmg-0.20.2 lib/bmg/summarizer/distinct_count.rb
bmg-0.20.1 lib/bmg/summarizer/distinct_count.rb
bmg-0.20.0 lib/bmg/summarizer/distinct_count.rb
bmg-0.19.2 lib/bmg/summarizer/distinct_count.rb
bmg-0.19.1 lib/bmg/summarizer/distinct_count.rb
bmg-0.19.0 lib/bmg/summarizer/distinct_count.rb
bmg-0.18.15 lib/bmg/summarizer/distinct_count.rb
bmg-0.18.14 lib/bmg/summarizer/distinct_count.rb