5 |
use DBI; |
use DBI; |
6 |
use Data::Dumper; |
use Data::Dumper; |
7 |
use Encode qw/from_to/; |
use Encode qw/from_to/; |
8 |
|
use Time::HiRes qw/time/; |
9 |
|
|
10 |
=head1 NAME |
=head1 NAME |
11 |
|
|
19 |
sql => qq{ |
sql => qq{ |
20 |
select * from history_collection_view_cache |
select * from history_collection_view_cache |
21 |
}, |
}, |
22 |
|
db_encoding => 'iso-8859-2', |
23 |
debug => 0, |
debug => 0, |
24 |
}; |
}; |
25 |
|
|
44 |
my $total = $sth->rows; |
my $total = $sth->rows; |
45 |
my $i = 1; |
my $i = 1; |
46 |
|
|
47 |
|
my $t = time(); |
48 |
|
|
49 |
while (my $row = $sth->fetchrow_hashref() ) { |
while (my $row = $sth->fetchrow_hashref() ) { |
50 |
|
|
51 |
warn "# row: ",Dumper($row) if ($c->{debug}); |
warn "# row: ",Dumper($row) if ($c->{debug}); |
61 |
|
|
62 |
if ($val) { |
if ($val) { |
63 |
# change encoding? |
# change encoding? |
64 |
from_to($val, 'ISO-8859-2', 'UTF-8'); |
from_to($val, ($c->{db_encoding} || 'ISO-8859-1'), 'UTF-8'); |
65 |
|
|
66 |
# add attributes (make column usable from attribute search) |
# add attributes (make column usable from attribute search) |
67 |
$doc->add_attr($col, $val); |
$doc->add_attr($col, $val); |
76 |
|
|
77 |
} |
} |
78 |
|
|
|
print " ", int(( $i++ / $total) * 100), "%\n"; |
|
|
|
|
79 |
warn "# doc draft: ",$doc->dump_draft, "\n" if ($c->{debug}); |
warn "# doc draft: ",$doc->dump_draft, "\n" if ($c->{debug}); |
80 |
|
|
81 |
die "error: ", $node->status,"\n" unless (eval { $node->put_doc($doc) }); |
die "error: ", $node->status,"\n" unless (eval { $node->put_doc($doc) }); |
82 |
|
|
83 |
|
printf (" %d%% %.1f/s\n", int(( $i++ / $total) * 100), ( $i / (time() - $t) ) ); |
84 |
|
|
85 |
} |
} |