sajjad-moradi commented on code in PR #8786:
URL: https://github.com/apache/pinot/pull/8786#discussion_r884022458


##########
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:
   That's a valid point. Let's remove the duplicate code then. I suggest to 
modify private constructor to:
   ```java
   private LLCSegmentName(String tableName, int partitionGroupId, int 
sequenceNumber, String creationTime, bool validate) {
       String[] parts = StringUtils.splitByWholeSeparator(segmentName, 
SEPARATOR);
       if (validate) {
           Preconditions.checkArgument(parts.length == 4, "Invalid LLC segment 
name: %s", segmentName);
       }
       _tableName = parts[0];
       _partitionGroupId = Integer.parseInt(parts[1]);
       _sequenceNumber = Integer.parseInt(parts[2]);
       _creationTime = parts[3];
       _segmentName = segmentName;
   }
   ```
   Then in the main constructor calls this with true and in the static method 
it's called it with false.



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