Sha256: 90167098dfb043f2ec3ef4b2f15b2ceac6dd58443e4b4cf51902d6b2fe5473bf

Contents?: true

Size: 803 Bytes

Versions: 5

Compression:

Stored size: 803 Bytes

Contents

module Alf
  module Engine
    #
    # Provides hash-based join.
    #
    class Join::Hash < Cog

      # @return [Enumerable] The left operand
      attr_reader :left

      # @return [Enumerable] The right operand
      attr_reader :right

      # Creates a Join::Hash instance
      def initialize(left, right)
        @left = left
        @right = right
      end

      # (see Cog#each)
      def each(&block)
        index = nil
        left.each do |left_tuple|
          index ||= Materialize::Hash.new(right, lambda{|t|
            AttrList.new(left_tuple.keys & t.keys)
          }).prepare
          index[left_tuple, true].each do |right_tuple|
            yield left_tuple.merge(right_tuple)
          end
        end
      end

    end # class Hash
  end # module Engine
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 lib/alf-engine/alf/engine/join/hash.rb
alf-0.12.1 lib/alf-engine/alf/engine/join/hash.rb
alf-0.12.0 lib/alf-engine/alf/engine/join/hash.rb
alf-0.11.1 lib/alf-engine/alf/engine/join/hash.rb
alf-0.11.0 lib/alf-engine/alf/engine/join/hash.rb