1 package DBM::Deep::Iterator::File;
4 use warnings FATAL => 'all';
6 use base qw( DBM::Deep::Iterator );
8 use DBM::Deep::Iterator::File::BucketList ();
9 use DBM::Deep::Iterator::File::Index ();
11 sub reset { $_[0]{breadcrumbs} = []; return }
13 sub get_sector_iterator {
17 my $sector = $self->{engine}->load_sector( $loc )
20 if ( $sector->isa( 'DBM::Deep::Sector::File::Index' ) ) {
21 return DBM::Deep::Iterator::File::Index->new({
26 elsif ( $sector->isa( 'DBM::Deep::Sector::File::BucketList' ) ) {
27 return DBM::Deep::Iterator::File::BucketList->new({
33 DBM::Deep->_throw_error( "get_sector_iterator(): Why did $loc make a $sector?" );
40 my $crumbs = $self->{breadcrumbs};
41 my $e = $self->{engine};
44 # This will be a Reference sector
45 my $sector = $e->load_sector( $self->{base_offset} )
46 # If no sector is found, this must have been deleted from under us.
49 if ( $sector->staleness != $obj->_staleness ) {
53 my $loc = $sector->get_blist_loc
56 push @$crumbs, $self->get_sector_iterator( $loc );
66 my $iterator = $crumbs->[-1];
69 if ( $iterator->at_end ) {
74 if ( $iterator->isa( 'DBM::Deep::Iterator::File::Index' ) ) {
75 # If we don't have any more, it will be caught at the
77 if ( my $next = $iterator->get_next_iterator ) {
83 unless ( $iterator->isa( 'DBM::Deep::Iterator::File::BucketList' ) ) {
84 DBM::Deep->_throw_error(
85 "Should have a bucketlist iterator here - instead have $iterator"
89 # At this point, we have a BucketList iterator
90 my $key = $iterator->get_next_key;
94 #XXX else { $iterator->set_to_end() } ?
96 # We hit the end of the bucketlist iterator, so redo
100 DBM::Deep->_throw_error( "get_next_key(): How did we get here?" );