Method: Fairy::PBasicMGroupBy#start_export

Defined in:
lib/fairy/node/p-basic-group-by.rb

#start_exportObject



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/fairy/node/p-basic-group-by.rb', line 144

def start_export
  Log::debug(self, "START_EXPORT")

  start do
	hash_opt = @opts[:grouping_optimize]
	hash_opt = CONF.GROUP_BY_GROUPING_OPTIMIZE if hash_opt.nil?

	if hash_opt
	  @key_proc = eval("proc{#{@block_source.source}}", @context.binding)
	else
	  @key_proc = BBlock.new(@block_source, @context, self)
	end

	policy = @opts[:postqueuing_policy]
    begin
      @input.each do |e|
        keys = @key_proc.yield(e)
        keys = [keys] unless keys.kind_of?(Array)
        
        for key in keys 
   if Import::CTLTOKEN_NULLVALUE === key
		next
   end
          export = @exports[key]
          unless export
            export = Export.new(policy)
		export.njob_id = @id
            export.add_key(key)
            add_export(key, export)
          end
          export.push e
        end
      end
    rescue
	  Log::debug_exception(self)
	  raise
    ensure
      @exports_queue.push nil
      @exports.each_pair do |key, export| 
 next unless export
 export.push END_OF_STREAM
	  end
    end
  end
end