line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBM::Deep::Iterator::File::BucketList; |
2
|
|
|
|
|
|
|
|
3
|
23
|
|
|
23
|
|
728
|
use 5.008_004; |
|
23
|
|
|
|
|
86
|
|
4
|
|
|
|
|
|
|
|
5
|
23
|
|
|
23
|
|
130
|
use strict; |
|
23
|
|
|
|
|
61
|
|
|
23
|
|
|
|
|
750
|
|
6
|
23
|
|
|
23
|
|
131
|
use warnings FATAL => 'all'; |
|
23
|
|
|
|
|
60
|
|
|
23
|
|
|
|
|
6113
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
DBM::Deep::Iterator::BucketList - mediate between DBM::Deep::Iterator and DBM::Deep::Engine::Sector::BucketList |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 PURPOSE |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This is an internal-use-only object for L. It acts as the mediator |
15
|
|
|
|
|
|
|
between the L object and a L |
16
|
|
|
|
|
|
|
sector. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 OVERVIEW |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This object, despite the implied class hierarchy, does B inherit from |
21
|
|
|
|
|
|
|
L. Instead, it delegates to it, essentially acting as a |
22
|
|
|
|
|
|
|
facade over it. L will instantiate one of |
23
|
|
|
|
|
|
|
these objects as needed to handle an BucketList sector. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 METHODS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 new(\%params) |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The constructor takes a hashref of params and blesses it into the invoking class. The |
30
|
|
|
|
|
|
|
hashref is assumed to have the following elements: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=over 4 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item * iterator (of type L |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item * sector (of type L |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=back |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
331
|
|
|
331
|
1
|
791
|
my $self = bless $_[1] => $_[0]; |
44
|
331
|
|
|
|
|
713
|
$self->{curr_index} = 0; |
45
|
331
|
|
|
|
|
1352
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 at_end() |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This takes no arguments. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This returns true/false indicating whether this sector has any more elements that can be |
53
|
|
|
|
|
|
|
iterated over. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub at_end { |
58
|
10894
|
|
|
10894
|
1
|
15965
|
my $self = shift; |
59
|
10894
|
|
|
|
|
24430
|
return $self->{curr_index} >= $self->{iterator}{engine}->max_buckets; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 get_next_iterator() |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This takes no arguments. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This returns the next key pointed to by this bucketlist. This value is suitable for |
67
|
|
|
|
|
|
|
returning by FIRSTKEY or NEXTKEY(). |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
If the bucketlist is exhausted, it returns nothing. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub get_next_key { |
74
|
5282
|
|
|
5282
|
0
|
7838
|
my $self = shift; |
75
|
|
|
|
|
|
|
|
76
|
5282
|
50
|
|
|
|
8566
|
return if $self->at_end; |
77
|
|
|
|
|
|
|
|
78
|
5282
|
|
|
|
|
9784
|
my $idx = $self->{curr_index}++; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $data_loc = $self->{sector}->get_data_location_for({ |
81
|
5282
|
100
|
|
|
|
17868
|
allow_head => 1, |
82
|
|
|
|
|
|
|
idx => $idx, |
83
|
|
|
|
|
|
|
}) or return; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#XXX Do we want to add corruption checks here? |
86
|
384
|
|
|
|
|
1549
|
return $self->{sector}->get_key_for( $idx )->data; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
__END__ |