tustvold commented on code in PR #3818:
URL: https://github.com/apache/arrow-rs/pull/3818#discussion_r1131340070
##########
arrow-data/src/data/run.rs:
##########
@@ -88,26 +105,63 @@ pub enum ArrayDataRun {
impl ArrayDataRun {
/// Downcast this [`ArrayDataRun`] to the corresponding [`RunArrayData`]
pub fn downcast_ref<E: RunEnd>(&self) -> Option<&RunArrayData<E>> {
- E::downcast_ref(self)
+ <E as private::RunEndSealed>::downcast_ref(self)
}
/// Downcast this [`ArrayDataRun`] to the corresponding [`RunArrayData`]
pub fn downcast<E: RunEnd>(self) -> Option<RunArrayData<E>> {
- E::downcast(self)
+ <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::upcast(value)
+ <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: ScalarBuffer<E>,
- child: Box<ArrayData>,
+ run_ends: RunEndBuffer<E>,
+ /// The children of this RunArrayData
+ /// 1: the run ends
+ /// 2: the values
+ children: Box<[ArrayData; 2]>,
Review Comment:
So that we can return a slice of children in ArrayDataLayout, this type is a
little funky because there is an impedence mismatch between the arrow
representation and the arrow-rs representation
--
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]