rdblue commented on code in PR #8920:
URL: https://github.com/apache/iceberg/pull/8920#discussion_r1375308246


##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -839,11 +841,37 @@ private FileIO tableFileIO(SessionContext context, 
Map<String, String> config) {
   }
 
   private AuthSession tableSession(Map<String, String> tableConf, AuthSession 
parent) {
-    AuthSession session = newSession(tableConf, tableConf, parent);
+    String cacheKey = cacheKeyFromConf(tableConf);
+
+    if (null == cacheKey) {
+      return parent;
+    }
+
+    AuthSession session =
+        tableSessions.get(cacheKey, id -> newSession(tableConf, tableConf, 
parent));
 
     return session != null ? session : parent;
   }
 
+  private String cacheKeyFromConf(Map<String, String> tableConf) {
+    // this logic needs to be in-line with newSession(credentials, properties, 
parent)

Review Comment:
   Because of this, I think it makes more sense to rely on the same code. What 
about refactoring to extract a pair, which is the key that was found and the 
value? Then we can use that pair for caching and pass it into `newSession`.



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