JingsongLi commented on a change in pull request #8029: [FLINK-11898] [table-planner-blink] Support code generation for all Blink built-in functions and operators URL: https://github.com/apache/flink/pull/8029#discussion_r268527363
########## File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/util/StringUtf8Utils.java ########## @@ -0,0 +1,342 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.runtime.util; + +import org.apache.flink.core.memory.MemorySegment; + +import java.io.UnsupportedEncodingException; +import java.util.Arrays; + +/** + * String utf-8 utils. + * + * <p>{@code StringUtf8Utils} refers to the implementation from SerializeWriter and IOUtils of Alibaba fastjson. + * The difference is that StringUtf8Utils need to handle the wrong code, just like StringCoding.decode. + */ +public class StringUtf8Utils { + + private static final int MAX_CHARS_LENGTH = 1024 * 32; + private static final int MAX_BYTES_LENGTH = 1024 * 64; + public static final int MAX_BYTES_PER_CHAR = 3; + + private static final ThreadLocal<char[]> CHARS_LOCAL = new ThreadLocal<>(); + private static final ThreadLocal<byte[]> BYTES_LOCAL = new ThreadLocal<>(); + + public static char[] allocateChars(int length) { Review comment: Move allocateChars and allocateBytes(allocateReuseBytes existed) to SegmentsUtil ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
