Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/13680
  
    One more thought about the format: `UnsafeRow` use 8 bytes to store offset 
and length for variable-length type, this is because `UnsafeRow` is 
word-aligned, so we can't calculate the element size by subtracting 2 adjacent 
offsets, but need an extra length information. This is also why in unsafe row 
writer we call `zeroOutPaddingBytes` before we write variable-length field.
    
    However, `UnsafeArrayData` doesn't have this requirement, as it's already a 
field of row and itself will be word-aligned. So we can:
    
    1. only use 4 bytes to store offset for variable-length type element, and 
calculate the length by subtracting 2 adjacent offsets.
    2. still use 8 bytes to store offset and length, and follow unsafe row 
writer to `zeroOutPaddingBytes` before write.
    
    Personally I prefer option 1 as it's more compact.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to