-
Notifications
You must be signed in to change notification settings - Fork 146
Remove metadata from DynArray
#7435
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -170,16 +170,6 @@ impl<'a> ArrayNodeFlatBuffer<'a> { | |
| session: &'a VortexSession, | ||
| array: &'a ArrayRef, | ||
| ) -> VortexResult<Self> { | ||
| // Depth-first traversal of the array to ensure it supports serialization. | ||
| // FIXME(ngates): this serializes the metadata and throws it away! | ||
| for child in array.depth_first_traversal() { | ||
| if child.metadata(session)?.is_none() { | ||
| vortex_bail!( | ||
| "Array {} does not support serialization", | ||
| child.encoding_id() | ||
| ); | ||
| } | ||
| } | ||
| let n_buffers_recursive = array.nbuffers_recursive(); | ||
| if n_buffers_recursive > u16::MAX as usize { | ||
| vortex_bail!( | ||
|
|
@@ -210,13 +200,13 @@ impl<'a> ArrayNodeFlatBuffer<'a> { | |
| ) | ||
| })?; | ||
|
|
||
| let metadata = self.array.metadata(self.session)?.ok_or_else(|| { | ||
| let metadata_bytes = self.session.array_serialize(self.array)?.ok_or_else(|| { | ||
| vortex_err!( | ||
| "Array {} does not support serialization", | ||
| self.array.encoding_id() | ||
| ) | ||
| })?; | ||
| let metadata = Some(fbb.create_vector(metadata.as_slice())); | ||
| let metadata = Some(fbb.create_vector(metadata_bytes.as_slice())); | ||
|
|
||
| // Assign buffer indices for all child arrays. | ||
| let nbuffers = u16::try_from(self.array.nbuffers()) | ||
|
|
@@ -701,101 +691,3 @@ impl TryFrom<BufferHandle> for SerializedArray { | |
| Self::try_from(value.try_to_host_sync()?) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use std::sync::LazyLock; | ||
|
|
||
| use flatbuffers::FlatBufferBuilder; | ||
| use vortex_session::VortexSession; | ||
| use vortex_session::registry::ReadContext; | ||
|
|
||
| use super::SerializeOptions; | ||
| use super::SerializedArray; | ||
| use crate::ArrayContext; | ||
| use crate::array::ArrayId; | ||
| use crate::dtype::DType; | ||
| use crate::dtype::Nullability; | ||
| use crate::flatbuffers as fba; | ||
| use crate::session::ArraySession; | ||
|
|
||
| static SESSION: LazyLock<VortexSession> = LazyLock::new(VortexSession::empty); | ||
|
|
||
| #[test] | ||
| fn unknown_array_encoding_allow_unknown() { | ||
|
Comment on lines
-724
to
-725
Contributor
Author
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. this test didnt actually test anything, and was broken |
||
| let mut fbb = FlatBufferBuilder::new(); | ||
|
|
||
| let child_metadata = fbb.create_vector(&[9u8]); | ||
| let child = fba::ArrayNode::create( | ||
| &mut fbb, | ||
| &fba::ArrayNodeArgs { | ||
| encoding: 1, | ||
| metadata: Some(child_metadata), | ||
| children: None, | ||
| buffers: None, | ||
| stats: None, | ||
| }, | ||
| ); | ||
|
|
||
| let children = fbb.create_vector(&[child]); | ||
| let metadata = fbb.create_vector(&[1u8, 2, 3]); | ||
| let root = fba::ArrayNode::create( | ||
| &mut fbb, | ||
| &fba::ArrayNodeArgs { | ||
| encoding: 0, | ||
| metadata: Some(metadata), | ||
| children: Some(children), | ||
| buffers: None, | ||
| stats: None, | ||
| }, | ||
| ); | ||
| let array = fba::Array::create( | ||
| &mut fbb, | ||
| &fba::ArrayArgs { | ||
| root: Some(root), | ||
| buffers: None, | ||
| }, | ||
| ); | ||
| fbb.finish_minimal(array); | ||
| let (buf, start) = fbb.collapse(); | ||
| let tree = vortex_buffer::ByteBuffer::from(buf).slice(start..); | ||
|
|
||
| let ser = SerializedArray::from_array_tree(tree).unwrap(); | ||
| let ctx = ReadContext::new([ | ||
| ArrayId::new("vortex.test.foreign_array"), | ||
| ArrayId::new("vortex.test.foreign_child"), | ||
| ]); | ||
| let session = VortexSession::empty() | ||
| .with::<ArraySession>() | ||
| .allow_unknown(); | ||
|
|
||
| let decoded = ser | ||
| .decode(&DType::Variant(Nullability::Nullable), 5, &ctx, &session) | ||
| .unwrap(); | ||
| assert_eq!(decoded.encoding_id().as_ref(), "vortex.test.foreign_array"); | ||
| assert_eq!(decoded.nchildren(), 1); | ||
| assert_eq!( | ||
| decoded.nth_child(0).unwrap().encoding_id().as_ref(), | ||
| "vortex.test.foreign_child" | ||
| ); | ||
| assert_eq!(decoded.metadata(&SESSION).unwrap().unwrap(), vec![1, 2, 3]); | ||
| assert_eq!( | ||
| decoded | ||
| .nth_child(0) | ||
| .unwrap() | ||
| .metadata(&SESSION) | ||
| .unwrap() | ||
| .unwrap(), | ||
| vec![9] | ||
| ); | ||
|
|
||
| let serialized = decoded | ||
| .serialize( | ||
| &ArrayContext::default(), | ||
| &SESSION, | ||
| &SerializeOptions::default(), | ||
| ) | ||
| .unwrap(); | ||
| assert!(!serialized.is_empty()); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
?
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.
ParquetVariant is registered above.
Variant is the canonical array, it's now registrered in default ArraySession