WillAyd commented on code in PR #596:
URL: https://github.com/apache/arrow-nanoarrow/pull/596#discussion_r1769577954


##########
src/nanoarrow/common/inline_array.h:
##########
@@ -972,6 +1101,26 @@ static inline struct ArrowBufferView 
ArrowArrayViewGetBytesUnsafe(
       view.data.as_uint8 =
           array_view->buffer_views[1].data.as_uint8 + (i * view.size_bytes);
       break;
+    case NANOARROW_TYPE_STRING_VIEW:
+    case NANOARROW_TYPE_BINARY_VIEW: {
+      const union ArrowBufferViewData value_view = 
array_view->buffer_views[1].data;
+      union ArrowBinaryViewType bvt;
+      const size_t idx = sizeof(union ArrowBinaryViewType) * i;
+      memcpy(&bvt, value_view.as_uint8 + idx, sizeof(union 
ArrowBinaryViewType));
+      const int32_t inline_size = bvt.inlined.size;
+      view.size_bytes = inline_size;
+      if (inline_size <= NANOARROW_BINARY_VIEW_INLINE_SIZE) {
+        view.data.as_uint8 = value_view.as_uint8 + idx +
+                             sizeof(((union 
ArrowBinaryViewType*)0)->inlined.size);
+      } else {
+        const int32_t buf_index = bvt.ref.buffer_index;
+        const int32_t nfixed_buf = NANOARROW_BINARY_VIEW_FIXED_BUFFERS;
+        const struct ArrowBufferView variadic_vw =
+            ArrowArrayViewBufferView(array_view, buf_index + nfixed_buf);
+        view.data.as_uint8 = variadic_vw.data.as_uint8 + bvt.ref.offset;
+      }

Review Comment:
   Awesome idea - thanks!



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