X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=perl%2Flib%2FIDZebra%2FResultset.pm;h=7408d353280e791cbfe3350d6a81a934dc9a48dc;hb=52551bf774d771a0422a401946fd0c5ee3788f34;hp=82a8771e139af0ee1ed85c627f39afabf4aa2143;hpb=62aeae27f2897b54a14c6fe60da004f2f23bd2e8;p=idzebra-moved-to-github.git diff --git a/perl/lib/IDZebra/Resultset.pm b/perl/lib/IDZebra/Resultset.pm index 82a8771..7408d35 100644 --- a/perl/lib/IDZebra/Resultset.pm +++ b/perl/lib/IDZebra/Resultset.pm @@ -1,4 +1,4 @@ -# $Id: Resultset.pm,v 1.6 2003-03-03 12:14:27 pop Exp $ +# $Id: Resultset.pm,v 1.9 2003-03-06 23:32:10 pop 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.6 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our $VERSION = do { my @r = (q$Revision: 1.9 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; our @ISA = qw(IDZebra::Logger); } @@ -62,6 +62,7 @@ sub errString { sub DESTROY { my $self = shift; +# print STDERR "Destroy RS\n"; # Deleteresultset? my $stats = 0; @@ -90,6 +91,14 @@ sub records { my $from = $args{from} ? $args{from} : 1; my $to = $args{to} ? $args{to} : $self->{recordCount}; + if (($to-$from) >= 1000) { + if ($args{to}) { + croak ("Cannot fetch more than 1000 records at a time"); + } else { + $to = $from + 999; + } + } + my $elementSet = $args{elementSet} ? $args{elementSet} : 'R'; my $schema = $args{schema} ? $args{schema} : ''; my $recordSyntax = $args{recordSyntax} ? $args{recordSyntax} : ''; @@ -108,7 +117,6 @@ sub records { $to, $ro); - my @res = (); for (my $i=$from; $i<=$to; $i++) { @@ -117,7 +125,7 @@ sub records { if ($class) { } else { - push (@res, $rec); + push (@res, $rec); } } @@ -135,8 +143,8 @@ sub sort { } unless ($setname) { - $_[0] = $self->{session}->sortResultsets($sortspec, - $self->{name}, ($self)); + return ($_[0] = $self->{session}->sortResultsets($sortspec, + $self->{session}->_new_setname, ($self))); return ($_[0]); } else { return ($self->{session}->sortResultsets($sortspec, @@ -222,7 +230,23 @@ The record syntax for retrieval. The default is SUTRS. =head1 SORTING +You can sort resultsets by calling: + + $rs1->sort($sort_expr); + +or create a new sorted resultset: + + $rs2 = $rs1->sort($sort_expr); + +The sort expression has the same format as described in the I documentation. For example: + + $rs1->sort('1=4 id'); + +will sort thr results by title, in a case insensitive way, in descending order, while + + $rs1->sort('1=4 a'); +will sort ascending by titles. =head1 COPYRIGHT @@ -234,6 +258,6 @@ Peter Popovics, pop@technomat.hu =head1 SEE ALSO -IDZebra, IDZebra::Data1, Zebra documentation +Zebra documentation, IDZebra::ResultSet, IDZebra::RetrievalRecord manpages. =cut