diff --git a/Cargo.lock b/Cargo.lock index a6aa10e..fba928f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,6 +38,21 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[package]] +name = "branches" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f11502672c5570f77f6bdf573332483f8475bab6a7fda00f1fae8ddb5a6245c0" +dependencies = [ + "rustc_version", +] + [[package]] name = "bumpalo" version = "3.20.2" @@ -184,6 +199,27 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "syn", +] + [[package]] name = "either" version = "1.15.0" @@ -260,6 +296,28 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "layout" +version = "0.0.1" +source = "git+https://github.com/dzmitry-lahoda-forks/layout.git?rev=507186970c57e8a168783ddefabf8cb08d7ba505#507186970c57e8a168783ddefabf8cb08d7ba505" +dependencies = [ + "bit-vec", + "branches", + "layout_internal", + "permutation", + "rustc_version", +] + +[[package]] +name = "layout_internal" +version = "0.0.1" +source = "git+https://github.com/dzmitry-lahoda-forks/layout.git?rev=507186970c57e8a168783ddefabf8cb08d7ba505#507186970c57e8a168783ddefabf8cb08d7ba505" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "libc" version = "0.2.185" @@ -297,7 +355,10 @@ checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" name = "oql" version = "1.0.0" dependencies = [ + "branches", "criterion", + "derive_more", + "layout", "oql-macro", "trybuild", ] @@ -321,6 +382,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "permutation" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df202b0b0f5b8e389955afd5f27b007b00fb948162953f1db9c70d2c7e3157d7" + [[package]] name = "plotters" version = "0.3.7" @@ -416,6 +483,15 @@ version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustversion" version = "1.0.22" @@ -431,6 +507,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + [[package]] name = "serde" version = "1.0.228" diff --git a/oql/Cargo.toml b/oql/Cargo.toml index a1214f9..71fd8a4 100644 --- a/oql/Cargo.toml +++ b/oql/Cargo.toml @@ -19,6 +19,10 @@ oql-macro = { version = "1.0.0", path = "../oql-macro" } [dev-dependencies] trybuild = "1" criterion = { version = "0.8", features = ["html_reports"] } +# https://github.com/fereidani/layout/pull/1 +layout = { git = "https://github.com/dzmitry-lahoda-forks/layout.git", rev = "507186970c57e8a168783ddefabf8cb08d7ba505", features = ["tuple", "std"] } +derive_more = { version = "2.1", features = ["from"] } +branches = "0.3" [[bench]] name = "throughput" diff --git a/oql/tests/soa.rs b/oql/tests/soa.rs new file mode 100644 index 0000000..53a4e81 --- /dev/null +++ b/oql/tests/soa.rs @@ -0,0 +1,51 @@ +use oql::oql; + +#[test] +fn join_emits_n_per_outer_on_n_matches_soa() { + // Two customer records share the same id; each matching order must + // produce two output rows (one per matching customer). + #[derive(Clone)] + struct Order { + id: u32, + customer_id: u32, + } + #[derive(Clone)] + struct Customer { + id: u32, + name: &'static str, + } + + let orders = vec![Order { + id: 1, + customer_id: 10, + }]; + let customers = vec![ + Customer { + id: 10, + name: "Anna", + }, + Customer { + id: 10, + name: "Ann", + }, + ]; + + #[derive(layout::SOA, derive_more::From)] + struct Report { + order_id: u32, + customer_name: &'static str, + } + + let out: ReportVec = oql! { + from o in orders + join c in customers on o.customer_id == c.id + select ( + o.id, + c.name, + ) + } + .collect(); + + assert_eq!(out.order_id, vec![1, 1]); + assert_eq!(out.customer_name, vec!["Anna", "Ann"]); +}