Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/23043#discussion_r235237048
  
    --- Diff: 
common/unsafe/src/test/java/org/apache/spark/unsafe/PlatformUtilSuite.java ---
    @@ -157,4 +159,15 @@ public void heapMemoryReuse() {
         Assert.assertEquals(onheap4.size(), 1024 * 1024 + 7);
         Assert.assertEquals(obj3, onheap4.getBaseObject());
       }
    +
    +  @Test
    +  // SPARK-26021
    +  public void writeMinusZeroIsReplacedWithZero() {
    +    byte[] doubleBytes = new byte[Double.BYTES];
    +    byte[] floatBytes = new byte[Float.BYTES];
    +    Platform.putDouble(doubleBytes, Platform.BYTE_ARRAY_OFFSET, -0.0d);
    +    Platform.putFloat(floatBytes, Platform.BYTE_ARRAY_OFFSET, -0.0f);
    +    Assert.assertEquals(0, Double.compare(0.0d, 
ByteBuffer.wrap(doubleBytes).getDouble()));
    +    Assert.assertEquals(0, Float.compare(0.0f, 
ByteBuffer.wrap(floatBytes).getFloat()));
    --- End diff --
    
    can we use `Platform.getFloat` to read the value back? to match how we 
write it.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to