| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::Backend::Role::Query::Simple; | ||||||||||
| 4 | 21 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 21 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 21 | requires "simple_search"; | |||||||||
| 9 | |||||||||||
| 10 | sub simple_search_filter { | ||||||||||
| 11 | 50 | ▶ | my ( $self, $stream, $proto ) = @_; | ||||||||
|
Subroutine
simple_search_filter: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 12 | 50 | return $stream; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | # FIXME unify with Attribute, and put this in the default simple_search_filter | ||||||||||
| 16 | # implementation | ||||||||||
| 17 | # that way *really* lazy backends can just alias simple_search to scan and | ||||||||||
| 18 | # still be feature complete even if they are retardedly slow | ||||||||||
| 19 | |||||||||||
| 20 | sub compare_naive { | ||||||||||
| 21 | 153 | ▶ | my ( $self, $got, $exp ) = @_; | ||||||||
|
Subroutine
compare_naive: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 22 | |||||||||||
| 23 | 153 | foreach my $key ( keys %$exp ) { | |||||||||
| 24 | 153 | ▶ | return unless overload::StrVal($got->{$key}) eq overload::StrVal($exp->{$key}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 77 | return 1; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 21 | __PACKAGE__ | |||||||||
| 31 | |||||||||||
| 32 | __END__ | ||||||||||
| 33 | |||||||||||
| 34 | =pod | ||||||||||
| 35 | |||||||||||
| 36 | =head1 NAME | ||||||||||
| 37 | |||||||||||
| 38 | KiokuDB::Backend::Role::Query::Simple - Simple query api | ||||||||||
| 39 | |||||||||||
| 40 | =head1 SYNOPSIS | ||||||||||
| 41 | |||||||||||
| 42 | with qw(KiokuDB::Backend::Role::Query::Simple); | ||||||||||
| 43 | |||||||||||
| 44 | sub simple_search { | ||||||||||
| 45 | my ( $self, $proto ) = @_; | ||||||||||
| 46 | |||||||||||
| 47 | # return all candidate entries in the root set matching fields in $proto | ||||||||||
| 48 | return Data::Stream::Bulk::Foo->new(...); | ||||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | =head1 DESCRIPTION | ||||||||||
| 52 | |||||||||||
| 53 | This role requires a C<simple_search> method to be implemented. | ||||||||||
| 54 | |||||||||||
| 55 | The method accepts one argument, the hash of the proto to search for. | ||||||||||
| 56 | |||||||||||
| 57 | This is still loosely defined, but the basic functionality is based on | ||||||||||
| 58 | attribute matching: | ||||||||||
| 59 | |||||||||||
| 60 | $kiokudb->search({ name => "Mia" }); | ||||||||||
| 61 | |||||||||||
| 62 | will search for objects whose C<name> attribute contains the string C<Mia>. | ||||||||||
| 63 | |||||||||||
| 64 | More complex operations will be defined in the future. | ||||||||||
| 65 | |||||||||||
| 66 | =cut | ||||||||||
| 67 | |||||||||||
| 68 | |||||||||||