89 |
Run databases in parallel (aproximatly same as number of processors in |
Run databases in parallel (aproximatly same as number of processors in |
90 |
machine if you want to use full load) |
machine if you want to use full load) |
91 |
|
|
92 |
|
=item --only-links |
93 |
|
|
94 |
|
Create just links |
95 |
|
|
96 |
=back |
=back |
97 |
|
|
98 |
=cut |
=cut |
109 |
my ($marc_normalize, $marc_output); |
my ($marc_normalize, $marc_output); |
110 |
my $marc_lint = 1; |
my $marc_lint = 1; |
111 |
my $marc_dump = 0; |
my $marc_dump = 0; |
|
|
|
112 |
my $parallel = 0; |
my $parallel = 0; |
113 |
|
my $only_links = 0; |
114 |
|
|
115 |
GetOptions( |
GetOptions( |
116 |
"limit=i" => \$limit, |
"limit=i" => \$limit, |
127 |
"marc-lint!" => \$marc_lint, |
"marc-lint!" => \$marc_lint, |
128 |
"marc-dump!" => \$marc_dump, |
"marc-dump!" => \$marc_dump, |
129 |
"parallel=i" => \$parallel, |
"parallel=i" => \$parallel, |
130 |
|
"only-links!" => \$only_links, |
131 |
); |
); |
132 |
|
|
133 |
$config = LoadFile($config); |
$config = LoadFile($config); |
159 |
my $start_t = time(); |
my $start_t = time(); |
160 |
|
|
161 |
my @links; |
my @links; |
|
my $indexer; |
|
162 |
|
|
163 |
if ($parallel) { |
if ($parallel) { |
164 |
$log->info("Using $parallel processes for speedup"); |
$log->info("Using $parallel processes for speedup"); |
179 |
} |
} |
180 |
} |
} |
181 |
|
|
182 |
|
my $indexer; |
183 |
if ($use_indexer) { |
if ($use_indexer) { |
184 |
my $indexer_config = $config->{$use_indexer} || $log->logdie("can't find '$use_indexer' part in confguration"); |
my $indexer_config = $config->{$use_indexer} || $log->logdie("can't find '$use_indexer' part in confguration"); |
185 |
$indexer_config->{database} = $database; |
$indexer_config->{database} = $database; |
208 |
|
|
209 |
|
|
210 |
# |
# |
211 |
|
# store Hyper Estraier links to other databases |
212 |
|
# |
213 |
|
if (ref($db_config->{links}) eq 'ARRAY' && $use_indexer) { |
214 |
|
foreach my $link (@{ $db_config->{links} }) { |
215 |
|
if ($use_indexer eq 'hyperestraier') { |
216 |
|
$log->info("saving link $database -> $link->{to} [$link->{credit}]"); |
217 |
|
push @links, sub { |
218 |
|
$log->info("adding link $database -> $link->{to} [$link->{credit}]"); |
219 |
|
$indexer->add_link( |
220 |
|
from => $database, |
221 |
|
to => $link->{to}, |
222 |
|
credit => $link->{credit}, |
223 |
|
); |
224 |
|
}; |
225 |
|
} else { |
226 |
|
$log->warn("NOT IMPLEMENTED WITH $use_indexer: adding link $database -> $link->{to} [$link->{credit}]"); |
227 |
|
} |
228 |
|
} |
229 |
|
} |
230 |
|
next if ($only_links); |
231 |
|
|
232 |
|
|
233 |
|
# |
234 |
# now WebPAC::Store |
# now WebPAC::Store |
235 |
# |
# |
236 |
my $abs_path = abs_path($0); |
my $abs_path = abs_path($0); |
425 |
) |
) |
426 |
); |
); |
427 |
|
|
|
# |
|
|
# add Hyper Estraier links to other databases |
|
|
# |
|
|
if (ref($db_config->{links}) eq 'ARRAY' && $use_indexer) { |
|
|
foreach my $link (@{ $db_config->{links} }) { |
|
|
if ($use_indexer eq 'hyperestraier') { |
|
|
$log->info("saving link $database -> $link->{to} [$link->{credit}]"); |
|
|
push @links, { |
|
|
from => $database, |
|
|
to => $link->{to}, |
|
|
credit => $link->{credit}, |
|
|
}; |
|
|
} else { |
|
|
$log->warn("NOT IMPLEMENTED WITH $use_indexer: adding link $database -> $link->{to} [$link->{credit}]"); |
|
|
} |
|
|
} |
|
|
} |
|
428 |
|
|
429 |
# end forked process |
# end forked process |
430 |
if ($parallel) { |
if ($parallel) { |
440 |
$log->info("all parallel processes finished"); |
$log->info("all parallel processes finished"); |
441 |
} |
} |
442 |
|
|
443 |
|
|
444 |
foreach my $link (@links) { |
foreach my $link (@links) { |
445 |
$log->info("adding link $link->{from} -> $link->{to} [$link->{credit}]"); |
$log->logdie("coderef in link ", Dumper($link), " is ", ref($link), " and not CODE") unless (ref($link) eq 'CODE'); |
446 |
$indexer->add_link( %{ $link } ); |
$link->(); |
447 |
} |
} |
448 |
|
|