jingz-db commented on code in PR #47107:
URL: https://github.com/apache/spark/pull/47107#discussion_r1664823721


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateEncoder.scala:
##########
@@ -185,19 +216,44 @@ class PrefixKeyScanStateEncoder(
     
restoreKeyProjection(joinedRowOnKey.withLeft(prefixKeyDecoded).withRight(remainingKeyDecoded))
   }
 
+  override def decodeKey(
+      keyBytes: Array[Byte],
+      hasVirtualColFamilyPrefix: Boolean = false): UnsafeRow = {
+    decodeKeyWithColFamilyPrefix(keyBytes, hasVirtualColFamilyPrefix)
+  }
+
   private def extractPrefixKey(key: UnsafeRow): UnsafeRow = {
     prefixKeyProjection(key)
   }
 
-  override def encodePrefixKey(prefixKey: UnsafeRow): Array[Byte] = {
+  private def encodePrefixKeyWithColFamilyPrefix(
+    prefixKey: UnsafeRow,
+    hasVirtualColFamilyPrefix: Boolean = false,
+    colFamilyId: Long = -1L): Array[Byte] = {
+    val offSetForColFamilyPrefix = if (hasVirtualColFamilyPrefix) 8 else 0
+
     val prefixKeyEncoded = encodeUnsafeRow(prefixKey)
-    val prefix = new Array[Byte](prefixKeyEncoded.length + 4)
-    Platform.putInt(prefix, Platform.BYTE_ARRAY_OFFSET, 
prefixKeyEncoded.length)
+    val prefix = new Array[Byte](
+      prefixKeyEncoded.length + 4 + offSetForColFamilyPrefix)
+    if (hasVirtualColFamilyPrefix) {
+      Platform.putLong(prefix, Platform.BYTE_ARRAY_OFFSET, colFamilyId)

Review Comment:
   Use `Short` instead of `Long` as VCF id.



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