anishshri-db commented on code in PR #47107:
URL: https://github.com/apache/spark/pull/47107#discussion_r1663048425
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateStoreProvider.scala:
##########
@@ -60,16 +61,35 @@ private[sql] class RocksDBStateStoreProvider
s"Failed to create column family with reserved_name=$colFamilyName")
verify(useColumnFamilies, "Column families are not supported in this
store")
rocksDB.createColFamilyIfAbsent(colFamilyName, isInternal)
+
+ // TODO how to efficiently guarantee there isn't any value conflict for
different key
+ def getNextRandShort: Short = {
+ (scala.util.Random.nextInt(Short.MaxValue - Short.MinValue + 1) +
Short.MinValue).toShort
+ }
+ colFamilyToIdMap.putIfAbsent(colFamilyName, getNextRandShort)
+
keyValueEncoderMap.putIfAbsent(colFamilyName,
(RocksDBStateEncoder.getKeyEncoder(keyStateEncoderSpec),
RocksDBStateEncoder.getValueEncoder(valueSchema,
useMultipleValuesPerKey)))
}
+ private def getEncodedKey(
+ keyEncoder: RocksDBKeyStateEncoder,
+ key: UnsafeRow,
+ colFamilyName: String): Array[Byte] = {
+ if (useColumnFamilies) {
+ keyEncoder.encodeKey(key, colFamilyToIdMap.get(colFamilyName))
Review Comment:
maybe we can call this directly from the places below ?
--
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]