From 7f34cc1f12efb6eb8991b643c1e9fd2ad6ac2ff7 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Wed, 29 Dec 2004 16:01:41 +0000 Subject: [PATCH] logically deleted records are by default skipped, but can be included using include_deleted option to new git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@9 4670fa4d-42ec-0310-ab5b-a66af6943492 --- IsisDB.pm | 30 ++++++++++++++++++++---------- scripts/dump_isis.pl | 1 + 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/IsisDB.pm b/IsisDB.pm index 2733dad..6ca64f1 100644 --- 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 of debugging output. +=item include_deleted + +Don't skip logically deleted records. + =back It will also set C<$isis-E{'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'}; diff --git a/scripts/dump_isis.pl b/scripts/dump_isis.pl index bd0e379..9537987 100755 --- a/scripts/dump_isis.pl +++ b/scripts/dump_isis.pl @@ -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"; -- 2.20.1