Skip to content

Commit

Permalink
Generating (de)serialization code for dense unions in Rust backend (#…
Browse files Browse the repository at this point in the history
…2626)

**COMMIT BY COMMIT!**

What the title says.

Adding support for sparse unions would be trivial, but nobody ever uses
those so I've refrained from doing it for now.

Fixes #2625 
Requires #2618 
Requires #2619

---

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2626) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/2626)
- [Docs preview](https://rerun.io/preview/pr%3Acmc%2Farrow_union/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Acmc%2Farrow_union/examples)
  • Loading branch information
teh-cmc authored Jul 7, 2023
1 parent 670812d commit 2d8fd0a
Show file tree
Hide file tree
Showing 18 changed files with 6,018 additions and 40 deletions.
25 changes: 24 additions & 1 deletion crates/re_types/definitions/rerun/testing/archetypes/fuzzy.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ table AffixFuzzer1 (
fuzz1011: rerun.testing.components.AffixFuzzer11 ("attr.rerun.component_required", order: 1011);
fuzz1012: rerun.testing.components.AffixFuzzer12 ("attr.rerun.component_required", order: 1012);
fuzz1013: rerun.testing.components.AffixFuzzer13 ("attr.rerun.component_required", order: 1013);
fuzz1014: rerun.testing.components.AffixFuzzer14 ("attr.rerun.component_required", order: 1014);
// NOTE: nullable union -- illegal!
// fuzz1015: rerun.testing.components.AffixFuzzer15 ("attr.rerun.component_required", order: 1015);
fuzz1016: rerun.testing.components.AffixFuzzer16 ("attr.rerun.component_required", order: 1016);
fuzz1017: rerun.testing.components.AffixFuzzer17 ("attr.rerun.component_required", order: 1017);
fuzz1018: rerun.testing.components.AffixFuzzer18 ("attr.rerun.component_required", order: 1018);

fuzz1101: [rerun.testing.components.AffixFuzzer1] ("attr.rerun.component_required", order: 1101);
fuzz1102: [rerun.testing.components.AffixFuzzer2] ("attr.rerun.component_required", order: 1102);
Expand All @@ -42,6 +48,12 @@ table AffixFuzzer1 (
fuzz1111: [rerun.testing.components.AffixFuzzer11] ("attr.rerun.component_required", order: 1111);
fuzz1112: [rerun.testing.components.AffixFuzzer12] ("attr.rerun.component_required", order: 1112);
fuzz1113: [rerun.testing.components.AffixFuzzer13] ("attr.rerun.component_required", order: 1113);
fuzz1114: [rerun.testing.components.AffixFuzzer14] ("attr.rerun.component_required", order: 1114);
// NOTE: nullable union -- illegal!
// fuzz1115: [rerun.testing.components.AffixFuzzer15] ("attr.rerun.component_required", order: 1115);
fuzz1116: [rerun.testing.components.AffixFuzzer16] ("attr.rerun.component_required", order: 1116);
fuzz1117: [rerun.testing.components.AffixFuzzer17] ("attr.rerun.component_required", order: 1117);
fuzz1118: [rerun.testing.components.AffixFuzzer18] ("attr.rerun.component_required", order: 1118);

fuzz2001: rerun.testing.components.AffixFuzzer1 ("attr.rerun.component_optional", nullable, order: 2001);
fuzz2002: rerun.testing.components.AffixFuzzer2 ("attr.rerun.component_optional", nullable, order: 2002);
Expand All @@ -56,6 +68,12 @@ table AffixFuzzer1 (
fuzz2011: rerun.testing.components.AffixFuzzer11 ("attr.rerun.component_optional", nullable, order: 2011);
fuzz2012: rerun.testing.components.AffixFuzzer12 ("attr.rerun.component_optional", nullable, order: 2012);
fuzz2013: rerun.testing.components.AffixFuzzer13 ("attr.rerun.component_optional", nullable, order: 2013);
fuzz2014: rerun.testing.components.AffixFuzzer14 ("attr.rerun.component_optional", nullable, order: 2014);
// NOTE: nullable union -- illegal!
// fuzz2015: rerun.testing.components.AffixFuzzer15 ("attr.rerun.component_optional", nullable, order: 2015);
fuzz2016: rerun.testing.components.AffixFuzzer16 ("attr.rerun.component_optional", nullable, order: 2016);
fuzz2017: rerun.testing.components.AffixFuzzer17 ("attr.rerun.component_optional", nullable, order: 2017);
fuzz2018: rerun.testing.components.AffixFuzzer18 ("attr.rerun.component_optional", nullable, order: 2018);

fuzz2101: [rerun.testing.components.AffixFuzzer1] ("attr.rerun.component_optional", nullable, order: 2101);
fuzz2102: [rerun.testing.components.AffixFuzzer2] ("attr.rerun.component_optional", nullable, order: 2102);
Expand All @@ -70,5 +88,10 @@ table AffixFuzzer1 (
fuzz2111: [rerun.testing.components.AffixFuzzer11] ("attr.rerun.component_optional", nullable, order: 2111);
fuzz2112: [rerun.testing.components.AffixFuzzer12] ("attr.rerun.component_optional", nullable, order: 2112);
fuzz2113: [rerun.testing.components.AffixFuzzer13] ("attr.rerun.component_optional", nullable, order: 2113);
fuzz2114: [rerun.testing.components.AffixFuzzer14] ("attr.rerun.component_optional", nullable, order: 2114);
// NOTE: nullable union -- illegal!
// fuzz2115: [rerun.testing.components.AffixFuzzer15] ("attr.rerun.component_optional", nullable, order: 2115);
fuzz2116: [rerun.testing.components.AffixFuzzer16] ("attr.rerun.component_optional", nullable, order: 2116);
fuzz2117: [rerun.testing.components.AffixFuzzer17] ("attr.rerun.component_optional", nullable, order: 2117);
fuzz2118: [rerun.testing.components.AffixFuzzer18] ("attr.rerun.component_optional", nullable, order: 2118);
}

38 changes: 37 additions & 1 deletion crates/re_types/definitions/rerun/testing/components/fuzzy.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,47 @@ table AffixFuzzer13 (
many_strings_optional: [string] (nullable, order: 113);
}

table AffixFuzzer14 (
"attr.rust.derive": "PartialEq",
order: 1400
) {
single_required_union: rerun.testing.datatypes.AffixFuzzer3 (order: 114);
}

// NOTE: Illegal: union don't have top-level bitmaps! Commenting out will/should break the build.
// table AffixFuzzer15 (
// "attr.rust.derive": "PartialEq",
// order: 1500
// ) {
// single_optional_union: rerun.testing.datatypes.AffixFuzzer3 (nullable, order: 115);
// }

table AffixFuzzer16 (
"attr.rust.derive": "PartialEq",
order: 1600
) {
many_required_unions: [rerun.testing.datatypes.AffixFuzzer3] (order: 116);
}

table AffixFuzzer17 (
"attr.rust.derive": "PartialEq",
order: 1700
) {
many_optional_unions: [rerun.testing.datatypes.AffixFuzzer3] (nullable, order: 117);
}

table AffixFuzzer18 (
"attr.rust.derive": "PartialEq",
order: 1800
) {
many_optional_unions: [rerun.testing.datatypes.AffixFuzzer4] (nullable, order: 118);
}

// TODO(cmc): the ugly bug we need to take care of at some point
// table AffixFuzzer14 (
// "attr.rust.derive": "PartialEq",
// order: 1400
// ) {
//
// many_transparent_optionals: rerun.testing.datatypes.AffixFuzzer2 (order: 107);
// many_transparent_optionals: rerun.testing.datatypes.AffixFuzzer2 (nullable, order: 107);
// }
32 changes: 31 additions & 1 deletion crates/re_types/definitions/rerun/testing/datatypes/fuzzy.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ table VeryDeeplyFlattenedScalar (transparent, order: 001) {
}

table SurprisinglyShallowScalar (transparent, order: 001) {
value: FlattenedScalar (required, order: 100);
value: FlattenedScalar (order: 100);
}

table AffixFuzzer1 (
Expand All @@ -36,6 +36,10 @@ table AffixFuzzer1 (
almost_flattened_scalar: SurprisinglyShallowScalar (order: 108, transparent);
}

table __AffixFuzzer1Vec (transparent, order: 0) {
inner: [AffixFuzzer1] (order: 0);
}

table AffixFuzzer2 (
"attr.arrow.transparent",
"attr.rust.derive": "PartialEq",
Expand All @@ -44,3 +48,29 @@ table AffixFuzzer2 (
) {
single_float_optional: float (nullable, order: 101);
}

union AffixFuzzer3 (
"attr.rust.derive": "PartialEq",
order: 300
) {
degrees: FlattenedScalar (transparent, order: 100),
radians: FlattenedScalar (transparent, nullable, order: 101),
craziness: __AffixFuzzer1Vec (transparent, order: 102),
}

table __AffixFuzzer3 (transparent, order: 0) {
inner: AffixFuzzer3 (order: 0);
}

table __AffixFuzzer3Vec (transparent, order: 0) {
inner: [AffixFuzzer3] (order: 0);
}

union AffixFuzzer4 (
"attr.rust.derive": "PartialEq",
order: 300
) {
single_required: __AffixFuzzer3 (transparent, order: 100),
many_required: __AffixFuzzer3Vec (transparent, order: 101),
many_optional: __AffixFuzzer3Vec (transparent, order: 102, nullable),
}
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is a sha256 hash for all direct and indirect dependencies of this crate's build script.
# It can be safely removed at anytime to force the build script to run again.
# Check out build.rs to see how it's computed.
b0b0d5d6d0f4131e52331303a2c2dfdfa11e03936e97242ef897c2b158979273
51e4e1d21a853de2f4d3b55d7d34d75cb3d6f0f7c01b701e9750256c759e9827
Loading

0 comments on commit 2d8fd0a

Please sign in to comment.