WweiL commented on code in PR #48355:
URL: https://github.com/apache/spark/pull/48355#discussion_r1872546318
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBFileManager.scala:
##########
@@ -331,20 +346,51 @@ class RocksDBFileManager(
}
}
+ /**
+ * Based on the ground truth lineage loaded from changelog file (lineage),
this function
+ * does file listing to find all snapshot (version, uniqueId) pairs, and
finds
+ * the ground truth latest snapshot (version, uniqueId) the db instance
needs to load.
+ *
+ * @param lineage the ground truth lineage loaded from changelog file
+ * @return the ground truth latest snapshot (version, uniqueId) the db
instance needs to load
+ */
+ def getLatestSnapshotVersionAndUniqueIdFromLineage(
+ lineage: Array[LineageItem]): Option[(Long, Option[String])] = {
+ val path = new Path(dfsRootDir)
+ if (fm.exists(path)) {
+ fm.list(path, onlyZipFiles)
+ .map(_.getPath.getName.stripSuffix(".zip").split("_"))
+ .filter {
+ case Array(ver, id) => lineage.contains(LineageItem(ver.toLong, id))
+ }
+ .map {
+ case Array(version, uniqueId) => (version.toLong, Option(uniqueId))
+ }
+ .sortBy(_._1)
+ .reverse
+ .headOption
+ } else {
+ Some(0, None)
Review Comment:
changed
--
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]