This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
218a031
commit c06a80e
Showing
3 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use crate::array::{Array, StructArray}; | ||
use crate::error::Result; | ||
use crate::{array::MutableArray, datatypes::DataType}; | ||
|
||
use super::make_mutable; | ||
|
||
#[derive(Debug)] | ||
pub struct DynMutableStructArray { | ||
data_type: DataType, | ||
pub inner: Vec<Box<dyn MutableArray>>, | ||
} | ||
|
||
impl DynMutableStructArray { | ||
pub fn try_with_capacity(data_type: DataType, capacity: usize) -> Result<Self> { | ||
let inners = match data_type.to_logical_type() { | ||
DataType::Struct(inner) => inner, | ||
_ => unreachable!(), | ||
}; | ||
let inner = inners | ||
.iter() | ||
.map(|f| make_mutable(f.data_type(), capacity)) | ||
.collect::<Result<Vec<_>>>()?; | ||
|
||
Ok(Self { data_type, inner }) | ||
} | ||
} | ||
impl MutableArray for DynMutableStructArray { | ||
fn data_type(&self) -> &DataType { | ||
&self.data_type | ||
} | ||
|
||
fn len(&self) -> usize { | ||
self.inner.len() | ||
} | ||
|
||
fn validity(&self) -> Option<&crate::bitmap::MutableBitmap> { | ||
None | ||
} | ||
|
||
fn as_box(&mut self) -> Box<dyn Array> { | ||
let inner = self.inner.iter_mut().map(|x| x.as_arc()).collect(); | ||
|
||
Box::new(StructArray::new(self.data_type.clone(), inner, None)) | ||
} | ||
|
||
fn as_any(&self) -> &dyn std::any::Any { | ||
self | ||
} | ||
|
||
fn as_mut_any(&mut self) -> &mut dyn std::any::Any { | ||
self | ||
} | ||
|
||
fn push_null(&mut self) { | ||
todo!() | ||
} | ||
|
||
fn shrink_to_fit(&mut self) { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters