mustiikhalil commented on issue #45276:
URL: https://github.com/apache/arrow/issues/45276#issuecomment-2598476136
That's perfect!
1- In theory, it should be alright since most of the time when creating a
flat buffer object we used to copy the unaligned data into the `ByteBuffer`.
And then read from it, but now we are just reading the unaligned data directly.
2- The only downside to all of this is that now reading would take a bit
longer compared to earlier `47 ns`, compared to `4 ns` but it's safer and it
works. If you still want the speed you can always use the copying method since
we kept that!
```swift
/// This will copy the data and create a byte buffer that will have 7/9 ns
of reading
data.withUnsafePointer {
ByteBuffer(copying...: $0)
}
```
or
```swift
/// This will use the data pointer directly and create a byte buffer that
will have 7/9 ns of reading
data.withUnsafePointer {
// do everything you need with flatbuffers here
ByteBuffer(assumingMemoryBound: $0)
}
```
or
```
/// This will be reduced performance but in the grand scheme of things, when
having data as 1gb, its okay to be slower
ByteBuffer(data: data)
```
--
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]