C# Класс Lucene.Net.Codecs.CodecUtil

Utility class for reading and writing versioned headers.

Writing codec headers is useful to ensure that a file is in the format you think it is. @lucene.experimental

Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
FOOTER_MAGIC int

Открытые методы

Метод Описание
CheckEOF ( IndexInput @in ) : void

Checks that the stream is positioned at the end, and throws exception if it is not.

CheckFooter ( Lucene.Net.Store.ChecksumIndexInput @in ) : long

Validates the codec footer previously written by #writeFooter.

CheckHeader ( DataInput @in, string codec, int minVersion, int maxVersion ) : int

Reads and validates a header previously written with #writeHeader(DataOutput, String, int).

When reading a file, supply the expected codec and an expected version range (minVersion to maxVersion).

CheckHeaderNoMagic ( DataInput @in, string codec, int minVersion, int maxVersion ) : int

Like {@link #checkHeader(DataInput,String,int,int)} except this version assumes the first int has already been read and validated from the input.

ChecksumEntireFile ( IndexInput input ) : long

Clones the provided input, reads all bytes from the file, and calls #checkFooter

Note that this method may be slow, as it must process the entire file. If you just need to extract the checksum value, call #retrieveChecksum.

FooterLength ( ) : int

Computes the length of a codec footer.

HeaderLength ( string codec ) : int

Computes the length of a codec header.

RetrieveChecksum ( IndexInput @in ) : long

Returns (but does not validate) the checksum previously written by #checkFooter.

WriteFooter ( Lucene.Net.Store.IndexOutput @out ) : void

Writes a codec footer, which records both a checksum algorithm ID and a checksum. this footer can be parsed and validated with #checkFooter(ChecksumIndexInput) checkFooter().

CodecFooter --> Magic,AlgorithmID,Checksum

  • Magic --> DataOutput#writeInt Uint32. this identifies the start of the footer. It is always {@value #FOOTER_MAGIC}.
  • AlgorithmID --> DataOutput#writeInt Uint32. this indicates the checksum algorithm used. Currently this is always 0, for zlib-crc32.
  • Checksum --> DataOutput#writeLong Uint32. The actual checksum value for all previous bytes in the stream, including the bytes from Magic and AlgorithmID.

WriteHeader ( DataOutput @out, string codec, int version ) : void

Writes a codec header, which records both a string to identify the file and a version number. this header can be parsed and validated with #checkHeader(DataInput, String, int, int) checkHeader().

CodecHeader --> Magic,CodecName,Version

  • Magic --> DataOutput#writeInt Uint32. this identifies the start of the header. It is always {@value #CODEC_MAGIC}.
  • CodecName --> DataOutput#writeString String. this is a string to identify this file.
  • Version --> DataOutput#writeInt Uint32. Records the version of the file.

Note that the length of a codec header depends only upon the name of the codec, so this length can be computed at any time with #headerLength(String).

Приватные методы

Метод Описание
CodecUtil ( ) : Lucene.Net.Store
ValidateFooter ( IndexInput @in ) : void

Описание методов

CheckEOF() публичный статический Метод

Checks that the stream is positioned at the end, and throws exception if it is not.
public static CheckEOF ( IndexInput @in ) : void
@in Lucene.Net.Store.IndexInput
Результат void

CheckFooter() публичный статический Метод

Validates the codec footer previously written by #writeFooter.
if the footer is invalid, if the checksum does not match, /// or if {@code in} is not properly positioned before the footer /// at the end of the stream.
public static CheckFooter ( Lucene.Net.Store.ChecksumIndexInput @in ) : long
@in Lucene.Net.Store.ChecksumIndexInput
Результат long

CheckHeader() публичный статический Метод

Reads and validates a header previously written with #writeHeader(DataOutput, String, int).

When reading a file, supply the expected codec and an expected version range (minVersion to maxVersion).

If the first four bytes are not /// , or if the actual codec found is /// not codec. If the actual version is less /// than minVersion. If the actual version is greater /// than maxVersion. If there is an I/O error reading from the underlying medium.
public static CheckHeader ( DataInput @in, string codec, int minVersion, int maxVersion ) : int
@in Lucene.Net.Store.DataInput
codec string The expected codec name.
minVersion int The minimum supported expected version number.
maxVersion int The maximum supported expected version number.
Результат int

CheckHeaderNoMagic() публичный статический Метод

Like {@link #checkHeader(DataInput,String,int,int)} except this version assumes the first int has already been read and validated from the input.
public static CheckHeaderNoMagic ( DataInput @in, string codec, int minVersion, int maxVersion ) : int
@in Lucene.Net.Store.DataInput
codec string
minVersion int
maxVersion int
Результат int

ChecksumEntireFile() публичный статический Метод

Clones the provided input, reads all bytes from the file, and calls #checkFooter

Note that this method may be slow, as it must process the entire file. If you just need to extract the checksum value, call #retrieveChecksum.

public static ChecksumEntireFile ( IndexInput input ) : long
input Lucene.Net.Store.IndexInput
Результат long

FooterLength() публичный статический Метод

Computes the length of a codec footer.
public static FooterLength ( ) : int
Результат int

HeaderLength() публичный статический Метод

Computes the length of a codec header.
public static HeaderLength ( string codec ) : int
codec string Codec name.
Результат int

RetrieveChecksum() публичный статический Метод

Returns (but does not validate) the checksum previously written by #checkFooter.
if the footer is invalid
public static RetrieveChecksum ( IndexInput @in ) : long
@in Lucene.Net.Store.IndexInput
Результат long

WriteFooter() публичный статический Метод

Writes a codec footer, which records both a checksum algorithm ID and a checksum. this footer can be parsed and validated with #checkFooter(ChecksumIndexInput) checkFooter().

CodecFooter --> Magic,AlgorithmID,Checksum

  • Magic --> DataOutput#writeInt Uint32. this identifies the start of the footer. It is always {@value #FOOTER_MAGIC}.
  • AlgorithmID --> DataOutput#writeInt Uint32. this indicates the checksum algorithm used. Currently this is always 0, for zlib-crc32.
  • Checksum --> DataOutput#writeLong Uint32. The actual checksum value for all previous bytes in the stream, including the bytes from Magic and AlgorithmID.
If there is an I/O error writing to the underlying medium.
public static WriteFooter ( Lucene.Net.Store.IndexOutput @out ) : void
@out Lucene.Net.Store.IndexOutput
Результат void

WriteHeader() публичный статический Метод

Writes a codec header, which records both a string to identify the file and a version number. this header can be parsed and validated with #checkHeader(DataInput, String, int, int) checkHeader().

CodecHeader --> Magic,CodecName,Version

  • Magic --> DataOutput#writeInt Uint32. this identifies the start of the header. It is always {@value #CODEC_MAGIC}.
  • CodecName --> DataOutput#writeString String. this is a string to identify this file.
  • Version --> DataOutput#writeInt Uint32. Records the version of the file.

Note that the length of a codec header depends only upon the name of the codec, so this length can be computed at any time with #headerLength(String).

If there is an I/O error writing to the underlying medium.
public static WriteHeader ( DataOutput @out, string codec, int version ) : void
@out Lucene.Net.Store.DataOutput
codec string String to identify this file. It should be simple ASCII, /// less than 128 characters in length.
version int Version number
Результат void

Описание свойств

FOOTER_MAGIC публичное статическое свойство

Constant to identify the start of a codec footer.
public static int FOOTER_MAGIC
Результат int