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

📄 outputstream.pm

📁 Plucene-1.25.tar.gz PERL版本的lucene
💻 PM
字号:
package Plucene::Store::OutputStream;=head1 NAME Plucene::Store::OutputStream - a random-access output stream=head1 SYNOPSIS	# isa Plucene::Store::InputStream=head1 DESCRIPTIONThis is an abstract class for output to a file in a Directory. A random-access output stream. Used for all Plucene index output operations.=head1 METHODS=cutuse strict;use warnings;no warnings 'uninitialized';use Encode qw(encode);=head2 newCreate a new Plucene::Store::OutputStream=cutsub new {	my ($self, $filename) = @_;	$self = ref $self || $self;	open my $fh, '>', $filename		or die "$self cannot open $filename for writing: $!";	binmode $fh;	bless [ $fh, $filename ], $self;}sub DESTROY { CORE::close $_[0]->[0] }=head2 cloneClone this=cutsub clone {	my $orig  = shift;	my $clone = $orig->new($orig->[1]);	CORE::seek($clone->[0], CORE::tell($orig->[0]), 0);	return $clone;}=head2 fh / read / seek / tell / getc / print / eof / closeFile operations=cutuse Carp 'croak';sub fh    { croak "OutputStream fh called" }sub read  { croak "OutputStream read called" }sub seek  { CORE::seek $_[0]->[0], $_[1], $_[2] }sub tell  { CORE::tell $_[0]->[0] }sub getc  { croak "OutputStream getc called" }sub print { local $\; my $fh = shift->[0]; CORE::print $fh @_ }sub eof   { CORE::eof $_[0]->[0] }sub close { CORE::close $_[0]->[0] }=head2 write_byteThis will write a single byte.=cutsub write_byte {	local $\;	CORE::print { $_[0]->[0] } $_[1];}=head2 write_intThis will write an int as four bytes.=cutsub write_int {	local $\;	CORE::print { $_[0]->[0] } pack("N", $_[1]);}=head2 write_vintThis will write an int in a variable length format.=cutsub write_vint {	local $\;	use bytes;	my $i = $_[1];	my $txt;	while ($i & ~0x7f) {		$txt .= chr($i | 0x80);		$i >>= 7;	}	$txt .= chr($i);	CORE::print { $_[0]->[0] } $txt;}=head2 write_longThis will write a long as eight bytes.=cutsub write_long {	local $\;	CORE::print { $_[0]->[0] }		pack("NN", 0xffffffff & ($_[1] >> 32), 0xffffffff & $_[1]);}=head2 write_vlongThis will write a long in variable length format.=cut*write_vlong = *write_vint;=head2 write_stringThis will write a string.=cutsub write_string {	local $\;	my $s = $_[1];	$s = encode("utf8", $s) if $s =~ /[^\x00-\x7f]/;	$_[0]->write_vint(length $s);	CORE::print { $_[0]->[0] } $s;}1;

⌨️ 快捷键说明

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