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.
Added support to read dictionary from nested types.
- Loading branch information
1 parent
caf764e
commit 693a7c1
Showing
11 changed files
with
178 additions
and
48 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
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 |
---|---|---|
@@ -1,14 +1,5 @@ | ||
use crate::array::{Array, DictionaryArray, DictionaryKey}; | ||
|
||
pub(super) fn equal<K: DictionaryKey>(lhs: &DictionaryArray<K>, rhs: &DictionaryArray<K>) -> bool { | ||
if !(lhs.data_type() == rhs.data_type() && lhs.len() == rhs.len()) { | ||
return false; | ||
}; | ||
|
||
// if x is not valid and y is but its child is not, the slots are equal. | ||
lhs.iter().zip(rhs.iter()).all(|(x, y)| match (&x, &y) { | ||
(None, Some(y)) => !y.is_valid(), | ||
(Some(x), None) => !x.is_valid(), | ||
_ => x == y, | ||
}) | ||
lhs.data_type() == rhs.data_type() && lhs.len() == rhs.len() && lhs.iter().eq(rhs.iter()) | ||
} |
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
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
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,55 @@ | ||
use std::any::Any; | ||
use std::sync::Arc; | ||
|
||
use crate::{array::*, datatypes::DataType}; | ||
|
||
use super::Scalar; | ||
|
||
/// The [`DictionaryArray`] equivalent of [`Array`] for [`Scalar`]. | ||
#[derive(Debug, Clone)] | ||
pub struct DictionaryScalar<K: DictionaryKey> { | ||
value: Option<Arc<dyn Scalar>>, | ||
phantom: std::marker::PhantomData<K>, | ||
data_type: DataType, | ||
} | ||
|
||
impl<K: DictionaryKey> PartialEq for DictionaryScalar<K> { | ||
fn eq(&self, other: &Self) -> bool { | ||
(self.data_type == other.data_type) && (self.value.as_ref() == other.value.as_ref()) | ||
} | ||
} | ||
|
||
impl<K: DictionaryKey> DictionaryScalar<K> { | ||
/// returns a new [`DictionaryScalar`] | ||
/// # Panics | ||
/// iff | ||
/// * the `data_type` is not `List` or `LargeList` (depending on this scalar's offset `O`) | ||
/// * the child of the `data_type` is not equal to the `values` | ||
#[inline] | ||
pub fn new(data_type: DataType, value: Option<Arc<dyn Scalar>>) -> Self { | ||
Self { | ||
value, | ||
phantom: std::marker::PhantomData, | ||
data_type, | ||
} | ||
} | ||
|
||
/// The values of the [`DictionaryScalar`] | ||
pub fn value(&self) -> Option<&Arc<dyn Scalar>> { | ||
self.value.as_ref() | ||
} | ||
} | ||
|
||
impl<K: DictionaryKey> Scalar for DictionaryScalar<K> { | ||
fn as_any(&self) -> &dyn Any { | ||
self | ||
} | ||
|
||
fn is_valid(&self) -> bool { | ||
self.value.is_some() | ||
} | ||
|
||
fn data_type(&self) -> &DataType { | ||
&self.data_type | ||
} | ||
} |
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
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