liyafan82 commented on a change in pull request #8689: [FLINK-12802][table-runtime-blink] Reducing the Code of BinaryString URL: https://github.com/apache/flink/pull/8689#discussion_r295182445
########## File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryString.java ########## @@ -334,64 +326,10 @@ private int compareMultiSegments(BinaryString other) { return sizeInBytes - other.sizeInBytes; } - public static String safeToString(BinaryString str) { - if (str == null) { - return null; - } else { - return str.toString(); - } - } - - private boolean inFirstSegment() { - return sizeInBytes + offset <= segments[0].size(); - } - - - // ------------------------------------------------------------------------------------------ - // Utility methods on BinaryString - // ------------------------------------------------------------------------------------------ - - public BinaryString substringSQL(int pos) { - return substringSQL(pos, Integer.MAX_VALUE); - } - - public BinaryString substringSQL(int pos, int length) { - if (length < 0) { - return null; - } - ensureMaterialized(); - if (equals(EMPTY_UTF8)) { - return EMPTY_UTF8; - } - - int start; - int end; - int numChars = numChars(); - - if (pos > 0) { - start = pos - 1; - if (start >= numChars) { - return EMPTY_UTF8; - } - } else if (pos < 0) { - start = numChars + pos; - if (start < 0) { - return EMPTY_UTF8; - } - } else { - start = 0; - } - - if ((numChars - start) < length) { - end = numChars; - } else { - end = start + length; - } - return substring(start, end); - } - /** - * Returns a substring of this. + * Returns a substring of this. The substring begins with the code point at the specified + * index and extends to the end of this BinaryString. Review comment: According to the function signature. It does not extend to the end of the string. Instead, the end position is specified by the 'until' parameter. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services