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 get_sector_iterator {
15 my $sector = $self->{engine}->load_sector( $loc )
18 if ( $sector->isa( 'DBM::Deep::Sector::File::Index' ) ) {
19 return DBM::Deep::Iterator::Index->new({
24 elsif ( $sector->isa( 'DBM::Deep::Sector::File::BucketList' ) ) {
25 return DBM::Deep::Iterator::BucketList->new({
31 DBM::Deep->_throw_error( "get_sector_iterator(): Why did $loc make a $sector?" );
38 my $crumbs = $self->{breadcrumbs};
39 my $e = $self->{engine};
42 # This will be a Reference sector
43 my $sector = $e->load_sector( $self->{base_offset} )
44 # If no sector is found, this must have been deleted from under us.
47 if ( $sector->staleness != $obj->_staleness ) {
51 my $loc = $sector->get_blist_loc
54 push @$crumbs, $self->get_sector_iterator( $loc );
64 my $iterator = $crumbs->[-1];
67 if ( $iterator->at_end ) {
72 if ( $iterator->isa( 'DBM::Deep::Iterator::Index' ) ) {
73 # If we don't have any more, it will be caught at the
75 if ( my $next = $iterator->get_next_iterator ) {
81 unless ( $iterator->isa( 'DBM::Deep::Iterator::BucketList' ) ) {
82 DBM::Deep->_throw_error(
83 "Should have a bucketlist iterator here - instead have $iterator"
87 # At this point, we have a BucketList iterator
88 my $key = $iterator->get_next_key;
92 #XXX else { $iterator->set_to_end() } ?
94 # We hit the end of the bucketlist iterator, so redo
98 DBM::Deep->_throw_error( "get_next_key(): How did we get here?" );