line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBM::Deep::Iterator::File; |
2
|
|
|
|
|
|
|
|
3
|
23
|
|
|
23
|
|
204
|
use strict; |
|
23
|
|
|
|
|
58
|
|
|
23
|
|
|
|
|
878
|
|
4
|
23
|
|
|
23
|
|
132
|
use warnings FATAL => 'all'; |
|
23
|
|
|
|
|
165
|
|
|
23
|
|
|
|
|
1133
|
|
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
249
|
use base qw( DBM::Deep::Iterator ); |
|
23
|
|
|
|
|
50
|
|
|
23
|
|
|
|
|
2306
|
|
7
|
|
|
|
|
|
|
|
8
|
23
|
|
|
23
|
|
11504
|
use DBM::Deep::Iterator::File::BucketList (); |
|
23
|
|
|
|
|
151
|
|
|
23
|
|
|
|
|
503
|
|
9
|
23
|
|
|
23
|
|
10600
|
use DBM::Deep::Iterator::File::Index (); |
|
23
|
|
|
|
|
68
|
|
|
23
|
|
|
|
|
9813
|
|
10
|
|
|
|
|
|
|
|
11
|
308
|
|
|
308
|
1
|
669
|
sub reset { $_[0]{breadcrumbs} = []; return } |
|
308
|
|
|
|
|
543
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub get_sector_iterator { |
14
|
346
|
|
|
346
|
0
|
654
|
my $self = shift; |
15
|
346
|
|
|
|
|
613
|
my ($loc) = @_; |
16
|
|
|
|
|
|
|
|
17
|
346
|
50
|
|
|
|
1000
|
my $sector = $self->{engine}->load_sector( $loc ) |
18
|
|
|
|
|
|
|
or return; |
19
|
|
|
|
|
|
|
|
20
|
346
|
100
|
|
|
|
2062
|
if ( $sector->isa( 'DBM::Deep::Sector::File::Index' ) ) { |
|
|
50
|
|
|
|
|
|
21
|
15
|
|
|
|
|
91
|
return DBM::Deep::Iterator::File::Index->new({ |
22
|
|
|
|
|
|
|
iterator => $self, |
23
|
|
|
|
|
|
|
sector => $sector, |
24
|
|
|
|
|
|
|
}); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif ( $sector->isa( 'DBM::Deep::Sector::File::BucketList' ) ) { |
27
|
331
|
|
|
|
|
1445
|
return DBM::Deep::Iterator::File::BucketList->new({ |
28
|
|
|
|
|
|
|
iterator => $self, |
29
|
|
|
|
|
|
|
sector => $sector, |
30
|
|
|
|
|
|
|
}); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
DBM::Deep->_throw_error( "get_sector_iterator(): Why did $loc make a $sector?" ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_next_key { |
37
|
541
|
|
|
541
|
1
|
844
|
my $self = shift; |
38
|
541
|
|
|
|
|
911
|
my ($obj) = @_; |
39
|
|
|
|
|
|
|
|
40
|
541
|
|
|
|
|
879
|
my $crumbs = $self->{breadcrumbs}; |
41
|
541
|
|
|
|
|
799
|
my $e = $self->{engine}; |
42
|
|
|
|
|
|
|
|
43
|
541
|
100
|
|
|
|
1206
|
unless ( @$crumbs ) { |
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. |
47
|
158
|
100
|
|
|
|
684
|
or return; |
48
|
|
|
|
|
|
|
|
49
|
157
|
50
|
|
|
|
556
|
if ( $sector->staleness != $obj->_staleness ) { |
50
|
0
|
|
|
|
|
0
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
157
|
100
|
|
|
|
542
|
my $loc = $sector->get_blist_loc |
54
|
|
|
|
|
|
|
or return; |
55
|
|
|
|
|
|
|
|
56
|
151
|
|
|
|
|
549
|
push @$crumbs, $self->get_sector_iterator( $loc ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
FIND_NEXT_KEY: { |
60
|
|
|
|
|
|
|
# We're at the end. |
61
|
534
|
100
|
|
|
|
873
|
unless ( @$crumbs ) { |
|
5987
|
|
|
|
|
11692
|
|
62
|
150
|
|
|
|
|
494
|
$self->reset; |
63
|
150
|
|
|
|
|
500
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
5837
|
|
|
|
|
8668
|
my $iterator = $crumbs->[-1]; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# This level is done. |
69
|
5837
|
100
|
|
|
|
12866
|
if ( $iterator->at_end ) { |
70
|
345
|
|
|
|
|
615
|
pop @$crumbs; |
71
|
345
|
|
|
|
|
1445
|
redo FIND_NEXT_KEY; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
5492
|
100
|
|
|
|
20501
|
if ( $iterator->isa( 'DBM::Deep::Iterator::File::Index' ) ) { |
75
|
|
|
|
|
|
|
# If we don't have any more, it will be caught at the |
76
|
|
|
|
|
|
|
# prior check. |
77
|
210
|
100
|
|
|
|
497
|
if ( my $next = $iterator->get_next_iterator ) { |
78
|
195
|
|
|
|
|
385
|
push @$crumbs, $next; |
79
|
|
|
|
|
|
|
} |
80
|
210
|
|
|
|
|
405
|
redo FIND_NEXT_KEY; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
5282
|
50
|
|
|
|
12776
|
unless ( $iterator->isa( 'DBM::Deep::Iterator::File::BucketList' ) ) { |
84
|
0
|
|
|
|
|
0
|
DBM::Deep->_throw_error( |
85
|
|
|
|
|
|
|
"Should have a bucketlist iterator here - instead have $iterator" |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# At this point, we have a BucketList iterator |
90
|
5282
|
|
|
|
|
10594
|
my $key = $iterator->get_next_key; |
91
|
5282
|
100
|
|
|
|
11352
|
if ( defined $key ) { |
92
|
384
|
|
|
|
|
1458
|
return $key; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
#XXX else { $iterator->set_to_end() } ? |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# We hit the end of the bucketlist iterator, so redo |
97
|
4898
|
|
|
|
|
8497
|
redo FIND_NEXT_KEY; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
DBM::Deep->_throw_error( "get_next_key(): How did we get here?" ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
__END__ |