C# Class Lucene.Net.Store.DataOutput

Abstract base class for performing write operations of Lucene's low-level data types.

{@code DataOutput} may only be used from one thread, because it is not thread safe (it keeps internal state like file position).

Mostrar archivo Open project: apache/lucenenet Class Usage Examples

Public Methods

Method Description
CopyBytes ( DataInput input, long numBytes ) : void

Copy numBytes bytes from input to ourself.

Write ( byte b, int off, int len ) : void
WriteByte ( byte b ) : void

Writes a single byte.

The most primitive data type is an eight-bit byte. Files are accessed as sequences of bytes. All other data types are defined as sequences of bytes, so file formats are byte-order independent.

WriteBytes ( byte b, int length ) : void
WriteBytes ( byte b, int offset, int length ) : void

Writes an array of bytes.

WriteInt ( int i ) : void

Writes an int as four bytes.

32-bit unsigned integer written as four bytes, high-order bytes first.

WriteLong ( long i ) : void

Writes a long as eight bytes.

64-bit unsigned integer written as eight bytes, high-order bytes first.

WriteShort ( short i ) : void

Writes a short as two bytes.

WriteString ( string s ) : void

Writes a string.

Writes strings as UTF-8 encoded bytes. First the length, in bytes, is written as a #writeVInt VInt, followed by the bytes.

WriteStringSet ( ISet set ) : void

Writes a String set.

First the size is written as an #writeInt(int) Int32, followed by each value written as a #writeString(String) String.

WriteStringStringMap ( string>.IDictionary map ) : void

Writes a String map.

First the size is written as an #writeInt(int) Int32, followed by each key-value pair written as two consecutive #writeString(String) Strings.

WriteVInt ( int i ) : void

Writes an int in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers are supported, but should be avoided.

VByte is a variable-length format for positive integers is defined where the high-order bit of each byte indicates whether more bytes remain to be read. The low-order seven bits are appended as increasingly more significant bits in the resulting integer value. Thus values from zero to 127 may be stored in a single byte, values from 128 to 16,383 may be stored in two bytes, and so on.

VByte Encoding Example

Value Byte 1 Byte 2 Byte 3
0 00000000
1 00000001
2 00000010
...
127 01111111
128 10000000 00000001
129 10000001 00000001
130 10000010 00000001
...
16,383 11111111 01111111
16,384 10000000 10000000 00000001
16,385 10000001 10000000 00000001
...

this provides compression while still being efficient to decode.

WriteVLong ( long i ) : void

Writes an long in a variable-length format. Writes between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.

The format is described further in DataOutput#writeVInt(int).

Method Details

CopyBytes() public method

Copy numBytes bytes from input to ourself.
public CopyBytes ( DataInput input, long numBytes ) : void
input DataInput
numBytes long
return void

Write() public method

public Write ( byte b, int off, int len ) : void
b byte
off int
len int
return void

WriteByte() public abstract method

Writes a single byte.

The most primitive data type is an eight-bit byte. Files are accessed as sequences of bytes. All other data types are defined as sequences of bytes, so file formats are byte-order independent.

public abstract WriteByte ( byte b ) : void
b byte
return void

WriteBytes() public method

public WriteBytes ( byte b, int length ) : void
b byte
length int
return void

WriteBytes() public abstract method

Writes an array of bytes.
public abstract WriteBytes ( byte b, int offset, int length ) : void
b byte the bytes to write
offset int the offset in the byte array
length int the number of bytes to write
return void

WriteInt() public method

Writes an int as four bytes.

32-bit unsigned integer written as four bytes, high-order bytes first.

public WriteInt ( int i ) : void
i int
return void

WriteLong() public method

Writes a long as eight bytes.

64-bit unsigned integer written as eight bytes, high-order bytes first.

public WriteLong ( long i ) : void
i long
return void

WriteShort() public method

Writes a short as two bytes.
public WriteShort ( short i ) : void
i short
return void

WriteString() public method

Writes a string.

Writes strings as UTF-8 encoded bytes. First the length, in bytes, is written as a #writeVInt VInt, followed by the bytes.

public WriteString ( string s ) : void
s string
return void

WriteStringSet() public method

Writes a String set.

First the size is written as an #writeInt(int) Int32, followed by each value written as a #writeString(String) String.

public WriteStringSet ( ISet set ) : void
set ISet Input set. May be null (equivalent to an empty set)
return void

WriteStringStringMap() public method

Writes a String map.

First the size is written as an #writeInt(int) Int32, followed by each key-value pair written as two consecutive #writeString(String) Strings.

public WriteStringStringMap ( string>.IDictionary map ) : void
map string>.IDictionary Input map. May be null (equivalent to an empty map)
return void

WriteVInt() public method

Writes an int in a variable-length format. Writes between one and five bytes. Smaller values take fewer bytes. Negative numbers are supported, but should be avoided.

VByte is a variable-length format for positive integers is defined where the high-order bit of each byte indicates whether more bytes remain to be read. The low-order seven bits are appended as increasingly more significant bits in the resulting integer value. Thus values from zero to 127 may be stored in a single byte, values from 128 to 16,383 may be stored in two bytes, and so on.

VByte Encoding Example

Value Byte 1 Byte 2 Byte 3
0 00000000
1 00000001
2 00000010
...
127 01111111
128 10000000 00000001
129 10000001 00000001
130 10000010 00000001
...
16,383 11111111 01111111
16,384 10000000 10000000 00000001
16,385 10000001 10000000 00000001
...

this provides compression while still being efficient to decode.

If there is an I/O error writing to the underlying medium.
public WriteVInt ( int i ) : void
i int Smaller values take fewer bytes. Negative numbers are /// supported, but should be avoided.
return void

WriteVLong() public method

Writes an long in a variable-length format. Writes between one and nine bytes. Smaller values take fewer bytes. Negative numbers are not supported.

The format is described further in DataOutput#writeVInt(int).

public WriteVLong ( long i ) : void
i long
return void