Skip to content
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 transparency at the semantic layer #2611

Merged
merged 7 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions crates/re_types/definitions/fbs/attributes.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,19 @@ namespace fbs.attributes;
/// NOTE: We do not use flatbuffers' builtin `id` attribute as it only works on `table`s, whereas we
/// need a stable order for all kinds of things.
attribute "order";

/// This attribute enables _semantic_ transparency.
///
/// * When applied to a table's field that is itself a table, this removes the extra table
/// layer during the semantic pass, leaving just the inner field's type in its stead.
///
/// * When applied to a table object, this indicates that the object is only ever used as a
/// field type, and thus should not generate any standalone code for itself.
///
/// Since all of this is done during the semantic pass, none of the other passes will ever know
/// that the extra layer ever existed in the first place.
///
/// This allows to bypass all of Flatbuffers artificial limitations (have to wrap scalars in a
/// table when defining a union, cannot put arrays (as opposed to vectors) into tables, etc) that
/// do not apply in our case.
attribute "transparent";
13 changes: 0 additions & 13 deletions crates/re_types/definitions/fbs/scalars.fbs

This file was deleted.

18 changes: 18 additions & 0 deletions crates/re_types/definitions/rerun/testing/datatypes/fuzzy.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ namespace rerun.testing.datatypes;

// ---

table FlattenedScalar ("attr.rust.derive": "PartialEq", order: 001) {
value: float (order: 100);
}

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

table VeryDeeplyFlattenedScalar (transparent, order: 001) {
value: DeeplyFlattenedScalar (order: 100, transparent);
}

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

table AffixFuzzer1 (
"attr.rust.derive": "PartialEq",
order: 100
Expand All @@ -16,6 +32,8 @@ table AffixFuzzer1 (
many_floats_optional: [float] (order: 104);
many_strings_required: [string] (order: 105, required);
many_strings_optional: [string] (order: 106);
flattened_scalar: VeryDeeplyFlattenedScalar (order: 107, required, transparent);
almost_flattened_scalar: SurprisinglyShallowScalar (order: 108, required, transparent);
}

table AffixFuzzer2 (
Expand Down
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.
65d6bf828303169287dd4a8df605e50acbde791fa0f2e8167ea751fd23d3a56f
d05383876b33ae3b108ceffac46e0292a0dbc2253e3e777028181b4ed338315f
153 changes: 153 additions & 0 deletions crates/re_types/src/components/fuzzy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ impl crate::Component for AffixFuzzer1 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
])
}

Expand Down Expand Up @@ -230,6 +247,23 @@ impl crate::Component for AffixFuzzer2 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
])
}

Expand Down Expand Up @@ -372,6 +406,23 @@ impl crate::Component for AffixFuzzer3 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
])
}

Expand Down Expand Up @@ -514,6 +565,23 @@ impl crate::Component for AffixFuzzer4 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
])
}

Expand Down Expand Up @@ -652,6 +720,23 @@ impl crate::Component for AffixFuzzer5 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
])
}

Expand Down Expand Up @@ -792,6 +877,23 @@ impl crate::Component for AffixFuzzer6 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
])
}

Expand Down Expand Up @@ -934,6 +1036,23 @@ impl crate::Component for AffixFuzzer7 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
]),
is_nullable: true,
metadata: [].into(),
Expand Down Expand Up @@ -1052,6 +1171,23 @@ impl crate::Component for AffixFuzzer7 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
]),
is_nullable: true,
metadata: [].into(),
Expand Down Expand Up @@ -1154,6 +1290,23 @@ impl crate::Component for AffixFuzzer7 {
is_nullable: true,
metadata: [].into(),
},
Field {
name: "flattened_scalar".to_owned(),
data_type: DataType::Float32,
is_nullable: false,
metadata: [].into(),
},
Field {
name: "almost_flattened_scalar".to_owned(),
data_type: DataType::Struct(vec![Field {
name: "value".to_owned(),
data_type: DataType::Float32,
is_nullable: true,
metadata: [].into(),
}]),
is_nullable: false,
metadata: [].into(),
},
]),
})
})
Expand Down
Loading
Loading