marton-bod commented on a change in pull request #2261:
URL: https://github.com/apache/hive/pull/2261#discussion_r630915112



##########
File path: 
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/Catalogs.java
##########
@@ -284,4 +333,40 @@ private static String getCatalogType(Configuration conf, 
String catalogName) {
       }
     }
   }
+
+  public static class TableCache {
+    private static final Cache<String, Table> tableCache = 
Caffeine.newBuilder()
+        .expireAfterAccess(12, TimeUnit.HOURS).build();
+    private static final Set<String> keys = new TreeSet<>();
+
+    public static void removeTable(Configuration conf) {
+      String queryId = conf.get(HiveConf.ConfVars.HIVEQUERYID.varname);
+      if (queryId != null && !queryId.isEmpty()) {
+        Set<String> queryKeys = keys.stream().filter(k -> 
k.startsWith(queryId)).collect(Collectors.toSet());
+        tableCache.invalidateAll(queryKeys);
+        keys.removeAll(queryKeys);
+      }

Review comment:
       shall we add an else branch here with some warn logging? It might be a 
problem here worth noting if the query id is not present in the config, because 
that will cause cache pollution over time. In the other methods, if the query 
id is not present we just reload the table, so that's not as big of a deal




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to