tustvold commented on code in PR #3877:
URL: https://github.com/apache/arrow-rs/pull/3877#discussion_r1139226872
##########
arrow-data/src/data/dictionary.rs:
##########
@@ -86,100 +48,13 @@ dictionary!(u16, UInt16);
dictionary!(u32, UInt32);
dictionary!(u64, UInt64);
-/// Applies op to each variant of [`ArrayDataDictionary`]
-macro_rules! dictionary_op {
- ($array:ident, $op:block) => {
- match $array {
- ArrayDataDictionary::Int8($array) => $op
- ArrayDataDictionary::Int16($array) => $op
- ArrayDataDictionary::Int32($array) => $op
- ArrayDataDictionary::Int64($array) => $op
- ArrayDataDictionary::UInt8($array) => $op
- ArrayDataDictionary::UInt16($array) => $op
- ArrayDataDictionary::UInt32($array) => $op
- ArrayDataDictionary::UInt64($array) => $op
- }
- };
-}
-
-/// An enumeration of the types of [`DictionaryArrayData`]
-#[derive(Debug, Clone)]
-pub enum ArrayDataDictionary {
- Int8(DictionaryArrayData<i8>),
- Int16(DictionaryArrayData<i16>),
- Int32(DictionaryArrayData<i32>),
- Int64(DictionaryArrayData<i64>),
- UInt8(DictionaryArrayData<u8>),
- UInt16(DictionaryArrayData<u16>),
- UInt32(DictionaryArrayData<u32>),
- UInt64(DictionaryArrayData<u64>),
-}
-
-impl ArrayDataDictionary {
- /// Downcast this [`ArrayDataDictionary`] to the corresponding
[`DictionaryArrayData`]
- pub fn downcast_ref<K: DictionaryKey>(&self) ->
Option<&DictionaryArrayData<K>> {
- K::downcast_ref(self)
- }
-
- /// Downcast this [`ArrayDataDictionary`] to the corresponding
[`DictionaryArrayData`]
- pub fn downcast<K: DictionaryKey>(self) -> Option<DictionaryArrayData<K>> {
- K::downcast(self)
- }
-
- /// Returns the values of this dictionary
- pub fn values(&self) -> &ArrayData {
- let s = self;
- dictionary_op!(s, { s.values() })
- }
-
- /// Returns a zero-copy slice of this array
- pub fn slice(&self, offset: usize, len: usize) -> Self {
- let s = self;
- dictionary_op!(s, { s.slice(offset, len).into() })
- }
-
- /// Returns an [`ArrayDataLayout`] representation of this
- pub(crate) fn layout(&self) -> ArrayDataLayout<'_> {
- let s = self;
- dictionary_op!(s, { s.layout() })
- }
-
- /// Creates a new [`ArrayDataDictionary`] from raw buffers
- ///
- /// # Safety
- ///
- /// See [`DictionaryArrayData::new_unchecked`]
- pub(crate) unsafe fn from_raw(
- builder: ArrayDataBuilder,
- key: DictionaryKeyType,
- ) -> Self {
- use DictionaryKeyType::*;
- match key {
- Int8 => Self::Int8(DictionaryArrayData::from_raw(builder)),
- Int16 => Self::Int16(DictionaryArrayData::from_raw(builder)),
- Int32 => Self::Int32(DictionaryArrayData::from_raw(builder)),
- Int64 => Self::Int64(DictionaryArrayData::from_raw(builder)),
- UInt8 => Self::UInt8(DictionaryArrayData::from_raw(builder)),
- UInt16 => Self::UInt16(DictionaryArrayData::from_raw(builder)),
- UInt32 => Self::UInt32(DictionaryArrayData::from_raw(builder)),
- UInt64 => Self::UInt64(DictionaryArrayData::from_raw(builder)),
- }
- }
-}
-
-impl<K: DictionaryKey> From<DictionaryArrayData<K>> for ArrayDataDictionary {
- fn from(value: DictionaryArrayData<K>) -> Self {
- K::upcast(value)
- }
-}
-
/// ArrayData for [dictionary
arrays](https://arrow.apache.org/docs/format/Columnar.html#dictionary-encoded-layout)
#[derive(Debug, Clone)]
pub struct DictionaryArrayData<K: DictionaryKey> {
data_type: DataType,
nulls: Option<NullBuffer>,
keys: ScalarBuffer<K>,
- values: Box<ArrayData>,
+ values: ArrayData,
Review Comment:
We no longer need to Box children, as not intending to use within an
ArrayData enumeration
--
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]