-
Notifications
You must be signed in to change notification settings - Fork 373
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
Drive blueprints off of a DataStore #2010
Changes from 105 commits
b7971bf
dd7a3f8
10b6cde
3fb1f63
df0c7cc
1eb5024
8d0bbdf
468e0ca
63775a8
633c923
9d8abf5
36d19ff
f42b2e7
4bb548f
2599c65
8bb6e80
9b9aba6
06e1505
68fe9fd
6874eeb
d54fadf
ba564c9
6fedb47
68dc65e
5e7307b
97f089f
38f5e4f
b7f6345
4618529
6a3b169
73abfa9
06be29a
4a988b6
2f1717e
9407501
feac631
15257cd
c13a46a
d6c779a
f09ce3c
22a0280
2f4c1e0
77a5fb9
2c36827
5ee8be2
f4b65c3
7077765
3ce99ad
1d04b65
96d0876
48bfa80
6f17cbb
e7983cc
ae3f9b3
5320ffb
2c13f38
76c20b5
1355907
9d9d483
b9732f1
ead1c71
5976c3a
06031f0
4dc8d6e
d6fc7d0
6e61cc9
7edc687
dd52e7f
ca083a5
a36f7a3
87844dd
0c608d7
0b88614
992d7de
52e03e7
92075fe
19c0ae7
bae874a
914a12e
06b3a40
bb0fa6d
6a87fd7
007189f
7594345
0d3bfe7
58a8a47
4608d46
746b85c
9a3afaa
d242fdb
2c0de29
803d2ba
60c5f82
d01b6c0
46fa1dd
20e8715
6a03325
63dedb3
78a5157
d1efba7
7424638
6aa84cd
f441e18
9b3097c
3f629e8
6764bb1
71829fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ use re_arrow_store::{DataStoreConfig, TimeInt}; | |
use re_log_types::{ | ||
component_types::InstanceKey, ArrowMsg, Component as _, ComponentPath, DataCell, DataRow, | ||
DataTable, EntityPath, EntityPathHash, EntityPathOpMsg, LogMsg, PathOp, RecordingId, | ||
RecordingInfo, RowId, SetRecordingInfo, TimePoint, Timeline, | ||
RecordingInfo, RecordingType, RowId, SetRecordingInfo, TimePoint, Timeline, | ||
}; | ||
|
||
use crate::{Error, TimesPerTimeline}; | ||
|
@@ -69,7 +69,8 @@ impl EntityDb { | |
Ok(()) | ||
} | ||
|
||
fn try_add_data_row(&mut self, row: &DataRow) -> Result<(), Error> { | ||
// TODO(jleibs): If this shouldn't be public, chain together other setters | ||
pub fn try_add_data_row(&mut self, row: &DataRow) -> Result<(), Error> { | ||
Comment on lines
+72
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wanted to chat with @teh-cmc about whether this should be public... if it's not there's probably some other way of adding a data-row but it requires using other less direct APIs. |
||
for (&timeline, &time_int) in row.timepoint().iter() { | ||
self.times_per_timeline.insert(timeline, time_int); | ||
} | ||
|
@@ -195,6 +196,10 @@ impl LogDb { | |
self.recording_msg().map(|msg| &msg.info) | ||
} | ||
|
||
pub fn recording_type(&self) -> RecordingType { | ||
self.recording_id.variant | ||
} | ||
|
||
pub fn recording_id(&self) -> &RecordingId { | ||
&self.recording_id | ||
} | ||
|
@@ -241,7 +246,7 @@ impl LogDb { | |
Ok(()) | ||
} | ||
|
||
fn add_begin_recording_msg(&mut self, msg: &SetRecordingInfo) { | ||
pub fn add_begin_recording_msg(&mut self, msg: &SetRecordingInfo) { | ||
self.recording_msg = Some(msg.clone()); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
use re_arrow_store::LatestAtQuery; | ||
use re_log_types::{ | ||
DataRow, DeserializableComponent, EntityPath, RowId, SerializableComponent, TimeInt, TimePoint, | ||
Timeline, | ||
}; | ||
|
||
use crate::LogDb; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
/// Get the latest value for a given [`re_log_types::Component`]. | ||
/// | ||
/// This assumes that the row we get from the store only contains a single instance for this | ||
/// component; it will log a warning otherwise. | ||
/// | ||
/// This should only be used for "mono-components" such as `Transform` and `Tensor`. | ||
pub fn query_latest_single<C: DeserializableComponent>( | ||
data_store: &re_arrow_store::DataStore, | ||
entity_path: &EntityPath, | ||
query: &LatestAtQuery, | ||
) -> Option<C> | ||
where | ||
for<'b> &'b C::ArrayType: IntoIterator, | ||
{ | ||
crate::profile_function!(); | ||
|
||
// Although it would be nice to use the `re_query` helpers for this, we would need to move | ||
// this out of re_data_store to avoid a circular dep. Since we don't need to do a join for | ||
// single components this is easy enough. | ||
|
||
let (_, cells) = data_store.latest_at(query, entity_path, C::name(), &[C::name()])?; | ||
let cell = cells.get(0)?.as_ref()?; | ||
|
||
let mut iter = cell.try_to_native::<C>().ok()?; | ||
|
||
let component = iter.next(); | ||
|
||
if iter.next().is_some() { | ||
re_log::warn_once!("Unexpected batch for {} at: {}", C::name(), entity_path); | ||
} | ||
|
||
component | ||
} | ||
|
||
/// Get the latest value for a given [`re_log_types::Component`] assuming it is timeless. | ||
/// | ||
/// This assumes that the row we get from the store only contains a single instance for this | ||
/// component; it will log a warning otherwise. | ||
pub fn query_timeless_single<C: DeserializableComponent>( | ||
data_store: &re_arrow_store::DataStore, | ||
entity_path: &EntityPath, | ||
) -> Option<C> | ||
where | ||
for<'b> &'b C::ArrayType: IntoIterator, | ||
{ | ||
let query = re_arrow_store::LatestAtQuery::new(Timeline::default(), TimeInt::MAX); | ||
query_latest_single(data_store, entity_path, &query) | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
/// Store a single value for a given [`re_log_types::Component`]. | ||
pub fn store_one_component<C: SerializableComponent>( | ||
log_db: &mut LogDb, | ||
entity_path: &EntityPath, | ||
timepoint: &TimePoint, | ||
component: C, | ||
) { | ||
let mut row = DataRow::from_cells1( | ||
RowId::random(), | ||
entity_path.clone(), | ||
timepoint.clone(), | ||
1, | ||
[component].as_slice(), | ||
); | ||
row.compute_all_size_bytes(); | ||
|
||
match log_db.entity_db.try_add_data_row(&row) { | ||
Ok(()) => {} | ||
Err(err) => { | ||
re_log::warn_once!( | ||
"Failed to store component {}.{}: {err}", | ||
entity_path, | ||
C::name(), | ||
); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,7 @@ pub fn new_recording_info( | |
rustc_version: env!("RE_BUILD_RUSTC_VERSION").into(), | ||
llvm_version: env!("RE_BUILD_LLVM_VERSION").into(), | ||
}, | ||
recording_type: re_log_types::RecordingType::Data, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be passed as a parameter to this function? or renaming the function to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to force a rust-API change on this one until we know we have the naming right. I'm still not really a fan of "data recording" vs "blueprint recording". My preference on user-facing terminology is still "Recording" vs "Blueprint". |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more wildcards please.. 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For stuff like this I'm always going to default to matching the existing patterns established in the files.