-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce DeserializableComponent
trait and high-level query_latest
#1417
Changes from 4 commits
5c3aa92
cc16340
9af4328
a30ecd5
bd36535
dee47a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ use arrow2::{ | |
offset::Offsets, | ||
}; | ||
use arrow2_convert::{ | ||
deserialize::{ArrowArray, ArrowDeserialize}, | ||
field::ArrowField, | ||
serialize::{ArrowSerialize, TryIntoArrow}, | ||
}; | ||
|
@@ -88,9 +89,8 @@ pub trait Component: ArrowField { | |
} | ||
} | ||
|
||
/// A trait to identify any [`Component`] that is ready to be collected and subsequently serialized | ||
/// into an Arrow payload. | ||
pub trait SerializableComponent | ||
/// A [`Component`] that fulfils all the conditions required to be serialized as an Arrow payload. | ||
pub trait SerializableComponent<ArrowFieldType = Self> | ||
where | ||
Self: Component + ArrowSerialize + ArrowField<Type = Self> + 'static, | ||
{ | ||
|
@@ -101,6 +101,33 @@ impl<C> SerializableComponent for C where | |
{ | ||
} | ||
|
||
/// A [`Component`] that fulfils all the conditions required to be deserialized from an Arrow | ||
/// payload. | ||
/// | ||
/// Note that due to the use of HRTBs in `arrow2_convert` traits, you will still need an extra HRTB | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://doc.rust-lang.org/nomicon/hrtb.html An old-school workaround for the lack of generic associated types... which actually have landed since then, at least in part. |
||
/// clause when marking a type as `DeserializableComponent`: | ||
/// ```ignore | ||
/// where | ||
/// T: SerializableComponent, | ||
/// for<'a> &'a T::ArrayType: IntoIterator, | ||
/// ``` | ||
pub trait DeserializableComponent<ArrowFieldType = Self> | ||
where | ||
Self: Component + ArrowDeserialize + ArrowField<Type = ArrowFieldType> + 'static, | ||
teh-cmc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Self::ArrayType: ArrowArray, | ||
for<'b> &'b Self::ArrayType: IntoIterator, | ||
{ | ||
} | ||
|
||
impl<C> DeserializableComponent for C | ||
where | ||
C: Component, | ||
C: ArrowDeserialize + ArrowField<Type = C> + 'static, | ||
C::ArrayType: ArrowArray, | ||
for<'b> &'b C::ArrayType: IntoIterator, | ||
{ | ||
} | ||
|
||
/// A [`ComponentBundle`] holds an Arrow component column, and its field name. | ||
/// | ||
/// A [`ComponentBundle`] can be created from a collection of any element that implements the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should there be something in the name or comment on how this expects that there is only a single component of the type on the entity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's already guaranteed by the data model 🤔Ha, you mean a single instance. Yes.