From 619b7a25eae7bffe31395d103d8eb4c5d0a84581 Mon Sep 17 00:00:00 2001 From: pop Date: Tue, 4 Mar 2003 19:33:52 +0000 Subject: [PATCH] Scan feature added, not documented yet --- perl/IDZebra.i | 2 +- perl/IDZebra_wrap.c | 100 +++++++++++++------------- perl/MANIFEST | 20 ++++-- perl/demo/pod.abs | 4 +- perl/lib/IDZebra.pm | 20 +++--- perl/lib/IDZebra/ScanEntry.pm | 79 ++++++++++++++++++++ perl/lib/IDZebra/ScanList.pm | 160 +++++++++++++++++++++++++++++++++++++++++ perl/lib/IDZebra/Session.pm | 21 +++++- perl/t/01_base.t | 5 +- perl/t/02_directory_update.t | 4 +- perl/t/05_search.t | 4 +- perl/t/06_retrieval.t | 4 +- perl/t/08_scan.t | Bin 0 -> 3058 bytes perl/zebra_api_ext.c | 4 +- perl/zebra_perl.h | 4 +- 15 files changed, 349 insertions(+), 82 deletions(-) create mode 100644 perl/lib/IDZebra/ScanEntry.pm create mode 100644 perl/lib/IDZebra/ScanList.pm create mode 100644 perl/t/08_scan.t diff --git a/perl/IDZebra.i b/perl/IDZebra.i index 0d020ed..2031e8b 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -327,7 +327,7 @@ void zebra_scan_PQF (ZebraHandle zh, ODR stream, const char *pqf_query); -ScanEntry *getScanEntry(ScanObj *so, int pos); +scanEntry *getScanEntry(ScanObj *so, int pos); /* Admin functionality */ /* diff --git a/perl/IDZebra_wrap.c b/perl/IDZebra_wrap.c index 60b9800..a5afdc0 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.9 2003-03-03 12:14:27 pop Exp $ + * $Header: /home/cvsroot/idis/perl/Attic/IDZebra_wrap.c,v 1.10 2003-03-04 19:33:52 pop Exp $ * ----------------------------------------------------------------------------- */ #define SWIGPERL @@ -530,7 +530,7 @@ static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (C #define SWIGTYPE_p_data1_marctab swig_types[29] #define SWIGTYPE_p_ZebraTransactionStatus swig_types[30] #define SWIGTYPE_p_Z_BriefBib swig_types[31] -#define SWIGTYPE_p_ScanEntry swig_types[32] +#define SWIGTYPE_p_scanEntry swig_types[32] #define SWIGTYPE_p_f_p_void_p_char_size_t__int swig_types[33] #define SWIGTYPE_p_FILE swig_types[34] #define SWIGTYPE_p_data1_element swig_types[35] @@ -2099,21 +2099,21 @@ XS(_wrap_delete_RetrievalRecord) { } -XS(_wrap_ScanEntry_occurrences_set) { +XS(_wrap_scanEntry_occurrences_set) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; { - ScanEntry *arg1 ; + scanEntry *arg1 ; int arg2 ; int argvi = 0; dXSARGS; if ((items < 2) || (items > 2)) { - SWIG_croak("Usage: ScanEntry_occurrences_set(self,occurrences);"); + SWIG_croak("Usage: scanEntry_occurrences_set(self,occurrences);"); } { - if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_ScanEntry,0) < 0) { - SWIG_croak("Type error in argument 1 of ScanEntry_occurrences_set. Expected _p_ScanEntry"); + if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_scanEntry,0) < 0) { + SWIG_croak("Type error in argument 1 of scanEntry_occurrences_set. Expected _p_scanEntry"); } } arg2 = (int) SvIV(ST(1)); @@ -2128,21 +2128,21 @@ XS(_wrap_ScanEntry_occurrences_set) { } -XS(_wrap_ScanEntry_occurrences_get) { +XS(_wrap_scanEntry_occurrences_get) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; { - ScanEntry *arg1 ; + scanEntry *arg1 ; int result; int argvi = 0; dXSARGS; if ((items < 1) || (items > 1)) { - SWIG_croak("Usage: ScanEntry_occurrences_get(self);"); + SWIG_croak("Usage: scanEntry_occurrences_get(self);"); } { - if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_ScanEntry,0) < 0) { - SWIG_croak("Type error in argument 1 of ScanEntry_occurrences_get. Expected _p_ScanEntry"); + if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_scanEntry,0) < 0) { + SWIG_croak("Type error in argument 1 of scanEntry_occurrences_get. Expected _p_scanEntry"); } } result = (int) ((arg1)->occurrences); @@ -2157,21 +2157,21 @@ XS(_wrap_ScanEntry_occurrences_get) { } -XS(_wrap_ScanEntry_term_set) { +XS(_wrap_scanEntry_term_set) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; { - ScanEntry *arg1 ; + scanEntry *arg1 ; char *arg2 ; int argvi = 0; dXSARGS; if ((items < 2) || (items > 2)) { - SWIG_croak("Usage: ScanEntry_term_set(self,term);"); + SWIG_croak("Usage: scanEntry_term_set(self,term);"); } { - if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_ScanEntry,0) < 0) { - SWIG_croak("Type error in argument 1 of ScanEntry_term_set. Expected _p_ScanEntry"); + if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_scanEntry,0) < 0) { + SWIG_croak("Type error in argument 1 of scanEntry_term_set. Expected _p_scanEntry"); } } if (!SvOK((SV*) ST(1))) arg2 = 0; @@ -2190,21 +2190,21 @@ XS(_wrap_ScanEntry_term_set) { } -XS(_wrap_ScanEntry_term_get) { +XS(_wrap_scanEntry_term_get) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; { - ScanEntry *arg1 ; + scanEntry *arg1 ; char *result; int argvi = 0; dXSARGS; if ((items < 1) || (items > 1)) { - SWIG_croak("Usage: ScanEntry_term_get(self);"); + SWIG_croak("Usage: scanEntry_term_get(self);"); } { - if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_ScanEntry,0) < 0) { - SWIG_croak("Type error in argument 1 of ScanEntry_term_get. Expected _p_ScanEntry"); + if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_scanEntry,0) < 0) { + SWIG_croak("Type error in argument 1 of scanEntry_term_get. Expected _p_scanEntry"); } } result = (char *) ((arg1)->term); @@ -2223,21 +2223,21 @@ XS(_wrap_ScanEntry_term_get) { } -XS(_wrap_new_ScanEntry) { +XS(_wrap_new_scanEntry) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; { - ScanEntry *result; + scanEntry *result; int argvi = 0; dXSARGS; if ((items < 0) || (items > 0)) { - SWIG_croak("Usage: new_ScanEntry();"); + SWIG_croak("Usage: new_scanEntry();"); } - result = (ScanEntry *)(ScanEntry *) calloc(1, sizeof(ScanEntry)); + result = (scanEntry *)(scanEntry *) calloc(1, sizeof(scanEntry)); ST(argvi) = sv_newmortal(); - SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_ScanEntry,0); + SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_scanEntry,0); XSRETURN(argvi); fail: (void) _swigerr; @@ -2246,20 +2246,20 @@ XS(_wrap_new_ScanEntry) { } -XS(_wrap_delete_ScanEntry) { +XS(_wrap_delete_scanEntry) { char _swigmsg[SWIG_MAX_ERRMSG] = ""; const char *_swigerr = _swigmsg; { - ScanEntry *arg1 ; + scanEntry *arg1 ; int argvi = 0; dXSARGS; if ((items < 1) || (items > 1)) { - SWIG_croak("Usage: delete_ScanEntry(self);"); + SWIG_croak("Usage: delete_scanEntry(self);"); } { - if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_ScanEntry,0) < 0) { - SWIG_croak("Type error in argument 1 of delete_ScanEntry. Expected _p_ScanEntry"); + if (SWIG_ConvertPtr(ST(0), (void **) &arg1, SWIGTYPE_p_scanEntry,0) < 0) { + SWIG_croak("Type error in argument 1 of delete_scanEntry. Expected _p_scanEntry"); } } free((char *) arg1); @@ -2452,7 +2452,7 @@ XS(_wrap_ScanObj_entries_set) { const char *_swigerr = _swigmsg; { ScanObj *arg1 ; - ScanEntry *arg2 ; + scanEntry *arg2 ; int argvi = 0; dXSARGS; @@ -2465,8 +2465,8 @@ XS(_wrap_ScanObj_entries_set) { } } { - if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_ScanEntry,0) < 0) { - SWIG_croak("Type error in argument 2 of ScanObj_entries_set. Expected _p_ScanEntry"); + if (SWIG_ConvertPtr(ST(1), (void **) &arg2, SWIGTYPE_p_scanEntry,0) < 0) { + SWIG_croak("Type error in argument 2 of ScanObj_entries_set. Expected _p_scanEntry"); } } if (arg1) (arg1)->entries = arg2; @@ -2485,7 +2485,7 @@ XS(_wrap_ScanObj_entries_get) { const char *_swigerr = _swigmsg; { ScanObj *arg1 ; - ScanEntry *result; + scanEntry *result; int argvi = 0; dXSARGS; @@ -2497,10 +2497,10 @@ XS(_wrap_ScanObj_entries_get) { SWIG_croak("Type error in argument 1 of ScanObj_entries_get. Expected _p_ScanObj"); } } - result = (ScanEntry *) ((arg1)->entries); + result = (scanEntry *) ((arg1)->entries); ST(argvi) = sv_newmortal(); - SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_ScanEntry,0); + SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_scanEntry,0); XSRETURN(argvi); fail: (void) _swigerr; @@ -4668,7 +4668,7 @@ XS(_wrap_getScanEntry) { { ScanObj *arg1 ; int arg2 ; - ScanEntry *result; + scanEntry *result; int argvi = 0; dXSARGS; @@ -4681,10 +4681,10 @@ XS(_wrap_getScanEntry) { } } arg2 = (int) SvIV(ST(1)); - result = (ScanEntry *)getScanEntry(arg1,arg2); + result = (scanEntry *)getScanEntry(arg1,arg2); ST(argvi) = sv_newmortal(); - SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_ScanEntry,0); + SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE_p_scanEntry,0); XSRETURN(argvi); fail: (void) _swigerr; @@ -8320,7 +8320,7 @@ static swig_type_info _swigt__p_Z_ExplainRecord[] = {{"_p_Z_ExplainRecord", 0, " static swig_type_info _swigt__p_data1_marctab[] = {{"_p_data1_marctab", 0, "data1_marctab *", 0},{"_p_data1_marctab"},{0}}; static swig_type_info _swigt__p_ZebraTransactionStatus[] = {{"IDZebra::ZebraTransactionStatus", 0, "ZebraTransactionStatus *", 0},{"IDZebra::ZebraTransactionStatus"},{0}}; static swig_type_info _swigt__p_Z_BriefBib[] = {{"_p_Z_BriefBib", 0, "Z_BriefBib *", 0},{"_p_Z_BriefBib"},{0}}; -static swig_type_info _swigt__p_ScanEntry[] = {{"IDZebra::ScanEntry", 0, "ScanEntry *", 0},{"IDZebra::ScanEntry"},{0}}; +static swig_type_info _swigt__p_scanEntry[] = {{"IDZebra::scanEntry", 0, "scanEntry *", 0},{"IDZebra::scanEntry"},{0}}; static swig_type_info _swigt__p_f_p_void_p_char_size_t__int[] = {{"_p_f_p_void_p_char_size_t__int", 0, "int (*)(void *,char *,size_t)", 0},{"_p_f_p_void_p_char_size_t__int"},{0}}; static swig_type_info _swigt__p_FILE[] = {{"_p_FILE", 0, "FILE *", 0},{"_p_FILE"},{0}}; static swig_type_info _swigt__p_data1_element[] = {{"_p_data1_element", 0, "data1_element *", 0},{"_p_data1_element"},{0}}; @@ -8366,7 +8366,7 @@ _swigt__p_Z_ExplainRecord, _swigt__p_data1_marctab, _swigt__p_ZebraTransactionStatus, _swigt__p_Z_BriefBib, -_swigt__p_ScanEntry, +_swigt__p_scanEntry, _swigt__p_f_p_void_p_char_size_t__int, _swigt__p_FILE, _swigt__p_data1_element, @@ -8483,12 +8483,12 @@ static swig_command_info swig_commands[] = { {"IDZebrac::RetrievalRecord_buf_get", _wrap_RetrievalRecord_buf_get}, {"IDZebrac::new_RetrievalRecord", _wrap_new_RetrievalRecord}, {"IDZebrac::delete_RetrievalRecord", _wrap_delete_RetrievalRecord}, -{"IDZebrac::ScanEntry_occurrences_set", _wrap_ScanEntry_occurrences_set}, -{"IDZebrac::ScanEntry_occurrences_get", _wrap_ScanEntry_occurrences_get}, -{"IDZebrac::ScanEntry_term_set", _wrap_ScanEntry_term_set}, -{"IDZebrac::ScanEntry_term_get", _wrap_ScanEntry_term_get}, -{"IDZebrac::new_ScanEntry", _wrap_new_ScanEntry}, -{"IDZebrac::delete_ScanEntry", _wrap_delete_ScanEntry}, +{"IDZebrac::scanEntry_occurrences_set", _wrap_scanEntry_occurrences_set}, +{"IDZebrac::scanEntry_occurrences_get", _wrap_scanEntry_occurrences_get}, +{"IDZebrac::scanEntry_term_set", _wrap_scanEntry_term_set}, +{"IDZebrac::scanEntry_term_get", _wrap_scanEntry_term_get}, +{"IDZebrac::new_scanEntry", _wrap_new_scanEntry}, +{"IDZebrac::delete_scanEntry", _wrap_delete_scanEntry}, {"IDZebrac::ScanObj_num_entries_set", _wrap_ScanObj_num_entries_set}, {"IDZebrac::ScanObj_num_entries_get", _wrap_ScanObj_num_entries_get}, {"IDZebrac::ScanObj_position_set", _wrap_ScanObj_position_set}, @@ -8709,7 +8709,7 @@ XS(SWIG_init) { SWIG_TypeClientData(SWIGTYPE_p_recordGroup, (void*) "IDZebra::recordGroup"); SWIG_TypeClientData(SWIGTYPE_p_RetrievalObj, (void*) "IDZebra::RetrievalObj"); SWIG_TypeClientData(SWIGTYPE_p_RetrievalRecord, (void*) "IDZebra::RetrievalRecord"); - SWIG_TypeClientData(SWIGTYPE_p_ScanEntry, (void*) "IDZebra::ScanEntry"); + SWIG_TypeClientData(SWIGTYPE_p_scanEntry, (void*) "IDZebra::scanEntry"); SWIG_TypeClientData(SWIGTYPE_p_ScanObj, (void*) "IDZebra::ScanObj"); SWIG_TypeClientData(SWIGTYPE_p_ZebraTransactionStatus, (void*) "IDZebra::ZebraTransactionStatus"); ST(0) = &PL_sv_yes; diff --git a/perl/MANIFEST b/perl/MANIFEST index 34e1616..f293370 100644 --- a/perl/MANIFEST +++ b/perl/MANIFEST @@ -1,22 +1,32 @@ +.cvsignore IDZebra_wrap.c +MANIFEST +Makefile.PL Makefile.PL.in README +demo/cql.map demo/filter_test.pl demo/index.sh demo/pod.abs demo/pod.pm demo/zebra.cfg -doclean -doswig lib/IDZebra.pm lib/IDZebra/Data1.pm lib/IDZebra/Filter.pm lib/IDZebra/Logger.pm -lib/IDZebra/Repository.pm lib/IDZebra/Resultset.pm -lib/IDZebra/Service.pm +lib/IDZebra/RetrievalRecord.pm +lib/IDZebra/ScanEntry.pm +lib/IDZebra/ScanList.pm lib/IDZebra/Session.pm -test.pl +t/01_base.t +t/02_directory_update.t +t/03_record_update.t +t/04_cql.t +t/05_search.t +t/06_retrieval.t +t/07_sort.t +t/08_scan.t zebra_api_ext.c zebra_api_ext.h zebra_perl.c diff --git a/perl/demo/pod.abs b/perl/demo/pod.abs index 4097b44..c2bf9ac 100644 --- a/perl/demo/pod.abs +++ b/perl/demo/pod.abs @@ -13,5 +13,5 @@ maptab meta-usmarc.map # These tags are required by Zebra for GRS-1 generation elm (1,10) rank - elm (1,14) localControlNumber Local-number -elm name NAME Title:p,Any,Title:s -elm description description Any +elm name NAME Title:p,Title:w,Any,Title:s +elm description description Any diff --git a/perl/lib/IDZebra.pm b/perl/lib/IDZebra.pm index 0853842..e41d642 100644 --- a/perl/lib/IDZebra.pm +++ b/perl/lib/IDZebra.pm @@ -418,27 +418,27 @@ sub STORE { } -############# Class : IDZebra::ScanEntry ############## +############# Class : IDZebra::scanEntry ############## -package IDZebra::ScanEntry; +package IDZebra::scanEntry; @ISA = qw( IDZebra ); %OWNER = (); %BLESSEDMEMBERS = ( ); %ITERATORS = (); -*swig_occurrences_get = *IDZebrac::ScanEntry_occurrences_get; -*swig_occurrences_set = *IDZebrac::ScanEntry_occurrences_set; -*swig_term_get = *IDZebrac::ScanEntry_term_get; -*swig_term_set = *IDZebrac::ScanEntry_term_set; +*swig_occurrences_get = *IDZebrac::scanEntry_occurrences_get; +*swig_occurrences_set = *IDZebrac::scanEntry_occurrences_set; +*swig_term_get = *IDZebrac::scanEntry_term_get; +*swig_term_set = *IDZebrac::scanEntry_term_set; sub new { my $pkg = shift; my @args = @_; - my $self = IDZebrac::new_ScanEntry(@args); + my $self = IDZebrac::new_scanEntry(@args); return undef if (!defined($self)); $OWNER{$self} = 1; my %retval; - tie %retval, "IDZebra::ScanEntry", $self; + tie %retval, "IDZebra::scanEntry", $self; return bless \%retval, $pkg; } @@ -448,7 +448,7 @@ sub DESTROY { return unless defined $self; delete $ITERATORS{$self}; if (exists $OWNER{$self}) { - IDZebrac::delete_ScanEntry($self); + IDZebrac::delete_scanEntry($self); delete $OWNER{$self}; } } @@ -495,7 +495,7 @@ package IDZebra::ScanObj; @ISA = qw( IDZebra ); %OWNER = (); %BLESSEDMEMBERS = ( - entries => 'IDZebra::ScanEntry', + entries => 'IDZebra::scanEntry', ); %ITERATORS = (); diff --git a/perl/lib/IDZebra/ScanEntry.pm b/perl/lib/IDZebra/ScanEntry.pm new file mode 100644 index 0000000..1ee9779 --- /dev/null +++ b/perl/lib/IDZebra/ScanEntry.pm @@ -0,0 +1,79 @@ +# $Id: ScanEntry.pm,v 1.1 2003-03-04 19:33:52 pop Exp $ +# +# Zebra perl API header +# ============================================================================= +package IDZebra::ScanEntry; + +use strict; +use warnings; + +BEGIN { + use IDZebra; + use IDZebra::Logger qw(:flags :calls); + use Scalar::Util qw(weaken); + use Carp; + our $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +} + +1; + +# ----------------------------------------------------------------------------- +# Class constructors, destructor +# ----------------------------------------------------------------------------- + + +sub new { + my ($proto,%args) = @_; + my $class = ref($proto) || $proto; + my $self = \%args; + bless ($self, $class); + weaken ($self->{list}); + return ($self); +} + +# ============================================================================= +sub DESTROY { + my $self = shift; +} + +# ----------------------------------------------------------------------------- +sub term { + my $self = shift; + return ($self->{entry}{term}); +} + +sub occurrences { + my $self = shift; + return ($self->{entry}{occurrences}); +} + +sub position { + my $self = shift; + return ($self->{position}); +} +# ----------------------------------------------------------------------------- +__END__ + +=head1 NAME + +IDZebra::ScanEntry - An entry of the scan results + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 PROPERTIES + +=head1 COPYRIGHT + +Fill in + +=head1 AUTHOR + +Peter Popovics, pop@technomat.hu + +=head1 SEE ALSO + +IDZebra, IDZebra::ScanList, Zebra documentation + +=cut diff --git a/perl/lib/IDZebra/ScanList.pm b/perl/lib/IDZebra/ScanList.pm new file mode 100644 index 0000000..155b1ba --- /dev/null +++ b/perl/lib/IDZebra/ScanList.pm @@ -0,0 +1,160 @@ +# $Id: ScanList.pm,v 1.1 2003-03-04 19:33:52 pop Exp $ +# +# Zebra perl API header +# ============================================================================= +package IDZebra::ScanList; + +use strict; +use warnings; + +BEGIN { + use IDZebra; + use IDZebra::Logger qw(:flags :calls); + use IDZebra::ScanEntry; + use Scalar::Util qw(weaken); + use Carp; + our $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our @ISA = qw(IDZebra::Logger); +} + +1; +# ----------------------------------------------------------------------------- +# Class constructors, destructor +# ----------------------------------------------------------------------------- +sub new { + my ($proto,$session, %args) = @_; + my $class = ref($proto) || $proto; + my $self = {}; + bless ($self, $class); + + $self->{session} = $session; + weaken ($self->{session}); + + $self->{expression} = $args{expression}; + $self->{databases} = $args{databases}; + + $self->{so} = IDZebra::ScanObj->new(); + + $self->{odr_stream} = IDZebra::odr_createmem($IDZebra::ODR_DECODE); + + $self->entries(num_entries => 0); + + return ($self); +} + +sub DESTROY { + my $self = shift; + + if ($self->{odr_stream}) { + IDZebra::odr_reset($self->{odr_stream}); + IDZebra::odr_destroy($self->{odr_stream}); + $self->{odr_stream} = undef; + } + + delete($self->{so}); + delete($self->{session}); +} + +# ============================================================================= +sub is_partial { + my ($self) = @_; + return ($self->{so}{is_partial}); +} + +sub position { + my ($self) = @_; + return ($self->{so}{position}); +} + +sub num_entries { + my ($self) = @_; + return ($self->{so}{num_entries}); +} + +sub errCode { + my ($self) = @_; + return ($self->{session}->errCode); +} + +sub errString { + my ($self) = @_; + return ($self->{session}->errString); +} + +# ----------------------------------------------------------------------------- +sub entries { + my ($self, %args) = @_; + + unless ($self->{session}{zh}) { + croak ("Session is closed or out of scope"); + } + + my $so=$self->{so}; + + $so->{position} = defined($args{position}) ? $args{position} : 1; + $so->{num_entries} = defined($args{num_entries}) ? $args{num_entries} : 20; + + my @origdbs; + if ($self->{databases}) { + @origdbs = $self->{session}->databases; + $self->{session}->databases(@{$self->{databases}}); + } + + $so->{is_partial} = 0; + + my $r = IDZebra::scan_PQF($self->{session}{zh}, $so, + $self->{odr_stream}, + $self->{expression}); + + if ($self->{session}->errCode) { + croak ("Error in scan, code: ".$self->{session}->errCode . + ", message: ".$self->{session}->errString); + } + + my @res; + for (my $i=1; $i<=$so->{num_entries}; $i++) { + + push (@res, + IDZebra::ScanEntry->new(entry => IDZebra::getScanEntry($so, $i), + position => $i, + list => $self)); + } + + if ($self->{databases}) { + $self->{session}->databases(@origdbs); + } + + IDZebra::odr_reset($self->{odr_stream}); + + $self->{so} = $so; + + return (@res); +} + + +# ============================================================================ +__END__ + +=head1 NAME + +IDZebra::ScanList - Scan results + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 PROPERTIES + +=head1 COPYRIGHT + +Fill in + +=head1 AUTHOR + +Peter Popovics, pop@technomat.hu + +=head1 SEE ALSO + +IDZebra, IDZebra::Session, Zebra documentation + +=cut diff --git a/perl/lib/IDZebra/Session.pm b/perl/lib/IDZebra/Session.pm index a72e229..394e8cb 100644 --- a/perl/lib/IDZebra/Session.pm +++ b/perl/lib/IDZebra/Session.pm @@ -1,4 +1,4 @@ -# $Id: Session.pm,v 1.10 2003-03-03 18:27:25 pop Exp $ +# $Id: Session.pm,v 1.11 2003-03-04 19:33:52 pop Exp $ # # Zebra perl API header # ============================================================================= @@ -13,8 +13,9 @@ BEGIN { use Scalar::Util; use IDZebra::Logger qw(:flags :calls); use IDZebra::Resultset; + use IDZebra::ScanList; use IDZebra::RetrievalRecord; - 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); } @@ -656,6 +657,22 @@ sub sortResultsets { return ($rs); } +# ----------------------------------------------------------------------------- +# Scan +# ----------------------------------------------------------------------------- +sub scan { + my ($self, %args) = @_; + + $self->checkzh; + + unless ($args{expression}) { + croak ("No scan expression given"); + } + + my $sl = IDZebra::ScanList->new($self,%args); + + return ($sl); +} # ============================================================================ diff --git a/perl/t/01_base.t b/perl/t/01_base.t index 535d880..85b2191 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.1 2003-03-03 00:44:39 pop Exp $ +# $Id: 01_base.t,v 1.2 2003-03-04 19:33:53 pop Exp $ # # Perl API header # ============================================================================= @@ -14,7 +14,7 @@ BEGIN { use strict; use warnings; -use Test::More tests => 9; +use Test::More tests=>9; # ---------------------------------------------------------------------------- # Session opening and closing @@ -54,3 +54,4 @@ ok(($sess->group->{databaseName} eq "demo2"),"Record group is selected"); # Close session $sess->close; + diff --git a/perl/t/02_directory_update.t b/perl/t/02_directory_update.t index e641dc8..861b71d 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.1 2003-03-03 00:44:39 pop Exp $ +# $Id: 02_directory_update.t,v 1.2 2003-03-04 19:33:53 pop Exp $ # # Perl API header # ============================================================================= @@ -42,7 +42,7 @@ $sess->init(); # ---------------------------------------------------------------------------- # repository upadte -our $filecount = 6; +our $filecount = 8; $sess->begin_trans; $sess->update(path => 'lib'); my $stat = $sess->end_trans; diff --git a/perl/t/05_search.t b/perl/t/05_search.t index e6eefa4..404c23f 100644 --- a/perl/t/05_search.t +++ b/perl/t/05_search.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 05_search.t,v 1.1 2003-03-03 00:44:39 pop Exp $ +# $Id: 05_search.t,v 1.2 2003-03-04 19:33:53 pop Exp $ # # Perl API header # ============================================================================= @@ -34,7 +34,7 @@ isa_ok($sess,"IDZebra::Session"); # ---------------------------------------------------------------------------- # search -our $filecount = 6; +our $filecount = 8; my ($hits, $expected); diff --git a/perl/t/06_retrieval.t b/perl/t/06_retrieval.t index 3c84573..152c8c3 100644 --- a/perl/t/06_retrieval.t +++ b/perl/t/06_retrieval.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 06_retrieval.t,v 1.2 2003-03-03 12:14:28 pop Exp $ +# $Id: 06_retrieval.t,v 1.3 2003-03-04 19:33:53 pop Exp $ # # Perl API header # ============================================================================= @@ -32,7 +32,7 @@ my $sess = IDZebra::Session->open(configFile => 'demo/zebra.cfg', groupName => 'demo2'); # ---------------------------------------------------------------------------- # search -our $filecount = 6; +our $filecount = 8; my ($hits, $expected); diff --git a/perl/t/08_scan.t b/perl/t/08_scan.t new file mode 100644 index 0000000000000000000000000000000000000000..c7bfd8ebbef5a90a464ecbaa6cc9023e48b73899 GIT binary patch literal 3058 zcmcgue{b715Z%Agr?|>SEible*-6*hu;DFp2LoLew8IAM2Mk%FVxqLDkyO$x@OR%G zMalMnWWeBzNDN9m9^bupcU0>|!Ibb?Fg@i!f9+*DhQXVaPU1W?y*r4)2!?~fs84?v z5WO9bM&rv76taND=K|VZ3%A`M8uJ0?*<@Hssld`Ss^g3(7*RSxup2jNK zbh;C7=Xs@OppD{*nb`S#ta6^;>PfZqBhzL){$45u2B#XPGl;&z#TN8WIMCfkrZty2 z$bu07i1QQ@AvMmuLvjf4^4nk7TE$h=?qNI@^7b7UEbs|wh)+I-*n-;H8oXzBOa##- zt`L>zY$ZPhoyLblf#krEK_OE|*#8^(_D^VQWCo`DFdWAIjHn6{nP=PvPTE+-U;Rbw zgh_VW>3L^30B)5mi|csH8l#Bf@mkho5#i|h^80drmv?% zh<&1fw1&M$BH`CR?gJ{12&Odu}$^b2T^E1;Q|N@r@pj zk5t^N9u1<`s5YsH=`v?IHZ{yBN*OWg&)joRpFsJ5`!8*Q&_iBsSIs7DaswRBS-Z~v zcB{5HhiKx-PY_U^kb9-BWQx@_g+aIHQ+|RjlLYfKD}^9f2i8YtAwugPw`I&E82lo~D91+*9IiE2CE@Xvy)z;?0teOy{I z1(e*bWpHiPMSKU_9K;HP18IB9vDH&GOpuy5ktOS8I&fba6#PM1lQF%bqIYCgBt2E{ zXGDGl?wr73spE@MDVAd=3NVJV=8PxX!CBP{2t@T!X>n8V`xB6StF?b{#Mr*F2q@uc Mf5q6pHj|zAH_}QuL;wH) literal 0 HcmV?d00001 diff --git a/perl/zebra_api_ext.c b/perl/zebra_api_ext.c index 49663f4..32f9f27 100644 --- a/perl/zebra_api_ext.c +++ b/perl/zebra_api_ext.c @@ -275,7 +275,7 @@ void zebra_scan_PQF (ZebraHandle zh, return; } - so->entries = (ScanEntry *) + so->entries = (scanEntry *) odr_malloc (stream, sizeof(so->entries) * (so->num_entries)); @@ -288,7 +288,7 @@ void zebra_scan_PQF (ZebraHandle zh, so->position, so->num_entries, so->is_partial); } -ScanEntry *getScanEntry(ScanObj *so, int pos) { +scanEntry *getScanEntry(ScanObj *so, int pos) { return (&so->entries[pos-1]); } diff --git a/perl/zebra_perl.h b/perl/zebra_perl.h index b7826df..3a3135c 100644 --- a/perl/zebra_perl.h +++ b/perl/zebra_perl.h @@ -39,13 +39,13 @@ typedef struct { typedef struct { int occurrences; /* scan term occurrences */ char *term; /* scan term string */ -} ScanEntry; +} scanEntry; typedef struct { int num_entries; int position; int is_partial; - ScanEntry *entries; + scanEntry *entries; } ScanObj; #endif -- 1.7.10.4