Class: Fairy::PSort::PPostSort

Inherits:
Fairy::PSingleExportFilter show all
Defined in:
lib/fairy/node/p-sort.rb

Constant Summary

Constants included from Fairy::PSingleExportable

Fairy::PSingleExportable::END_OF_STREAM, Fairy::PSingleExportable::ST_EXPORT_FINISH, Fairy::PSingleExportable::ST_WAIT_EXPORT_FINISH

Constants inherited from Fairy::PIOFilter

Fairy::PIOFilter::ST_WAIT_IMPORT

Constants inherited from Fairy::PFilter

Fairy::PFilter::END_OF_STREAM, Fairy::PFilter::ST_ACTIVATE, Fairy::PFilter::ST_FINISH, Fairy::PFilter::ST_INIT

Instance Attribute Summary

Attributes included from Fairy::PSingleExportable

#export

Attributes inherited from Fairy::PFilter

#IGNORE_EXCEPTION, #id, #log_id, #ntask

Instance Method Summary collapse

Methods included from Fairy::PSingleExportable

#start, #start_export, #terminate, #wait_export_finish

Methods inherited from Fairy::PIOFilter

#input=

Methods inherited from Fairy::PFilter

#abort_running, #basic_start, #break_running, #each, #global_break, #global_break_from_other, #handle_exception, #key, #key=, #next, #no, #no=, #notice_status, #processor, #start, #start_export, #start_watch_status, #status=, #terminate, #terminate_proc

Constructor Details

#initialize(id, ntask, bjob, opts, block_source) ⇒ PPostSort

Returns a new instance of PPostSort.



154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/fairy/node/p-sort.rb', line 154

def initialize(id, ntask, bjob, opts, block_source)
	super
	@block_source = block_source

	@buffering_policy = @opts[:buffering_policy]
	@buffering_policy ||= CONF.SORT_BUFFERING_POLICY

	unless CONF.BUG234
	  @cmp_optimize = CONF.SORT_CMP_OPTIMIZE
	  @cmp_optimize = opts[:cmp_optimize] if opts.key?(:cmp_optimize)
	end
end

Instance Method Details

#basic_each(&block) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/fairy/node/p-sort.rb', line 167

def basic_each(&block)
	@key_value_buffer = 
	  eval("#{@buffering_policy[:buffering_class]}").new(self, @buffering_policy)
	if @cmp_optimize
	  @hash_proc = eval("proc{#{@block_source.source}}")
	else
	  @hash_proc = BBlock.new(@block_source, @context, self)
	end

	@input.each do |e|
	  @key_value_buffer.push(e)
	  e = nil
	end
	@key_value_buffer.each do |values|
	  values.each(&block)
	end
	@key_value_buffer = nil
end

#hash_key(e) ⇒ Object



186
187
188
# File 'lib/fairy/node/p-sort.rb', line 186

def hash_key(e)
	@hash_proc.yield(e)
end