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.
Add support for union scalars (#930)
- Loading branch information
Showing
5 changed files
with
143 additions
and
49 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
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,54 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::datatypes::DataType; | ||
|
||
use super::Scalar; | ||
|
||
/// A single entry of a [`crate::array::UnionArray`]. | ||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct UnionScalar { | ||
value: Arc<dyn Scalar>, | ||
type_: i8, | ||
data_type: DataType, | ||
} | ||
|
||
impl UnionScalar { | ||
/// Returns a new [`UnionScalar`] | ||
#[inline] | ||
pub fn new(data_type: DataType, type_: i8, value: Arc<dyn Scalar>) -> Self { | ||
Self { | ||
value, | ||
type_, | ||
data_type, | ||
} | ||
} | ||
|
||
/// Returns the inner value | ||
#[inline] | ||
pub fn value(&self) -> &Arc<dyn Scalar> { | ||
&self.value | ||
} | ||
|
||
/// Returns the type of the union scalar | ||
#[inline] | ||
pub fn type_(&self) -> i8 { | ||
self.type_ | ||
} | ||
} | ||
|
||
impl Scalar for UnionScalar { | ||
#[inline] | ||
fn as_any(&self) -> &dyn std::any::Any { | ||
self | ||
} | ||
|
||
#[inline] | ||
fn is_valid(&self) -> bool { | ||
true | ||
} | ||
|
||
#[inline] | ||
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