| 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::Driver::Hash; | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 4 | our $VERSION = '0.11'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 4 | ▶ | use Moose::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 4 | ▶ | use Set::Object; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 4 | ▶ | use Data::Stream::Bulk::Util qw(bulk); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 4 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 4 | with qw(Search::GIN::Driver); | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | has values => ( | ||||||||||||||||||||
| 16 | isa => "HashRef", | ||||||||||||||||||||
| 17 | is => "ro", | ||||||||||||||||||||
| 18 | 4 | ▶ | default => sub { {} }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 4 | ); | |||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | has objects => ( | ||||||||||||||||||||
| 22 | isa => "HashRef", | ||||||||||||||||||||
| 23 | is => "ro", | ||||||||||||||||||||
| 24 | 4 | ▶ | default => sub { {} }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 4 | ); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | sub clear { | ||||||||||||||||||
|
Subroutine
clear: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 28 | 0 | my $self = shift; | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | %{ $self->values } = (); | |||||||||||||||||||
| 31 | 0 | %{ $self->objects } = (); | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 0 | return; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 15 | ▶ | sub fetch_entry { | ||||||||||||||||||
|
Subroutine
fetch_entry: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||
| 37 | 15 | my ( $self, $key ) = @_; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 15 | ▶ | if ( my $set = $self->values->{$key} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 15 | return bulk($set->members); | |||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||
| 42 | 0 | return; | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 16 | ▶ | sub remove_ids { | ||||||||||||||||||
|
Subroutine
remove_ids: called CC=5 SCAR=20.4
Pod
undocumented
| |||||||||||||||||||||
| 47 | 16 | my ( $self, @ids ) = @_; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 16 | my $values = $self->values; | |||||||||||||||||||
| 50 | 16 | my $objects = $self->objects; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 16 | ▶ | my @key_sets = grep { defined } delete @{$objects}{map { ref() ? refaddr($_) : $_ } @ids}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 16 | ▶ | return unless @key_sets; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 0 | my $keys = (shift @key_sets)->union(@key_sets); | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | foreach my $key ( $keys->members ) { | |||||||||||||||||||
| 57 | 0 | my $set = $values->{$key}; | |||||||||||||||||||
| 58 | 0 | $set->remove(@ids); | |||||||||||||||||||
| 59 | 0 | ▶ | delete $values->{$key} if $set->size == 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 16 | ▶ | sub insert_entry { | ||||||||||||||||||
|
Subroutine
insert_entry: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||
| 64 | 16 | my ( $self, $id, @keys ) = @_; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 16 | my $values = $self->values; | |||||||||||||||||||
| 67 | 16 | my $objects = $self->objects; | |||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 16 | $self->remove_ids($id); | |||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 16 | ▶ | my $set = $objects->{ref($id) ? refaddr($id) : $id} = Set::Object->new; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 16 | $set->insert(@keys); | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 16 | foreach my $id_set (@{$values}{@keys}) { | |||||||||||||||||||
| 76 | 45 | ▶ | $id_set ||= Set::Object->new; | ||||||||||||||||||
|
Condition66%2/3
$id_set ||= "Set::Object"->new
MC/DC0%0/2
$id_set ||= "Set::Object"->new
$id_set
"Set::Object"->new
Truth table66%2/3
A ||= B
A= $id_setB= "Set::Object"->new
| |||||||||||||||||||||
| 77 | 45 | $id_set->insert($id); | |||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 4 | 1; | |||||||||||||||||||