FMX commented on code in PR #3825:
URL: https://github.com/apache/celeborn/pull/3825#discussion_r3853636464
##########
common/src/main/java/org/apache/celeborn/common/protocol/PartitionLocation.java:
##########
@@ -243,32 +229,93 @@ public String getUniqueId() {
return id + "-" + epoch;
}
+ public long getUniqueIdLong() {
+ return toUniqueIdLong(id, epoch);
+ }
+
+ public static long toUniqueIdLong(int id, int epoch) {
+ return ((long) id << 32) | (epoch & 0xffffffffL);
+ }
+
+ public static long toUniqueIdLong(String uniqueId) {
+ Long packedUniqueId = tryToUniqueIdLong(uniqueId);
+ if (packedUniqueId == null) {
+ throw new IllegalArgumentException("Invalid partition location unique
id: " + uniqueId);
+ }
+ return packedUniqueId;
+ }
+
+ public static Long tryToUniqueIdLong(String uniqueId) {
+ if (uniqueId == null || uniqueId.length() < 3) {
+ return null;
+ }
+ int idStart = uniqueId.charAt(0) == '-' ? 1 : 0;
+ int separatorIndex = uniqueId.indexOf('-', idStart);
+ if (separatorIndex < 0) {
+ return null;
+ }
+ long id = tryParseInt(uniqueId, 0, separatorIndex);
+ long epoch = tryParseInt(uniqueId, separatorIndex + 1, uniqueId.length());
+ if (id == INVALID_PARSED_INT || epoch == INVALID_PARSED_INT) {
+ return null;
+ }
+ return toUniqueIdLong((int) id, (int) epoch);
+ }
Review Comment:
I'll remove unused methods.
--
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]