Sha256: 4cca38df1b0c46c0ada48ab41ee36a43a0f738bbd80ea207ef2a4eda8d2a959a

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

module Alf
  module Operator::Relational
    class NotMatching < Alf::Operator()
      include Operator::Relational, Operator::Shortcut, Operator::Binary
      
      signature do |s|
      end
      
      #
      # Performs a NotMatching of two relations through a Hash buffer on the 
      # right one.
      #
      class HashBased
        include Operator, Operator::Binary
      
        # (see Operator#_each)
        def _each
          seen, key = nil, nil
          left.each do |left_tuple|
            seen ||= begin
              h = Hash.new
              right.each do |right_tuple|
                key ||= coerce(left_tuple.keys & right_tuple.keys, AttrList)
                h[key.project(right_tuple)] = true
              end
              key ||= coerce([], AttrList)
              h
            end
            yield(left_tuple) unless seen.has_key?(key.project(left_tuple))
          end
        end
        
      end # class HashBased
      
      protected
      
      # (see Shortcut#longexpr)
      def longexpr
        chain HashBased.new,
              datasets 
      end
      
    end # class NotMatching
  end # module Operator::Relational
end # module Alf

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.10.1 lib/alf/operator/relational/not_matching.rb
alf-0.10.0 lib/alf/operator/relational/not_matching.rb