jdere commented on a change in pull request #582: Hive 21386: Extend the fetch 
task enhancement done in HIVE-21279 to make it work with query result cache
URL: https://github.com/apache/hive/pull/582#discussion_r270973907
 
 

 ##########
 File path: ql/src/java/org/apache/hadoop/hive/ql/Context.java
 ##########
 @@ -625,17 +637,43 @@ private Path getExternalScratchDir(URI extURI) {
     return getStagingDir(new Path(extURI.getScheme(), extURI.getAuthority(), 
extURI.getPath()), !isExplainSkipExecution());
   }
 
+  /**
+   * Remove any created scratch directories.
+   */
+  public void removeResultCacheDir() {
+    if(this.fsResultCacheDirs != null) {
+      try {
+        Path p = this.fsResultCacheDirs;
+        FileSystem fs = p.getFileSystem(conf);
+        LOG.debug("Deleting result cache dir: {}", p);
+        fs.delete(p, true);
+        fs.cancelDeleteOnExit(p);
+      } catch (Exception e) {
+        LOG.warn("Error Removing result cache dir: "
+                     + StringUtils.stringifyException(e));
+      }
+    }
+  }
+
   /**
    * Remove any created scratch directories.
    */
   public void removeScratchDir() {
+    String resultCacheDir = null;
+    if(this.fsResultCacheDirs != null) {
+      resultCacheDir = this.fsResultCacheDirs.toUri().getPath();
+    }
     for (Map.Entry<String, Path> entry : fsScratchDirs.entrySet()) {
       try {
         Path p = entry.getValue();
+        if(resultCacheDir == null || 
!p.toUri().getPath().contains(resultCacheDir)) {
 
 Review comment:
   One example which I believe I have seen:
   
   fsScratchDirs = [ /base/scratchdir/path ]
   resultCacheDir = [ /base/scratchdir/path/with/resultcache/ ]
   
   The result of this logic change will be that /base/scratchdir/path/ goes 
undeleted. With resultCacheDir eventually being deleted later. One question, is 
there any additional data in /base/scratchdir/path/ besides just the final 
query result, such as other temporary data generated by the query? If so, this 
additional data, in addition to the /base/scratchdir/path/ directory itself 
(empty or not) will be left around.

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


With regards,
Apache Git Services

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

Reply via email to