9fa1cacdf98389107df29677d5d653576815055b
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep / Iterator / BucketList.pm
1 package DBM::Deep::Iterator::BucketList;
2
3 use 5.006_000;
4
5 use strict;
6 use warnings FATAL => 'all';
7
8 sub new {
9     my $self = bless $_[1] => $_[0];
10     $self->{curr_index} = 0;
11     return $self;
12 }
13
14 sub at_end {
15     my $self = shift;
16     return $self->{curr_index} >= $self->{iterator}{engine}->max_buckets;
17 }
18
19 sub get_next_key {
20     my $self = shift;
21
22     return if $self->at_end;
23
24     my $idx = $self->{curr_index}++;
25
26     my $data_loc = $self->{sector}->get_data_location_for({
27         allow_head => 1,
28         idx        => $idx,
29     }) or return;
30
31     #XXX Do we want to add corruption checks here?
32     return $self->{sector}->get_key_for( $idx )->data;
33 }
34
35 1;
36 __END__