imback82 commented on a change in pull request #30825:
URL: https://github.com/apache/spark/pull/30825#discussion_r546163071



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
##########
@@ -52,21 +52,36 @@ class DataSourceV2Strategy(session: SparkSession) extends 
Strategy with Predicat
     }
   }
 
+  private def cache(relation: DataSourceV2Relation, cacheInfo: CacheInfo): 
Unit = {
+    session.sharedState.cacheManager.cacheQuery(
+      session,
+      relation,
+      cacheInfo.tableName,
+      cacheInfo.storageLevel)
+  }
+
   private def refreshCache(r: DataSourceV2Relation)(): Unit = {
     session.sharedState.cacheManager.recacheByPlan(session, r)
   }
 
-  private def invalidateCache(r: ResolvedTable, recacheTable: Boolean = 
false)(): Unit = {
+  // Invalidates the cache associated with the given table. If there exists a 
cache with the given
+  // table, the cache's info (table name and storage level) is returned.
+  private def invalidateCache(
+      r: ResolvedTable,
+      recacheTable: Boolean = false)(): Option[CacheInfo] = {

Review comment:
       OK, I changed to use `Option[StorageLevel]`. The reason I wrapped it 
with `CacheInfo` was to simplify callback signatures:
   ```scala
   invalidateCache: () => Option[CacheInfo],
   cacheTable: (DataSourceV2Relation, CacheInfo) => Unit
   ```
   vs.
   ```scala
   invalidateCache: () => Option[StorageLevel],
   cacheTable: (DataSourceV2Relation, String, StorageLevel) => Unit)
   ```




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to