Fork me on GitHub
  • API

    Show / Hide Table of Contents

    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
    object
    DataOutput
    ByteArrayDataOutput
    IndexOutput
    OutputStreamDataOutput
    GrowableByteArrayDataOutput
    PagedBytes.PagedBytesDataOutput
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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
    ReadByte()

    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
    ReadBytes(byte[], int, int)

    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
    ReadBytes(byte[], int, int)

    WriteInt16(short)

    Writes a short as two bytes.

    NOTE: this was writeShort() in Lucene
    Declaration
    public virtual void WriteInt16(short i)
    Parameters
    Type Name Description
    short i
    See Also
    ReadInt16()

    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 Lucene
    Declaration
    public virtual void WriteInt32(int i)
    Parameters
    Type Name Description
    int i
    See Also
    ReadInt32()

    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 Lucene
    Declaration
    public virtual void WriteInt64(long i)
    Parameters
    Type Name Description
    long i
    See Also
    ReadInt64()

    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
    ReadString()

    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 null (equivalent to an empty set)

    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 null (equivalent to an empty dictionary)

    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

    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
    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
    ReadVInt32()

    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 Lucene
    Declaration
    public void WriteVInt64(long i)
    Parameters
    Type Name Description
    long i
    See Also
    ReadVInt64()
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.