LuciferYang commented on a change in pull request #31517:
URL: https://github.com/apache/spark/pull/31517#discussion_r677086519



##########
File path: core/src/main/scala/org/apache/spark/rdd/ReliableCheckpointRDD.scala
##########
@@ -84,16 +84,18 @@ private[spark] class ReliableCheckpointRDD[T: ClassTag](
   }
 
   // Cache of preferred locations of checkpointed files.
-  @transient private[spark] lazy val cachedPreferredLocations = 
CacheBuilder.newBuilder()
-    .expireAfterWrite(
-      SparkEnv.get.conf.get(CACHE_CHECKPOINT_PREFERRED_LOCS_EXPIRE_TIME).get,
-      TimeUnit.MINUTES)
-    .build(
-      new CacheLoader[Partition, Seq[String]]() {
-        override def load(split: Partition): Seq[String] = {
-          getPartitionBlockLocations(split)
-        }
-      })
+  @transient private[spark] lazy val cachedPreferredLocations = {
+    val builder = Caffeine.newBuilder()
+      .expireAfterWrite(
+        SparkEnv.get.conf.get(CACHE_CHECKPOINT_PREFERRED_LOCS_EXPIRE_TIME).get,
+        TimeUnit.MINUTES)
+    val loader = new CacheLoader[Partition, Seq[String]]() {
+      override def load(split: Partition): Seq[String] = {
+        getPartitionBlockLocations(split)
+      }
+    }
+    builder.build[Partition, Seq[String]](loader)

Review comment:
       1. Try to use `builder.build[Partition, 
Seq[String]](getPartitionBlockLocations)`
   The compile errors as follows:
   ```
   [ERROR] 
/spark-mine/core/src/main/scala/org/apache/spark/rdd/ReliableCheckpointRDD.scala:92:
 missing argument list for method getPartitionBlockLocations in class 
ReliableCheckpointRDD
   Unapplied methods are only converted to functions when a function type is 
expected.
   You can make this conversion explicit by writing `getPartitionBlockLocations 
_` or `getPartitionBlockLocations(_)` instead of `getPartitionBlockLocations`.
   ```
   
   2. Then try to use  `getPartitionBlockLocations(_)` and 
`getPartitionBlockLocations _`
   
   The compile errors as follows:
   ```
   [ERROR] 
/spark-mine/core/src/main/scala/org/apache/spark/rdd/ReliableCheckpointRDD.scala:92:
 overloaded method value build with alternatives:
     (x$1: com.github.benmanes.caffeine.cache.CacheLoader[_ >: 
org.apache.spark.Partition, 
Seq[String]])com.github.benmanes.caffeine.cache.LoadingCache[org.apache.spark.Partition,Seq[String]]
 <and>
     
()com.github.benmanes.caffeine.cache.Cache[org.apache.spark.Partition,Seq[String]]
    cannot be applied to (org.apache.spark.Partition => Seq[String])
   ```




-- 
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.

To unsubscribe, e-mail: [email protected]

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