File Coverage

blib/lib/KiokuDB/Backend/Role/Query/Simple/Linear.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 16 17 94.1


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package KiokuDB::Backend::Role::Query::Simple::Linear;
4 21     21   10442 use Moose::Role;
  21         35  
  21         137  
5              
6 21     21   86531 use namespace::clean -except => 'meta';
  21         41  
  21         160  
7              
8             with qw(KiokuDB::Backend::Role::Query::Simple);
9              
10             requires "root_entries";
11              
12             sub simple_search {
13 67     67 0 122 my ( $self, $proto ) = @_;
14              
15             # FIXME $proto is sql::abstract 2? or...?
16              
17 67         349 my $root_set = $self->root_entries;
18              
19             return $root_set->filter(sub {
20 201         704 return [ grep {
21 67     67   4550 my $entry = $_;
22 201         4560 $self->compare_naive($entry->data, $proto);
23             } @$_ ]
24 67         1968 });
25             }
26              
27             __PACKAGE__
28              
29             __END__
30              
31             =pod
32              
33             =head1 NAME
34              
35             KiokuDB::Backend::Role::Query::Simple::Linear - Query::Simple implemented with
36             a linear scan of all entries.
37              
38             =head1 SYNOPSIS
39              
40             package MyBackend;
41             use Moose;
42              
43             with qw(
44             KiokuDB::Backend::Role::Scan
45             KiokuDB::Backend::Role::Query::Simple::Linear
46             );
47              
48             =head1 DESCRIPTION
49              
50             This role can provide a primitive C<search> facility (the API described in
51             L<KiokuDB::Backend::Role::Query::Simple>) using the api provided by
52             L<KiokuDB::Backend::Role::Scan>. While very inefficient for large data sets, of
53             your databases are small this can be useful.
54