line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
2180
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
147
|
|
2
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
193
|
|
3
|
|
|
|
|
|
|
package Search::GIN::Driver; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
16
|
use Moose::Role; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
38
|
|
8
|
4
|
|
|
4
|
|
16126
|
use Data::Stream::Bulk::Util qw(bulk nil cat unique); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
62
|
|
9
|
4
|
|
|
4
|
|
1272
|
use namespace::autoclean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
24
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
requires qw( |
12
|
|
|
|
|
|
|
insert_entry |
13
|
|
|
|
|
|
|
remove_ids |
14
|
|
|
|
|
|
|
fetch_entry |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub fetch_entry_streams { |
18
|
14
|
|
|
14
|
0
|
27
|
my ( $self, %args ) = @_; |
19
|
14
|
|
|
|
|
18
|
map { $self->fetch_entry($_) } @{ $args{values} }; |
|
15
|
|
|
|
|
133
|
|
|
14
|
|
|
|
|
27
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub fetch_entries { |
23
|
14
|
|
|
14
|
0
|
44
|
my ( $self, %args ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
14
|
|
100
|
|
|
52
|
my $method = "fetch_entries_" . ( $args{method} || "any" ); |
26
|
|
|
|
|
|
|
|
27
|
14
|
|
|
|
|
73
|
$self->$method(%args); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub fetch_entries_any { |
31
|
4
|
|
|
4
|
0
|
9
|
my ( $self, @args ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
4
|
|
|
|
|
10
|
my @streams = $self->fetch_entry_streams(@args); |
34
|
|
|
|
|
|
|
|
35
|
4
|
50
|
|
|
|
201
|
return nil unless @streams; |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
19
|
my $res = cat(splice @streams); # splice disposes of @streams ASAP, keeping memory utilization down |
38
|
|
|
|
|
|
|
|
39
|
4
|
50
|
|
|
|
223
|
if ( $res->loaded ) { |
40
|
|
|
|
|
|
|
# if all results are already ready, we can uniqify them to avoid |
41
|
|
|
|
|
|
|
# duplicate calls to ->consistent |
42
|
4
|
|
|
|
|
28
|
return unique($res); |
43
|
|
|
|
|
|
|
} else { |
44
|
0
|
|
|
|
|
0
|
return $res; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub fetch_entries_all { |
49
|
10
|
|
|
10
|
0
|
18
|
my ( $self, @args ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
10
|
|
|
|
|
25
|
my @streams = $self->fetch_entry_streams(@args); |
52
|
|
|
|
|
|
|
|
53
|
10
|
100
|
|
|
|
494
|
return nil unless @streams; |
54
|
9
|
100
|
|
|
|
44
|
return $streams[0] if @streams == 1; |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
3
|
foreach my $stream ( @streams ) { |
57
|
2
|
50
|
|
|
|
8
|
return cat(splice @streams) unless $stream->loaded; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# if we made it to here then we have a > 1 list of fully realized streams |
61
|
|
|
|
|
|
|
# we can compute the intersection of the IDs to avoid unnecessary calls to |
62
|
|
|
|
|
|
|
# ->consistent |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# If all streams are known to be sorted this method could be overridden to |
65
|
|
|
|
|
|
|
# use merge sorting |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
4
|
my $last = shift @streams; |
68
|
1
|
|
|
|
|
3
|
my $n = scalar @streams; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# compute intersection |
71
|
1
|
|
|
|
|
1
|
my %seen; |
72
|
1
|
|
|
|
|
3
|
foreach my $stream ( splice @streams ) { |
73
|
1
|
|
|
|
|
4
|
++$seen{$_} for $stream->all; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
4
|
|
|
4
|
|
1354
|
no warnings 'uninitialized'; # == with undef |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
431
|
|
77
|
1
|
|
|
|
|
149
|
return bulk( grep { $seen{$_} == $n } $last->all ); |
|
2
|
|
|
|
|
106
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |