jonathan-albrecht-ibm commented on code in PR #49773:
URL: https://github.com/apache/spark/pull/49773#discussion_r3320336429
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/UnsafeRowUtilsSuite.scala:
##########
@@ -157,4 +158,119 @@ class UnsafeRowUtilsSuite extends SparkFunSuite {
StructType(StructField("field",
StructType(StructField("sub", nonBinaryStringType) :: Nil)) :: Nil)))
}
+
+ test("PaddingProvider handles endianness") {
+ // The following arrays contain the same 8 byte field values as represented
+ // in memory on little endian and big endian platforms. They are
+ // what would be seen in memory if the following values were set:
+ //
+ // row.setBoolean(0, true)
+ // row.setByte(1, 0xFF.toByte)
+ // row.setShort(2, 0xFFFE.toShort)
+ // row.setInt(3, 0xFFFEFDFC.toInt)
+ // row.setFloat(4, java.lang.Float.intBitsToFloat(0xFF7FFDFC.toInt))
+ //
+ // Note that in either platform endianness, the values are placed in the
first N bytes
+ // of the 8 byte field. The difference is in the order of the bytes in the
field.
+ val boolLE = Array[Byte](1, 0, 0, 0, 0, 0, 0, 0)
+ val byteLE = Array[Byte](0xFF.toByte, 0, 0, 0, 0, 0, 0, 0)
+ val shortLE = Array[Byte](0xFE.toByte, 0xFF.toByte, 0, 0, 0, 0, 0, 0)
+ val intLE = Array[Byte](0xFC.toByte, 0xFD.toByte, 0xFE.toByte,
0xFF.toByte, 0, 0, 0, 0)
+ val floatLE = Array[Byte](0xFC.toByte, 0xFD.toByte, 0x7F.toByte,
0xFF.toByte, 0, 0, 0, 0)
+
+ val boolBE = Array[Byte](1, 0, 0, 0, 0, 0, 0, 0)
+ val byteBE = Array[Byte](0xFF.toByte, 0, 0, 0, 0, 0, 0, 0)
+ val shortBE = Array[Byte](0xFF.toByte, 0xFE.toByte, 0, 0, 0, 0, 0, 0)
+ val intBE = Array[Byte](0xFF.toByte, 0xFE.toByte, 0xFD.toByte,
0xFC.toByte, 0, 0, 0, 0)
+ val floatBE = Array[Byte](0xFF.toByte, 0x7F.toByte, 0x7D.toByte,
0xFC.toByte, 0, 0, 0, 0)
Review Comment:
Fixed, thx
--
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]