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
| Improve this Doc View SourceCopyBytes(DataInput, Int64)
Copy numBytes bytes from input to ourself.
Declaration
public virtual void CopyBytes(DataInput input, long numBytes)
Parameters
Type | Name | Description |
---|---|---|
DataInput | input | |
System.Int64 | 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 |
---|---|---|
System.Byte | b |
See Also
WriteBytes(Byte[], Int32)
Writes an array of bytes.
Declaration
public virtual void WriteBytes(byte[] b, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | b | the bytes to write |
System.Int32 | length | the number of bytes to write |
See Also
WriteBytes(Byte[], Int32, Int32)
Writes an array of bytes.
Declaration
public abstract void WriteBytes(byte[] b, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | b | the bytes to write |
System.Int32 | offset | the offset in the byte array |
System.Int32 | length | the number of bytes to write |
See Also
WriteInt16(Int16)
Writes a short as two bytes.
NOTE: this was writeShort() in Lucene
Declaration
public virtual void WriteInt16(short i)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | i |
See Also
| Improve this Doc View SourceWriteInt32(Int32)
Writes an System.Int32 as four bytes.
32-bit unsigned integer written as four bytes, high-order bytes first.
NOTE: this was writeInt() in Lucene
Declaration
public virtual void WriteInt32(int i)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i |
See Also
| Improve this Doc View SourceWriteInt64(Int64)
Writes a System.Int64 as eight bytes.
64-bit unsigned integer written as eight bytes, high-order bytes first.
NOTE: this was writeLong() in Lucene
Declaration
public virtual void WriteInt64(long i)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | i |
See Also
| Improve this Doc View SourceWriteString(String)
Writes a string.
Writes strings as UTF-8 encoded bytes. First the length, in bytes, is written as a WriteVInt32(Int32), followed by the bytes.
Declaration
public virtual void WriteString(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s |
See Also
| Improve this Doc View SourceWriteStringSet(ISet<String>)
Writes a System.String set.
First the size is written as an WriteInt32(Int32), followed by each value written as a WriteString(String).
Declaration
public virtual void WriteStringSet(ISet<string> set)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.ISet<System.String> | set | Input ISet{string}. May be |
WriteStringStringMap(IDictionary<String, String>)
Writes a
First the size is written as an WriteInt32(Int32), 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 |
---|---|---|
System.Collections.Generic.IDictionary<System.String, System.String> | map | Input |
WriteVInt32(Int32)
Writes an System.Int32 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
ValueByte 1Byte 2Byte 3 | |
---|---|
000000000 | |
100000001 | |
200000010 | |
... | |
12701111111 | |
1281000000000000001 | |
1291000000100000001 | |
1301000001000000001 | |
... | |
16,3831111111101111111 | |
16,384100000001000000000000001 | |
16,385100000011000000000000001 | |
... |
this provides compression while still being efficient to decode.
NOTE: this was writeVInt() in Lucene
Declaration
public void WriteVInt32(int i)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i | Smaller values take fewer bytes. Negative numbers are supported, but should be avoided. |
Exceptions
Type | Condition |
---|---|
System.IO.IOException | If there is an I/O error writing to the underlying medium. |
See Also
| Improve this Doc View SourceWriteVInt64(Int64)
Writes an System.Int64 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(Int32).
NOTE: this was writeVLong() in Lucene
Declaration
public void WriteVInt64(long i)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | i |