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.
Inherited Members
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 |
int | inputLength | Number of chars in |
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 |
int | inputLength | Number of chars in |
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 |
int | inputLength | Number of bytes in |
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 |
int | inputLength | Number of bytes in |
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 |
int | inputLength | Number of bytes in |
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 |
int | inputLength | Number of sbytes in |
Returns
Type | Description |
---|---|
int | The number of chars required to encode the number of sbytes. |