You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by rx...@apache.org on 2017/01/11 22:25:40 UTC
spark git commit: [SPARK-19149][SQL] Follow-up: simplify cache
implementation.
Repository: spark
Updated Branches:
refs/heads/master 30a07071f -> 66fe819ad
[SPARK-19149][SQL] Follow-up: simplify cache implementation.
## What changes were proposed in this pull request?
This patch simplifies slightly the logical plan statistics cache implementation, as discussed in https://github.com/apache/spark/pull/16529
## How was this patch tested?
N/A - this has no behavior change.
Author: Reynold Xin <rx...@databricks.com>
Closes #16544 from rxin/SPARK-19149.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/66fe819a
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/66fe819a
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/66fe819a
Branch: refs/heads/master
Commit: 66fe819ada6435f3a351c2d257e73b8e6f6085cd
Parents: 30a0707
Author: Reynold Xin <rx...@databricks.com>
Authored: Wed Jan 11 14:25:36 2017 -0800
Committer: Reynold Xin <rx...@databricks.com>
Committed: Wed Jan 11 14:25:36 2017 -0800
----------------------------------------------------------------------
.../catalyst/plans/logical/LogicalPlan.scala | 21 ++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/66fe819a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
index 9e5ba9c..0587a59 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
@@ -82,17 +82,22 @@ abstract class LogicalPlan extends QueryPlan[LogicalPlan] with Logging {
}
/** A cache for the estimated statistics, such that it will only be computed once. */
- private val statsCache = new ThreadLocal[Option[Statistics]] {
- override protected def initialValue: Option[Statistics] = None
- }
+ private var statsCache: Option[Statistics] = None
- def stats(conf: CatalystConf): Statistics = statsCache.get.getOrElse {
- statsCache.set(Some(computeStats(conf)))
- statsCache.get.get
+ /**
+ * Returns the estimated statistics for the current logical plan node. Under the hood, this
+ * method caches the return value, which is computed based on the configuration passed in the
+ * first time. If the configuration changes, the cache can be invalidated by calling
+ * [[invalidateStatsCache()]].
+ */
+ final def stats(conf: CatalystConf): Statistics = statsCache.getOrElse {
+ statsCache = Some(computeStats(conf))
+ statsCache.get
}
- def invalidateStatsCache(): Unit = {
- statsCache.set(None)
+ /** Invalidates the stats cache. See [[stats]] for more information. */
+ final def invalidateStatsCache(): Unit = {
+ statsCache = None
children.foreach(_.invalidateStatsCache())
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org