From: Adam Dickmeiss Date: Wed, 28 Jul 2004 08:15:44 +0000 (+0000) Subject: Update Perl internals so that it matches the current Zebra API. X-Git-Tag: ZEBRA.1.3.16~27 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=4a3a97df9d47b8d099e403308f8015f130366994;p=idzebra-moved-to-github.git Update Perl internals so that it matches the current Zebra API. The recordGroup structure is no longer available. A group of resources can still be referenced by setting groupName=>.. in various methods. --- diff --git a/NEWS b/NEWS index 0683137..c1d1704 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,8 @@ +Update Perl internals so that it matches the current Zebra API. +The recordGroup structure is no longer available. A group of resources +can still be referenced by setting groupName=>.. in various methods. + Maximum number of records to be sorted in a result set can be specified by setting "sortmax". Default is 1000. diff --git a/include/zebraapi.h b/include/zebraapi.h index 65faace..f7facec 100644 --- a/include/zebraapi.h +++ b/include/zebraapi.h @@ -1,4 +1,4 @@ -/* $Id: zebraapi.h,v 1.12 2004-01-22 11:27:21 adam Exp $ +/* $Id: zebraapi.h,v 1.13 2004-07-28 08:15:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -82,8 +82,9 @@ typedef struct zebra_service *ZebraService; /* Start Zebra using file 'configName' (usually zebra.cfg) */ /* There should be exactly one ZebraService */ -YAZ_EXPORT ZebraService zebra_start (const char *configName, - Res def_res, Res over_res); +YAZ_EXPORT ZebraService zebra_start (const char *configName); +YAZ_EXPORT ZebraService zebra_start_res (const char *configName, + Res def_res, Res over_res); /* Close the whole Zebra */ YAZ_EXPORT int zebra_stop (ZebraService zs); @@ -210,7 +211,8 @@ int zebra_add_record (ZebraHandle zh, const char *buf, int buf_size); int zebra_insert_record (ZebraHandle zh, const char *recordType, int *sysno, const char *match, const char *fname, - const char *buf, int buf_size); + const char *buf, int buf_size, + int force_update); int zebra_update_record (ZebraHandle zh, const char *recordType, int* sysno, const char *match, const char *fname, @@ -233,7 +235,6 @@ YAZ_EXPORT int zebra_sort (ZebraHandle zh, ODR stream, Z_SortKeySpecList *sort_sequence, int *sort_status); - YAZ_EXPORT int zebra_select_databases (ZebraHandle zh, int num_bases, const char **basenames); diff --git a/index/apitest.c b/index/apitest.c index 2694eb8..38720ea 100644 --- a/index/apitest.c +++ b/index/apitest.c @@ -1,4 +1,4 @@ -/* $Id: apitest.c,v 1.15 2004-01-22 11:27:21 adam Exp $ +/* $Id: apitest.c,v 1.16 2004-07-28 08:15:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -140,7 +140,7 @@ int main (int argc, char **argv) odr_input = odr_createmem (ODR_DECODE); odr_output = odr_createmem (ODR_ENCODE); - zs = zebra_start ("zebra.cfg", 0, 0); + zs = zebra_start ("zebra.cfg"); if (!zs) { printf ("zebra_start failed; missing zebra.cfg?\n"); diff --git a/index/extract.c b/index/extract.c index c2a664b..9183bbc 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.155 2004-06-03 11:45:28 adam Exp $ +/* $Id: extract.c,v 1.156 2004-07-28 08:15:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -1032,7 +1032,7 @@ int buffer_extract_record (ZebraHandle zh, extract_flushSortKeys (zh, *sysno, -1, &zh->reg->sortKeys); rec_rm (&rec); logRecord(zh); - return 0; + return -1; } } diff --git a/index/main.c b/index/main.c index 5afdd3a..25f59ff 100644 --- a/index/main.c +++ b/index/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.111 2004-05-30 18:05:30 adam Exp $ +/* $Id: main.c,v 1.112 2004-07-28 08:15:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -122,7 +122,7 @@ int main (int argc, char **argv) const char *config = configName ? configName : "zebra.cfg"; logf (LOG_LOG, "Zebra version %s %s", ZEBRAVER, ZEBRADATE); - zs = zebra_start (config, 0, res); + zs = zebra_start_res (config, 0, res); if (!zs) { yaz_log (LOG_FATAL, "Cannot read config %s", config); diff --git a/index/zebraapi.c b/index/zebraapi.c index 5124ad2..0b854ea 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.119 2004-05-10 08:47:54 adam Exp $ +/* $Id: zebraapi.c,v 1.120 2004-07-28 08:15:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -147,7 +147,12 @@ ZebraHandle zebra_open (ZebraService zs) return zh; } -ZebraService zebra_start (const char *configName, Res def_res, Res over_res) +ZebraService zebra_start (const char *configName) +{ + return zebra_start_res(configName, 0, 0); +} + +ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res) { Res res; @@ -1340,7 +1345,10 @@ int zebra_begin_trans (ZebraHandle zh, int rw) (zh->trans_no++); if (zh->trans_w_no) + { + read_res_for_transaction(zh); return 0; + } if (zh->trans_no != 1) { zh->errCode = 2; @@ -1947,7 +1955,7 @@ int zebra_add_record(ZebraHandle zh, int zebra_insert_record (ZebraHandle zh, const char *recordType, int *sysno, const char *match, const char *fname, - const char *buf, int buf_size) + const char *buf, int buf_size, int force_update) { int res; yaz_log(LOG_API,"zebra_insert_record sysno=%d", *sysno); @@ -1990,6 +1998,7 @@ int zebra_update_record (ZebraHandle zh, match, fname, force_update, 1); /* allow_update */ + yaz_log(LOG_LOG, "zebra_update_record returned res=%d", res); zebra_end_trans(zh); return res; } @@ -2084,3 +2093,4 @@ int zebra_sort_by_specstr (ZebraHandle zh, zebra_end_read(zh); return sort_status; } + diff --git a/index/zebrash.c b/index/zebrash.c index 6980699..4a1f992 100644 --- a/index/zebrash.c +++ b/index/zebrash.c @@ -1,4 +1,4 @@ -/* $Id: zebrash.c,v 1.26 2004-06-15 07:42:45 adam Exp $ +/* $Id: zebrash.c,v 1.27 2004-07-28 08:15:45 adam Exp $ Copyright (C) 2002,2003,2004 Index Data Aps @@ -166,7 +166,7 @@ static int cmd_zebra_start( char *args[], WRBUF outbuff) wrbuf_puts(outbuff, "\n"); conf=default_config; } - zs=zebra_start(conf, 0, 0); + zs=zebra_start(conf); if (!zs) { wrbuf_puts(outbuff, "zebra_start failed" ); return 2; @@ -357,7 +357,8 @@ static int cmd_record_insert( char *args[], WRBUF outbuff) 0, /* match */ 0, /* fname */ rec, - strlen(rec)); + strlen(rec), + 0); if (0==rc) { wrbuf_printf(outbuff,"ok sysno=%d\n",sysno); diff --git a/index/zserver.c b/index/zserver.c index 3ba03d9..ca01ed7 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -1,4 +1,4 @@ -/* $Id: zserver.c,v 1.115 2004-05-05 16:22:18 mike Exp $ +/* $Id: zserver.c,v 1.116 2004-07-28 08:15:45 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -638,7 +638,8 @@ int bend_esrequest (void *handle, bend_esrequest_rr *rr) 0, /* match */ 0, /* fname */ rec->u.octet_aligned->buf, - rec->u.octet_aligned->len); + rec->u.octet_aligned->len, + 0); if (r) { rr->errcode = 224; @@ -700,7 +701,7 @@ static void bend_start (struct statserv_options_block *sob) { if (sob->handle) zebra_stop((ZebraService) sob->handle); - sob->handle = zebra_start(sob->configname, 0, 0); + sob->handle = zebra_start(sob->configname); if (!sob->handle) { yaz_log (LOG_FATAL, "Failed to read config `%s'", sob->configname); diff --git a/perl/IDZebra.i b/perl/IDZebra.i index 020e8db..c1f1ec2 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -88,20 +88,6 @@ /*%include "zebra_perl.h" */ -typedef struct { - char *groupName; - char *databaseName; - char *path; - char *recordId; - char *recordType; - int flagStoreData; - int flagStoreKeys; - int flagRw; - int fileVerboseLimit; - int databaseNamePath; - int explainDatabase; - int followLinks; -} recordGroup; typedef struct { int noOfRecords; @@ -216,18 +202,16 @@ const char * zebra_errString (ZebraHandle zh); char * zebra_errAdd (ZebraHandle zh); -/* == Record groups and database selection ================================= */ +/* == Zebra resources and database selection =============================== */ -/* initialize a recordGroup (zebra_api_ext.c); */ -void init_recordGroup (recordGroup *rg); +/* set a resource */ +%name(set_resource) +void zebra_set_resource(ZebraHandle zh, const char *name, const char *value); -/* set up a recordGroup for a specific file extension from zebra.cfg - (zebra_api_ext.c); */ -void res_get_recordGroup (ZebraHandle zh, recordGroup *rg, - const char *ext); -/* set current record group for update purposes (zebraapi.c) */ -%name(set_group) -void zebra_set_group (ZebraHandle zh, struct recordGroup *rg); +/* get a resource */ +%name(get_resource) +const char *zebra_set_resource(ZebraHandle zh, const char *name, + const char *defaultvalue); /* select database for update purposes (zebraapi.c) */ %name(select_database) @@ -297,7 +281,8 @@ int zebra_insert_record (ZebraHandle zh, const char *match, const char *fname, const char *buf, - int buf_size); + int buf_size, + int force_update); %name(update_record) int zebra_update_record (ZebraHandle zh, diff --git a/perl/lib/IDZebra.pm b/perl/lib/IDZebra.pm index 4661205..e1c7cf1 100644 --- a/perl/lib/IDZebra.pm +++ b/perl/lib/IDZebra.pm @@ -50,9 +50,8 @@ package IDZebra; *errCode = *IDZebrac::errCode; *errString = *IDZebrac::errString; *errAdd = *IDZebrac::errAdd; -*init_recordGroup = *IDZebrac::init_recordGroup; -*res_get_recordGroup = *IDZebrac::res_get_recordGroup; -*set_group = *IDZebrac::set_group; +*set_resource = *IDZebrac::set_resource; +*get_resource = *IDZebrac::get_resource; *select_database = *IDZebrac::select_database; *select_databases = *IDZebrac::select_databases; *begin_trans = *IDZebrac::begin_trans; @@ -174,97 +173,6 @@ sub getScanEntry { *grs_perl_get_mem = *IDZebrac::grs_perl_get_mem; *grs_perl_set_res = *IDZebrac::grs_perl_set_res; -############# Class : IDZebra::recordGroup ############## - -package IDZebra::recordGroup; -@ISA = qw( IDZebra ); -%OWNER = (); -%BLESSEDMEMBERS = ( -); - -%ITERATORS = (); -*swig_groupName_get = *IDZebrac::recordGroup_groupName_get; -*swig_groupName_set = *IDZebrac::recordGroup_groupName_set; -*swig_databaseName_get = *IDZebrac::recordGroup_databaseName_get; -*swig_databaseName_set = *IDZebrac::recordGroup_databaseName_set; -*swig_path_get = *IDZebrac::recordGroup_path_get; -*swig_path_set = *IDZebrac::recordGroup_path_set; -*swig_recordId_get = *IDZebrac::recordGroup_recordId_get; -*swig_recordId_set = *IDZebrac::recordGroup_recordId_set; -*swig_recordType_get = *IDZebrac::recordGroup_recordType_get; -*swig_recordType_set = *IDZebrac::recordGroup_recordType_set; -*swig_flagStoreData_get = *IDZebrac::recordGroup_flagStoreData_get; -*swig_flagStoreData_set = *IDZebrac::recordGroup_flagStoreData_set; -*swig_flagStoreKeys_get = *IDZebrac::recordGroup_flagStoreKeys_get; -*swig_flagStoreKeys_set = *IDZebrac::recordGroup_flagStoreKeys_set; -*swig_flagRw_get = *IDZebrac::recordGroup_flagRw_get; -*swig_flagRw_set = *IDZebrac::recordGroup_flagRw_set; -*swig_fileVerboseLimit_get = *IDZebrac::recordGroup_fileVerboseLimit_get; -*swig_fileVerboseLimit_set = *IDZebrac::recordGroup_fileVerboseLimit_set; -*swig_databaseNamePath_get = *IDZebrac::recordGroup_databaseNamePath_get; -*swig_databaseNamePath_set = *IDZebrac::recordGroup_databaseNamePath_set; -*swig_explainDatabase_get = *IDZebrac::recordGroup_explainDatabase_get; -*swig_explainDatabase_set = *IDZebrac::recordGroup_explainDatabase_set; -*swig_followLinks_get = *IDZebrac::recordGroup_followLinks_get; -*swig_followLinks_set = *IDZebrac::recordGroup_followLinks_set; -sub new { - my $pkg = shift; - my @args = @_; - my $self = IDZebrac::new_recordGroup(@args); - return undef if (!defined($self)); - $OWNER{$self} = 1; - my %retval; - tie %retval, "IDZebra::recordGroup", $self; - return bless \%retval, $pkg; -} - -sub DESTROY { - return unless $_[0]->isa('HASH'); - my $self = tied(%{$_[0]}); - return unless defined $self; - delete $ITERATORS{$self}; - if (exists $OWNER{$self}) { - IDZebrac::delete_recordGroup($self); - delete $OWNER{$self}; - } -} - -sub DISOWN { - my $self = shift; - my $ptr = tied(%$self); - delete $OWNER{$ptr}; - }; - -sub ACQUIRE { - my $self = shift; - my $ptr = tied(%$self); - $OWNER{$ptr} = 1; - }; - -sub FETCH { - my ($self,$field) = @_; - my $member_func = "swig_${field}_get"; - my $val = $self->$member_func(); - if (exists $BLESSEDMEMBERS{$field}) { - return undef if (!defined($val)); - my %retval; - tie %retval,$BLESSEDMEMBERS{$field},$val; - return bless \%retval, $BLESSEDMEMBERS{$field}; - } - return $val; -} - -sub STORE { - my ($self,$field,$newval) = @_; - my $member_func = "swig_${field}_set"; - if (exists $BLESSEDMEMBERS{$field}) { - $self->$member_func(tied(%{$newval})); - } else { - $self->$member_func($newval); - } -} - - ############# Class : IDZebra::RetrievalObj ############## package IDZebra::RetrievalObj; diff --git a/perl/lib/IDZebra/Resultset.pm b/perl/lib/IDZebra/Resultset.pm index 28db014..253bba1 100644 --- a/perl/lib/IDZebra/Resultset.pm +++ b/perl/lib/IDZebra/Resultset.pm @@ -1,4 +1,4 @@ -# $Id: Resultset.pm,v 1.10 2003-07-26 16:27:46 pop Exp $ +# $Id: Resultset.pm,v 1.11 2004-07-28 08:15:46 adam Exp $ # # Zebra perl API header # ============================================================================= @@ -12,7 +12,7 @@ BEGIN { use IDZebra::Logger qw(:flags :calls); use Scalar::Util qw(weaken); use Carp; - our $VERSION = do { my @r = (q$Revision: 1.10 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our $VERSION = do { my @r = (q$Revision: 1.11 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our @ISA = qw(IDZebra::Logger); } @@ -131,6 +131,8 @@ sub records { my $class = $args{class} ? $args{class} : ''; + # ADAM: Reset before we use it (not after) + IDZebra::odr_reset($self->{odr_stream}); my $ro = IDZebra::RetrievalObj->new(); IDZebra::records_retrieve($self->{session}{zh}, @@ -155,8 +157,6 @@ sub records { } } - IDZebra::odr_reset($self->{odr_stream}); - return (@res); } diff --git a/perl/lib/IDZebra/Session.pm b/perl/lib/IDZebra/Session.pm index 30c4877..744ab6a 100644 --- a/perl/lib/IDZebra/Session.pm +++ b/perl/lib/IDZebra/Session.pm @@ -1,4 +1,4 @@ -# $Id: Session.pm,v 1.19 2003-07-26 16:27:46 pop Exp $ +# $Id: Session.pm,v 1.20 2004-07-28 08:15:46 adam Exp $ # # Zebra perl API header # ============================================================================= @@ -16,7 +16,7 @@ BEGIN { use IDZebra::ScanList; use IDZebra::RetrievalRecord; require Exporter; - our $VERSION = do { my @r = (q$Revision: 1.19 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our $VERSION = do { my @r = (q$Revision: 1.20 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our @ISA = qw(IDZebra::Logger Exporter); our @EXPORT = qw (TRANS_RW TRANS_RO); } @@ -91,10 +91,15 @@ sub open { # This is needed in order to somehow initialize the service $self->databases("Default"); - + + # ADAM: group call deleted # Load the default configuration - $self->group(%args); + # $self->group(%args); + # ADAM: Set group resource instead + if (defined($args{groupName})) { + IDZebra::set_resource($self->{zh}, "group", $args{groupName}); + } # Set shadow usage my $shadow = defined($args{shadow}) ? $args{shadow} : 0; @@ -162,7 +167,9 @@ sub DESTROY { # ----------------------------------------------------------------------------- # Record group selection This is a bit nasty... but used at many places # ----------------------------------------------------------------------------- -sub group { + +# ADAM: All these group functions have been disabled. +sub group_deleted { my ($self,%args) = @_; $self->checkzh; if ($#_ > 0) { @@ -172,14 +179,14 @@ sub group { return($self->{rg}); } -sub selectRecordGroup { +sub selectRecordGroup_deleted { my ($self, $groupName) = @_; $self->checkzh; $self->{rg} = $self->_getRecordGroup($groupName); $self->_selectRecordGroup($self->{rg}); } -sub _displayRecordGroup { +sub _displayRecordGroup_deleted { my ($self, $rg) = @_; print STDERR "-----\n"; foreach my $key qw (groupName @@ -197,7 +204,7 @@ sub _displayRecordGroup { } } -sub _cloneRecordGroup { +sub _cloneRecordGroup_deleted { my ($self, $orig) = @_; my $rg = IDZebra::recordGroup->new(); my $r = IDZebra::init_recordGroup($rg); @@ -218,7 +225,7 @@ sub _cloneRecordGroup { return ($rg); } -sub _getRecordGroup { +sub _getRecordGroup_deleted { my ($self, $groupName, $ext) = @_; my $rg = IDZebra::recordGroup->new(); my $r = IDZebra::init_recordGroup($rg); @@ -228,7 +235,7 @@ sub _getRecordGroup { return ($rg); } -sub _makeRecordGroup { +sub _makeRecordGroup_deleted { my ($self, %args) = @_; my $rg; @@ -246,7 +253,7 @@ sub _makeRecordGroup { return ($rg); } -sub _setRecordGroupOptions { +sub _setRecordGroupOptions_deleted { my ($self, $rg, %args) = @_; foreach my $key qw (databaseName @@ -265,7 +272,7 @@ sub _setRecordGroupOptions { } } } -sub _selectRecordGroup { +sub _selectRecordGroup_deleted { my ($self, $rg) = @_; my $r = IDZebra::set_group($self->{zh}, $rg); @@ -412,37 +419,54 @@ sub compact { sub update { my ($self, %args) = @_; $self->checkzh; - my $rg = $self->_update_args(%args); - $self->_selectRecordGroup($rg); + # ADAM: Set group resource + if (defined($args{groupName})) { + IDZebra::set_resource($self->{zh}, "group", $args{groupName}); + } + # ADAM: disabled +# my $rg = $self->_update_args(%args); deleted +# $self->_selectRecordGroup($rg); deleted $self->begin_trans; - IDZebra::repository_update($self->{zh}); - $self->_selectRecordGroup($self->{rg}); + IDZebra::repository_update($self->{zh}, $args{path}); +# $self->_selectRecordGroup($self->{rg}); deleted $self->end_trans; } sub delete { my ($self, %args) = @_; $self->checkzh; - my $rg = $self->_update_args(%args); - $self->_selectRecordGroup($rg); + # ADAM: Set group resource + if (defined($args{groupName})) { + IDZebra::set_resource($self->{zh}, "group", $args{groupName}); + } + # ADAM: disabled +# my $rg = $self->_update_args(%args); deleted +# $self->_selectRecordGroup($rg); deleted $self->begin_trans; - IDZebra::repository_delete($self->{zh}); - $self->_selectRecordGroup($self->{rg}); + IDZebra::repository_delete($self->{zh}, $args{path}); + # ADAM: disabled +# $self->_selectRecordGroup($self->{rg}); $self->end_trans; } sub show { my ($self, %args) = @_; $self->checkzh; - my $rg = $self->_update_args(%args); - $self->_selectRecordGroup($rg); + # ADAM: Set group resource + if (defined($args{groupName})) { + IDZebra::set_resource($self->{zh}, "group", $args{groupName}); + } + # ADAM: disabled +# my $rg = $self->_update_args(%args); +# $self->_selectRecordGroup($rg); + $self->begin_trans; IDZebra::repository_show($self->{zh}); $self->_selectRecordGroup($self->{rg}); $self->end_trans; } -sub _update_args { +sub _update_args_deleted { my ($self, %args) = @_; my $rg = $self->_makeRecordGroup(%args); $self->_selectRecordGroup($rg); @@ -457,9 +481,9 @@ sub insert_record { $self->checkzh; my @args = $self->_record_update_args(%args); my $stat = IDZebra::insert_record($self->{zh}, @args); - my $sysno = $args[2]; $stat = -1 * $stat if ($stat > 0); + # ADAM: rg no longer part of vector + my $sysno = $args[1]; $stat = -1 * $stat if ($stat > 0); return $stat ? $stat : $$sysno; - if ($stat) { return ($stat); } else { return $sysno}; } sub update_record { @@ -467,9 +491,9 @@ sub update_record { $self->checkzh; my @args = $self->_record_update_args(%args); my $stat = IDZebra::update_record($self->{zh}, @args); - my $sysno = $args[2]; $stat = -1 * $stat if ($stat > 0); + # ADAM: rg no longer part of vector + my $sysno = $args[1]; $stat = -1 * $stat if ($stat > 0); return $stat ? $stat : $$sysno; - if ($stat) { return ($stat); } else { return $$sysno}; } sub delete_record { @@ -477,8 +501,8 @@ sub delete_record { $self->checkzh; my @args = $self->_record_update_args(%args); my $stat = IDZebra::delete_record($self->{zh}, @args); - my $sysno = $args[2]; $stat = -1 * $stat if ($stat > 0); - return $stat ? $stat : $$sysno; + # ADAM: rg no longer part of vector + my $sysno = $args[1]; $stat = -1 * $stat if ($stat > 0); } sub _record_update_args { @@ -509,23 +533,30 @@ sub _record_update_args { delete ($args{data}); delete ($args{force}); - my $rg = $self->_makeRecordGroup(%args); +# ADAM: recordGroup removed ... +# my $rg = $self->_makeRecordGroup(%args); # If no record type is given, then try to find it out from the - # file extension; - unless ($rectype) { - if (my ($ext) = $fname =~ /\.(\w+)$/) { - my $rg2 = $self->_getRecordGroup($rg->{groupName},$ext); - $rectype = $rg2->{recordType}; - } - } + # file extension; deleted + #unless ($rectype) { +# if (my ($ext) = $fname =~ /\.(\w+)$/) { +# my $rg2 = $self->_getRecordGroup($rg->{groupName},$ext); +# $rectype = $rg2->{recordType}; +# } +# } - $rg->{databaseName} = "Default" unless ($rg->{databaseName}); +# $rg->{databaseName} = "Default" unless ($rg->{databaseName}); unless ($rectype) { $rectype=""; } - return ($rg, $rectype, \$sysno, $match, $fname, $buff, $len, $force); + # ADAM: set group resource + if (defined($args{groupName})) { + IDZebra::set_resource($self->{zh}, "group", $args{groupName}); + } + + # ADAM: rg no longer part of vector.. + return ($rectype, \$sysno, $match, $fname, $buff, $len, $force); } # ----------------------------------------------------------------------------- diff --git a/perl/t/01_base.t b/perl/t/01_base.t index 8ca7498..80cec33 100644 --- a/perl/t/01_base.t +++ b/perl/t/01_base.t @@ -1,6 +1,6 @@ #!perl -Tw # ============================================================================= -# $Id: 01_base.t,v 1.5 2003-03-05 14:15:07 pop Exp $ +# $Id: 01_base.t,v 1.6 2004-07-28 08:15:47 adam Exp $ # # Perl API header # ============================================================================= @@ -14,13 +14,14 @@ BEGIN { use strict; use warnings; -use Test::More tests=>10; +use Test::More tests=>8; # ---------------------------------------------------------------------------- # Session opening and closing BEGIN { use_ok('IDZebra'); - IDZebra::logFile("test.log"); + unlink("test01.log"); + IDZebra::logFile("test01.log"); use_ok('IDZebra::Session'); } @@ -49,12 +50,13 @@ isa_ok($sess,"IDZebra::Session"); ok(defined($sess->{zh}), "Zebra handle opened"); # ---------------------------------------------------------------------------- -# Record group tests -ok(($sess->group->{databaseName} eq "demo1"),"Record group is selected"); +# Record group tests deleted +# ADAM: we cant do this anymore! +#ok(($sess->group->{databaseName} eq "demo1"),"Record group is selected"); -$sess->group(groupName => 'demo2'); +#$sess->group(groupName => 'demo2'); -ok(($sess->group->{databaseName} eq "demo2"),"Record group is selected"); +#ok(($sess->group->{databaseName} eq "demo2"),"Record group is selected"); # --------------------------------------------------------------------------- # Transactions @@ -65,8 +67,6 @@ $sess->end_trans; $sess->end_trans; - - # ---------------------------------------------------------------------------- # Close session diff --git a/perl/t/02_directory_update.t b/perl/t/02_directory_update.t index 6ba4c3f..03fe3a4 100644 --- a/perl/t/02_directory_update.t +++ b/perl/t/02_directory_update.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 02_directory_update.t,v 1.3 2003-03-05 13:55:22 pop Exp $ +# $Id: 02_directory_update.t,v 1.4 2004-07-28 08:15:47 adam Exp $ # # Perl API header # ============================================================================= @@ -14,13 +14,14 @@ BEGIN { use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 8; # ---------------------------------------------------------------------------- # Session opening and closing BEGIN { use_ok('IDZebra'); - IDZebra::logFile("test.log"); + unlink("test02.log"); + IDZebra::logFile("test02.log"); use_ok('IDZebra::Session'); use_ok('pod'); } @@ -41,6 +42,9 @@ $sess->init(); # ---------------------------------------------------------------------------- # repository upadte +# ADAM: we must set database separately (can't be used from group) +$sess->databases('demo2'); + our $filecount = 8; $sess->begin_trans; $sess->update(path => 'lib'); @@ -49,6 +53,9 @@ my $stat = $sess->end_trans; ok(($stat->{inserted} == $filecount), "Inserted $stat->{inserted}/$filecount records"); +# ADAM: we must set database separately (can't be used from group) +$sess->databases('demo1'); + $sess->begin_trans; $sess->update(groupName => 'demo1', path => 'lib'); @@ -72,7 +79,7 @@ $stat = $sess->end_trans; ok(($stat->{inserted} == $filecount), "Inserted $stat->{inserted}/$filecount records with shadow"); -ok(($sess->group->{databaseName} eq "demo2"),"Original group is selected"); +# ok(($sess->group->{databaseName} eq "demo2"),"Original group is selected"); deleted # ---------------------------------------------------------------------------- # Close session diff --git a/perl/t/03_record_update.t b/perl/t/03_record_update.t index 762c78a..9742fc7 100644 --- a/perl/t/03_record_update.t +++ b/perl/t/03_record_update.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 03_record_update.t,v 1.6 2003-07-07 10:59:33 pop Exp $ +# $Id: 03_record_update.t,v 1.7 2004-07-28 08:15:47 adam Exp $ # # Perl API header # ============================================================================= @@ -20,7 +20,8 @@ use Test::More tests => 18; # Session opening and closing BEGIN { use_ok('IDZebra'); - IDZebra::logFile("test.log"); + unlink("test03.log"); + IDZebra::logFile("test03.log"); use_ok('IDZebra::Session'); use_ok('pod'); } @@ -41,6 +42,8 @@ my $rec3=`cat lib/IDZebra/Session.pm`; my ($sysno, $stat); +# ADAM: we must set database separately (can't be set from group) +$sess->databases('demo1'); $sess->begin_trans; $sysno = $sess->update_record(data => $rec1, recordType => 'grs.perl.pod', diff --git a/perl/t/04_cql.t b/perl/t/04_cql.t index 010c010..ff8e743 100644 --- a/perl/t/04_cql.t +++ b/perl/t/04_cql.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 04_cql.t,v 1.2 2004-05-25 14:11:26 adam Exp $ +# $Id: 04_cql.t,v 1.3 2004-07-28 08:15:47 adam Exp $ # # Perl API header # ============================================================================= @@ -20,7 +20,8 @@ use Test::More tests => 7; # Session opening and closing BEGIN { use IDZebra; - IDZebra::logFile("test.log"); + unlink("test04.log"); + IDZebra::logFile("test04.log"); use_ok('IDZebra::Session'); } diff --git a/perl/t/05_search.t b/perl/t/05_search.t index 0ba8ad2..9765983 100644 --- a/perl/t/05_search.t +++ b/perl/t/05_search.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 05_search.t,v 1.3 2003-07-26 16:27:46 pop Exp $ +# $Id: 05_search.t,v 1.4 2004-07-28 08:15:47 adam Exp $ # # Perl API header # ============================================================================= @@ -20,7 +20,8 @@ use Test::More tests => 12; # Session opening and closing BEGIN { use IDZebra; - IDZebra::logFile("test.log"); + unlink("test05.log"); + IDZebra::logFile("test05.log"); use_ok('IDZebra::Session'); use_ok('pod'); } diff --git a/perl/t/06_retrieval.t b/perl/t/06_retrieval.t index 9ddec71..fe6710c 100644 --- a/perl/t/06_retrieval.t +++ b/perl/t/06_retrieval.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 06_retrieval.t,v 1.4 2003-03-04 23:32:55 pop Exp $ +# $Id: 06_retrieval.t,v 1.5 2004-07-28 08:15:47 adam Exp $ # # Perl API header # ============================================================================= @@ -20,7 +20,8 @@ use Test::More tests => 19; # Session opening and closing BEGIN { use IDZebra; - IDZebra::logFile("test.log"); + unlink("test06.log"); + IDZebra::logFile("test06.log"); use_ok('IDZebra::Session'); use_ok('pod'); } diff --git a/perl/t/07_sort.t b/perl/t/07_sort.t index 11f985b..e457fd9 100644 --- a/perl/t/07_sort.t +++ b/perl/t/07_sort.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 07_sort.t,v 1.1 2003-03-03 18:27:25 pop Exp $ +# $Id: 07_sort.t,v 1.2 2004-07-28 08:15:47 adam Exp $ # # Perl API header # ============================================================================= @@ -20,7 +20,8 @@ use Test::More tests => 14; # Session opening and closing BEGIN { use IDZebra; - IDZebra::logFile("test.log"); + unlink("test07.log"); + IDZebra::logFile("test07.log"); # IDZebra::logLevel(15); use_ok('IDZebra::Session'); use_ok('pod'); diff --git a/perl/t/08_scan.t b/perl/t/08_scan.t index c7bfd8e..8c345e9 100644 Binary files a/perl/t/08_scan.t and b/perl/t/08_scan.t differ diff --git a/test/api/t1.c b/test/api/t1.c index 2b06fa9..8c5e48b 100644 --- a/test/api/t1.c +++ b/test/api/t1.c @@ -1,4 +1,4 @@ -/* $Id: t1.c,v 1.6 2004-06-14 23:43:32 adam Exp $ +/* $Id: t1.c,v 1.7 2004-07-28 08:15:47 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -30,7 +30,7 @@ static ZebraService start_service() char cfg[256]; char *srcdir = getenv("srcdir"); sprintf(cfg, "%.200s%szebra.cfg", srcdir ? srcdir : "", srcdir ? "/" : ""); - return zebra_start(cfg, 0, 0); + return zebra_start(cfg); } int main(int argc, char **argv) diff --git a/test/api/t2.c b/test/api/t2.c index beb66d6..7a93156 100644 --- a/test/api/t2.c +++ b/test/api/t2.c @@ -1,4 +1,4 @@ -/* $Id: t2.c,v 1.10 2004-06-14 23:43:32 adam Exp $ +/* $Id: t2.c,v 1.11 2004-07-28 08:15:47 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -30,7 +30,7 @@ static ZebraService start_service() char cfg[256]; char *srcdir = getenv("srcdir"); sprintf(cfg, "%.200s%szebra.cfg", srcdir ? srcdir : "", srcdir ? "/" : ""); - return zebra_start(cfg, 0, 0); + return zebra_start(cfg); } int main(int argc, char **argv) diff --git a/test/api/t3.c b/test/api/t3.c index 1239654..5a4a574 100644 --- a/test/api/t3.c +++ b/test/api/t3.c @@ -1,4 +1,4 @@ -/* $Id: t3.c,v 1.7 2004-06-14 23:43:32 adam Exp $ +/* $Id: t3.c,v 1.8 2004-07-28 08:15:47 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -30,7 +30,7 @@ static ZebraService start_service() char cfg[256]; char *srcdir = getenv("srcdir"); sprintf(cfg, "%.200s%szebra.cfg", srcdir ? srcdir : "", srcdir ? "/" : ""); - return zebra_start(cfg, 0, 0); + return zebra_start(cfg); } int main(int argc, char **argv) diff --git a/test/api/t4.c b/test/api/t4.c index 4d3da92..9fb81b7 100644 --- a/test/api/t4.c +++ b/test/api/t4.c @@ -1,4 +1,4 @@ -/* $Id: t4.c,v 1.7 2004-06-14 23:43:32 adam Exp $ +/* $Id: t4.c,v 1.8 2004-07-28 08:15:47 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -30,7 +30,7 @@ static ZebraService start_service() char cfg[256]; char *srcdir = getenv("srcdir"); sprintf(cfg, "%.200s%szebra.cfg", srcdir ? srcdir : "", srcdir ? "/" : ""); - return zebra_start(cfg, 0, 0); + return zebra_start(cfg); } int main(int argc, char **argv) diff --git a/test/api/t5.c b/test/api/t5.c index dc19264..cd9e0e6 100644 --- a/test/api/t5.c +++ b/test/api/t5.c @@ -1,4 +1,4 @@ -/* $Id: t5.c,v 1.3 2004-06-16 22:06:49 adam Exp $ +/* $Id: t5.c,v 1.4 2004-07-28 08:15:47 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -30,7 +30,7 @@ static ZebraService start_service() char cfg[256]; char *srcdir = getenv("srcdir"); sprintf(cfg, "%.200s%szebra.cfg", srcdir ? srcdir : "", srcdir ? "/" : ""); - return zebra_start(cfg, 0, 0); + return zebra_start(cfg); } static void expect(ZebraHandle zh, const char *pqf, int hits_expect,