Github user chhao01 commented on a diff in the pull request:
https://github.com/apache/spark/pull/8023#discussion_r37488201
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala ---
@@ -156,10 +165,27 @@ private[sql] class CacheManager(sqlContext:
SQLContext) extends Logging {
* function will over invalidate.
*/
private[sql] def invalidateCache(plan: LogicalPlan): Unit = writeLock {
- cachedData.foreach {
- case data if data.plan.collect { case p if p.sameResult(plan) => p
}.nonEmpty =>
- data.cachedRepresentation.recache()
- case _ =>
+ var i = 0
+ var locatedIdx = -1
+ // find the index of the cached data, according to the specified
logical plan
+ while (i < cachedData.length && locatedIdx < 0) {
+ cachedData(i) match {
+ case data if data.plan.collect { case p if p.sameResult(plan) => p
}.nonEmpty =>
+ locatedIdx = i
+ case _ =>
+ }
+ i += 1
+ }
+
+ if (locatedIdx >= 0) {
+ // if the cached data exists, remove it from the cache data list, as
we need to
+ // re-generate the spark plan, and we don't want the this to be used
during the
+ // re-generation
+ val entry = cachedData.remove(locatedIdx) // TODO do we have to use
ArrayBuffer?
+ // rebuild the cache
+ entry.recache(sqlContext)
+ // add it back to the cache data list
+ cachedData += entry
--- End diff --
And probably we can not simply use the `data.plan.find`, as the cached data
most likely will add wrapper like `LogicalPlan` etc.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]