9 |
use WebPAC::Common 0.02; |
use WebPAC::Common 0.02; |
10 |
use WebPAC::Parser 0.08; |
use WebPAC::Parser 0.08; |
11 |
use WebPAC::Input 0.16; |
use WebPAC::Input 0.16; |
12 |
use WebPAC::Store 0.14; |
use WebPAC::Store 0.15; |
13 |
use WebPAC::Normalize 0.22; |
use WebPAC::Normalize 0.22; |
14 |
use WebPAC::Output::TT; |
use WebPAC::Output::TT; |
15 |
use WebPAC::Validate 0.11; |
use WebPAC::Validate 0.11; |
298 |
# |
# |
299 |
# now WebPAC::Store |
# now WebPAC::Store |
300 |
# |
# |
301 |
my $abs_path = abs_path($0); |
my $store = new WebPAC::Store({ |
302 |
$abs_path =~ s#/[^/]*$#/#; |
debug => $debug, |
303 |
|
}); |
|
my $db_path = $config->webpac('db_path'); |
|
304 |
|
|
305 |
if ($clean) { |
# |
306 |
$log->info("creating new database '$database' in $db_path"); |
# prepare output |
307 |
rmtree( $db_path ) || $log->warn("can't remove $db_path: $!"); |
# |
308 |
} else { |
my @outputs; |
309 |
$log->info("working on database '$database' in $db_path"); |
if (defined( $db_config->{output} )) { |
310 |
|
my $module = $db_config->{output}->{module} || $log->logdie("need module in output section of $database"); |
311 |
|
$module = 'WebPAC::Output::' . $module unless $module =~ m/::/; |
312 |
|
$log->debug("loading output module $module"); |
313 |
|
eval "require $module"; |
314 |
|
my $out = new $module->new( $db_config->{output} ); |
315 |
|
$out->init; |
316 |
|
push @outputs, $out; |
317 |
} |
} |
318 |
|
|
|
my $store = new WebPAC::Store( |
|
|
path => $db_path, |
|
|
debug => $debug, |
|
|
); |
|
|
|
|
319 |
|
|
320 |
# |
# |
321 |
# now, iterate through input formats |
# now, iterate through input formats |
508 |
|
|
509 |
my $mfn = $row->{'000'}->[0]; |
my $mfn = $row->{'000'}->[0]; |
510 |
|
|
511 |
if (! $mfn || $mfn !~ m#^\d+$#) { |
if (! $mfn || $mfn !~ m{^\d+$}) { |
512 |
$log->warn("record $pos doesn't have valid MFN but '$mfn', using $pos"); |
$log->warn("record $pos doesn't have valid MFN but '$mfn', using $pos"); |
513 |
$mfn = $pos; |
$mfn = $pos; |
514 |
push @{ $row->{'000'} }, $pos; |
push @{ $row->{'000'} }, $pos; |
570 |
|
|
571 |
$log->info("Created $i instances of MFN $mfn\n") if ($i > 1); |
$log->info("Created $i instances of MFN $mfn\n") if ($i > 1); |
572 |
} |
} |
573 |
|
|
574 |
|
foreach my $out ( @outputs ) { |
575 |
|
$out->add( $mfn, $ds ) if $out->can('add'); |
576 |
|
} |
577 |
|
|
578 |
} |
} |
579 |
|
|
580 |
if ($validate) { |
if ($validate) { |
605 |
|
|
606 |
eval { $indexer->finish } if ($indexer && $indexer->can('finish')); |
eval { $indexer->finish } if ($indexer && $indexer->can('finish')); |
607 |
|
|
608 |
|
foreach my $out ( @outputs ) { |
609 |
|
$out->finish if $out->can('finish'); |
610 |
|
} |
611 |
|
|
612 |
my $dt = time() - $start_t; |
my $dt = time() - $start_t; |
613 |
$log->info("$total_rows records ", $indexer ? "indexed " : "", |
$log->info("$total_rows records ", $indexer ? "indexed " : "", |
614 |
sprintf("in %.2f sec [%.2f rec/sec]", |
sprintf("in %.2f sec [%.2f rec/sec]", |