-
Notifications
You must be signed in to change notification settings - Fork 875
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
Support Rust structures --> RecordBatch
by adding Serde
support to RawDecoder
(#3949)
#3979
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d267ed2
Add serde support to RawDecoder (#3949)
tustvold 787e6ec
Clippy
tustvold 7413f31
Merge remote-tracking branch 'upstream/master' into add-serde-raw-dec…
tustvold 335c96f
More examples
tustvold d889ca5
Use BTreeMap for deterministic test output
tustvold f81f984
Merge remote-tracking branch 'upstream/master' into add-serde-raw-dec…
tustvold d81eccb
Use new Field constructors
tustvold 0fb956c
Review feedback
tustvold 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 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 |
---|---|---|
|
@@ -271,6 +271,52 @@ | |
//! | ||
//! Parquet is published as a [separate crate](https://crates.io/crates/parquet) | ||
//! | ||
//! # Serde Compatibility | ||
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. ❤️ |
||
//! | ||
//! [`arrow_json::RawDecoder`] provides a mechanism to convert arbitrary, serde-compatible | ||
//! structures into [`RecordBatch`]. | ||
//! | ||
//! Whilst likely less performant than implementing a custom builder, as described in | ||
//! [arrow_array::builder], this provides a simple mechanism to get up and running quickly | ||
//! | ||
//! ``` | ||
//! # use std::sync::Arc; | ||
//! # use arrow_json::RawReaderBuilder; | ||
//! # use arrow_schema::{DataType, Field, Schema}; | ||
//! # use serde::Serialize; | ||
//! # use arrow_array::cast::AsArray; | ||
//! # use arrow_array::types::{Float32Type, Int32Type}; | ||
//! # | ||
//! #[derive(Serialize)] | ||
//! struct MyStruct { | ||
//! int32: i32, | ||
//! string: String, | ||
//! } | ||
//! | ||
//! let schema = Schema::new(vec![ | ||
//! Field::new("int32", DataType::Int32, false), | ||
//! Field::new("string", DataType::Utf8, false), | ||
//! ]); | ||
//! | ||
//! let rows = vec![ | ||
//! MyStruct{ int32: 5, string: "bar".to_string() }, | ||
//! MyStruct{ int32: 8, string: "foo".to_string() }, | ||
//! ]; | ||
//! | ||
//! let mut decoder = RawReaderBuilder::new(Arc::new(schema)).build_decoder().unwrap(); | ||
//! decoder.serialize(&rows).unwrap(); | ||
//! | ||
//! let batch = decoder.flush().unwrap().unwrap(); | ||
//! | ||
//! // Expect batch containing two columns | ||
//! let int32 = batch.column(0).as_primitive::<Int32Type>(); | ||
//! assert_eq!(int32.values(), &[5, 8]); | ||
//! | ||
//! let string = batch.column(1).as_string::<i32>(); | ||
//! assert_eq!(string.value(0), "bar"); | ||
//! assert_eq!(string.value(1), "foo"); | ||
//! ``` | ||
//! | ||
//! # Memory and Buffers | ||
//! | ||
//! Advanced users may wish to interact with the underlying buffers of an [`Array`], for example, | ||
|
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.
I think a more compelling example would be to implement some struct
And demonstrate how to turn that into a
RecordBatch
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.
Added a fairly comprehensive example
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.
This example is very cool. However, I think it is very hard to find (given that it is on "RawDecoder" that is part of arrow_json).
I suggest we add a sentence / link to this example from the front page (and maybe even bring a simpler example to the front page): https://docs.rs/arrow/latest/arrow/index.html#io