dimas-b commented on code in PR #2170:
URL: https://github.com/apache/polaris/pull/2170#discussion_r2227050567


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisResolvedPathWrapper.java:
##########
@@ -77,6 +80,38 @@ public List<PolarisEntity> getRawParentPath() {
         .collect(Collectors.toList());
   }
 
+  /**
+   * Checks if a namespace is fully resolved.
+   *
+   * @param catalogName the name of the catalog
+   * @param namespace the namespace we're trying to resolve
+   * @return true if the namespace is considered fully resolved for the given 
catalog type
+   */
+  public boolean isFullyResolvedNamespace(
+      @Nonnull String catalogName, @Nonnull Namespace namespace) {
+    if (resolvedPath == null) {
+      return false;
+    }
+
+    List<PolarisEntity> fullPath = getRawFullPath();
+    int expectedPathLength = 1 + namespace.levels().length;
+    if (fullPath.size() != expectedPathLength) {
+      return false;
+    }
+
+    if (!fullPath.get(0).getName().equals(catalogName)) {
+      return false;
+    }
+
+    for (int i = 0; i < namespace.levels().length; i++) {
+      if (!fullPath.get(i + 1).getName().equals(namespace.levels()[i])

Review Comment:
   This may not be a big deal, but since we're always scanning this list from 
head to tail, using iterators might be more portable and easier to understand. 
Probably as efficient as `.get(N)` for array-based lists, but potentially more 
efficient for linked lists.
   
   It might be preferable to move `namespace.levels()` to a local variable. 
Iterate it in `for`, but do simple `iterator.next()` for `fullPath`.



-- 
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: issues-unsubscr...@polaris.apache.org

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

Reply via email to