| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# $Id: SinFP3.pm,v 451c3602d7b2 2015/11/25 06:13:53 gomor $ |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
package Net::SinFP3; |
|
5
|
1
|
|
|
1
|
|
27384
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
38
|
|
|
6
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
81
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.23'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
8
|
use base qw(Class::Gomor::Array DynaLoader); |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
1202
|
|
|
11
|
|
|
|
|
|
|
our @AS = qw( |
|
12
|
|
|
|
|
|
|
global |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
our @AA = qw( |
|
15
|
|
|
|
|
|
|
db |
|
16
|
|
|
|
|
|
|
mode |
|
17
|
|
|
|
|
|
|
search |
|
18
|
|
|
|
|
|
|
input |
|
19
|
|
|
|
|
|
|
output |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
__PACKAGE__->cgBuildIndices; |
|
22
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsScalar(\@AS); |
|
23
|
|
|
|
|
|
|
__PACKAGE__->cgBuildAccessorsArray (\@AA); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
26
|
|
|
|
|
|
|
matchType => [qw( |
|
27
|
|
|
|
|
|
|
NS_MATCH_TYPE_S1S2S3 |
|
28
|
|
|
|
|
|
|
NS_MATCH_TYPE_S1S2 |
|
29
|
|
|
|
|
|
|
NS_MATCH_TYPE_S2 |
|
30
|
|
|
|
|
|
|
)], |
|
31
|
|
|
|
|
|
|
matchMask => [qw( |
|
32
|
|
|
|
|
|
|
NS_MATCH_MASK_HEURISTIC0 |
|
33
|
|
|
|
|
|
|
NS_MATCH_MASK_HEURISTIC1 |
|
34
|
|
|
|
|
|
|
NS_MATCH_MASK_HEURISTIC2 |
|
35
|
|
|
|
|
|
|
)], |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
our @EXPORT_OK = ( |
|
39
|
|
|
|
|
|
|
@{$EXPORT_TAGS{matchType}}, |
|
40
|
|
|
|
|
|
|
@{$EXPORT_TAGS{matchMask}}, |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
24492
|
use constant NS_MATCH_TYPE_S1S2S3 => 'S1S2S3'; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
156
|
|
|
44
|
1
|
|
|
1
|
|
8
|
use constant NS_MATCH_TYPE_S1S2 => 'S1S2'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
77
|
|
|
45
|
1
|
|
|
1
|
|
19
|
use constant NS_MATCH_TYPE_S2 => 'S2'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
72
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
|
|
1
|
|
8
|
use constant NS_MATCH_MASK_HEURISTIC0 => 'BH0FH0WH0OH0MH0SH0LH0'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
80
|
|
|
48
|
1
|
|
|
1
|
|
7
|
use constant NS_MATCH_MASK_HEURISTIC1 => 'BH1FH1WH1OH1MH1SH1LH1'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
67
|
|
|
49
|
1
|
|
|
1
|
|
7
|
use constant NS_MATCH_MASK_HEURISTIC2 => 'BH2FH2WH2OH2MH2SH2LH2'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
74
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
|
|
1
|
|
993
|
use Net::SinFP3::Worker qw(:consts); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
491
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new { |
|
54
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
55
|
0
|
|
|
|
|
|
my %param = @_; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Sets unbuffered STDOUT |
|
58
|
0
|
|
|
|
|
|
$|++; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
0
|
0
|
|
|
|
if (!exists($param{output}) |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|| !exists($param{input}) |
|
62
|
|
|
|
|
|
|
|| !exists($param{mode}) |
|
63
|
|
|
|
|
|
|
|| !exists($param{search}) |
|
64
|
|
|
|
|
|
|
|| !exists($param{global}) |
|
65
|
|
|
|
|
|
|
|| !exists($param{db})) { |
|
66
|
0
|
|
|
|
|
|
die("[-] ".__PACKAGE__.": You must provide all of the following ". |
|
67
|
|
|
|
|
|
|
"attributes: output, input, mode, search, db, global\n"); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new( |
|
71
|
|
|
|
|
|
|
db => [], |
|
72
|
|
|
|
|
|
|
input => [], |
|
73
|
|
|
|
|
|
|
mode => [], |
|
74
|
|
|
|
|
|
|
search => [], |
|
75
|
|
|
|
|
|
|
output => [], |
|
76
|
|
|
|
|
|
|
@_, |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $log = $self->global->log; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
{ |
|
82
|
1
|
|
|
1
|
|
10
|
no strict 'vars'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
2403
|
|
|
|
0
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
for my $var ('output', 'input', 'db', 'mode', 'search') { |
|
84
|
0
|
|
|
|
|
|
my $idx = '$__'.$var; |
|
85
|
0
|
|
|
|
|
|
my $ref = ref($self->[eval($idx)]); |
|
86
|
0
|
0
|
|
|
|
|
if ($ref !~ /^ARRAY$/) { |
|
87
|
0
|
|
|
|
|
|
$log->fatal("$var attribute must be an ARRAYREF and it is [$ref]"); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return $self; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _do { |
|
96
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $global = $self->global; |
|
99
|
0
|
|
|
|
|
|
my $log = $global->log; |
|
100
|
0
|
|
|
|
|
|
my $input = $global->input; |
|
101
|
0
|
|
|
|
|
|
my $next = $global->next; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$log->info("Starting of job with Next ".$next->print); |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my @db = $self->db; |
|
106
|
0
|
|
|
|
|
|
my @mode = $self->mode; |
|
107
|
0
|
|
|
|
|
|
my @search = $self->search; |
|
108
|
0
|
|
|
|
|
|
my @output = $self->output; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
$input->postRun or return; |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
for my $db (@db) { |
|
113
|
0
|
|
|
|
|
|
$log->verbose("Starting of DB [".ref($db)."]"); |
|
114
|
0
|
|
|
|
|
|
$global->db($db); |
|
115
|
0
|
0
|
|
|
|
|
$db->init or $log->fatal("Unable to init [".ref($db)."] module"); |
|
116
|
0
|
0
|
|
|
|
|
$db->run or next; |
|
117
|
0
|
|
|
|
|
|
$log->verbose("Running of DB [".ref($db)."]: Done"); |
|
118
|
0
|
|
|
|
|
|
for my $mode (@mode) { |
|
119
|
0
|
|
|
|
|
|
$global->mode($mode); |
|
120
|
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
$log->verbose( |
|
122
|
|
|
|
|
|
|
"Running with Next: ".$next->print." with type [".ref($next)."]" |
|
123
|
|
|
|
|
|
|
); |
|
124
|
0
|
|
|
|
|
|
$log->verbose("Starting of Mode [".ref($mode)."]"); |
|
125
|
0
|
0
|
|
|
|
|
$mode->init or $log->fatal("Unable to init [".ref($mode)."] module"); |
|
126
|
0
|
0
|
|
|
|
|
$mode->run or next; |
|
127
|
0
|
|
|
|
|
|
$log->verbose("Running of Mode [".ref($mode)."]: Done"); |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
for my $search (@search) { |
|
130
|
0
|
|
|
|
|
|
$global->search($search); |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$log->verbose("Starting of Search [".ref($search)."]"); |
|
133
|
0
|
0
|
|
|
|
|
$search->init or $log->fatal("Unable to init [".ref($search). |
|
134
|
|
|
|
|
|
|
"] module"); |
|
135
|
0
|
0
|
|
|
|
|
my $result = $search->run or next; |
|
136
|
0
|
|
|
|
|
|
$global->result($result); |
|
137
|
0
|
|
|
|
|
|
$log->verbose("Running of Search [".ref($search)."]: Done"); |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$mode->postSearch; |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
for my $output (@output) { |
|
142
|
0
|
|
|
|
|
|
$global->output($output); |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
$log->verbose("Starting of Output [".ref($output)."]"); |
|
145
|
0
|
|
|
|
|
|
$output->firstInit; |
|
146
|
0
|
0
|
|
|
|
|
$output->init or $log->fatal("Unable to init [".ref($output). |
|
147
|
|
|
|
|
|
|
"] module"); |
|
148
|
0
|
0
|
|
|
|
|
$output->run or next; |
|
149
|
0
|
|
|
|
|
|
$output->post; |
|
150
|
0
|
|
|
|
|
|
$log->verbose("Running of Output [".ref($output)."]: Done"); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
0
|
|
|
|
|
|
$search->post; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
0
|
|
|
|
|
|
$mode->post; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
# To have persistent $dbh, we MUST post() in main process |
|
157
|
|
|
|
|
|
|
#$db->post; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
return 1; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub _getWorkerModel { |
|
164
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
165
|
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
my $global = $self->global; |
|
167
|
0
|
|
|
|
|
|
my $log = $global->log; |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my $model; |
|
170
|
0
|
0
|
|
|
|
|
if ($global->worker =~ /fork/i) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
eval "use Net::SinFP3::Worker::Fork"; |
|
172
|
0
|
0
|
|
|
|
|
if ($@) { |
|
173
|
0
|
|
|
|
|
|
chomp($@); |
|
174
|
0
|
|
|
|
|
|
$log->fatal("Unable to use worker model Fork: error [$@]"); |
|
175
|
|
|
|
|
|
|
} |
|
176
|
0
|
|
|
|
|
|
$model = 'Net::SinFP3::Worker::Fork'; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
elsif ($global->worker =~ /thread/i) { |
|
179
|
0
|
|
|
|
|
|
eval "use Net::SinFP3::Worker::Thread"; |
|
180
|
0
|
0
|
|
|
|
|
if ($@) { |
|
181
|
0
|
|
|
|
|
|
chomp($@); |
|
182
|
0
|
|
|
|
|
|
$log->fatal("Unable to use worker model Thread: error [$@]"); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
0
|
|
|
|
|
|
$model = 'Net::SinFP3::Worker::Thread'; |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
elsif ($global->worker =~ /single/i) { |
|
187
|
0
|
|
|
|
|
|
eval "use Net::SinFP3::Worker::Single"; |
|
188
|
0
|
0
|
|
|
|
|
if ($@) { |
|
189
|
0
|
|
|
|
|
|
chomp($@); |
|
190
|
0
|
|
|
|
|
|
$log->fatal("Unable to use worker model Single: error [$@]"); |
|
191
|
|
|
|
|
|
|
} |
|
192
|
0
|
|
|
|
|
|
$model = 'Net::SinFP3::Worker::Single'; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
return $model; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub run { |
|
199
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
200
|
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
my $global = $self->global; |
|
202
|
0
|
|
|
|
|
|
my $log = $global->log; |
|
203
|
0
|
|
|
|
|
|
my @input = $self->input; |
|
204
|
0
|
|
|
|
|
|
my @output = $self->output; |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
# Beware, recursive loop |
|
207
|
0
|
|
|
|
|
|
$log->global($global); |
|
208
|
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
my $worker = $self->_getWorkerModel->new( |
|
210
|
|
|
|
|
|
|
global => $global, |
|
211
|
|
|
|
|
|
|
); |
|
212
|
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
$log->info("Loaded Input: ".join(', ', map { ref($_) } $self->input)); |
|
|
0
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
$log->info("Loaded DB: ".join(', ', map { ref($_) } $self->db)); |
|
|
0
|
|
|
|
|
|
|
|
215
|
0
|
|
|
|
|
|
$log->info("Loaded Mode: ".join(', ', map { ref($_) } $self->mode)); |
|
|
0
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$log->info("Loaded Search: ".join(', ', map { ref($_) } $self->search)); |
|
|
0
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
$log->info("Loaded Output: ".join(', ', map { ref($_) } $self->output)); |
|
|
0
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
for my $output (@output) { |
|
220
|
0
|
|
|
|
|
|
$output->preInit; |
|
221
|
|
|
|
|
|
|
} |
|
222
|
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
|
my $job = 0; |
|
224
|
0
|
|
|
|
|
|
for my $input (@input) { |
|
225
|
0
|
|
|
|
|
|
$log->info("Starting of Input [".ref($input)."]"); |
|
226
|
0
|
0
|
|
|
|
|
$input->init or $log->fatal("Unable to init [".ref($input)."] module"); |
|
227
|
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
$global->input($input); |
|
229
|
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
while (my $next = $input->run) { |
|
231
|
0
|
0
|
|
|
|
|
last unless defined($next); |
|
232
|
|
|
|
|
|
|
|
|
233
|
0
|
0
|
|
|
|
|
my @next = (ref($next) =~ /^ARRAY$/) ? @$next : ( $next ); |
|
234
|
0
|
|
|
|
|
|
for my $next (@next) { |
|
235
|
0
|
|
|
|
|
|
$global->job(++$job); |
|
236
|
0
|
|
|
|
|
|
$global->next($next); |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
$worker->init( |
|
239
|
|
|
|
|
|
|
callback => sub { |
|
240
|
0
|
|
|
0
|
|
|
$self->_do; |
|
241
|
|
|
|
|
|
|
}, |
|
242
|
0
|
0
|
|
|
|
|
) or $log->fatal("Unable to init [".ref($worker)."] module"); |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# We are just before fork()ing or thread()ing. |
|
245
|
|
|
|
|
|
|
# Now, all data will be copied to the new process. |
|
246
|
0
|
|
|
|
|
|
my $r = $worker->run; |
|
247
|
0
|
0
|
|
|
|
|
if ($r == NS_WORKER_SUCCESS) { |
|
248
|
0
|
|
|
|
|
|
$input->postFork; |
|
249
|
0
|
|
|
|
|
|
next; |
|
250
|
|
|
|
|
|
|
} |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# Father process will skip that part |
|
253
|
0
|
|
|
|
|
|
$log->verbose("Running of job with Next ".$next->print.": Done"); |
|
254
|
|
|
|
|
|
|
|
|
255
|
0
|
|
|
|
|
|
$worker->post; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
} |
|
258
|
0
|
|
|
|
|
|
$global->job(0); |
|
259
|
0
|
|
|
|
|
|
$input->post; |
|
260
|
0
|
|
|
|
|
|
$log->verbose("Running of Input [".ref($input)."]: Done"); |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
0
|
|
|
|
|
|
$worker->clean; |
|
264
|
|
|
|
|
|
|
|
|
265
|
0
|
|
|
|
|
|
for my $db ($self->db) { |
|
266
|
0
|
|
|
|
|
|
$db->post; |
|
267
|
|
|
|
|
|
|
} |
|
268
|
|
|
|
|
|
|
|
|
269
|
0
|
|
|
|
|
|
for my $output (@output) { |
|
270
|
0
|
|
|
|
|
|
$output->lastPost; |
|
271
|
|
|
|
|
|
|
} |
|
272
|
|
|
|
|
|
|
|
|
273
|
0
|
|
|
|
|
|
$log->info("Done: operation successful"); |
|
274
|
|
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
|
return 1; |
|
276
|
|
|
|
|
|
|
} |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
1; |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
__END__ |