Skip to content

Commit

Permalink
WIP: revise data model
Browse files Browse the repository at this point in the history
  • Loading branch information
grtlr committed Sep 25, 2024
1 parent f13d598 commit b5d7d7b
Show file tree
Hide file tree
Showing 38 changed files with 1,282 additions and 356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ namespace rerun.components;
/// An edge in a graph connecting two nodes.
///
/// Depending on the context this could represent a directed or undirected edge.
//
// TODO(grtlr): Why do we need `Default` here?
struct GraphEdge (
"attr.arrow.transparent",
"attr.python.aliases": "Tuple(int, int)",
"attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, bytemuck::Pod, bytemuck::Zeroable",
table GraphEdge (
"attr.rust.derive": "Default, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.repr": "transparent",
"attr.rust.custom_clause":
'cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))'
) {
edge: [rerun.datatypes.GraphNodeId: 2] (order: 100);
edge: [rerun.datatypes.GraphEdge] (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ namespace rerun.components;
// ---

/// A 32-bit ID representing a node in a graph.
//
// TODO(grtlr): Why do we need `Default` here?
struct GraphNodeId (
"attr.arrow.transparent",
"attr.python.aliases": "int",
"attr.python.array_aliases": "int, npt.NDArray[np.uint8], npt.NDArray[np.uint16], npt.NDArray[np.uint32], npt.NDArray[np.uint64]",
"attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, bytemuck::Pod, bytemuck::Zeroable",
table GraphNodeId (
"attr.python.aliases": "str",
"attr.python.array_aliases": "str, Sequence[str]",
"attr.rust.derive": "Default, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.repr": "transparent",
"attr.rust.custom_clause":
'cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))'
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/datatypes.fbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions crates/store/re_types/definitions/rerun/datatypes/graph_edge.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include "entity_path.fbs";
include "graph_node_id.fbs";

namespace rerun.datatypes;

/// Represents an edge in a graph connecting two nodes (possible in different entities).
///
/// If `source_entity` or `dest_entity` is left out then the node id is assumed to be within the current entity.
table GraphEdge (
"attr.rust.derive": "Default, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.custom_clause":
'cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))'
) {
/// The id of the source node.
source: rerun.datatypes.GraphNodeId (order: 100);

/// The id of the target node.
dest: rerun.datatypes.GraphNodeId (order: 200);

/// The entity path of the source node.
source_entity: rerun.datatypes.EntityPath (order: 300, nullable);

/// The entity path of the target node.
dest_entity: rerun.datatypes.EntityPath (order: 400, nullable);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
namespace rerun.datatypes;

// ---

/// A 32-bit ID representing a node in a graph.
struct GraphNodeId (
table GraphNodeId (
"attr.arrow.transparent",
"attr.python.aliases": "int",
"attr.python.array_aliases": "int, npt.ArrayLike",
"attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, bytemuck::Pod, bytemuck::Zeroable",
"attr.python.aliases": "str",
"attr.python.array_aliases": "Sequence[str]",
"attr.rust.derive": "Default, PartialEq, Eq, PartialOrd, Ord, Hash",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct",
"attr.rust.custom_clause":
'cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))'
) {
id: uint (order: 100);
id: string (order: 100);
}
188 changes: 40 additions & 148 deletions crates/store/re_types/src/components/graph_edge.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions crates/store/re_types/src/components/graph_edge_ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// TODO(grtlr): improve these convenience methods

use re_types_core::datatypes::EntityPath;

use crate::datatypes::{GraphEdge, GraphNodeId};

impl super::GraphEdge {
pub fn new(source: impl Into<GraphNodeId>, dest: impl Into<GraphNodeId>) -> Self {
Self(vec![GraphEdge {
source: source.into(),
dest: dest.into(),
source_entity: None,
dest_entity: None,
}])
}

pub fn new_global(
(source_entity, source): (impl Into<EntityPath>, impl Into<GraphNodeId>),
(dest_entity, dest): (impl Into<EntityPath>, impl Into<GraphNodeId>),
) -> Self {
Self(vec![GraphEdge {
source_entity: Some(source_entity.into()),
source: source.into(),
dest_entity: Some(dest_entity.into()),
dest: dest.into(),
}])
}
}
Loading

0 comments on commit b5d7d7b

Please sign in to comment.