logically deleted records are by default skipped, but can be included using
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 29 Dec 2004 16:01:41 +0000 (16:01 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 29 Dec 2004 16:01:41 +0000 (16:01 +0000)
include_deleted option to new

git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@9 4670fa4d-42ec-0310-ab5b-a66af6943492

IsisDB.pm
scripts/dump_isis.pl

index 2733dad..6ca64f1 100644 (file)
--- a/IsisDB.pm
+++ b/IsisDB.pm
@@ -7,7 +7,7 @@ use Data::Dumper;
 BEGIN {
        use Exporter ();
        use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-       $VERSION     = 0.02;
+       $VERSION     = 0.03;
        @ISA         = qw (Exporter);
        #Give a hoot don't pollute, do not export more than needed by default
        @EXPORT      = qw ();
@@ -66,6 +66,7 @@ Open CDS/ISIS database
        isisdb => './cds/cds',
        read_fdt => 1,
        debug => 1,
+       include_deleted => 1,
  );
 
 Options are described below:
@@ -86,6 +87,10 @@ by default.
 
 Dump a C<lot> of debugging output.
 
+=item include_deleted
+
+Don't skip logically deleted records.
+
 =back
 
 It will also set C<$isis-E<gt>{'maxmfn'}> which is maximum MFN stored in database.
@@ -97,9 +102,11 @@ sub new {
        my $self = {};
        bless($self, $class);
 
-       $self->{isisdb} = {@_}->{isisdb} || croak "new needs database name as argument!";
+       croak "new needs database name (isisdb) as argument!" unless ({@_}->{isisdb});
 
-       $self->{debug} = {@_}->{debug};
+       foreach my $v (qw{isisdb debug include_deleted}) {
+               $self->{$v} = {@_}->{$v};
+       }
 
        # if you want to read .FDT file use read_fdt argument when creating class!
        if ({@_}->{read_fdt} && -e $self->{isisdb}.".FDT") {
@@ -173,6 +180,8 @@ sub new {
                my $buff = shift || return;
                my @arr = unpack("ssssssllls", $buff);
 
+               print "unpack_cnt: ",join(" ",@arr),"\n" if ($self->{'debug'});
+
                my $IDTYPE = shift @arr;
                foreach (@flds) {
                        $self->{$IDTYPE}->{$_} = abs(shift @arr);
@@ -270,6 +279,14 @@ print ("Error: The MFN:".$mfn." is not found in MST(".$value.")");
 
        print "MFRL: $MFRL MFBWB: $MFBWB MFBWP: $MFBWP BASE: $BASE NVF: $NVF STATUS: $STATUS\n" if ($self->{debug});
 
+       # delete old record
+       delete $self->{record};
+
+       if (! $self->{'include_deleted'} && $MFRL < 0) {
+               print "## logically deleted record $mfn, skipping...\n" if ($self->{debug});
+               return;
+       }
+
        # Get Directory Format
 
        my @FieldPOS;
@@ -309,8 +326,6 @@ print ("Error: The MFN:".$mfn." is not found in MST(".$value.")");
 
        # Get Variable Fields
 
-       delete $self->{record};
-
        read($self->{'fileMST'},$buff,$fld_len);
 
        for (my $i = 0 ; $i < $NVF ; $i++) {
@@ -318,11 +333,6 @@ print ("Error: The MFN:".$mfn." is not found in MST(".$value.")");
        }
        close(fileMST);
 
-       # The record is marked for deletion
-       if ($STATUS==1) {
-               return -1;
-       }
-
        print Dumper($self) if ($self->{debug});
 
        return $self->{'record'};
index bd0e379..9537987 100755 (executable)
@@ -9,6 +9,7 @@ use Data::Dumper;
 my $isis = IsisDB->new (
        isisdb => shift @ARGV || '/data/isis_data/ps/LIBRI/LIBRI',
        debug => shift @ARGV,
+       include_deleted => 1,
 );
 
 print "rows: ",$isis->{'maxmfn'},"\n\n";