You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/03/22 19:51:23 UTC
[GitHub] [spark] attilapiros commented on a change in pull request #24178:
[SPARK-25196][SQL][FOLLOWUP] Add synchronized for
InMemoryRelation.statsOfPlanToCache
attilapiros commented on a change in pull request #24178: [SPARK-25196][SQL][FOLLOWUP] Add synchronized for InMemoryRelation.statsOfPlanToCache
URL: https://github.com/apache/spark/pull/24178#discussion_r268317291
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/CacheManager.scala
##########
@@ -163,12 +161,15 @@ class CacheManager extends Logging {
val relation = cachedData.cachedRepresentation
val (rowCount, newColStats) =
CommandUtils.computeColumnStats(sparkSession, relation, column)
- val oldStats = relation.statsOfPlanToCache
- val newStats = oldStats.copy(
- rowCount = Some(rowCount),
- attributeStats = AttributeMap((oldStats.attributeStats ++ newColStats).toSeq)
- )
- relation.statsOfPlanToCache = newStats
+
+ relation.synchronized {
Review comment:
I would move this logic into the class `InMemoryRelation`. Like:
```scala
def updateStats(rowCount: Long, newColStats: Map[Attribute, ColumnStat]): Unit = synchronized {
val newStats = statsOfPlanToCache.copy(
rowCount = Some(rowCount),
attributeStats = AttributeMap((statsOfPlanToCache.attributeStats ++ newColStats).toSeq)
)
statsOfPlanToCache = newStats
}
```
This way both the write and the `synchronized` is in the member function of the `InMemoryRelation` (I think it is bit more readable). What is your opinion?
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org