Class DataOutput
Abstract base class for performing write operations of Lucene's low-level data types.
DataOutput may only be used from one thread, because it is not thread safe (it keeps internal state like file position).Inheritance
Inherited Members
Namespace: Lucene.Net.Store
Assembly: Lucene.Net.dll
Syntax
public abstract class DataOutput
Methods
CopyBytes(DataInput, long)
Copy numBytes bytes from input to ourself.
Declaration
public virtual void CopyBytes(DataInput input, long numBytes)
Parameters
| Type | Name | Description |
|---|---|---|
| DataInput | input | |
| long | numBytes |
WriteByte(byte)
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.Declaration
public abstract void WriteByte(byte b)
Parameters
| Type | Name | Description |
|---|---|---|
| byte | b |
See Also
WriteBytes(byte[], int)
Writes an array of bytes.
Declaration
public virtual void WriteBytes(byte[] b, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | b | the bytes to write |
| int | length | the number of bytes to write |
See Also
WriteBytes(byte[], int, int)
Writes an array of bytes.
Declaration
public abstract void WriteBytes(byte[] b, int offset, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | b | the bytes to write |
| int | offset | the offset in the byte array |
| int | length | the number of bytes to write |
See Also
WriteInt16(short)
Writes a short as two bytes.
NOTE: this was writeShort() in LuceneDeclaration
public virtual void WriteInt16(short i)
Parameters
| Type | Name | Description |
|---|---|---|
| short | i |
See Also
WriteInt32(int)
Writes an int as four bytes.
32-bit unsigned integer written as four bytes, high-order bytes first. NOTE: this was writeInt() in LuceneDeclaration
public virtual void WriteInt32(int i)
Parameters
| Type | Name | Description |
|---|---|---|
| int | i |
See Also
WriteInt64(long)
Writes a long as eight bytes.
64-bit unsigned integer written as eight bytes, high-order bytes first. NOTE: this was writeLong() in LuceneDeclaration
public virtual void WriteInt64(long i)
Parameters
| Type | Name | Description |
|---|---|---|
| long | i |
See Also
WriteString(string)
Writes a string.
Writes strings as UTF-8 encoded bytes. First the length, in bytes, is written as a WriteVInt32(int), followed by the bytes.Declaration
public virtual void WriteString(string s)
Parameters
| Type | Name | Description |
|---|---|---|
| string | s |
See Also
WriteStringSet(ISet<string>)
Writes a string set.
First the size is written as an WriteInt32(int), followed by each value written as a WriteString(string).Declaration
public virtual void WriteStringSet(ISet<string> set)
Parameters
| Type | Name | Description |
|---|---|---|
| ISet<string> | set | Input ISet{string}. May be |
WriteStringStringMap(IDictionary<string, string>)
Writes a IDictionary{string,string}.
First the size is written as an WriteInt32(int), followed by each key-value pair written as two consecutive WriteString(string)s.Declaration
public virtual void WriteStringStringMap(IDictionary<string, string> map)
Parameters
| Type | Name | Description |
|---|---|---|
| IDictionary<string, string> | map | Input IDictionary{string,string}. May be |
WriteVInt32(int)
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.
NOTE: this was writeVInt() in LuceneDeclaration
public void WriteVInt32(int i)
Parameters
| Type | Name | Description |
|---|---|---|
| int | i | Smaller values take fewer bytes. Negative numbers are supported, but should be avoided. |
Exceptions
| Type | Condition |
|---|---|
| IOException | If there is an I/O error writing to the underlying medium. |
See Also
WriteVInt64(long)
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 WriteVInt32(int). NOTE: this was writeVLong() in LuceneDeclaration
public void WriteVInt64(long i)
Parameters
| Type | Name | Description |
|---|---|---|
| long | i |