anishshri-db commented on code in PR #43961:
URL: https://github.com/apache/spark/pull/43961#discussion_r1430755529
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -604,17 +728,57 @@ class RocksDB(
}
private def getDBProperty(property: String): Long = {
- db.getProperty(property).toLong
+ if (useColumnFamilies) {
+ // get cumulative sum across all available column families
+ assert(!colFamilyNameToHandleMap.isEmpty)
+ colFamilyNameToHandleMap
+ .values
+ .map(handle => db.getProperty(handle, property).toLong)
+ .sum
+ } else {
+ db.getProperty(property).toLong
+ }
}
private def openDB(): Unit = {
assert(db == null)
- db = NativeRocksDB.open(dbOptions, workingDir.toString)
- logInfo(s"Opened DB with conf ${conf}")
+ if (useColumnFamilies) {
+ val colFamilies = NativeRocksDB.listColumnFamilies(dbOptions,
workingDir.toString)
+
+ var colFamilyDescriptors: Seq[ColumnFamilyDescriptor] =
Seq.empty[ColumnFamilyDescriptor]
+ // populate the list of available col family descriptors
+ colFamilies.asScala.toList.foreach(family => {
+ val descriptor = new ColumnFamilyDescriptor(family,
columnFamilyOptions)
+ colFamilyDescriptors = colFamilyDescriptors :+ descriptor
+ })
+
+ if (colFamilyDescriptors.isEmpty) {
+ colFamilyDescriptors = colFamilyDescriptors :+
+ new ColumnFamilyDescriptor(NativeRocksDB.DEFAULT_COLUMN_FAMILY,
columnFamilyOptions)
+ }
+
+ val colFamilyHandles = new java.util.ArrayList[ColumnFamilyHandle]()
+ db = NativeRocksDB.open(new DBOptions(dbOptions), workingDir.toString,
+ colFamilyDescriptors.asJava, colFamilyHandles)
+
+ // Store the mapping of names to handles in the internal map
+ colFamilyHandles.asScala.toList.map(
Review Comment:
Done
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDB.scala:
##########
@@ -604,17 +728,57 @@ class RocksDB(
}
private def getDBProperty(property: String): Long = {
- db.getProperty(property).toLong
+ if (useColumnFamilies) {
+ // get cumulative sum across all available column families
+ assert(!colFamilyNameToHandleMap.isEmpty)
+ colFamilyNameToHandleMap
+ .values
+ .map(handle => db.getProperty(handle, property).toLong)
+ .sum
+ } else {
+ db.getProperty(property).toLong
+ }
}
private def openDB(): Unit = {
assert(db == null)
- db = NativeRocksDB.open(dbOptions, workingDir.toString)
- logInfo(s"Opened DB with conf ${conf}")
+ if (useColumnFamilies) {
+ val colFamilies = NativeRocksDB.listColumnFamilies(dbOptions,
workingDir.toString)
+
+ var colFamilyDescriptors: Seq[ColumnFamilyDescriptor] =
Seq.empty[ColumnFamilyDescriptor]
+ // populate the list of available col family descriptors
+ colFamilies.asScala.toList.foreach(family => {
Review Comment:
Done
--
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]