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