westonpace commented on issue #35226:
URL: https://github.com/apache/arrow/issues/35226#issuecomment-1516558160

   Null values are not guaranteed to be 0.  We use a separate bitmask validity 
vector to determine if an element is null or not.  If an element is null then 
it's value is undefined and could be anything.
   
   However, creating spans from buffers is fine.
   
   Those spans will not keep the buffer alive though.  So you need to avoid 
something like this:
   
   ```
   std::span GetMyData() {
     std::shared_ptr<Array> m_array = GetSomeArray();
     auto ptr = reinterpret_cast<const 
double*>(m_array->data()->buffers[1]->data()) + m_array->offset();
     std::span view(ptr, m_array->length);
     return view;
   }
   ```
   
   Also, that reinterpret cast is only valid if 
`m_array->data()->buffers[1]->data()` is 8-byte aligned.  This is true for any 
buffer allocated by Arrow-C++ and is supposed to be true for any buffer sent 
over IPC but it is not currently guaranteed for buffers received over Flight 
due to https://github.com/apache/arrow/issues/32276.


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

Reply via email to