Sha256: c7cfb686c75024cd43aa9fc16ca0f626c132046d30a2e0c2b3409f33fcff8e1e

Contents?: true

Size: 959 Bytes

Versions: 5

Compression:

Stored size: 959 Bytes

Contents

module Alf
  module Algebra
    class Summarize
      include Operator
      include Relational
      include Unary

      signature do |s|
        s.argument :by,            AttrList, []
        s.argument :summarization, Summarization, {}
        s.option   :allbut,        Boolean, false, "Summarize on all but specified attributes?"
      end

      def heading
        @heading ||= begin
          op_h = operand.heading.project(by, allbut)
          op_h.merge(summarization.to_heading)
        end
      end

      def keys
        @keys ||= begin
          attrs = operand.heading.to_attr_list.project(by, allbut)
          operand.keys.select{|k| k.subset?(attrs) }.if_empty{ Keys[ attrs ] }
        end
      end

    private

      def _type_check(options)
        no_unknown!(by - operand.attr_list)
        no_name_clash!(operand.attr_list, summarization.to_attr_list)
      end

    end # class Summarize
  end # module Algebra
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/algebra/operator/summarize.rb
alf-core-0.16.2 lib/alf/algebra/operator/summarize.rb
alf-core-0.16.1 lib/alf/algebra/operator/summarize.rb
alf-core-0.16.0 lib/alf/algebra/operator/summarize.rb
alf-core-0.15.0 lib/alf/algebra/operator/summarize.rb