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


##########
src/nanoarrow/array_inline.h:
##########
@@ -928,6 +928,34 @@ static inline struct ArrowBufferView 
ArrowArrayViewGetBytesUnsafe(
   return view;
 }
 
+static inline void ArrowArrayViewGetIntervalUnsafe(struct ArrowArrayView* 
array_view,
+                                                   int64_t i, struct 
ArrowInterval* out) {
+  const uint8_t* data_view = array_view->buffer_views[1].data.as_uint8;
+  switch (array_view->storage_type) {
+    case NANOARROW_TYPE_INTERVAL_MONTHS: {
+      const size_t size = 4;
+      memcpy(&out->months, data_view + i * size, 4);
+      break;
+    }
+    case NANOARROW_TYPE_INTERVAL_DAY_TIME: {
+      const size_t size = 8;
+      memcpy(&out->days, data_view + i * size, 4);
+      memcpy(&out->ms, data_view + i * size + 4, 4);
+      break;
+    }
+    case NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO: {
+      const size_t size = 16;
+      memcpy(&out->months, data_view + i * size, 4);
+      memcpy(&out->days, data_view + i * size + 4, 4);
+      memcpy(&out->ns, data_view + i * size + 8, 8);
+      break;
+    }
+    default:
+      out = NULL;

Review Comment:
   Sure removed that for now. Another thought I had was returning an 
`ArrowInterval`; that would break the usage pattern with `GetDecimalUnsafe` but 
arguably be more consistent with `GetStringUnsafe`, `GetBytesUnsafe`, etc... 
   
   Those methods do assign some members to NULL so the caller has a way of 
checking if they've made a mistake



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