-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22b0bd9
commit ba95c01
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
use dora_node_api::{ | ||
arrow::array::{Float32Array, Float64Array, Int32Array, Int64Array}, | ||
dora_core::config::DataId, | ||
ArrowData, | ||
}; | ||
use eyre::{Context, ContextCompat, Result}; | ||
use rerun::RecordingStream; | ||
|
||
pub fn update_series(rec: &RecordingStream, id: DataId, data: ArrowData) -> Result<()> { | ||
match data.data_type() { | ||
dora_node_api::arrow::datatypes::DataType::Float32 => { | ||
let buffer: &Float32Array = data | ||
.as_any() | ||
.downcast_ref() | ||
.context("series is not float32")?; | ||
let series: Vec<_> = buffer.values().to_vec(); | ||
for (i, value) in series.iter().enumerate() { | ||
rec.log( | ||
format!("{}_{}", id.as_str(), i), | ||
&rerun::Scalar::new(*value as f64), | ||
) | ||
.wrap_err("could not log series")?; | ||
} | ||
} | ||
dora_node_api::arrow::datatypes::DataType::Float64 => { | ||
let buffer: &Float64Array = data | ||
.as_any() | ||
.downcast_ref() | ||
.context("series is not float64")?; | ||
let series: Vec<_> = buffer.values().to_vec(); | ||
for (i, value) in series.iter().enumerate() { | ||
rec.log( | ||
format!("{}_{}", id.as_str(), i), | ||
&rerun::Scalar::new(*value as f64), | ||
) | ||
.wrap_err("could not log series")?; | ||
} | ||
} | ||
dora_node_api::arrow::datatypes::DataType::Int32 => { | ||
let buffer: &Int32Array = data | ||
.as_any() | ||
.downcast_ref() | ||
.context("series is not Int32")?; | ||
let series: Vec<_> = buffer.values().to_vec(); | ||
for (i, value) in series.iter().enumerate() { | ||
rec.log( | ||
format!("{}_{}", id.as_str(), i), | ||
&rerun::Scalar::new(*value as f64), | ||
) | ||
.wrap_err("could not log series")?; | ||
} | ||
} | ||
dora_node_api::arrow::datatypes::DataType::Int64 => { | ||
let buffer: &Int64Array = data | ||
.as_any() | ||
.downcast_ref() | ||
.context("series is not Int64")?; | ||
let series: Vec<_> = buffer.values().to_vec(); | ||
for (i, value) in series.iter().enumerate() { | ||
rec.log( | ||
format!("{}_{}", id.as_str(), i), | ||
&rerun::Scalar::new(*value as f64), | ||
) | ||
.wrap_err("could not log series")?; | ||
} | ||
} | ||
|
||
_ => unimplemented!("This has not yet implemented. Please contribute to dora-rerun :)"), | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters