Sha256: bc19ac861c82ef57ac6540a21887cbd8e97289cbcc1dc8dc82d49b2c1b8abbc4

Contents?: true

Size: 915 Bytes

Versions: 5

Compression:

Stored size: 915 Bytes

Contents

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

      signature do |s|
        s.argument :attributes, AttrList, []
        s.argument :as,         AttrName, :group
        s.option   :allbut,     Boolean,  false, 'Group all but specified attributes?'
      end

      def heading
        @heading ||= begin
          keep, sub = operand.heading.split(attributes, !allbut)
          keep.merge(as => Relation[sub])
        end
      end

      def keys
        @keys ||= operand.keys.map{|k|
          proj = k.project(attributes, !allbut)
          proj.empty? ? AttrList[as] : proj
        }.freeze
      end

    private

      def _type_check(options)
        no_unknown!(attributes - operand.attr_list)
        no_name_clash!(operand.attr_list - attributes, AttrList[as])
      end

    end # class Group
  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/group.rb
alf-core-0.16.2 lib/alf/algebra/operator/group.rb
alf-core-0.16.1 lib/alf/algebra/operator/group.rb
alf-core-0.16.0 lib/alf/algebra/operator/group.rb
alf-core-0.15.0 lib/alf/algebra/operator/group.rb