Skip to content

Commit f0be9da

Browse files
askoaask
and
ask
authored
feat: Add RunEndEncodedArray (#3553)
* Add `RunEndEncodedArray` * fix doctest and clippy issues * fix doc issues * fix doc issue * add validation for run_ends array and corresponding tests * PR comments * seal ArrowRunEndIndexType per PR suggestion * Fix PR suggestions * few more PR coments * run array name change * fix doc issues * doc change * lint fix * make append methods infallible * fix array.len and other minor changes * formatting fix * add validation of array len * fmt fix * PR comment and some documentation changes * pr suggestion * empty commit Co-authored-by: ask <ask@local>
1 parent 98d35d3 commit f0be9da

File tree

16 files changed

+1511
-4
lines changed

16 files changed

+1511
-4
lines changed

arrow-array/src/array/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ pub use struct_array::*;
6464
mod union_array;
6565
pub use union_array::*;
6666

67+
mod run_array;
68+
pub use run_array::*;
69+
6770
/// Trait for dealing with different types of array at runtime when the type of the
6871
/// array is not known in advance.
6972
pub trait Array: std::fmt::Debug + Send + Sync {
@@ -579,6 +582,20 @@ pub fn make_array(data: ArrayData) -> ArrayRef {
579582
}
580583
dt => panic!("Unexpected dictionary key type {:?}", dt),
581584
},
585+
DataType::RunEndEncoded(ref run_ends_type, _) => {
586+
match run_ends_type.data_type() {
587+
DataType::Int16 => {
588+
Arc::new(RunArray::<Int16Type>::from(data)) as ArrayRef
589+
}
590+
DataType::Int32 => {
591+
Arc::new(RunArray::<Int32Type>::from(data)) as ArrayRef
592+
}
593+
DataType::Int64 => {
594+
Arc::new(RunArray::<Int64Type>::from(data)) as ArrayRef
595+
}
596+
dt => panic!("Unexpected data type for run_ends array {:?}", dt),
597+
}
598+
}
582599
DataType::Null => Arc::new(NullArray::from(data)) as ArrayRef,
583600
DataType::Decimal128(_, _) => Arc::new(Decimal128Array::from(data)) as ArrayRef,
584601
DataType::Decimal256(_, _) => Arc::new(Decimal256Array::from(data)) as ArrayRef,
@@ -737,6 +754,7 @@ pub fn new_null_array(data_type: &DataType, length: usize) -> ArrayRef {
737754
new_null_sized_decimal(data_type, length, std::mem::size_of::<i128>())
738755
}
739756
DataType::Decimal256(_, _) => new_null_sized_decimal(data_type, length, 32),
757+
DataType::RunEndEncoded(_, _) => todo!(),
740758
}
741759
}
742760

0 commit comments

Comments
 (0)