Package org.postgresql.core
Class OptimizedUTF8Encoder
java.lang.Object
org.postgresql.core.Encoding
org.postgresql.core.OptimizedUTF8Encoder
- Direct Known Subclasses:
ByteOptimizedUTF8Encoder
,CharOptimizedUTF8Encoder
UTF-8 encoder implementation which validates values during decoding which is
significantly faster than using a
CharsetDecoder
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate char[]
private static final int
private static final int
private static final int
private static final int
private final int
(package private) static final Charset
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) String
charDecode
(byte[] encodedString, int offset, int length) Decodes binary content toString
by first converting tochar[]
.private static void
checkByte
(int ch, int pos, int len) private static void
checkMinimal
(int ch, int minValue) (package private) static String
decodeToChars
(byte[] data, int offset, int length, char[] chars, int out) Decodes data from offset with given length as utf-8 and gives each decoded code point to the codePointConsumer.(package private) char[]
getCharArray
(int size) Returns achar[]
to use for decoding.Methods inherited from class org.postgresql.core.Encoding
decode, decode, defaultEncoding, encode, getDatabaseEncoding, getDecodingReader, getEncodingWriter, getJVMEncoding, hasAsciiNumbers, name, toString
-
Field Details
-
UTF_8_CHARSET
-
MIN_2_BYTES
private static final int MIN_2_BYTES- See Also:
-
MIN_3_BYTES
private static final int MIN_3_BYTES- See Also:
-
MIN_4_BYTES
private static final int MIN_4_BYTES- See Also:
-
MAX_CODE_POINT
private static final int MAX_CODE_POINT- See Also:
-
thresholdSize
private final int thresholdSize- See Also:
-
decoderArray
private char[] decoderArray
-
-
Constructor Details
-
OptimizedUTF8Encoder
OptimizedUTF8Encoder()
-
-
Method Details
-
getCharArray
char[] getCharArray(int size) Returns achar[]
to use for decoding. Will use member variable if size is small enough. This method must be called, and returnedchar[]
only used, fromsynchronized
block.- Parameters:
size
- The needed size of returnedchar[]
.- Returns:
- A
char[]
at least as long as length.
-
charDecode
Decodes binary content toString
by first converting tochar[]
.- Throws:
IOException
-
decodeToChars
static String decodeToChars(byte[] data, int offset, int length, char[] chars, int out) throws IOException Decodes data from offset with given length as utf-8 and gives each decoded code point to the codePointConsumer.- Parameters:
data
- Thebyte[]
to decode.offset
- The starting index in data.length
- The number of bytes in data to decode.codePointConsumer
- The consumer of all decoded code points.- Throws:
IOException
- If data is not valid utf-8 content.
-
checkByte
- Throws:
IOException
-
checkMinimal
- Throws:
IOException
-