/[Search-Estraier]/trunk/scripts/dbi-indexer.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/scripts/dbi-indexer.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 144 by dpavlin, Wed May 10 20:31:02 2006 UTC revision 146 by dpavlin, Wed May 10 21:33:32 2006 UTC
# Line 5  use Search::Estraier 0.06; Line 5  use Search::Estraier 0.06;
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    
# Line 18  my $c = { Line 19  my $c = {
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    
# Line 42  warn "# columns: ",join(",",@{ $sth->{NA Line 44  warn "# columns: ",join(",",@{ $sth->{NA
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});
# Line 57  while (my $row = $sth->fetchrow_hashref( Line 61  while (my $row = $sth->fetchrow_hashref(
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);
# Line 72  while (my $row = $sth->fetchrow_hashref( Line 76  while (my $row = $sth->fetchrow_hashref(
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  }  }

Legend:
Removed from v.144  
changed lines
  Added in v.146

  ViewVC Help
Powered by ViewVC 1.1.26