You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2021/08/30 09:27:41 UTC

[GitHub] [hadoop] 9uapaw commented on a change in pull request #3342: YARN-10897. Introduce QueuePath class

9uapaw commented on a change in pull request #3342:
URL: https://github.com/apache/hadoop/pull/3342#discussion_r698335050



##########
File path: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/QueuePath.java
##########
@@ -116,8 +121,79 @@ public boolean hasParent() {
     return parent != null;
   }
 
+  /**
+   * Creates a new {@code QueuePath} from the current full path as parent, and
+   * the appended child queue path as leaf.
+   * @param childQueue path of leaf queue
+   * @return new queue path made of current full path and appended leaf path
+   */
+  public QueuePath append(String childQueue) {
+    return new QueuePath(getFullPath(), childQueue);
+  }
+
+  /**
+   * Returns an iterator of queue path parts, starting from the highest level
+   * (generally root).
+   * @return queue part iterator
+   */
+  @Override
+  public Iterator<String> iterator() {
+    return Arrays.asList(getFullPath().split(QUEUE_REGEX_DELIMITER)).iterator();

Review comment:
       I agree that returning a pointer based on a temporary object/local variable is discouraged in non-GC languages, but it is completely safe to do so in Java (there are only some very intricate, JVM distribution specific methods that allow one to create a dangling pointer) as long as you are not returning a null explicitly.




-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org