From: pop Date: Wed, 12 Mar 2003 17:08:53 +0000 (+0000) Subject: added force_update option for update_record, delete_record calls, to hopefully allow... X-Git-Tag: ZEBRA.1.3.8~18 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=6aa184fabb86b0535bc1d4d50cb6967e7425a068;p=idzebra-moved-to-github.git added force_update option for update_record, delete_record calls, to hopefully allow multiple changes of a record within one transaction. Stupid, idn't it? IDZebra::ScanEntry is an array ref now; --- diff --git a/perl/IDZebra.i b/perl/IDZebra.i index 70efba5..27af217 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -286,7 +286,8 @@ int zebra_update_record (ZebraHandle zh, const char *match, const char *fname, const char *buf, - int buf_size); + int buf_size, + int force_update); %name(delete_record) int zebra_delete_record (ZebraHandle zh, @@ -296,7 +297,9 @@ int zebra_delete_record (ZebraHandle zh, const char *match, const char *fname, const char *buf, - int buf_size); + int buf_size, + int force_update); + /* == Search (zebra_api_ext.c) ============================================= */ diff --git a/perl/IDZebra_wrap.c b/perl/IDZebra_wrap.c index c4224ea..73c64e9 100644 --- a/perl/IDZebra_wrap.c +++ b/perl/IDZebra_wrap.c @@ -212,7 +212,7 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { * perl5.swg * * Perl5 runtime library - * $Header: /home/cvsroot/idis/perl/Attic/IDZebra_wrap.c,v 1.14 2003-03-05 13:55:21 pop Exp $ + * $Header: /home/cvsroot/idis/perl/Attic/IDZebra_wrap.c,v 1.15 2003-03-12 17:08:53 pop Exp $ * ----------------------------------------------------------------------------- */ #define SWIGPERL @@ -3988,12 +3988,13 @@ XS(_wrap_update_record) { char *arg6 ; char *arg7 ; int arg8 ; + int arg9 ; int result; int argvi = 0; dXSARGS; - if ((items < 8) || (items > 8)) { - SWIG_croak("Usage: update_record(zh,rGroup,recordType,sysno,match,fname,buf,buf_size);"); + if ((items < 9) || (items > 9)) { + SWIG_croak("Usage: update_record(zh,rGroup,recordType,sysno,match,fname,buf,buf_size,force_update);"); } { ZebraHandle * argp; @@ -4017,7 +4018,8 @@ XS(_wrap_update_record) { if (!SvOK((SV*) ST(6))) arg7 = 0; else arg7 = (char *) SvPV(ST(6), PL_na); arg8 = (int) SvIV(ST(7)); - result = (int)zebra_update_record(arg1,arg2,(char const *)arg3,arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,arg8); + arg9 = (int) SvIV(ST(8)); + result = (int)zebra_update_record(arg1,arg2,(char const *)arg3,arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,arg8,arg9); ST(argvi) = sv_newmortal(); sv_setiv(ST(argvi++), (IV) result); @@ -4041,12 +4043,13 @@ XS(_wrap_delete_record) { char *arg6 ; char *arg7 ; int arg8 ; + int arg9 ; int result; int argvi = 0; dXSARGS; - if ((items < 8) || (items > 8)) { - SWIG_croak("Usage: delete_record(zh,rGroup,recordType,sysno,match,fname,buf,buf_size);"); + if ((items < 9) || (items > 9)) { + SWIG_croak("Usage: delete_record(zh,rGroup,recordType,sysno,match,fname,buf,buf_size,force_update);"); } { ZebraHandle * argp; @@ -4070,7 +4073,8 @@ XS(_wrap_delete_record) { if (!SvOK((SV*) ST(6))) arg7 = 0; else arg7 = (char *) SvPV(ST(6), PL_na); arg8 = (int) SvIV(ST(7)); - result = (int)zebra_delete_record(arg1,arg2,(char const *)arg3,arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,arg8); + arg9 = (int) SvIV(ST(8)); + result = (int)zebra_delete_record(arg1,arg2,(char const *)arg3,arg4,(char const *)arg5,(char const *)arg6,(char const *)arg7,arg8,arg9); ST(argvi) = sv_newmortal(); sv_setiv(ST(argvi++), (IV) result); diff --git a/perl/lib/IDZebra/ScanEntry.pm b/perl/lib/IDZebra/ScanEntry.pm index eddf3a6..2e02d9c 100644 --- a/perl/lib/IDZebra/ScanEntry.pm +++ b/perl/lib/IDZebra/ScanEntry.pm @@ -1,4 +1,4 @@ -# $Id: ScanEntry.pm,v 1.2 2003-03-05 13:55:22 pop Exp $ +# $Id: ScanEntry.pm,v 1.3 2003-03-12 17:08:53 pop Exp $ # # Zebra perl API header # ============================================================================= @@ -12,9 +12,13 @@ BEGIN { use IDZebra::Logger qw(:flags :calls); use Scalar::Util qw(weaken); use Carp; - our $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our $VERSION = do { my @r = (q$Revision: 1.3 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; } +use constant _term => 0; +use constant _occurrences => 1; +use constant _position => 2; +use constant _list => 3; 1; # ----------------------------------------------------------------------------- @@ -23,34 +27,38 @@ BEGIN { sub new { - my ($proto,%args) = @_; + my ($proto,@args) = @_; my $class = ref($proto) || $proto; - my $self = \%args; + my $self = \@args; bless ($self, $class); - weaken ($self->{list}); + weaken ($self->[_list]); return ($self); } # ============================================================================= sub DESTROY { my $self = shift; +# logf(LOG_LOG,"DESTROY: IDZebra::ScanEntry"); } # ----------------------------------------------------------------------------- sub term { my $self = shift; - return ($self->{entry}{term}); + return ($self->[_term]); } sub occurrences { my $self = shift; - return ($self->{entry}{occurrences}); + return ($self->[_occurrences]); } sub position { my $self = shift; - return ($self->{position}); + return ($self->[_position]); } + + + # ----------------------------------------------------------------------------- __END__ diff --git a/perl/lib/IDZebra/ScanList.pm b/perl/lib/IDZebra/ScanList.pm index 9383f00..8bf5025 100644 --- a/perl/lib/IDZebra/ScanList.pm +++ b/perl/lib/IDZebra/ScanList.pm @@ -1,4 +1,4 @@ -# $Id: ScanList.pm,v 1.2 2003-03-05 13:55:22 pop Exp $ +# $Id: ScanList.pm,v 1.3 2003-03-12 17:08:53 pop Exp $ # # Zebra perl API header # ============================================================================= @@ -13,7 +13,7 @@ BEGIN { use IDZebra::ScanEntry; use Scalar::Util qw(weaken); use Carp; - our $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our $VERSION = do { my @r = (q$Revision: 1.3 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our @ISA = qw(IDZebra::Logger); } @@ -45,6 +45,8 @@ sub new { sub DESTROY { my $self = shift; +# logf(LOG_LOG,"DESTROY: IDZebra::ScanList"); + if ($self->{odr_stream}) { IDZebra::odr_reset($self->{odr_stream}); IDZebra::odr_destroy($self->{odr_stream}); @@ -113,11 +115,12 @@ sub entries { my @res; for (my $i=1; $i<=$so->{num_entries}; $i++) { - + my $se = IDZebra::getScanEntry($so, $i); push (@res, - IDZebra::ScanEntry->new(entry => IDZebra::getScanEntry($so, $i), - position => $i, - list => $self)); + IDZebra::ScanEntry->new($se->{term}, + $se->{occurrences}, + $i, + $self)); } if ($self->{databases}) { diff --git a/perl/lib/IDZebra/Session.pm b/perl/lib/IDZebra/Session.pm index d86cd0d..258ffc5 100644 --- a/perl/lib/IDZebra/Session.pm +++ b/perl/lib/IDZebra/Session.pm @@ -1,4 +1,4 @@ -# $Id: Session.pm,v 1.13 2003-03-05 13:55:22 pop Exp $ +# $Id: Session.pm,v 1.14 2003-03-12 17:08:53 pop Exp $ # # Zebra perl API header # ============================================================================= @@ -15,7 +15,7 @@ BEGIN { use IDZebra::ScanList; use IDZebra::RetrievalRecord; require Exporter; - our $VERSION = do { my @r = (q$Revision: 1.13 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our $VERSION = do { my @r = (q$Revision: 1.14 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our @ISA = qw(IDZebra::Logger Exporter); our @EXPORT = qw (TRANS_RW TRANS_RO); } @@ -266,6 +266,7 @@ sub _setRecordGroupOptions { } sub _selectRecordGroup { my ($self, $rg) = @_; + my $r = IDZebra::set_group($self->{zh}, $rg); my $dbName; unless ($dbName = $rg->{databaseName}) { @@ -288,11 +289,10 @@ sub databases { } my %tmp; - my $changed = 0; foreach my $db (@databases) { - next if ($self->{databases}{$db}); $tmp{$db}++; + next if ($self->{databases}{$db}); $changed++; } @@ -465,6 +465,7 @@ sub delete_record { return(IDZebra::delete_record($self->{zh}, $self->_record_update_args(%args))); } + sub _record_update_args { my ($self, %args) = @_; @@ -472,6 +473,7 @@ sub _record_update_args { my $match = $args{match} ? $args{match} : ""; my $rectype = $args{recordType} ? $args{recordType} : ""; my $fname = $args{file} ? $args{file} : ""; + my $force = $args{force} ? $args{force} : 0; my $buff; @@ -490,6 +492,7 @@ sub _record_update_args { delete ($args{recordType}); delete ($args{file}); delete ($args{data}); + delete ($args{force}); my $rg = $self->_makeRecordGroup(%args); @@ -507,7 +510,7 @@ sub _record_update_args { unless ($rectype) { $rectype=""; } - return ($rg, $rectype, $sysno, $match, $fname, $buff, $len); + return ($rg, $rectype, $sysno, $match, $fname, $buff, $len, $force); } # ----------------------------------------------------------------------------- @@ -683,7 +686,6 @@ sub scan { # ============================================================================ - __END__ =head1 NAME