You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/15 03:27:09 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3115: Add some initial APIs for copy-on-write support

tustvold commented on code in PR #3115:
URL: https://github.com/apache/arrow-rs/pull/3115#discussion_r1022279925


##########
arrow-array/src/array/mod.rs:
##########
@@ -372,6 +372,28 @@ impl<'a, T: Array> Array for &'a T {
     }
 }
 
+/// A kind of `Array` which can be downcasted by `downcast_array`.
+pub(crate) trait SizedArray: AsDynAny + Array {}
+
+/// A trait used to help conversion from `Arc<Self>` to `Arc<Any>`.
+pub(crate) trait AsDynAny: Any {
+    fn as_dyn_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static>;
+}
+
+impl<T: Sized + Send + Sync + 'static> AsDynAny for T {
+    fn as_dyn_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static> {
+        self
+    }
+}
+
+/// Downcasts an Arc-ed sized `Array` to Arc-ed underlying arrow type.
+#[allow(dead_code)]
+pub(crate) fn downcast_array<T: Send + Sync + 'static>(
+    array: Arc<dyn SizedArray>,

Review Comment:
   How do you go from an `ArrayRef` to `Arc<dyn SizedArray>`?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org