You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/05/14 09:29:37 UTC

[GitHub] [hive] pvary commented on a change in pull request #2261: HIVE-25102: Cache Iceberg table objects within same query

pvary commented on a change in pull request #2261:
URL: https://github.com/apache/hive/pull/2261#discussion_r632404816



##########
File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/Catalogs.java
##########
@@ -284,4 +334,42 @@ 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 Logger LOG = LoggerFactory.getLogger(TableCache.class);
+
+    public static void removeTables(Configuration conf) {
+      String queryId = conf.get(HiveConf.ConfVars.HIVEQUERYID.varname);
+      if (queryId != null && !queryId.isEmpty()) {
+        Set<String> queryKeys = tableCache.asMap().keySet().stream()
+            .filter(k -> k.startsWith(queryId)).collect(Collectors.toSet());
+        tableCache.invalidateAll(queryKeys);
+      } else {
+        LOG.warn("Query id is not present in config, therefore no Iceberg table object is removed " +

Review comment:
       Is this really a `warn`? Do we expect at least one table it the cache every time?




-- 
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:
users@infra.apache.org



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