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