szehon-ho commented on code in PR #59890:
URL: https://github.com/apache/spark/pull/59890#discussion_r4569534947


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala:
##########
@@ -634,26 +636,45 @@ class CacheManager extends Logging with 
AdaptiveSparkPlanHelper {
       fs: FileSystem,
       includeTimeTravel: Boolean): Unit = {
     val qualifiedPath = fs.makeQualified(resourcePath)
+    // recacheByCondition eagerly filters all entries before rebuilding any of 
them, so an
+    // index shared across entries needs refreshing only once during this 
call. Use object
+    // identity: equal root paths can have independent file-listing caches.
+    val refreshedIndexes = Collections.newSetFromMap(
+      new IdentityHashMap[FileIndex, java.lang.Boolean]())
     recacheByCondition(
       spark,
-      _.plan.exists(lookupAndRefresh(_, fs, qualifiedPath, includeTimeTravel)))
+      cached => {
+        var refreshed = false
+        // lookupAndRefresh has side effects: exists would stop after the 
first matching read.
+        // Refresh matching indexes in the operator tree before rebuilding a 
multi-read cache.
+        // As before, this traversal does not enter plans held by subquery 
expressions.

Review Comment:
   nit: let's remove comment bloat 'as before' serves no purpose as the code is 
gone



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