From: Dobrica Pavlinusic Date: Thu, 6 Jan 2005 16:27:07 +0000 (+0000) Subject: moved *_cnt function to end of module (so that documetation ends up at end) X-Git-Url: http://git.rot13.org/?p=Biblio-Isis;a=commitdiff_plain;h=c0734ad5ae0c34cb9c78488995daafbe8217d8c3 moved *_cnt function to end of module (so that documetation ends up at end) git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@35 4670fa4d-42ec-0310-ab5b-a66af6943492 --- diff --git a/IsisDB.pm b/IsisDB.pm index be47f6d..37f7030 100644 --- a/IsisDB.pm +++ b/IsisDB.pm @@ -221,80 +221,6 @@ sub count { return $self->{'NXTMFN'} - 1; } -=head2 read_cnt - -Read content of C<.CNT> file and return hash containing it. - - print Dumper($isis->read_cnt); - -This function is not used by module (C<.CNT> files are not required for this -module to work), but it can be useful to examine your index (while debugging -for example). - -=cut - -sub read_cnt { - my $self = shift; - - croak "missing CNT file in ",$self->{isisdb} unless ($self->{cnt_file}); - - # Get the index information from $db.CNT - - open(my $fileCNT, $self->{cnt_file}) || croak "can't read '$self->{cnt_file}': $!"; - binmode($fileCNT); - - my $buff; - - read($fileCNT, $buff, 26) || croak "can't read first table from CNT: $!"; - $self->unpack_cnt($buff); - - read($fileCNT, $buff, 26) || croak "can't read second table from CNT: $!"; - $self->unpack_cnt($buff); - - close($fileCNT); - - return $self->{cnt}; -} - -=head2 unpack_cnt - -Unpack one of two 26 bytes fixed length record in C<.CNT> file. - -Here is definition of record: - - off key description size - 0: IDTYPE BTree type s - 2: ORDN Nodes Order s - 4: ORDF Leafs Order s - 6: N Number of Memory buffers for nodes s - 8: K Number of buffers for first level index s - 10: LIV Current number of Index Levels s - 12: POSRX Pointer to Root Record in N0x l - 16: NMAXPOS Next Available position in N0x l - 20: FMAXPOS Next available position in L0x l - 24: ABNORMAL Formal BTree normality indicator s - length: 26 bytes - -This will fill C<$self> object under C with hash. It's used by C. - -=cut - -sub unpack_cnt { - my $self = shift; - - my @flds = qw(ORDN ORDF N K LIV POSRX NMAXPOS FMAXPOS ABNORMAL); - - my $buff = shift || return; - my @arr = unpack("vvvvvvVVVv", $buff); - - print STDERR "unpack_cnt: ",join(" ",@arr),"\n" if ($self->{'debug'}); - - my $IDTYPE = shift @arr; - foreach (@flds) { - $self->{cnt}->{$IDTYPE}->{$_} = abs(shift @arr); - } -} - =head2 fetch Read record with selected MFN @@ -576,6 +502,81 @@ sub tag_name { return $self->{'TagName'}->{$tag} || $tag; } + +=head2 read_cnt + +Read content of C<.CNT> file and return hash containing it. + + print Dumper($isis->read_cnt); + +This function is not used by module (C<.CNT> files are not required for this +module to work), but it can be useful to examine your index (while debugging +for example). + +=cut + +sub read_cnt { + my $self = shift; + + croak "missing CNT file in ",$self->{isisdb} unless ($self->{cnt_file}); + + # Get the index information from $db.CNT + + open(my $fileCNT, $self->{cnt_file}) || croak "can't read '$self->{cnt_file}': $!"; + binmode($fileCNT); + + my $buff; + + read($fileCNT, $buff, 26) || croak "can't read first table from CNT: $!"; + $self->unpack_cnt($buff); + + read($fileCNT, $buff, 26) || croak "can't read second table from CNT: $!"; + $self->unpack_cnt($buff); + + close($fileCNT); + + return $self->{cnt}; +} + +=head2 unpack_cnt + +Unpack one of two 26 bytes fixed length record in C<.CNT> file. + +Here is definition of record: + + off key description size + 0: IDTYPE BTree type s + 2: ORDN Nodes Order s + 4: ORDF Leafs Order s + 6: N Number of Memory buffers for nodes s + 8: K Number of buffers for first level index s + 10: LIV Current number of Index Levels s + 12: POSRX Pointer to Root Record in N0x l + 16: NMAXPOS Next Available position in N0x l + 20: FMAXPOS Next available position in L0x l + 24: ABNORMAL Formal BTree normality indicator s + length: 26 bytes + +This will fill C<$self> object under C with hash. It's used by C. + +=cut + +sub unpack_cnt { + my $self = shift; + + my @flds = qw(ORDN ORDF N K LIV POSRX NMAXPOS FMAXPOS ABNORMAL); + + my $buff = shift || return; + my @arr = unpack("vvvvvvVVVv", $buff); + + print STDERR "unpack_cnt: ",join(" ",@arr),"\n" if ($self->{'debug'}); + + my $IDTYPE = shift @arr; + foreach (@flds) { + $self->{cnt}->{$IDTYPE}->{$_} = abs(shift @arr); + } +} + 1; =head1 BUGS