You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/03/16 18:47:13 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3877: Rework Strongly Typed ArrayData Abstractions

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


##########
arrow-data/src/data/run.rs:
##########
@@ -83,87 +49,12 @@ run_end!(i16, Int16);
 run_end!(i32, Int32);
 run_end!(i64, Int64);
 
-/// Applies op to each variant of [`ArrayDataRun`]
-macro_rules! run_op {
-    ($array:ident, $op:block) => {
-        match $array {
-            ArrayDataRun::Int16($array) => $op
-            ArrayDataRun::Int32($array) => $op
-            ArrayDataRun::Int64($array) => $op
-        }
-    };
-}
-
-/// An enumeration of the types of [`RunArrayData`]
-#[derive(Debug, Clone)]
-pub enum ArrayDataRun {
-    Int16(RunArrayData<i16>),
-    Int32(RunArrayData<i32>),
-    Int64(RunArrayData<i64>),
-}
-
-impl ArrayDataRun {
-    /// Downcast this [`ArrayDataRun`] to the corresponding [`RunArrayData`]
-    pub fn downcast_ref<E: RunEnd>(&self) -> Option<&RunArrayData<E>> {
-        <E as private::RunEndSealed>::downcast_ref(self)
-    }
-
-    /// Downcast this [`ArrayDataRun`] to the corresponding [`RunArrayData`]
-    pub fn downcast<E: RunEnd>(self) -> Option<RunArrayData<E>> {
-        <E as private::RunEndSealed>::downcast(self)
-    }
-
-    /// Returns the values of this [`ArrayDataRun`]
-    #[inline]
-    pub fn values(&self) -> &ArrayData {
-        let s = self;
-        run_op!(s, { s.values() })
-    }
-
-    /// Returns a zero-copy slice of this array
-    pub fn slice(&self, offset: usize, len: usize) -> Self {
-        let s = self;
-        run_op!(s, { s.slice(offset, len).into() })
-    }
-
-    /// Returns an [`ArrayDataLayout`] representation of this
-    pub(crate) fn layout(&self) -> ArrayDataLayout<'_> {
-        let s = self;
-        run_op!(s, { s.layout() })
-    }
-
-    /// Creates a new [`ArrayDataRun`] from raw buffers
-    ///
-    /// # Safety
-    ///
-    /// See [`RunArrayData::new_unchecked`]
-    pub(crate) unsafe fn from_raw(builder: ArrayDataBuilder, run: RunEndType) -> Self {
-        use RunEndType::*;
-        match run {
-            Int16 => Self::Int16(RunArrayData::from_raw(builder)),
-            Int32 => Self::Int32(RunArrayData::from_raw(builder)),
-            Int64 => Self::Int64(RunArrayData::from_raw(builder)),
-        }
-    }
-}
-
-impl<E: RunEnd> From<RunArrayData<E>> for ArrayDataRun {
-    fn from(value: RunArrayData<E>) -> Self {
-        <E as private::RunEndSealed>::upcast(value)
-    }
-}
-
 /// ArrayData for [run-end encoded arrays](https://arrow.apache.org/docs/format/Columnar.html#run-end-encoded-layout)
 #[derive(Debug, Clone)]
 pub struct RunArrayData<E: RunEnd> {
     data_type: DataType,
     run_ends: RunEndBuffer<E>,
-    /// The children of this RunArrayData:
-    /// 1: the run ends
-    /// 2: the values
-    ///
-    /// We store an array so that a slice can be returned in [`RunArrayData::layout`]
-    children: Box<[ArrayData; 2]>,

Review Comment:
   We no longer need this hack :tada:



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