Skip to content

Commit

Permalink
Enable selecting data sources and blueprints and recordings in them (#…
Browse files Browse the repository at this point in the history
…5646)

### What
* Part of #5645

If you click a recording you will now see what blueprints are in the
same data source.
You can also select the data source directly to see all recordings and
blueprints in it.
Selecting a blueprint is now also possible.
I also added the size of the store to the selection panel.


https://github.com/rerun-io/rerun/assets/1148717/e353339b-56c1-4924-9523-59afea2b5da0


### 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 the web demo (if applicable):
* Using newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5646/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5646/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5646/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5646)
- [Docs
preview](https://rerun.io/preview/920381f809c2d96122511ff18de54795d7db7bd6/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/920381f809c2d96122511ff18de54795d7db7bd6/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
emilk authored Mar 25, 2024
1 parent dde0be0 commit 7e1bde9
Show file tree
Hide file tree
Showing 31 changed files with 543 additions and 209 deletions.
5 changes: 5 additions & 0 deletions Cargo.lock

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

4 changes: 1 addition & 3 deletions crates/re_build_search_index/src/ingest/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ impl Docstrings {
}

// if `path` is an alias, get the qualified path
let Some(path) = self.aliases.get(path) else {
return None;
};
let path = self.aliases.get(path)?;

self.docstrings.get(path)
}
Expand Down
7 changes: 7 additions & 0 deletions crates/re_data_store/src/store_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ impl SizeBytes for ClusterCellCache {
}
}

impl SizeBytes for DataStore {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.timeless_size_bytes() + self.temporal_size_bytes() // approximate
}
}

impl DataStore {
/// Returns the number of timeless index rows stored across this entire store, i.e. the sum of
/// the number of rows across all of its timeless indexed tables.
Expand Down
2 changes: 2 additions & 0 deletions crates/re_data_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ re_log.workspace = true
re_log_types.workspace = true
re_query.workspace = true
re_renderer.workspace = true
re_smart_channel.workspace = true
re_tracing.workspace = true
re_types = { workspace = true, features = [
"egui_plot", # Needed to draw marker shapes.
] }
re_types_core.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true

Expand Down
63 changes: 63 additions & 0 deletions crates/re_data_ui/src/data_source.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use re_log_types::StoreKind;
use re_viewer_context::{UiVerbosity, ViewerContext};

use crate::item_ui::entity_db_button_ui;

impl crate::DataUi for re_smart_channel::SmartChannelSource {
fn data_ui(
&self,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_query: &re_data_store::LatestAtQuery,
_store: &re_data_store::DataStore,
) {
ui.label(self.to_string());

if verbosity == UiVerbosity::Small {
return;
}

// TODO(emilk): show if we're still connected to this data source

// Find all stores from this data source
// (e.g. find the recordings and blueprint in this .rrd file).
let mut recordings = vec![];
let mut blueprints = vec![];

for other in ctx
.store_context
.bundle
.entity_dbs_from_channel_source(self)
{
match other.store_kind() {
StoreKind::Recording => {
recordings.push(other);
}
StoreKind::Blueprint => {
blueprints.push(other);
}
}
}

{
ui.add_space(8.0);
ui.strong("Recordings in this data source");
ui.indent("recordings", |ui| {
for entity_db in recordings {
entity_db_button_ui(ctx, ui, entity_db, true);
}
});
}

{
ui.add_space(8.0);
ui.strong("Blueprints in this data source");
ui.indent("blueprints", |ui| {
for entity_db in blueprints {
entity_db_button_ui(ctx, ui, entity_db, true);
}
});
}
}
}
120 changes: 104 additions & 16 deletions crates/re_data_ui/src/entity_db.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
impl crate::DataUi for re_entity_db::EntityDb {
use re_entity_db::EntityDb;
use re_log_types::StoreKind;
use re_types::SizeBytes;
use re_viewer_context::{UiVerbosity, ViewerContext};

use crate::item_ui::{data_source_button_ui, entity_db_button_ui};

impl crate::DataUi for EntityDb {
fn data_ui(
&self,
ctx: &re_viewer_context::ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: re_viewer_context::UiVerbosity,
verbosity: UiVerbosity,
_query: &re_data_store::LatestAtQuery,
_store: &re_data_store::DataStore,
) {
let re_ui = &ctx.re_ui;

if verbosity == re_viewer_context::UiVerbosity::Small {
if verbosity == UiVerbosity::Small {
let mut string = self.store_id().to_string();
if let Some(data_source) = &self.data_source {
string += &format!(", {data_source}");
Expand All @@ -22,13 +29,9 @@ impl crate::DataUi for re_entity_db::EntityDb {
}

egui::Grid::new("entity_db").num_columns(2).show(ui, |ui| {
re_ui.grid_left_hand_label(ui, &format!("{} ID", self.store_id().kind));
ui.label(self.store_id().to_string());
ui.end_row();

if let Some(data_source) = &self.data_source {
re_ui.grid_left_hand_label(ui, "Data source");
ui.label(data_source.to_string());
{
re_ui.grid_left_hand_label(ui, &format!("{} ID", self.store_id().kind));
ui.label(self.store_id().to_string());
ui.end_row();
}

Expand All @@ -54,12 +57,97 @@ impl crate::DataUi for re_entity_db::EntityDb {
ui.label(store_source.to_string());
ui.end_row();

// We are in the recordings menu, we know the kind
if false {
re_ui.grid_left_hand_label(ui, "Kind");
ui.label(store_kind.to_string());
ui.end_row();
re_ui.grid_left_hand_label(ui, "Kind");
ui.label(store_kind.to_string());
ui.end_row();
}

{
re_ui.grid_left_hand_label(ui, "Size");
ui.label(re_format::format_bytes(self.total_size_bytes() as _))
.on_hover_text(
"Approximate size in RAM (decompressed).\n\
If you hover an entity in the streams view (bottom panel) you can see the size of individual entities.");
ui.end_row();
}

if let Some(data_source) = &self.data_source {
re_ui.grid_left_hand_label(ui, "Data source");
data_source_button_ui(ctx, ui, data_source);
ui.end_row();
}
});

if ctx.store_context.is_active(self.store_id()) {
ui.add_space(8.0);
match self.store_kind() {
StoreKind::Recording => {
ui.label("This is the active recording");
}
StoreKind::Blueprint => {
ui.label("This is the active blueprint");
}
}
}

if verbosity == UiVerbosity::Full {
sibling_stores_ui(ctx, ui, self);
}
}
}

/// Show the other stores in the same data source.
fn sibling_stores_ui(ctx: &ViewerContext<'_>, ui: &mut egui::Ui, entity_db: &EntityDb) {
let Some(data_source) = &entity_db.data_source else {
return;
};

// Find other stores from the same data source
// (e.g. find the blueprint in this .rrd file, if any).
let mut other_recordings = vec![];
let mut other_blueprints = vec![];

for other in ctx
.store_context
.bundle
.entity_dbs_from_channel_source(data_source)
{
if other.store_id() == entity_db.store_id() {
continue;
}
match other.store_kind() {
StoreKind::Recording => {
other_recordings.push(other);
}
StoreKind::Blueprint => {
other_blueprints.push(other);
}
}
}

if !other_recordings.is_empty() {
ui.add_space(8.0);
if entity_db.store_kind() == StoreKind::Recording {
ui.strong("Other recordings in this data source");
} else {
ui.strong("Recordings in this data source");
}
ui.indent("recordings", |ui| {
for entity_db in other_recordings {
entity_db_button_ui(ctx, ui, entity_db, true);
}
});
}
if !other_blueprints.is_empty() {
ui.add_space(8.0);
if entity_db.store_kind() == StoreKind::Blueprint {
ui.strong("Other blueprints in this data source");
} else {
ui.strong("Blueprints in this data source");
}
ui.indent("blueprints", |ui| {
for entity_db in other_blueprints {
entity_db_button_ui(ctx, ui, entity_db, true);
}
});
}
Expand Down
Loading

0 comments on commit 7e1bde9

Please sign in to comment.