/[webpac2]/trunk/lib/WebPAC/Input.pm
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/lib/WebPAC/Input.pm

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

revision 506 by dpavlin, Mon May 15 09:59:05 2006 UTC revision 523 by dpavlin, Sun May 21 19:29:26 2006 UTC
# Line 3  package WebPAC::Input; Line 3  package WebPAC::Input;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6    use blib;
7    
8  use WebPAC::Common;  use WebPAC::Common;
9  use base qw/WebPAC::Common/;  use base qw/WebPAC::Common/;
10  use Text::Iconv;  use Text::Iconv;
# Line 225  sub open { Line 227  sub open {
227          my ($db, $size) = $self->{open_db}->( $self,          my ($db, $size) = $self->{open_db}->( $self,
228                  path => $arg->{path},                  path => $arg->{path},
229                  filter => $filter_ref,                  filter => $filter_ref,
230                    %{ $arg },
231          );          );
232    
233          unless (defined($db)) {          unless (defined($db)) {
# Line 241  sub open { Line 244  sub open {
244          my $to_rec = $size;          my $to_rec = $size;
245    
246          if (my $s = $self->{offset}) {          if (my $s = $self->{offset}) {
247                  $log->info("skipping to MFN $s");                  $log->debug("skipping to MFN $s");
248                  $from_rec = $s;                  $from_rec = $s;
249          } else {          } else {
250                  $self->{offset} = $from_rec;                  $self->{offset} = $from_rec;
# Line 426  sub seek { Line 429  sub seek {
429    
430  Dump statistics about field and subfield usage  Dump statistics about field and subfield usage
431    
432    print Dumper( $input->stats );    print $input->stats;
433    
434  =cut  =cut
435    
436  sub stats {  sub stats {
437          my $self = shift;          my $self = shift;
438          return $self->{_stats};  
439            my $log = $self->_get_logger();
440    
441            my $s = $self->{_stats};
442            if (! $s) {
443                    $log->warn("called stats, but there is no statistics collected");
444                    return;
445            }
446    
447            my $max_fld = 0;
448    
449            my $out = join("\n",
450                    map {
451                            my $f = $_ || die "no field";
452                            my $v = $s->{fld}->{$f} || die "no s->{fld}->{$f}";
453                            $max_fld = $v if ($v > $max_fld);
454    
455                            my $o = sprintf("%4s %d ~", $f, $v);
456    
457                            if (defined($s->{sf}->{$f})) {
458                                    map {
459                                            $o .= sprintf(" %s:%d", $_, $s->{sf}->{$f}->{$_});
460                                    } sort keys %{ $s->{sf}->{$f} };
461                            }
462    
463                            if (my $v_r = $s->{repeatable}->{$f}) {
464                                    $o .= " ($v_r)" if ($v_r != $v);
465                            }
466    
467                            $o;
468                    } sort { $a cmp $b } keys %{ $s->{fld} }
469            );
470    
471            $log->debug( sub { Dumper($s) } );
472    
473            return $out;
474  }  }
475    
476  =head1 MEMORY USAGE  =head1 MEMORY USAGE

Legend:
Removed from v.506  
changed lines
  Added in v.523

  ViewVC Help
Powered by ViewVC 1.1.26