Sha256: d153f9dd3ccfd708af5d39c6ef66a0a0a0699db1cda5d84df0e0504f7eaa1765

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

module Alf
  module Algebra
    module Operand

      def self.coerce(op)
        case op
        when Operand     then op
        when Symbol      then Operand::Named.new(op)
        when Reader      then Proxy.new(op)
        when Array       then Proxy.new(op)
        when Engine::Cog then Proxy.new(op)
        when TupleLike   then Proxy.new([op])
        else
          who = op.inspect
          who = "#{who[0..20]}..." if who.size>20
          raise TypeError, "Invalid relational operand `#{who}`"
        end
      end

      ### Static analysis & inference

      def heading
        raise NotSupportedError, "Heading inference unsupported on `#{self}`"
      end

      def attr_list
        heading.to_attr_list
      end

      def keys
        raise NotSupportedError, "Key inference unsupported on `#{self}`"
      end

      def type_check(options = {strict: false})
        heading
      end

      def resulting_type
        Relation[heading]
      end

      ### to_xxx

      def to_cog(plan = nil)
        raise NotSupportedError, "Compilation unsupported on `#{self}`"
      end

      def to_relation
        to_cog.to_relation
      end

      def to_ascii_tree(buffer = "")
        Support::Tree.new(self).to_text(buffer)
      end

    end # module Operand
  end # module Algebra
end # module Alf
require_relative 'operand/fake'
require_relative 'operand/proxy'
require_relative 'operand/named'

Version data entries

5 entries across 5 versions & 1 rubygems

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