Class: Fairy::CSort::CPreSort
Instance Attribute Summary
#input
#input
Instance Method Summary
collapse
#add_exports, #all_node_arrived?, #all_node_imported?, #bind_export, #each_assigned_filter, #each_export_by, #start_create_nodes, #start_watch_all_node_imported, #start_watch_all_node_imported_ORG, #update_exports
#node_class, #output=
#break_running, #inputtable?
#abort_create_node, #add_node, #assgin_number_of_nodes?, #bind_export, #break_create_node, #break_running, #create_and_add_node, #create_import, #create_node, #create_nodes, #def_job_pool_variable, #each_assigned_filter, #each_export_by, #each_node, #each_node_exist_only, #handle_exception, #input, #job_pool_dict, #job_pool_variable, #nodes, #number_of_nodes, #number_of_nodes=, #pool_dict, #postmapping_policy, #start_create_nodes, #start_export, #start_watch_node_status, #update_status, watch_status, watch_status=, #watch_status?
Constructor Details
#initialize(controller, opts, block_source) ⇒ CPreSort
Returns a new instance of CPreSort.
17
18
19
20
21
22
23
24
25
|
# File 'lib/fairy/master/c-sort.rb', line 17
def initialize(controller, opts, block_source)
super
@samplings = []
@pvs = nil
@pvs_mutex = Mutex.new
@pvs_cv = XThread::ConditionVariable.new
end
|
Instance Method Details
#get_pvs(buf = nil) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/fairy/master/c-sort.rb', line 27
def get_pvs(buf=nil)
if buf
@samplings.push buf
make_pvs
end
@pvs_mutex.synchronize do
while !@pvs
@pvs_cv.wait(@pvs_mutex)
end
end
@pvs
end
|
#make_pvs ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/fairy/master/c-sort.rb', line 49
def make_pvs
no_segment = @opts[:no_segment]
no_segment ||= Fairy::CONF.SORT_NO_SEGMENT
cmp_opt = @opts[:cmp_optimize]
cmp_opt = CONF.SORT_CMP_OPTIMIZE if cmp_opt.nil?
if cmp_opt
key_proc = eval("proc{#{@block_source.source}}", @context.binding)
else
key_proc = BBlock.new(@block_source, @context, self)
end
sorted = @samplings.flatten(1).map{|e| key_proc.call(e)}.sort_by{|e| e}
idxes = (1...no_segment).collect{|i| (sorted.size*i).div(no_segment)}
@pvs_mutex.synchronize do
@pvs = sorted.values_at(*idxes)
sorted.clear
sorted = nil
@samplings.clear
@samplings = nil
@pvs_cv.broadcast
end
end
|
#njob_creation_params ⇒ Object
81
82
83
|
# File 'lib/fairy/master/c-sort.rb', line 81
def njob_creation_params
[@block_source]
end
|
#node_class_name ⇒ Object
77
78
79
|
# File 'lib/fairy/master/c-sort.rb', line 77
def node_class_name
"PSort::PPreSort"
end
|