-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20926][SQL] Removing exposures to guava library caused by directly accessing SessionCatalog's tableRelationCache #18148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ package org.apache.spark.sql.catalyst.catalog | |
|
|
||
| import java.net.URI | ||
| import java.util.Locale | ||
| import java.util.concurrent.Callable | ||
| import javax.annotation.concurrent.GuardedBy | ||
|
|
||
| import scala.collection.mutable | ||
|
|
@@ -126,13 +127,55 @@ class SessionCatalog( | |
| } | ||
|
|
||
| /** | ||
| * A cache of qualified table names to table relation plans. | ||
| */ | ||
| * A cache of qualified table names to table relation plans. | ||
| * Accessing tableRelationCache directly is not recommended, | ||
| * since it will introduce exposures to guava libraries. | ||
| */ | ||
| val tableRelationCache: Cache[QualifiedTableName, LogicalPlan] = { | ||
| val cacheSize = conf.tableRelationCacheSize | ||
| CacheBuilder.newBuilder().maximumSize(cacheSize).build[QualifiedTableName, LogicalPlan]() | ||
| } | ||
|
|
||
| /** | ||
| * This method provides a way to get a cached plan | ||
|
||
| * without exposing components to Guava library. | ||
| */ | ||
| def getCachedPlan(t: QualifiedTableName, c: Callable[LogicalPlan]): LogicalPlan = { | ||
| tableRelationCache.get(t, c) | ||
| } | ||
|
|
||
| /** | ||
| * This method provides a way to get a cached plan if the key exists | ||
| * without exposing components to Guava library. | ||
| */ | ||
| def getCachedTableIfPresent(key: QualifiedTableName): LogicalPlan = { | ||
|
||
| tableRelationCache.getIfPresent(key) | ||
| } | ||
|
|
||
| /** | ||
| * This method provides a way to cache a plan | ||
| * without exposing components to Guava library. | ||
| */ | ||
| def putTableInCache(t: QualifiedTableName, l: LogicalPlan): Unit = { | ||
|
||
| tableRelationCache.put(t, l) | ||
| } | ||
|
|
||
| /** | ||
| * This method provides a way to invalidate a cached plan | ||
| * without exposing components to Guava library. | ||
| */ | ||
| def invalidateCachedTable(key: QualifiedTableName): Unit = { | ||
| tableRelationCache.invalidate(key) | ||
| } | ||
|
|
||
| /** | ||
| * This method provides a way to invalidate all the cached plans | ||
| * without exposing components to Guava library. | ||
| */ | ||
| def invalidateAllCachedTables(): Unit = { | ||
| tableRelationCache.invalidateAll() | ||
| } | ||
|
|
||
| /** | ||
| * This method is used to make the given path qualified before we | ||
| * store this path in the underlying external catalog. So, when a path | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to have been introduced in 2.2, can you make it private instead, and change all call sites?