Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class IndexableBinaryStringTools

    Provides support for converting byte sequences to strings and back again. The resulting strings preserve the original byte sequences' sort order.

    The strings are constructed using a Base 8000h encoding of the original binary data - each char of an encoded string represents a 15-bit chunk from the byte sequence. Base 8000h was chosen because it allows for all lower 15 bits of char to be used without restriction; the surrogate range [U+D8000-U+DFFF] does not represent valid chars, and would require complicated handling to avoid them and allow use of char's high bit.

    Although unset bits are used as padding in the final char, the original byte sequence could contain trailing bytes with no set bits (null bytes): padding is indistinguishable from valid information. To overcome this problem, a char is appended, indicating the number of encoded bytes in the final content char.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Inheritance
    object
    IndexableBinaryStringTools
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.dll
    Syntax
    [Obsolete("Implement Analysis.TokenAttributes.ITermToBytesRefAttribute and store bytes directly instead. this class will be removed in Lucene 5.0")]
    public static class IndexableBinaryStringTools

    Methods

    Decode(char[], int, int, byte[], int, int)

    Decodes the input char sequence into the output byte sequence. Before calling this method, ensure that the output array has sufficient capacity by calling GetDecodedLength(char[], int, int).

    Declaration
    public static void Decode(char[] inputArray, int inputOffset, int inputLength, byte[] outputArray, int outputOffset, int outputLength)
    Parameters
    Type Name Description
    char[] inputArray

    char sequence to be decoded

    int inputOffset

    Initial offset into inputArray

    int inputLength

    Number of chars in inputArray

    byte[] outputArray

    byte sequence to store encoded result

    int outputOffset

    Initial offset into outputArray

    int outputLength

    Length of output, must be GetDecodedLength(inputArray, inputOffset, inputLength)

    Decode(char[], int, int, sbyte[], int, int)

    Decodes the input char sequence into the output sbyte sequence. Before calling this method, ensure that the output array has sufficient capacity by calling GetDecodedLength(char[], int, int).

    Declaration
    [CLSCompliant(false)]
    public static void Decode(char[] inputArray, int inputOffset, int inputLength, sbyte[] outputArray, int outputOffset, int outputLength)
    Parameters
    Type Name Description
    char[] inputArray

    char sequence to be decoded

    int inputOffset

    Initial offset into inputArray

    int inputLength

    Number of chars in inputArray

    sbyte[] outputArray

    byte sequence to store encoded result

    int outputOffset

    Initial offset into outputArray

    int outputLength

    Length of output, must be GetDecodedLength(inputArray, inputOffset, inputLength)

    Encode(byte[], int, int, char[], int, int)

    Encodes the input byte sequence into the output char sequence. Before calling this method, ensure that the output array has sufficient capacity by calling GetEncodedLength(byte[], int, int).

    Declaration
    public static void Encode(byte[] inputArray, int inputOffset, int inputLength, char[] outputArray, int outputOffset, int outputLength)
    Parameters
    Type Name Description
    byte[] inputArray

    byte sequence to be encoded

    int inputOffset

    Initial offset into inputArray

    int inputLength

    Number of bytes in inputArray

    char[] outputArray

    char sequence to store encoded result

    int outputOffset

    Initial offset into outputArray

    int outputLength

    Length of output, must be GetEncodedLength(inputArray, inputOffset, inputLength)

    Encode(sbyte[], int, int, char[], int, int)

    Encodes the input sbyte sequence into the output char sequence. Before calling this method, ensure that the output array has sufficient capacity by calling GetEncodedLength(sbyte[], int, int).

    Declaration
    [CLSCompliant(false)]
    public static void Encode(sbyte[] inputArray, int inputOffset, int inputLength, char[] outputArray, int outputOffset, int outputLength)
    Parameters
    Type Name Description
    sbyte[] inputArray

    sbyte sequence to be encoded

    int inputOffset

    Initial offset into inputArray

    int inputLength

    Number of bytes in inputArray

    char[] outputArray

    char sequence to store encoded result

    int outputOffset

    Initial offset into outputArray

    int outputLength

    Length of output, must be getEncodedLength

    GetDecodedLength(char[], int, int)

    Returns the number of bytes required to decode the given char sequence.

    Declaration
    public static int GetDecodedLength(char[] encoded, int offset, int length)
    Parameters
    Type Name Description
    char[] encoded

    Char sequence to be decoded

    int offset

    Initial offset

    int length

    Number of characters

    Returns
    Type Description
    int

    The number of bytes required to decode the given char sequence

    GetEncodedLength(byte[], int, int)

    Returns the number of chars required to encode the given bytes.

    Declaration
    public static int GetEncodedLength(byte[] inputArray, int inputOffset, int inputLength)
    Parameters
    Type Name Description
    byte[] inputArray

    Byte sequence to be encoded

    int inputOffset

    Initial offset into inputArray

    int inputLength

    Number of bytes in inputArray

    Returns
    Type Description
    int

    The number of chars required to encode the number of bytes.

    GetEncodedLength(sbyte[], int, int)

    Returns the number of chars required to encode the given sbytes.

    Declaration
    [CLSCompliant(false)]
    public static int GetEncodedLength(sbyte[] inputArray, int inputOffset, int inputLength)
    Parameters
    Type Name Description
    sbyte[] inputArray

    sbyte sequence to be encoded

    int inputOffset

    Initial offset into inputArray

    int inputLength

    Number of sbytes in inputArray

    Returns
    Type Description
    int

    The number of chars required to encode the number of sbytes.

    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.