line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Search Complex Data Structures |
2
|
|
|
|
|
|
|
package Data::Seek; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1168
|
use Data::Seek::Data; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
454
|
use Data::Seek::Search; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Data::Object::Class; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.06'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'cache' => ( |
12
|
|
|
|
|
|
|
is => 'rw', |
13
|
|
|
|
|
|
|
default => 0 |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'data' => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
default => sub {{}} |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'ignore' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
default => 0 |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub search { |
27
|
47
|
|
|
47
|
1
|
10704
|
my ($self, @criteria) = @_; |
28
|
47
|
|
|
|
|
72
|
my $cache = $self->cache; |
29
|
47
|
|
|
|
|
70
|
my $data = $self->data; |
30
|
47
|
|
|
|
|
45
|
my $ignore = $self->ignore; |
31
|
|
|
|
|
|
|
|
32
|
47
|
50
|
|
|
|
119
|
unless (UNIVERSAL::isa($data, 'HASH')) { |
33
|
0
|
|
|
|
|
0
|
Data::Seek::Exception->throw( |
34
|
|
|
|
|
|
|
message => 'DATA NOT A HASH REFERENCE OR BLESSED HASH OBJECT' |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
47
|
|
|
|
|
32
|
my $search; |
39
|
|
|
|
|
|
|
|
40
|
47
|
100
|
|
|
|
74
|
if ($self->cache) { |
41
|
6
|
100
|
|
|
|
10
|
if ($search = $self->{cached_search}) { |
42
|
5
|
|
|
|
|
12
|
$search->criteria({}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
47
|
|
66
|
|
|
975
|
$search //= Data::Seek::Search->new( |
47
|
|
|
|
|
|
|
cache => $cache, |
48
|
|
|
|
|
|
|
ignore => $ignore, |
49
|
|
|
|
|
|
|
data => Data::Seek::Data->new( |
50
|
|
|
|
|
|
|
object => $data |
51
|
|
|
|
|
|
|
), |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
47
|
|
|
|
|
393
|
$search->criterion($_) for @criteria; |
55
|
|
|
|
|
|
|
|
56
|
47
|
100
|
|
|
|
93
|
if ($self->cache) { |
57
|
6
|
|
|
|
|
6
|
$self->{cached_search} = $search; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
41
|
|
|
|
|
45
|
$self->{cached_search} = undef; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
47
|
|
|
|
|
121
|
return $search->result; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |