/[wait]/branches/CPAN/lib/WAIT/IndexScan.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/CPAN/lib/WAIT/IndexScan.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 12 by unknown, Fri Apr 28 15:41:10 2000 UTC revision 13 by ulpfr, Fri Apr 28 15:42:44 2000 UTC
# Line 18  use strict; Line 18  use strict;
18  use DB_File;  use DB_File;
19  use Fcntl;  use Fcntl;
20    
 sub fail {  
   $@ .= join "\n", @_;  
   return undef;  
 }  
   
21  sub new {  sub new {
22    my $type  = shift;    my $type  = shift;
23    my $index = shift;    my $index = shift;
# Line 30  sub new { Line 25  sub new {
25    my ($first, $tid) = ('', '');    my ($first, $tid) = ('', '');
26    
27    # find the first key    # find the first key
28    $index->{dbh}->seq($first, $tid, R_FIRST)    if ($index->{dbh}->seq($first, $tid, R_FIRST)) {
29      and return fail("Could not open scan");      require Carp;
30        Carp::croak("Could not open scan");
31      }
32    # Not sure about this. R_FIRST sets $tid to no-of-records?    # Not sure about this. R_FIRST sets $tid to no-of-records?
33    # $index->{dbh}->seq($first, $tid, R_NEXT);    # $index->{dbh}->seq($first, $tid, R_NEXT);
34    # register to avoid unnecessary position calls    # register to avoid unnecessary position calls
# Line 47  sub next { Line 44  sub next {
44    my ($key, $tid, $ntid);    my ($key, $tid, $ntid);
45    
46    if (defined $self->{nextk}) {    if (defined $self->{nextk}) {
47      fail("Cannot scan closed index"),return unless $dbh;      unless ($dbh){
48          require Carp;
49          Carp::croak("Cannot scan closed index");
50        }
51      $key = $self->{nextk};      $key = $self->{nextk};
52        
53      if ($self->{Index}->{scans} > 1) {      if ($self->{Index}->{scans} > 1) {
54        # Another scan is open. Reset the cursor        # Another scan is open. Reset the cursor
55        $dbh->seq($key, $tid, R_CURSOR);        $dbh->seq($key, $tid, R_CURSOR);
# Line 60  sub next { Line 60  sub next {
60        # current tuple is last one        # current tuple is last one
61        delete $self->{nextk};        delete $self->{nextk};
62      }      }
63        
64      my @tuple = split /$;/, $key;      my @tuple = split /$;/, $key;
65      my %tuple = (_id => $tid);      my %tuple = (_id => $tid);
66      for (@{$self->{Index}->{attr}}) {      for (@{$self->{Index}->{attr}}) {

Legend:
Removed from v.12  
changed lines
  Added in v.13

  ViewVC Help
Powered by ViewVC 1.1.26