GIN/Core.pm

filter: Statementstmt 92.1% 35 / 38 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 86.5% 45 / 52 CC 3 SCAR 3.7
CC
3
Cov
92%
query
2.0
remove
2.0
insert
2.0
CRAP 1.5
« GIN/Query/Manual.pm ↑ Summary GIN/Indexable.pm »
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Search::GIN::Core;
4 # ABSTRACT: Core of Search::GIN
5  
6 4 our $VERSION = '0.11';
7  
8 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Data::Stream::Bulk::Util qw(bulk unique);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 with qw(
13 Search::GIN::Driver
14 Search::GIN::Extract
15 );
16  
17 4 requires qw(
18 objects_to_ids
19 ids_to_objects
20 );
21  
22 4 has distinct => (
23 isa => "Bool",
24 is => "rw",
25 default => 0, # FIXME what should the default be?
26 );
27  
28 14 ▶sub query {
Subroutine query: called CC=2 SCAR=6.9
Pod undocumented
29 14 my ( $self, $query, @args ) = @_;
30  
31 14 my %args = (
32 distinct => $self->distinct,
33 @args,
34 );
35  
36 14 my @spec = $query->extract_values($self);
37  
38 14 my $ids = $self->fetch_entries(@spec);
39  
40 14 ▶ $ids = unique($ids) if $args{distinct};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"distinct"} 6 8 14
41  
42 14 ▶ return $ids->filter(sub { [ grep { $query->consistent($self, $_) } $self->ids_to_objects(@$_) ] });
Subroutine __ANON__: called CC=1 SCAR=0.0
43 }
44  
45 0 ▶sub remove {
Subroutine remove: not called CC=1 SCAR=6.9
Pod undocumented
46 0 my ( $self, @items ) = @_;
47  
48 0 my @ids = $self->objects_to_ids(@items);
49  
50 0 $self->remove_ids(@ids);
51 }
52  
53 4 ▶sub insert {
Subroutine insert: called CC=2 SCAR=6.9
Pod undocumented
54 4 my ( $self, @items ) = @_;
55  
56 4 my @ids = $self->objects_to_ids(@items);
57  
58 4 my @entries;
59  
60 4 foreach my $item ( @items ) {
61 16 my @keys = $self->extract_values( $item, gin => $self );
62 16 my $id = shift @ids;
63  
64 16 $self->insert_entry( $id, @keys );
65 }
66 }
67  
68 4 1;
69  
70 __END__
« GIN/Query/Manual.pm ↑ Summary GIN/Indexable.pm »