[NO ISSUE] Polish String Util codes
Change-Id: Ice113810c5af052db144616e1374df759692c5b1
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/7364
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringPointable.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringPointable.java
index 21c8a36..828de18 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringPointable.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/main/java/org/apache/hyracks/data/std/primitive/UTF8StringPointable.java
@@ -316,7 +316,7 @@
if (resultInByte) {
return startMatchPos;
} else {
- if (prevHighSurrogate == true) {
+ if (prevHighSurrogate) {
throw new IllegalArgumentException(HIGH_SURROGATE_WITHOUT_LOW_SURROGATE);
}
return codePointCount;
@@ -329,7 +329,7 @@
if (Character.isHighSurrogate(ch)) {
prevHighSurrogate = true;
} else if (Character.isLowSurrogate(ch)) {
- if (prevHighSurrogate == true) {
+ if (prevHighSurrogate) {
codePointCount++;
prevHighSurrogate = false;
} else {
diff --git a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/test/java/org/apache/hyracks/data/std/primitive/UTF8StringPointableTest.java b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/test/java/org/apache/hyracks/data/std/primitive/UTF8StringPointableTest.java
index 8b62765..dcf9a10 100644
--- a/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/test/java/org/apache/hyracks/data/std/primitive/UTF8StringPointableTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-data/hyracks-data-std/src/test/java/org/apache/hyracks/data/std/primitive/UTF8StringPointableTest.java
@@ -72,9 +72,9 @@
UTF8StringPointable strp = generateUTF8Pointable(STRING_EMOJI_FAMILY_OF_4 + EMOJI_BASKETBALL);
UTF8StringPointable pattern = generateUTF8Pointable(EMOJI_BASKETBALL);
- assertEquals(UTF8StringPointable.findInCodePoint(strp, pattern, false), 7);
+ assertEquals(7, UTF8StringPointable.findInCodePoint(strp, pattern, false));
- assertEquals(UTF8StringPointable.findInCodePoint(strp, pattern, true), 7);
+ assertEquals(7, UTF8StringPointable.findInCodePoint(strp, pattern, true));
}
@Test
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
index d2cd050..d2dfc23 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/string/UTF8StringUtil.java
@@ -130,7 +130,7 @@
// Similar to the above codePointAt(),
// if c1 is the a high surrogate and also the last char in the byte array (that means the byte array is somehow illegal),
// then an exception will be thrown because there is no low surrogate available in the byte array
- s += charSize(b, s);
+ s += size1;
int size2 = charSize(b, s);
return size1 + size2;
}