Skip to content

Commit

Permalink
User insert_id instead of num_rows
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Jul 3, 2023
1 parent d9bc338 commit 0b3679c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions crates/re_arrow_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ impl DataStore {
"rerun.insert_id".into()
}

pub fn last_insert_id(&self) -> u64 {
self.insert_id
}

/// See [`Self::cluster_key`] for more information about the cluster key.
pub fn cluster_key(&self) -> ComponentName {
self.cluster_key
Expand Down
4 changes: 4 additions & 0 deletions crates/re_data_store/src/store_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ impl StoreDb {
+ self.entity_db.data_store.num_temporal_rows() as usize
}

pub fn last_insert_id(&self) -> u64 {
self.entity_db.data_store.last_insert_id()
}

pub fn is_empty(&self) -> bool {
self.recording_msg.is_none() && self.num_rows() == 0
}
Expand Down
8 changes: 4 additions & 4 deletions crates/re_viewer/src/store_hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct StoreHub {
store_dbs: StoreBundle,

// The number of rows in the blueprint the last time it was saved
blueprint_last_save: HashMap<StoreId, usize>,
blueprint_last_save: HashMap<StoreId, u64>,
}

/// Convenient information used for `MemoryPanel`
Expand Down Expand Up @@ -173,14 +173,14 @@ impl StoreHub {
if let Some(blueprint) = self.store_dbs.blueprint(blueprint_id) {
// TODO(jleibs): This check isn't perfect. If we GC the blueprint and then insert
// more rows we could end up with a collision.
if self.blueprint_last_save.get(blueprint_id) != Some(&blueprint.num_rows()) {
if self.blueprint_last_save.get(blueprint_id) != Some(&blueprint.last_insert_id()) {
// TODO(jleibs): We should "flatten" blueprints when we save them
// TODO(jleibs): Should we push this into a background thread? Blueprints should generally
// be small & fast to save, but maybe not once we start adding big pieces of user data?
let file_saver = save_database_to_file(blueprint, blueprint_path, None)?;
file_saver()?;
self.blueprint_last_save
.insert(blueprint_id.clone(), blueprint.num_rows());
.insert(blueprint_id.clone(), blueprint.last_insert_id());
}
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ impl StoreHub {
self.blueprint_by_app_id
.insert(app_id.clone(), store.store_id().clone());
self.blueprint_last_save
.insert(store.store_id().clone(), store.num_rows());
.insert(store.store_id().clone(), store.last_insert_id());
self.store_dbs.insert_blueprint(store);
} else {
re_log::warn!(
Expand Down

0 comments on commit 0b3679c

Please sign in to comment.