You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zeruibao (via GitHub)" <gi...@apache.org> on 2026/01/14 22:02:05 UTC
Re: [PR] [SPARK-54824] Add support for multiGet and deleteRange for Rocksdb State Store [spark]
zeruibao commented on code in PR #53583:
URL: https://github.com/apache/spark/pull/53583#discussion_r2692221761
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -1022,6 +1022,35 @@ class RocksDB(
}
}
+ /**
+ * Get the values for multiple keys in a single batch operation.
+ * Uses RocksDB's native multiGet for efficient batch lookups.
+ *
+ * @param keys Array of keys to look up
+ * @param cfName The column family name
+ * @return Array of values corresponding to the keys (null for keys that don't exist)
+ */
+ def multiGet(
+ keys: Array[Array[Byte]],
+ cfName: String = StateStore.DEFAULT_COL_FAMILY_NAME): Array[Array[Byte]] = {
+ updateMemoryUsageIfNeeded()
+ // Prepare keys
+ val finalKeys =
+ if (useColumnFamilies) {
+ keys.map(encodeStateRowWithPrefix(_, cfName))
+ } else {
+ keys
+ }
+
+ val keysList = java.util.Arrays.asList(finalKeys: _*)
+
+ // Call RocksDB multiGet
+ val valuesList = db.multiGetAsList(readOptions, keysList)
+
+ // Convert to Array[Array[Byte]] in one line
+ valuesList.toArray(new Array[Array[Byte]](valuesList.size()))
Review Comment:
Yeah, just return an iterator to avoid the copy.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org