line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Search Complex Data Structures |
2
|
|
|
|
|
|
|
package Data::Seek; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1103
|
use Data::Seek::Data; |
|
1
|
|
|
|
|
20
|
|
|
1
|
|
|
|
|
59
|
|
5
|
1
|
|
|
1
|
|
886
|
use Data::Seek::Search; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
38
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
9
|
use Data::Object::Class; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
318
|
use Data::Object qw(:core); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
511
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.08'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'cache' => ( |
13
|
|
|
|
|
|
|
is => 'rw', |
14
|
|
|
|
|
|
|
default => 0 |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'data' => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
default => sub {{}} |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has 'ignore' => ( |
23
|
|
|
|
|
|
|
is => 'rw', |
24
|
|
|
|
|
|
|
default => 0 |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub search { |
28
|
47
|
|
|
47
|
1
|
13847
|
my ($self, @criteria) = @_; |
29
|
47
|
|
|
|
|
169
|
my $cache = $self->cache; |
30
|
47
|
|
|
|
|
132
|
my $data = $self->data; |
31
|
47
|
|
|
|
|
114
|
my $ignore = $self->ignore; |
32
|
|
|
|
|
|
|
|
33
|
47
|
50
|
|
|
|
237
|
Data::Seek::Exception->throw('Not Searchable') |
34
|
|
|
|
|
|
|
unless UNIVERSAL::isa($data, 'HASH'); |
35
|
|
|
|
|
|
|
|
36
|
47
|
|
|
|
|
60
|
my $search; |
37
|
|
|
|
|
|
|
|
38
|
47
|
100
|
|
|
|
125
|
if ($self->cache) { |
39
|
6
|
100
|
|
|
|
16
|
if ($search = $self->{cached_search}) { |
40
|
5
|
|
|
|
|
17
|
$search->criteria({}); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
47
|
|
66
|
|
|
294
|
$search //= Data::Seek::Search->new( |
45
|
|
|
|
|
|
|
cache => $cache, |
46
|
|
|
|
|
|
|
ignore => $ignore, |
47
|
|
|
|
|
|
|
data => Data::Seek::Data->new($data), |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
47
|
|
|
|
|
846
|
$search->criterion($_) for @criteria; |
51
|
|
|
|
|
|
|
|
52
|
47
|
100
|
|
|
|
201
|
if ($self->cache) { |
53
|
6
|
|
|
|
|
8
|
$self->{cached_search} = $search; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
41
|
|
|
|
|
83
|
$self->{cached_search} = undef; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
47
|
|
|
|
|
264
|
return $search->result; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |