chaoqin-li1123 commented on code in PR #41099:
URL: https://github.com/apache/spark/pull/41099#discussion_r1199515925


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBFileManager.scala:
##########
@@ -205,19 +229,39 @@ class RocksDBFileManager(
     metadata
   }
 
-  /** Get the latest version available in the DFS directory. If no data 
present, it returns 0. */
-  def getLatestVersion(): Long = {
+  // Get latest snapshot version <= version
+  def getLatestSnapshotVersion(version: Long): Long = {
     val path = new Path(dfsRootDir)
     if (fm.exists(path)) {
       fm.list(path, onlyZipFiles)
         .map(_.getPath.getName.stripSuffix(".zip"))
         .map(_.toLong)
+        .filter(_ <= version)
         .foldLeft(0L)(math.max)
     } else {
       0
     }
   }
 
+  // Get latest snapshot version <= version
+  def getLatestDeltaVersion(version: Long): Long = {
+    val path = new Path(dfsRootDir)
+    if (fm.exists(path)) {
+      fm.list(path, onlyDeltaFiles)
+        .map(_.getPath.getName.stripSuffix(".changelog"))
+        .map(_.toLong)
+        .filter(_ <= version)
+        .foldLeft(0L)(math.max)
+    } else {
+      0
+    }
+  }
+
+  /** Get the latest version available in the DFS directory. If no data 
present, it returns 0. */
+  def getLatestVersion(): Long = {

Review Comment:
   Changed to 1 list call.



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