DBM::Deep::Iterator::File::BucketList - DBM::Deep::Iterator::File::BucketList documentation


DBM-Deep documentation Contained in the DBM-Deep distribution.

Index


Code Index:

NAME

Top

DBM::Deep::Iterator::BucketList

PURPOSE

Top

This is an internal-use-only object for DBM::Deep. It acts as the mediator between the DBM::Deep::Iterator object and a DBM::Deep::Engine::Sector::BucketList sector.

OVERVIEW

Top

This object, despite the implied class hiearchy, does NOT inherit from DBM::Deep::Iterator. Instead, it delegates to it, essentially acting as a facade over it. get_next_key in DBM::Deep::Iterator will instantiate one of these objects as needed to handle an BucketList sector.

METHODS

Top

new(\%params)

The constructor takes a hashref of params and blesses it into the invoking class. The hashref is assumed to have the following elements:

* iterator (of type DBM::Deep::Iterator
* sector (of type DBM::Deep::Engine::Sector::BucketList

at_end()

This takes no arguments.

This returns true/false indicating whether this sector has any more elements that can be iterated over.

get_next_iterator()

This takes no arguments.

This returns the next key pointed to by this bucketlist. This value is suitable for returning by FIRSTKEY or NEXTKEY().

If the bucketlist is exhausted, it returns nothing.


DBM-Deep documentation Contained in the DBM-Deep distribution.
package DBM::Deep::Iterator::File::BucketList;

use 5.008_004;

use strict;
use warnings FATAL => 'all';

sub new {
    my $self = bless $_[1] => $_[0];
    $self->{curr_index} = 0;
    return $self;
}

sub at_end {
    my $self = shift;
    return $self->{curr_index} >= $self->{iterator}{engine}->max_buckets;
}

sub get_next_key {
    my $self = shift;

    return if $self->at_end;

    my $idx = $self->{curr_index}++;

    my $data_loc = $self->{sector}->get_data_location_for({
        allow_head => 1,
        idx        => $idx,
    }) or return;

    #XXX Do we want to add corruption checks here?
    return $self->{sector}->get_key_for( $idx )->data;
}

1;
__END__