-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
55 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[workspace] | ||
members = [ | ||
"arrow2_convert", | ||
"arrow2_convert_derive" | ||
"arrow2_convert_derive", | ||
"examples/simple" | ||
] |
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,6 +1,6 @@ | ||
[package] | ||
name = "arrow2_convert" | ||
version = "0.3.1" | ||
version = "0.3.2" | ||
authors = [ | ||
"Jorge Leitao <[email protected]>", | ||
"Chandra Penke <[email protected]>" | ||
|
@@ -13,13 +13,13 @@ description = "Convert between nested rust types and Arrow with arrow2" | |
|
||
[dependencies] | ||
arrow2 = "0.14.1" | ||
arrow2_convert_derive = { version = "0.3.0", path = "../arrow2_convert_derive", optional = true } | ||
arrow2_convert_derive = { version = "0.3.2", path = "../arrow2_convert_derive", optional = true } | ||
chrono = { version = "0.4", default_features = false, features = ["std"] } | ||
err-derive = "0.3" | ||
trybuild = "1.0" | ||
|
||
[dev-dependencies] | ||
arrow2_convert_derive = { version = "0.3.1", path = "../arrow2_convert_derive" } | ||
arrow2_convert_derive = { version = "0.3.2", path = "../arrow2_convert_derive" } | ||
|
||
[features] | ||
default = [ "derive" ] | ||
|
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,6 +1,6 @@ | ||
[package] | ||
name = "arrow2_convert_derive" | ||
version = "0.3.1" | ||
version = "0.3.2" | ||
authors = [ | ||
"Jorge Leitao <[email protected]>", | ||
"Chandra Penke <[email protected]>" | ||
|
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,10 @@ | ||
[package] | ||
name = "arrow2_convert_example_simple" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
arrow2 = "0.14" | ||
arrow2_convert = { version = "0.3", path = "../../arrow2_convert" } |
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,38 @@ | ||
/// Simple example | ||
use arrow2::array::Array; | ||
use arrow2_convert::{deserialize::TryIntoCollection, serialize::TryIntoArrow, ArrowField}; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, ArrowField)] | ||
pub struct Foo { | ||
name: String, | ||
} | ||
|
||
fn main() { | ||
// an item | ||
let original_array = [ | ||
Foo { | ||
name: "hello".to_string(), | ||
}, | ||
Foo { | ||
name: "one more".to_string(), | ||
}, | ||
Foo { | ||
name: "good bye".to_string(), | ||
}, | ||
]; | ||
|
||
// serialize to an arrow array. try_into_arrow() is enabled by the TryIntoArrow trait | ||
let arrow_array: Box<dyn Array> = original_array.try_into_arrow().unwrap(); | ||
|
||
// which can be cast to an Arrow StructArray and be used for all kinds of IPC, FFI, etc. | ||
// supported by `arrow2` | ||
let struct_array = arrow_array | ||
.as_any() | ||
.downcast_ref::<arrow2::array::StructArray>() | ||
.unwrap(); | ||
assert_eq!(struct_array.len(), 3); | ||
|
||
// deserialize back to our original vector via TryIntoCollection trait. | ||
let round_trip_array: Vec<Foo> = arrow_array.try_into_collection().unwrap(); | ||
assert_eq!(round_trip_array, original_array); | ||
} |