Jackie-Jiang commented on code in PR #8786:
URL: https://github.com/apache/pinot/pull/8786#discussion_r884014858


##########
pinot-common/src/main/java/org/apache/pinot/common/utils/LLCSegmentName.java:
##########
@@ -59,6 +59,28 @@ public LLCSegmentName(String tableName, int 
partitionGroupId, int sequenceNumber
     _segmentName = tableName + SEPARATOR + partitionGroupId + SEPARATOR + 
sequenceNumber + SEPARATOR + _creationTime;
   }
 
+  private LLCSegmentName(String tableName, int partitionGroupId, int 
sequenceNumber, String creationTime,
+      String segmentName) {
+    _tableName = tableName;
+    _partitionGroupId = partitionGroupId;
+    _sequenceNumber = sequenceNumber;
+    _creationTime = creationTime;
+    _segmentName = segmentName;
+  }
+
+  /**
+   * Returns the {@link LLCSegmentName} for the given segment name, or {@code 
null} if the given segment name does not
+   * represent an LLC segment.
+   */
+  @Nullable
+  public static LLCSegmentName getLLCSegmentName(String segmentName) {
+    String[] parts = StringUtils.splitByWholeSeparator(segmentName, SEPARATOR);
+    if (parts.length != 4) {
+      return null;
+    }
+    return new LLCSegmentName(parts[0], Integer.parseInt(parts[1]), 
Integer.parseInt(parts[2]), parts[3], segmentName);

Review Comment:
   This method is added to avoid splitting the same string multiple times and 
creating extra garbage (it can avoid the extra check of segment name format 
before creating the `LLCSegmentName` object), so we need a new constructor 
without any extra processing.
   Changed the static method to `of()`



-- 
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]

Reply via email to