Sha256: a02b840c3af85867359aea4f0aeadf310224e5691de978156893dc5c22d0a371

Contents?: true

Size: 942 Bytes

Versions: 3

Compression:

Stored size: 942 Bytes

Contents

#
# The FOREACH relational operator
#
module Wukong
  module AndPig
    class PigVar
      #
      # Select all elements in the source relation that match on the selecting relation,
      # creating a relation with the same type as the source relation.
      #
      # For example, 
      #
      #   PV.isolate :isolated_cvals, :my_ids, :id, :my_complicated_values, :id
      #
      # returns a relation IsolatedCvals, whose type is identical to
      # MyComplicatedValues' type, with only the elements having an id also
      # presend in MyIds.
      #
      #
      def self.isolate lval, on, on_field, from, from_field, options={ }
        joined   = join anon(lval), on => on_field, from => from_field, :parallel => options.delete(:parallel)
        isolated = joined.generate lval, { "'#{from}'" => :rsrc}, *PV[from].fields.map{|field| [from, field]}
        isolated.klass = from.klass
        isolated
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
mrflip-wukong-0.1.0 lib/wukong/and_pig/operators/compound.rb
wukong-0.1.4 lib/wukong/and_pig/operators/compound.rb
wukong-0.1.1 lib/wukong/and_pig/operators/compound.rb