Class StringUtf8Utils
- java.lang.Object
-
- org.apache.flink.cdc.common.utils.StringUtf8Utils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]allocateReuseBytes(int length)Allocate bytes that is only for temporary usage, it should not be stored in somewhere else.static char[]allocateReuseChars(int length)static StringdecodeUTF8(byte[] input, int offset, int byteLen)static intdecodeUTF8Strict(byte[] sa, int sp, int len, char[] da)static StringdefaultDecodeUTF8(byte[] bytes, int offset, int len)static intdefaultEncodeUTF8(String str, byte[] bytes)static byte[]encodeUTF8(String str)This method must have the same result with JDK's String.getBytes.static intencodeUTF8(String str, byte[] bytes)
-
-
-
Method Detail
-
encodeUTF8
public static byte[] encodeUTF8(String str)
This method must have the same result with JDK's String.getBytes.
-
encodeUTF8
public static int encodeUTF8(String str, byte[] bytes)
-
defaultEncodeUTF8
public static int defaultEncodeUTF8(String str, byte[] bytes)
-
decodeUTF8
public static String decodeUTF8(byte[] input, int offset, int byteLen)
-
decodeUTF8Strict
public static int decodeUTF8Strict(byte[] sa, int sp, int len, char[] da)
-
defaultDecodeUTF8
public static String defaultDecodeUTF8(byte[] bytes, int offset, int len)
-
allocateReuseBytes
public static byte[] allocateReuseBytes(int length)
Allocate bytes that is only for temporary usage, it should not be stored in somewhere else. Use aThreadLocalto reuse bytes to avoid overhead of byte[] new and gc.If there are methods that can only accept a byte[], instead of a MemorySegment[] parameter, we can allocate a reuse bytes and copy the MemorySegment data to byte[], then call the method. Such as String deserialization.
-
allocateReuseChars
public static char[] allocateReuseChars(int length)
-
-