/usr/share/perl5/Search/GIN/Driver.pm is in libsearch-gin-perl 0.08-1.
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | use strict;
use warnings;
package Search::GIN::Driver;
BEGIN {
$Search::GIN::Driver::VERSION = '0.08';
}
# ABSTRACT:
use Moose::Role;
use Data::Stream::Bulk::Util qw(bulk nil cat unique);
use namespace::clean -except => [qw(meta)];
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;
=pod
=head1 NAME
Search::GIN::Driver - use Moose::Role;
=head1 VERSION
version 0.08
=head1 SYNOPSIS
use Search::GIN::Driver;
=head1 DESCRIPTION
=head1 AUTHOR
Yuval Kogman <nothingmuch@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Yuval Kogman, Infinity Interactive.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
__END__
|