| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::GIN; | ||||||||||
| 4 | 1 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | with qw( | |||||||||
| 9 | KiokuDB::Backend::Role::Query::GIN | ||||||||||
| 10 | Search::GIN::Driver | ||||||||||
| 11 | ); | ||||||||||
| 12 | |||||||||||
| 13 | 1 | has root_only => ( | |||||||||
| 14 | isa => "Bool", | ||||||||||
| 15 | is => "ro", | ||||||||||
| 16 | default => 1, | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | after insert => sub { | ||||||||||
| 20 | 49 | ▶ | my ( $self, @entries ) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||
| 21 | |||||||||||
| 22 | 49 | ▶ | @entries = grep { $_->root } @entries if $self->root_only; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | |||||||||||
| 24 | 49 | my @idx_entries = grep { $_->has_object } @entries; | |||||||||
| 25 | |||||||||||
| 26 | 49 | foreach my $entry ( @idx_entries ) { | |||||||||
| 27 | 102 | my @keys = $self->extract_values( $entry->object ); | |||||||||
| 28 | 102 | $self->insert_entry( $entry->id, @keys ); | |||||||||
| 29 | } | ||||||||||
| 30 | 1 | }; | |||||||||
| 31 | |||||||||||
| 32 | after delete => sub { | ||||||||||
| 33 | 5 | ▶ | my ( $self, @ids_or_entries ) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 34 | |||||||||||
| 35 | 5 | ▶ | my @ids = map { ref($_) ? $_->id : $_ } @ids_or_entries; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | |||||||||||
| 37 | 5 | $self->remove_ids(@ids); | |||||||||
| 38 | 1 | }; | |||||||||
| 39 | |||||||||||
| 40 | 1 | __PACKAGE__ | |||||||||
| 41 | |||||||||||
| 42 | __END__ | ||||||||||
| 43 | |||||||||||
| 44 | =pod | ||||||||||
| 45 | |||||||||||
| 46 | =head1 NAME | ||||||||||
| 47 | |||||||||||
| 48 | KiokuDB::GIN - Gin assisted recollection | ||||||||||
| 49 | |||||||||||
| 50 | =head1 SYNOPSIS | ||||||||||
| 51 | |||||||||||
| 52 | use KiokuDB::GIN; | ||||||||||
| 53 | |||||||||||
| 54 | =head1 DESCRIPTION | ||||||||||
| 55 | |||||||||||
| 56 | This is a generic backend wrapping role that allows adding L<Search::GIN> | ||||||||||
| 57 | queries to any backend. | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||
| 60 | |||||||||||
| 61 | |||||||||||