nebojsa-db commented on code in PR #45963:
URL: https://github.com/apache/spark/pull/45963#discussion_r1599656074
##########
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java:
##########
@@ -1509,12 +1515,62 @@ public boolean semanticEquals(final UTF8String other,
int collationId) {
return
CollationFactory.fetchCollation(collationId).equalsFunction.apply(this, other);
}
+ private interface SubstringEquals {
+ boolean equals(UTF8String left, UTF8String right, int posLeft, int
posRight,
+ int lenLeft, int lenRight);
+ }
+
+ private static class ByteSubstringEquals implements SubstringEquals {
+ @Override
+ public boolean equals(UTF8String left, UTF8String right, int posLeft, int
posRight,
+ int lenLeft, int lenRight) {
+ if (lenLeft != lenRight || left.getByte(posLeft) !=
right.getByte(posRight)) {
+ return false;
+ }
+ return (ByteArrayMethods.arrayEquals(left.base, left.offset + posLeft,
right.base,
+ right.offset + posRight, lenLeft));
+ }
+ }
+
+ private static final ByteSubstringEquals byteSubstringEquals = new
ByteSubstringEquals();
+
+ private static class CollationSubstringEquals implements SubstringEquals {
+ private final int collationId;
+ private final UTF8String left, right;
+
+ CollationSubstringEquals(int collationId) {
+ this.collationId = collationId;
+ this.left = new UTF8String();
+ this.right = new UTF8String();
+ }
+
+ @Override
+ public boolean equals(UTF8String left, UTF8String right, int posLeft, int
posRight,
+ int lenLeft, int lenRight) {
+ moveAddress(this.left, left.base, left.offset + posLeft, lenLeft);
Review Comment:
Done, in addition with baseString which is also needed.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]