⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 invindex.pm

📁 外国人写的Perl搜索引擎程序
💻 PM
字号:
package KinoSearch::Store::InvIndex;use strict;use warnings;use KinoSearch::Util::ToolSet;use base qw( KinoSearch::Util::Class );BEGIN {    __PACKAGE__->init_instance_vars(        create => 0,        path   => undef,    );}__PACKAGE__->ready_get(qw( create path ));=begin comment    my $outstream = $invindex->open_outstream($filename);Given a filename, return an OutStream object.=end comment=cutsub open_outstream { shift->abstract_death }=begin comment    my $instream = $invindex->open_instream($filename);Given a filename, return an InStream object.=end comment=cutsub open_instream { shift->abstract_death }=begin comment    my @files = $invindex->list;Return a list of all the files in the InvIndex=end comment=cutsub list { shift->abstract_death }=begin comment    my $truth = $invindex->file_exists($filename);Indicate whether the invindex contains a file with the given filename.=end comment=cutsub file_exists { shift->abstract_death }=begin comment    $invindex->rename_file( $from, $to );Rename a file.=end comment=cutsub rename_file { shift->abstract_death }=begin comment   $invindex->delete_file($filename);Delete a file from the invindex.=end comment=cutsub delete_file { shift->abstract_death }=begin comment    my $file_contents = $invindex->slurp_file($filename);Return a scalar with the file's contents.  Only for small files, obviously.=end comment=cutsub slurp_file { shift->abstract_death }=begin comment   my $lock = $invindex->make_lock(       lock_name => $name,       timeout   => $timeout,  # milliseconds   );Factory method for creating a KinoSearch::Store::Lock subclassed object.=end comment=cutsub make_lock { shift->abstract_death }=begin comment    $invindex->run_while_locked(        lock_name => $name,        timeout   => $timeout,  # milliseconds        do_body   => \&do_some_stuff,    );Create a Lock object and obtain a lock, run the subroutine specified bythe do_body parameter, then release the lock and discard the Lock object.The hash-style argument labels include all the arguments to make_lock, plusdo_body.=end comment=cutsub run_while_locked {    my ( $self, %args ) = @_;    my $do_body = delete $args{do_body};    my $lock = $self->make_lock( %args, invindex => $self, );    my $locked;    eval {        $locked = $lock->obtain;        $do_body->();    };    $lock->release if $lock->is_locked;    confess $@     if $@;}=begin comment    $invindex->close()Release any reserved resources.=end comment=cutsub close { shift->abstract_death }1;__END__=head1 NAMEKinoSearch::Store::InvIndex - inverted index=head1 SYNOPSIS    # abstract base class=head1 DESCRIPTIONAn InvIndex is an abstract representation of an inverted index, KinoSearch'score data structure.  The archetypal implementation of an invindex,FSInvIndex, is a single directory holding a collection of files.  However, toallow alternative implementations such as RAMInvIndex, i/o and filemanipulation are abstracted out rather than executed directly by KinoSearch'sclasses.A "file" within an invindex might be a real file -- or it might be a ram file,or eventually a database record, etc.  Similarly,C<< $invindex->delete_file($filename) >> might delete a file from the filesystem, or a key-value pair from a hash, or something else.=head1 SEE ALSOL<KinoSearch::Docs::FileFormat|KinoSearch::Docs::FileFormat>=head1 COPYRIGHTCopyright 2005-2007 Marvin Humphrey=head1 LICENSE, DISCLAIMER, BUGS, etc.See L<KinoSearch|KinoSearch> version 0.163.=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -