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_r294619334
##########
File path:
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryString.java
##########
@@ -569,42 +427,28 @@ public boolean startsWith(final BinaryString prefix) {
}
/**
- * Same to like '%suffix'.
+ * Tests if this BinaryString ends with the specified suffix.
+ *
+ * @param suffix the suffix.
+ * @return {@code true} if the bytes represented by the argument is a
suffix of the bytes
+ * represented by this object; {@code false} otherwise. Note
that the result will
+ * be {@code true} if the argument is the empty string or is
equal to this
+ * {@code BinaryString} object as determined by the {@link
#equals(Object)} method.
*/
public boolean endsWith(final BinaryString suffix) {
ensureMaterialized();
suffix.ensureMaterialized();
return matchAt(suffix, sizeInBytes - suffix.sizeInBytes);
}
- private boolean matchAt(final BinaryString s, int pos) {
- return (inFirstSegment() && s.inFirstSegment()) ?
matchAtOneSeg(s, pos) : matchAtVarSeg(s, pos);
- }
-
- private boolean matchAtOneSeg(final BinaryString s, int pos) {
- return s.sizeInBytes + pos <= sizeInBytes && pos >= 0 &&
- segments[0].equalTo(s.segments[0], offset + pos,
s.offset, s.sizeInBytes);
- }
-
- private boolean matchAtVarSeg(final BinaryString s, int pos) {
- return s.sizeInBytes + pos <= sizeInBytes && pos >= 0 &&
- SegmentsUtil.equals(segments, offset + pos, s.segments,
s.offset, s.sizeInBytes);
- }
-
- private BinaryString copyBinaryStringInOneSeg(int start, int end) {
- int len = end - start + 1;
- byte[] newBytes = new byte[len];
- segments[0].get(offset + start, newBytes, 0, len);
- return fromBytes(newBytes);
- }
-
- private BinaryString copyBinaryString(int start, int end) {
- int len = end - start + 1;
- byte[] newBytes = new byte[len];
- SegmentsUtil.copyToBytes(segments, offset + start, newBytes, 0,
len);
- return fromBytes(newBytes);
- }
-
+ /**
+ * Returns a string whose value is this string, with any leading and
trailing
+ * whitespace removed.
+ *
+ * @return A string whose value is this string, with any leading and
trailing white
+ * space removed, or this string if it has no leading or
Review comment:
or as it is if ...
----------------------------------------------------------------
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