anishshri-db commented on code in PR #45778:
URL: https://github.com/apache/spark/pull/45778#discussion_r1546616005


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/RocksDBStateEncoder.scala:
##########
@@ -292,7 +299,13 @@ class RangeKeyScanStateEncoder(
       // Note that we cannot allocate a smaller buffer here even if the value 
is null
       // because the effective byte array is considered variable size and 
needs to have
       // the same size across all rows for the ordering to work as expected.
-      val bbuf = ByteBuffer.allocate(field.dataType.defaultSize + 1)
+      val bbuf = if (!supportsSignedValues(field.dataType)) {
+        ByteBuffer.allocate(field.dataType.defaultSize + 1)
+      } else {
+        // for numeric types, we reserve 2 additional bytes. one to indicate 
if the value is null
+        // and the other to indicate if the value is negative.
+        ByteBuffer.allocate(field.dataType.defaultSize + 2)
+      }

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]

Reply via email to