diff --git a/.vscode/launch.json b/.vscode/launch.json index d1c98f5b6a36..4c0cfe3de3a2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,18 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Lauch C++ minimal example", + "type": "cppdbg", + "request": "launch", + "cwd": "${workspaceFolder}", + "program": "${workspaceFolder}/build/examples/cpp/minimal/example_minimal", + "args": [], + "stopAtEntry": false, + "environment": [], + "externalConsole": false, + "MIMode": "lldb" + }, { "name": "Launch tests", "type": "lldb", diff --git a/crates/re_types_builder/src/codegen/cpp/mod.rs b/crates/re_types_builder/src/codegen/cpp/mod.rs index cab50babfaa3..e2a53a3b287c 100644 --- a/crates/re_types_builder/src/codegen/cpp/mod.rs +++ b/crates/re_types_builder/src/codegen/cpp/mod.rs @@ -1281,7 +1281,11 @@ fn component_to_data_cell_method( ARROW_RETURN_NOT_OK(builder->Finish(&array)); #NEWLINE_TOKEN #NEWLINE_TOKEN - return rerun::DataCell::create(#type_ident::NAME, #type_ident::arrow_datatype(), std::move(array)); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = #type_ident::NAME; + cell.array = std::move(array); + return cell; }, inline: false, } @@ -1290,10 +1294,10 @@ fn component_to_data_cell_method( fn archetype_serialize(type_ident: &Ident, obj: &Object, hpp_includes: &mut Includes) -> Method { hpp_includes.insert_rerun("data_cell.hpp"); hpp_includes.insert_rerun("collection.hpp"); - hpp_includes.insert_rerun("serialized_component_batch.hpp"); + hpp_includes.insert_rerun("data_cell.hpp"); hpp_includes.insert_system("vector"); // std::vector - let num_fields = quote_integer(obj.fields.len()); + let num_fields = quote_integer(obj.fields.len() + 1); // Plus one for the indicator. let push_batches = obj.fields.iter().map(|field| { let field_name = format_ident!("{}", field.name); let field_accessor = quote!(archetype.#field_name); @@ -1307,7 +1311,7 @@ fn archetype_serialize(type_ident: &Ident, obj: &Object, hpp_includes: &mut Incl let emplace_back = quote! { RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); }; @@ -1316,15 +1320,13 @@ fn archetype_serialize(type_ident: &Ident, obj: &Object, hpp_includes: &mut Incl if field.is_nullable { quote! { if (#field_accessor.has_value()) { - const size_t size = #field_accessor.value().size(); - auto result = #field_type::to_data_cell(#field_accessor.value().data(), size); + auto result = #field_type::to_data_cell(#field_accessor.value().data(), #field_accessor.value().size()); #emplace_back } } } else { quote! { { - const size_t size = #field_accessor.size(); auto result = #field_type::to_data_cell(#field_accessor.data(), #field_accessor.size()); #emplace_back } @@ -1333,16 +1335,14 @@ fn archetype_serialize(type_ident: &Ident, obj: &Object, hpp_includes: &mut Incl } else if field.is_nullable { quote! { if (#field_accessor.has_value()) { - const size_t size = 1; - auto result = #field_type::to_data_cell(&#field_accessor.value(), size); + auto result = #field_type::to_data_cell(&#field_accessor.value(), 1); #emplace_back } } } else { quote! { { - const size_t size = 1; - auto result = #field_type::to_data_cell(&#field_accessor, size); + auto result = #field_type::to_data_cell(&#field_accessor, 1); #emplace_back } } @@ -1353,13 +1353,14 @@ fn archetype_serialize(type_ident: &Ident, obj: &Object, hpp_includes: &mut Incl docs: "Serialize all set component batches.".into(), declaration: MethodDeclaration { is_static: true, - return_type: quote!(Result>), + // TODO(andreas): Use a rerun::Collection here as well. + return_type: quote!(Result>), name_and_parameters: quote!(serialize(const archetypes::#type_ident& archetype)), }, definition_body: quote! { using namespace archetypes; #NEWLINE_TOKEN - std::vector cells; + std::vector cells; cells.reserve(#num_fields); #NEWLINE_TOKEN #NEWLINE_TOKEN @@ -1368,7 +1369,7 @@ fn archetype_serialize(type_ident: &Ident, obj: &Object, hpp_includes: &mut Incl auto indicator = #type_ident::IndicatorComponent(); auto result = #type_ident::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } #NEWLINE_TOKEN #NEWLINE_TOKEN diff --git a/crates/rerun_c/src/lib.rs b/crates/rerun_c/src/lib.rs index f220d140d8c4..3509ccdbca1c 100644 --- a/crates/rerun_c/src/lib.rs +++ b/crates/rerun_c/src/lib.rs @@ -112,11 +112,10 @@ pub struct CStoreInfo { pub struct CDataCell { pub component_name: CStringView, - /// Length of [`Self::bytes`]. - pub num_bytes: u64, + pub array: arrow2::ffi::ArrowArray, - /// Data in the Arrow IPC encapsulated message format. - pub bytes: *const u8, + /// TODO(andreas): Use a schema registry. + pub schema: arrow2::ffi::ArrowSchema, } #[repr(C)] @@ -124,7 +123,7 @@ pub struct CDataRow { pub entity_path: CStringView, pub num_instances: u32, pub num_data_cells: u32, - pub data_cells: *const CDataCell, + pub data_cells: *mut CDataCell, } #[repr(u32)] @@ -145,7 +144,8 @@ pub enum CErrorCode { RecordingStreamSpawnFailure, _CategoryArrow = 0x0000_1000, - ArrowIpcMessageParsingFailure, + ArrowFfiSchemaImportError, + ArrowFfiArrayImportError, ArrowDataCellError, Unknown = 0xFFFF_FFFF, @@ -559,55 +559,75 @@ pub extern "C" fn rr_recording_stream_reset_time(stream: CRecordingStream) { #[allow(unsafe_code)] #[allow(clippy::result_large_err)] +#[allow(clippy::needless_pass_by_value)] // Conceptually we're consuming the data_row, as we take ownership of data it points to. fn rr_log_impl( stream: CRecordingStream, - data_row: *const CDataRow, + data_row: CDataRow, inject_time: bool, ) -> Result<(), CError> { let stream = recording_stream(stream)?; - let data_row = ptr::try_ptr_as_ref(data_row, "data_row")?; - let CDataRow { entity_path, num_instances, num_data_cells, data_cells, - } = *data_row; + } = data_row; let entity_path = entity_path.as_str("entity_path")?; let entity_path = EntityPath::parse_forgiving(entity_path); + let num_data_cells = num_data_cells as usize; re_log::debug!( "rerun_log {entity_path:?}, num_instances: {num_instances}, num_data_cells: {num_data_cells}", ); let mut cells = re_log_types::DataCellVec::default(); - cells.reserve(num_data_cells as usize); - for i in 0..num_data_cells { - let data_cell: &CDataCell = unsafe { &*data_cells.wrapping_add(i as _) }; + cells.reserve(num_data_cells); + + let data_cells = unsafe { std::slice::from_raw_parts_mut(data_cells, num_data_cells) }; + + for data_cell in data_cells { + // Arrow2 implements drop for ArrowArray and ArrowSchema. + // + // Therefore, for things to work correctly we have to take ownership of the data cell! + // The C interface is documented to take ownership of the data cell - the user should NOT call `release`. + // This makes sense because from here on out we want to manage the lifetime of the underlying schema and array data: + // the schema won't survive a loop iteration since it's reference passed for import, whereas the ArrowArray lives + // on a longer within the resulting arrow::Array. let CDataCell { component_name, - num_bytes, - bytes, - } = *data_cell; + array, + schema, + } = unsafe { std::ptr::read(data_cell) }; + + // It would be nice to now mark the data_cell as "consumed" by setting the original release method to nullptr. + // This would signifies to the calling code that the data_cell is no longer owned. + // However, Arrow2 doesn't allow us to access the fields of the ArrowArray and ArrowSchema structs. let component_name = component_name.as_str("data_cells[i].component_name")?; let component_name = ComponentName::from(component_name); - let bytes = unsafe { std::slice::from_raw_parts(bytes, num_bytes as usize) }; - let array = parse_arrow_ipc_encapsulated_message(bytes).map_err(|err| { + let field = unsafe { arrow2::ffi::import_field_from_c(&schema) }.map_err(|err| { CError::new( - CErrorCode::ArrowIpcMessageParsingFailure, - &format!("Failed to parse Arrow IPC encapsulated message: {err}"), + CErrorCode::ArrowFfiSchemaImportError, + &format!("Failed to import ffi schema: {err}"), ) })?; + let values = + unsafe { arrow2::ffi::import_array_from_c(array, field.data_type) }.map_err(|err| { + CError::new( + CErrorCode::ArrowFfiArrayImportError, + &format!("Failed to import ffi array: {err}"), + ) + })?; + cells.push( - DataCell::try_from_arrow(component_name, array).map_err(|err| { + DataCell::try_from_arrow(component_name, values).map_err(|err| { CError::new( CErrorCode::ArrowDataCellError, - &format!("Failed to create arrow datacell from message: {err}"), + &format!("Failed to create arrow datacell: {err}"), ) })?, ); @@ -636,7 +656,7 @@ fn rr_log_impl( #[no_mangle] pub unsafe extern "C" fn rr_recording_stream_log( stream: CRecordingStream, - data_row: *const CDataRow, + data_row: CDataRow, inject_time: bool, error: *mut CError, ) { @@ -655,77 +675,3 @@ fn initialize_logging() { re_log::setup_native_logging(); }); } - -fn parse_arrow_ipc_encapsulated_message( - bytes: &[u8], -) -> Result, String> { - re_log::debug!( - "parse_arrow_ipc_encapsulated_message: {} bytes", - bytes.len() - ); - - use arrow2::io::ipc::read::{read_stream_metadata, StreamReader, StreamState}; - - let mut cursor = std::io::Cursor::new(bytes); - let metadata = match read_stream_metadata(&mut cursor) { - Ok(metadata) => metadata, - Err(err) => return Err(format!("Failed to read stream metadata: {err}")), - }; - - // This IPC message represents the contents of a single DataCell, thus we should have a single - // field. - if metadata.schema.fields.len() != 1 { - return Err(format!( - "Found {} fields in stream metadata - expected exactly one.", - metadata.schema.fields.len(), - )); - } - // Might need that later if it turns out we don't have any data to log. - let datatype = metadata.schema.fields[0].data_type().clone(); - - let stream = StreamReader::new(cursor, metadata, None); - let chunks: Result, _> = stream - .map(|state| match state { - Ok(StreamState::Some(chunk)) => Ok(chunk), - Ok(StreamState::Waiting) => { - unreachable!("cannot be waiting on a fixed buffer") - } - Err(err) => Err(err), - }) - .collect(); - - let chunks = chunks.map_err(|err| format!("Arrow error: {err}"))?; - - // We're not sending a `DataCellColumn`'s (i.e. `List`) worth of data like we normally do - // here, rather we're sending a single, independent `DataCell`'s worth of data. - // - // This distinction is crucial: - // - The data for a `DataCellColumn` containing a single empty `DataCell` is a unit-length list-array whose - // first and only entry is an empty array (`ListArray[[]]`). There's actually data there (as - // in bytes). - // - The data for a standalone empty `DataCell`, on the other hand, is literally nothing. It's - // zero bytes. - // - // Where there's no data whatsoever, the chunk gets optimized out, which is why logging an - // empty array in C++ ends up hitting this path. - if chunks.is_empty() { - // The fix is simple: craft an empty array with the correct datatype. - return Ok(arrow2::array::new_empty_array(datatype)); - } - - if chunks.len() > 1 { - return Err(format!( - "Found {} chunks in stream - expected just one.", - chunks.len() - )); - } - let chunk = chunks.into_iter().next().unwrap(); - - let arrays = chunk.into_arrays(); - - if arrays.len() != 1 { - return Err(format!("Expected one array, got {}", arrays.len())); - } - - Ok(arrays.into_iter().next().unwrap()) -} diff --git a/crates/rerun_c/src/rerun.h b/crates/rerun_c/src/rerun.h index c7fc87515af3..9103908a353d 100644 --- a/crates/rerun_c/src/rerun.h +++ b/crates/rerun_c/src/rerun.h @@ -16,6 +16,7 @@ extern "C" { #include #include +#include "arrow_c_data_interface.h" // ---------------------------------------------------------------------------- // Types: @@ -131,22 +132,17 @@ typedef struct rr_store_info { rr_store_kind store_kind; } rr_store_info; -/// Arrow-encoded data of a single component for a single entity. +/// Arrow-encoded data of a single batch components for a single entity. typedef struct rr_data_cell { /// The name of the component, e.g. `position`. rr_string component_name; - /// The number of bytes in the `bytes` field. - /// Must be a multiple of 8. - uint64_t num_bytes; + /// A batch of instances of this component serialized into an arrow array. + ArrowArray array; - /// Data in the Arrow IPC encapsulated message format. - /// - /// There must be exactly one chunk of data. - /// - /// * - /// * - const uint8_t* bytes; + /// The schema used for the arrow array. + /// TODO(andreas): Use a schema registry that identifies this and the component name with a unique schema ID. + ArrowSchema schema; } rr_data_cell; /// Arrow-encoded log data for a single entity. @@ -163,7 +159,7 @@ typedef struct { uint32_t num_data_cells; /// One for each component. - const rr_data_cell* data_cells; + rr_data_cell* data_cells; } rr_data_row; /// Error codes returned by the Rerun C SDK as part of `rr_error`. @@ -190,7 +186,8 @@ enum { // Arrow data processing errors. _RR_ERROR_CODE_CATEGORY_ARROW = 0x000001000, - RR_ERROR_CODE_ARROW_IPC_MESSAGE_PARSING_FAILURE, + RR_ERROR_CODE_ARROW_FFI_SCHEMA_IMPORT_ERROR, + RR_ERROR_CODE_ARROW_FFI_ARRAY_IMPORT_ERROR, RR_ERROR_CODE_ARROW_DATA_CELL_ERROR, // Generic errors. @@ -363,8 +360,12 @@ extern void rr_recording_stream_reset_time(rr_recording_stream stream); /// /// If `inject_time` is set to `true`, the row's timestamp data will be /// overridden using the recording streams internal clock. +/// +/// Takes ownership of the passed data cells and will release underlying +/// arrow data once it is no longer needed. +/// Any pointers passed via `rr_string` can be safely freed after this call. extern void rr_recording_stream_log( - rr_recording_stream stream, const rr_data_row* data_row, bool inject_time, rr_error* error + rr_recording_stream stream, rr_data_row data_row, bool inject_time, rr_error* error ); // ---------------------------------------------------------------------------- diff --git a/rerun_cpp/download_and_build_arrow.cmake b/rerun_cpp/download_and_build_arrow.cmake index 8a16da82b168..e5e7224be9ca 100644 --- a/rerun_cpp/download_and_build_arrow.cmake +++ b/rerun_cpp/download_and_build_arrow.cmake @@ -42,6 +42,7 @@ function(download_and_build_arrow) if(MSVC) # Enable multithreaded compiling of Arrow on MSVC. set(ARROW_CXXFLAGS "/MP") + # ASAN doesn't work with arrow (yet?) set(ARROW_ASAN OFF) else() @@ -83,7 +84,7 @@ function(download_and_build_arrow) -DARROW_BUILD_SHARED=${ARROW_BUILD_SHARED} -DARROW_BUILD_STATIC=${ARROW_BUILD_STATIC} -DARROW_CXXFLAGS=${DARROW_CXXFLAGS} - -DARROW_IPC=ON + -DARROW_IPC=OFF -DARROW_JEMALLOC=OFF # We encountered some build issues with jemalloc, use mimalloc instead. -DARROW_MIMALLOC=ON -DARROW_USE_ASAN=${RERUN_USE_ASAN} diff --git a/rerun_cpp/src/rerun/archetypes/annotation_context.cpp b/rerun_cpp/src/rerun/archetypes/annotation_context.cpp index e32be6825978..e742a6fbc192 100644 --- a/rerun_cpp/src/rerun/archetypes/annotation_context.cpp +++ b/rerun_cpp/src/rerun/archetypes/annotation_context.cpp @@ -12,24 +12,23 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents< - archetypes::AnnotationContext>::serialize(const archetypes::AnnotationContext& archetype) { + Result> AsComponents::serialize( + const archetypes::AnnotationContext& archetype + ) { using namespace archetypes; - std::vector cells; - cells.reserve(1); + std::vector cells; + cells.reserve(2); { - const size_t size = 1; - auto result = - rerun::components::AnnotationContext::to_data_cell(&archetype.context, size); + auto result = rerun::components::AnnotationContext::to_data_cell(&archetype.context, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = AnnotationContext::IndicatorComponent(); auto result = AnnotationContext::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/annotation_context.hpp b/rerun_cpp/src/rerun/archetypes/annotation_context.hpp index 75a8c677082c..38e075342609 100644 --- a/rerun_cpp/src/rerun/archetypes/annotation_context.hpp +++ b/rerun_cpp/src/rerun/archetypes/annotation_context.hpp @@ -8,7 +8,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -94,7 +93,7 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( + static Result> serialize( const archetypes::AnnotationContext& archetype ); }; diff --git a/rerun_cpp/src/rerun/archetypes/arrows3d.cpp b/rerun_cpp/src/rerun/archetypes/arrows3d.cpp index 6bd9617114d1..bc8e24ab0cca 100644 --- a/rerun_cpp/src/rerun/archetypes/arrows3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/arrows3d.cpp @@ -11,71 +11,74 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Arrows3D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(7); + std::vector cells; + cells.reserve(8); { - const size_t size = archetype.vectors.size(); auto result = rerun::components::Vector3D::to_data_cell( archetype.vectors.data(), archetype.vectors.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.origins.has_value()) { - const size_t size = archetype.origins.value().size(); - auto result = - rerun::components::Position3D::to_data_cell(archetype.origins.value().data(), size); + auto result = rerun::components::Position3D::to_data_cell( + archetype.origins.value().data(), + archetype.origins.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.radii.has_value()) { - const size_t size = archetype.radii.value().size(); - auto result = - rerun::components::Radius::to_data_cell(archetype.radii.value().data(), size); + auto result = rerun::components::Radius::to_data_cell( + archetype.radii.value().data(), + archetype.radii.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.colors.has_value()) { - const size_t size = archetype.colors.value().size(); - auto result = - rerun::components::Color::to_data_cell(archetype.colors.value().data(), size); + auto result = rerun::components::Color::to_data_cell( + archetype.colors.value().data(), + archetype.colors.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.labels.has_value()) { - const size_t size = archetype.labels.value().size(); - auto result = - rerun::components::Text::to_data_cell(archetype.labels.value().data(), size); + auto result = rerun::components::Text::to_data_cell( + archetype.labels.value().data(), + archetype.labels.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.class_ids.has_value()) { - const size_t size = archetype.class_ids.value().size(); - auto result = - rerun::components::ClassId::to_data_cell(archetype.class_ids.value().data(), size); + auto result = rerun::components::ClassId::to_data_cell( + archetype.class_ids.value().data(), + archetype.class_ids.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.instance_keys.has_value()) { - const size_t size = archetype.instance_keys.value().size(); auto result = rerun::components::InstanceKey::to_data_cell( archetype.instance_keys.value().data(), - size + archetype.instance_keys.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Arrows3D::IndicatorComponent(); auto result = Arrows3D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/arrows3d.hpp b/rerun_cpp/src/rerun/archetypes/arrows3d.hpp index 01ae04cde8f7..c9af047c249b 100644 --- a/rerun_cpp/src/rerun/archetypes/arrows3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/arrows3d.hpp @@ -15,7 +15,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -178,8 +177,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Arrows3D& archetype - ); + static Result> serialize(const archetypes::Arrows3D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/asset3d.cpp b/rerun_cpp/src/rerun/archetypes/asset3d.cpp index 6003e162da37..f55f56899d7b 100644 --- a/rerun_cpp/src/rerun/archetypes/asset3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/asset3d.cpp @@ -11,40 +11,37 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Asset3D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(3); + std::vector cells; + cells.reserve(4); { - const size_t size = 1; - auto result = rerun::components::Blob::to_data_cell(&archetype.blob, size); + auto result = rerun::components::Blob::to_data_cell(&archetype.blob, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.media_type.has_value()) { - const size_t size = 1; auto result = - rerun::components::MediaType::to_data_cell(&archetype.media_type.value(), size); + rerun::components::MediaType::to_data_cell(&archetype.media_type.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.transform.has_value()) { - const size_t size = 1; auto result = rerun::components::OutOfTreeTransform3D::to_data_cell( &archetype.transform.value(), - size + 1 ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Asset3D::IndicatorComponent(); auto result = Asset3D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/asset3d.hpp b/rerun_cpp/src/rerun/archetypes/asset3d.hpp index 3a565a74bcbc..3984feded22e 100644 --- a/rerun_cpp/src/rerun/archetypes/asset3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/asset3d.hpp @@ -11,7 +11,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -147,8 +146,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Asset3D& archetype - ); + static Result> serialize(const archetypes::Asset3D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/bar_chart.cpp b/rerun_cpp/src/rerun/archetypes/bar_chart.cpp index 5a3120e0b3dd..4de62eee08ec 100644 --- a/rerun_cpp/src/rerun/archetypes/bar_chart.cpp +++ b/rerun_cpp/src/rerun/archetypes/bar_chart.cpp @@ -11,24 +11,23 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::BarChart& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(1); + std::vector cells; + cells.reserve(2); { - const size_t size = 1; - auto result = rerun::components::TensorData::to_data_cell(&archetype.values, size); + auto result = rerun::components::TensorData::to_data_cell(&archetype.values, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = BarChart::IndicatorComponent(); auto result = BarChart::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/bar_chart.hpp b/rerun_cpp/src/rerun/archetypes/bar_chart.hpp index 856127436229..710c5c1f26da 100644 --- a/rerun_cpp/src/rerun/archetypes/bar_chart.hpp +++ b/rerun_cpp/src/rerun/archetypes/bar_chart.hpp @@ -8,7 +8,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -179,8 +178,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::BarChart& archetype - ); + static Result> serialize(const archetypes::BarChart& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/boxes2d.cpp b/rerun_cpp/src/rerun/archetypes/boxes2d.cpp index 0cb4806e42d1..cc92a07b80d4 100644 --- a/rerun_cpp/src/rerun/archetypes/boxes2d.cpp +++ b/rerun_cpp/src/rerun/archetypes/boxes2d.cpp @@ -11,78 +11,80 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Boxes2D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(8); + std::vector cells; + cells.reserve(9); { - const size_t size = archetype.half_sizes.size(); auto result = rerun::components::HalfSizes2D::to_data_cell( archetype.half_sizes.data(), archetype.half_sizes.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.centers.has_value()) { - const size_t size = archetype.centers.value().size(); - auto result = - rerun::components::Position2D::to_data_cell(archetype.centers.value().data(), size); + auto result = rerun::components::Position2D::to_data_cell( + archetype.centers.value().data(), + archetype.centers.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.colors.has_value()) { - const size_t size = archetype.colors.value().size(); - auto result = - rerun::components::Color::to_data_cell(archetype.colors.value().data(), size); + auto result = rerun::components::Color::to_data_cell( + archetype.colors.value().data(), + archetype.colors.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.radii.has_value()) { - const size_t size = archetype.radii.value().size(); - auto result = - rerun::components::Radius::to_data_cell(archetype.radii.value().data(), size); + auto result = rerun::components::Radius::to_data_cell( + archetype.radii.value().data(), + archetype.radii.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.labels.has_value()) { - const size_t size = archetype.labels.value().size(); - auto result = - rerun::components::Text::to_data_cell(archetype.labels.value().data(), size); + auto result = rerun::components::Text::to_data_cell( + archetype.labels.value().data(), + archetype.labels.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.draw_order.has_value()) { - const size_t size = 1; auto result = - rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), size); + rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.class_ids.has_value()) { - const size_t size = archetype.class_ids.value().size(); - auto result = - rerun::components::ClassId::to_data_cell(archetype.class_ids.value().data(), size); + auto result = rerun::components::ClassId::to_data_cell( + archetype.class_ids.value().data(), + archetype.class_ids.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.instance_keys.has_value()) { - const size_t size = archetype.instance_keys.value().size(); auto result = rerun::components::InstanceKey::to_data_cell( archetype.instance_keys.value().data(), - size + archetype.instance_keys.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Boxes2D::IndicatorComponent(); auto result = Boxes2D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/boxes2d.hpp b/rerun_cpp/src/rerun/archetypes/boxes2d.hpp index d483185dde30..8d4c4f8d07fa 100644 --- a/rerun_cpp/src/rerun/archetypes/boxes2d.hpp +++ b/rerun_cpp/src/rerun/archetypes/boxes2d.hpp @@ -16,7 +16,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -205,8 +204,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Boxes2D& archetype - ); + static Result> serialize(const archetypes::Boxes2D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/boxes3d.cpp b/rerun_cpp/src/rerun/archetypes/boxes3d.cpp index 363d46d31b2d..e028391a1495 100644 --- a/rerun_cpp/src/rerun/archetypes/boxes3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/boxes3d.cpp @@ -11,80 +11,82 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Boxes3D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(8); + std::vector cells; + cells.reserve(9); { - const size_t size = archetype.half_sizes.size(); auto result = rerun::components::HalfSizes3D::to_data_cell( archetype.half_sizes.data(), archetype.half_sizes.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.centers.has_value()) { - const size_t size = archetype.centers.value().size(); - auto result = - rerun::components::Position3D::to_data_cell(archetype.centers.value().data(), size); + auto result = rerun::components::Position3D::to_data_cell( + archetype.centers.value().data(), + archetype.centers.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.rotations.has_value()) { - const size_t size = archetype.rotations.value().size(); auto result = rerun::components::Rotation3D::to_data_cell( archetype.rotations.value().data(), - size + archetype.rotations.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.colors.has_value()) { - const size_t size = archetype.colors.value().size(); - auto result = - rerun::components::Color::to_data_cell(archetype.colors.value().data(), size); + auto result = rerun::components::Color::to_data_cell( + archetype.colors.value().data(), + archetype.colors.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.radii.has_value()) { - const size_t size = archetype.radii.value().size(); - auto result = - rerun::components::Radius::to_data_cell(archetype.radii.value().data(), size); + auto result = rerun::components::Radius::to_data_cell( + archetype.radii.value().data(), + archetype.radii.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.labels.has_value()) { - const size_t size = archetype.labels.value().size(); - auto result = - rerun::components::Text::to_data_cell(archetype.labels.value().data(), size); + auto result = rerun::components::Text::to_data_cell( + archetype.labels.value().data(), + archetype.labels.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.class_ids.has_value()) { - const size_t size = archetype.class_ids.value().size(); - auto result = - rerun::components::ClassId::to_data_cell(archetype.class_ids.value().data(), size); + auto result = rerun::components::ClassId::to_data_cell( + archetype.class_ids.value().data(), + archetype.class_ids.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.instance_keys.has_value()) { - const size_t size = archetype.instance_keys.value().size(); auto result = rerun::components::InstanceKey::to_data_cell( archetype.instance_keys.value().data(), - size + archetype.instance_keys.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Boxes3D::IndicatorComponent(); auto result = Boxes3D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/boxes3d.hpp b/rerun_cpp/src/rerun/archetypes/boxes3d.hpp index c279216d8c42..f4d9a92e4663 100644 --- a/rerun_cpp/src/rerun/archetypes/boxes3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/boxes3d.hpp @@ -16,7 +16,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -214,8 +213,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Boxes3D& archetype - ); + static Result> serialize(const archetypes::Boxes3D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/clear.cpp b/rerun_cpp/src/rerun/archetypes/clear.cpp index c91abfe4d3ad..11dbbd2b6aa3 100644 --- a/rerun_cpp/src/rerun/archetypes/clear.cpp +++ b/rerun_cpp/src/rerun/archetypes/clear.cpp @@ -11,25 +11,24 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Clear& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(1); + std::vector cells; + cells.reserve(2); { - const size_t size = 1; auto result = - rerun::components::ClearIsRecursive::to_data_cell(&archetype.is_recursive, size); + rerun::components::ClearIsRecursive::to_data_cell(&archetype.is_recursive, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Clear::IndicatorComponent(); auto result = Clear::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/clear.hpp b/rerun_cpp/src/rerun/archetypes/clear.hpp index 09d33ab65b22..ccc4a284fe28 100644 --- a/rerun_cpp/src/rerun/archetypes/clear.hpp +++ b/rerun_cpp/src/rerun/archetypes/clear.hpp @@ -8,7 +8,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -112,8 +111,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Clear& archetype - ); + static Result> serialize(const archetypes::Clear& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/depth_image.cpp b/rerun_cpp/src/rerun/archetypes/depth_image.cpp index cfaa1cf1fa8c..5cc7444424a8 100644 --- a/rerun_cpp/src/rerun/archetypes/depth_image.cpp +++ b/rerun_cpp/src/rerun/archetypes/depth_image.cpp @@ -11,38 +11,34 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::DepthImage& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(3); + std::vector cells; + cells.reserve(4); { - const size_t size = 1; - auto result = rerun::components::TensorData::to_data_cell(&archetype.data, size); + auto result = rerun::components::TensorData::to_data_cell(&archetype.data, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.meter.has_value()) { - const size_t size = 1; - auto result = - rerun::components::DepthMeter::to_data_cell(&archetype.meter.value(), size); + auto result = rerun::components::DepthMeter::to_data_cell(&archetype.meter.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.draw_order.has_value()) { - const size_t size = 1; auto result = - rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), size); + rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = DepthImage::IndicatorComponent(); auto result = DepthImage::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/depth_image.hpp b/rerun_cpp/src/rerun/archetypes/depth_image.hpp index f7cefc0c9c6c..c7f444412b8f 100644 --- a/rerun_cpp/src/rerun/archetypes/depth_image.hpp +++ b/rerun_cpp/src/rerun/archetypes/depth_image.hpp @@ -11,7 +11,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -141,8 +140,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::DepthImage& archetype - ); + static Result> serialize(const archetypes::DepthImage& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/disconnected_space.cpp b/rerun_cpp/src/rerun/archetypes/disconnected_space.cpp index 9441dd4e1ccb..0d1a2c27bffa 100644 --- a/rerun_cpp/src/rerun/archetypes/disconnected_space.cpp +++ b/rerun_cpp/src/rerun/archetypes/disconnected_space.cpp @@ -12,26 +12,26 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents< - archetypes::DisconnectedSpace>::serialize(const archetypes::DisconnectedSpace& archetype) { + Result> AsComponents::serialize( + const archetypes::DisconnectedSpace& archetype + ) { using namespace archetypes; - std::vector cells; - cells.reserve(1); + std::vector cells; + cells.reserve(2); { - const size_t size = 1; auto result = rerun::components::DisconnectedSpace::to_data_cell( &archetype.disconnected_space, - size + 1 ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = DisconnectedSpace::IndicatorComponent(); auto result = DisconnectedSpace::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/disconnected_space.hpp b/rerun_cpp/src/rerun/archetypes/disconnected_space.hpp index 603643c7102d..89a8d2ed14d2 100644 --- a/rerun_cpp/src/rerun/archetypes/disconnected_space.hpp +++ b/rerun_cpp/src/rerun/archetypes/disconnected_space.hpp @@ -8,7 +8,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -75,7 +74,7 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( + static Result> serialize( const archetypes::DisconnectedSpace& archetype ); }; diff --git a/rerun_cpp/src/rerun/archetypes/image.cpp b/rerun_cpp/src/rerun/archetypes/image.cpp index 49c89fa41fa3..daaf2a0c7767 100644 --- a/rerun_cpp/src/rerun/archetypes/image.cpp +++ b/rerun_cpp/src/rerun/archetypes/image.cpp @@ -11,31 +11,29 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Image& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(2); + std::vector cells; + cells.reserve(3); { - const size_t size = 1; - auto result = rerun::components::TensorData::to_data_cell(&archetype.data, size); + auto result = rerun::components::TensorData::to_data_cell(&archetype.data, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.draw_order.has_value()) { - const size_t size = 1; auto result = - rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), size); + rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Image::IndicatorComponent(); auto result = Image::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/image.hpp b/rerun_cpp/src/rerun/archetypes/image.hpp index 9e238f48478a..2f827e8edce8 100644 --- a/rerun_cpp/src/rerun/archetypes/image.hpp +++ b/rerun_cpp/src/rerun/archetypes/image.hpp @@ -10,7 +10,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -120,8 +119,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Image& archetype - ); + static Result> serialize(const archetypes::Image& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/line_strips2d.cpp b/rerun_cpp/src/rerun/archetypes/line_strips2d.cpp index 11a2feb97d95..5164d7eeec49 100644 --- a/rerun_cpp/src/rerun/archetypes/line_strips2d.cpp +++ b/rerun_cpp/src/rerun/archetypes/line_strips2d.cpp @@ -11,71 +11,72 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::LineStrips2D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(7); + std::vector cells; + cells.reserve(8); { - const size_t size = archetype.strips.size(); auto result = rerun::components::LineStrip2D::to_data_cell( archetype.strips.data(), archetype.strips.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.radii.has_value()) { - const size_t size = archetype.radii.value().size(); - auto result = - rerun::components::Radius::to_data_cell(archetype.radii.value().data(), size); + auto result = rerun::components::Radius::to_data_cell( + archetype.radii.value().data(), + archetype.radii.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.colors.has_value()) { - const size_t size = archetype.colors.value().size(); - auto result = - rerun::components::Color::to_data_cell(archetype.colors.value().data(), size); + auto result = rerun::components::Color::to_data_cell( + archetype.colors.value().data(), + archetype.colors.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.labels.has_value()) { - const size_t size = archetype.labels.value().size(); - auto result = - rerun::components::Text::to_data_cell(archetype.labels.value().data(), size); + auto result = rerun::components::Text::to_data_cell( + archetype.labels.value().data(), + archetype.labels.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.draw_order.has_value()) { - const size_t size = 1; auto result = - rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), size); + rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.class_ids.has_value()) { - const size_t size = archetype.class_ids.value().size(); - auto result = - rerun::components::ClassId::to_data_cell(archetype.class_ids.value().data(), size); + auto result = rerun::components::ClassId::to_data_cell( + archetype.class_ids.value().data(), + archetype.class_ids.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.instance_keys.has_value()) { - const size_t size = archetype.instance_keys.value().size(); auto result = rerun::components::InstanceKey::to_data_cell( archetype.instance_keys.value().data(), - size + archetype.instance_keys.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = LineStrips2D::IndicatorComponent(); auto result = LineStrips2D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/line_strips2d.hpp b/rerun_cpp/src/rerun/archetypes/line_strips2d.hpp index fe18393e2d2d..bf46d559efec 100644 --- a/rerun_cpp/src/rerun/archetypes/line_strips2d.hpp +++ b/rerun_cpp/src/rerun/archetypes/line_strips2d.hpp @@ -15,7 +15,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -156,8 +155,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::LineStrips2D& archetype - ); + static Result> serialize(const archetypes::LineStrips2D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/line_strips3d.cpp b/rerun_cpp/src/rerun/archetypes/line_strips3d.cpp index bf3a72a50cd5..dae5a1aeb3be 100644 --- a/rerun_cpp/src/rerun/archetypes/line_strips3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/line_strips3d.cpp @@ -11,64 +11,66 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::LineStrips3D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(6); + std::vector cells; + cells.reserve(7); { - const size_t size = archetype.strips.size(); auto result = rerun::components::LineStrip3D::to_data_cell( archetype.strips.data(), archetype.strips.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.radii.has_value()) { - const size_t size = archetype.radii.value().size(); - auto result = - rerun::components::Radius::to_data_cell(archetype.radii.value().data(), size); + auto result = rerun::components::Radius::to_data_cell( + archetype.radii.value().data(), + archetype.radii.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.colors.has_value()) { - const size_t size = archetype.colors.value().size(); - auto result = - rerun::components::Color::to_data_cell(archetype.colors.value().data(), size); + auto result = rerun::components::Color::to_data_cell( + archetype.colors.value().data(), + archetype.colors.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.labels.has_value()) { - const size_t size = archetype.labels.value().size(); - auto result = - rerun::components::Text::to_data_cell(archetype.labels.value().data(), size); + auto result = rerun::components::Text::to_data_cell( + archetype.labels.value().data(), + archetype.labels.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.class_ids.has_value()) { - const size_t size = archetype.class_ids.value().size(); - auto result = - rerun::components::ClassId::to_data_cell(archetype.class_ids.value().data(), size); + auto result = rerun::components::ClassId::to_data_cell( + archetype.class_ids.value().data(), + archetype.class_ids.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.instance_keys.has_value()) { - const size_t size = archetype.instance_keys.value().size(); auto result = rerun::components::InstanceKey::to_data_cell( archetype.instance_keys.value().data(), - size + archetype.instance_keys.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = LineStrips3D::IndicatorComponent(); auto result = LineStrips3D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/line_strips3d.hpp b/rerun_cpp/src/rerun/archetypes/line_strips3d.hpp index c59425606c48..3a1e9a7d9159 100644 --- a/rerun_cpp/src/rerun/archetypes/line_strips3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/line_strips3d.hpp @@ -14,7 +14,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -151,8 +150,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::LineStrips3D& archetype - ); + static Result> serialize(const archetypes::LineStrips3D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/mesh3d.cpp b/rerun_cpp/src/rerun/archetypes/mesh3d.cpp index 236f916d2310..3e1f53ca1731 100644 --- a/rerun_cpp/src/rerun/archetypes/mesh3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/mesh3d.cpp @@ -11,77 +11,72 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Mesh3D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(7); + std::vector cells; + cells.reserve(8); { - const size_t size = archetype.vertex_positions.size(); auto result = rerun::components::Position3D::to_data_cell( archetype.vertex_positions.data(), archetype.vertex_positions.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.mesh_properties.has_value()) { - const size_t size = 1; auto result = rerun::components::MeshProperties::to_data_cell( &archetype.mesh_properties.value(), - size + 1 ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.vertex_normals.has_value()) { - const size_t size = archetype.vertex_normals.value().size(); auto result = rerun::components::Vector3D::to_data_cell( archetype.vertex_normals.value().data(), - size + archetype.vertex_normals.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.vertex_colors.has_value()) { - const size_t size = archetype.vertex_colors.value().size(); auto result = rerun::components::Color::to_data_cell( archetype.vertex_colors.value().data(), - size + archetype.vertex_colors.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.mesh_material.has_value()) { - const size_t size = 1; auto result = - rerun::components::Material::to_data_cell(&archetype.mesh_material.value(), size); + rerun::components::Material::to_data_cell(&archetype.mesh_material.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.class_ids.has_value()) { - const size_t size = archetype.class_ids.value().size(); - auto result = - rerun::components::ClassId::to_data_cell(archetype.class_ids.value().data(), size); + auto result = rerun::components::ClassId::to_data_cell( + archetype.class_ids.value().data(), + archetype.class_ids.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.instance_keys.has_value()) { - const size_t size = archetype.instance_keys.value().size(); auto result = rerun::components::InstanceKey::to_data_cell( archetype.instance_keys.value().data(), - size + archetype.instance_keys.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Mesh3D::IndicatorComponent(); auto result = Mesh3D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/mesh3d.hpp b/rerun_cpp/src/rerun/archetypes/mesh3d.hpp index b55b1f98be66..00bfed623b32 100644 --- a/rerun_cpp/src/rerun/archetypes/mesh3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/mesh3d.hpp @@ -15,7 +15,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -164,8 +163,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Mesh3D& archetype - ); + static Result> serialize(const archetypes::Mesh3D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/pinhole.cpp b/rerun_cpp/src/rerun/archetypes/pinhole.cpp index 7cde848d56f0..2fe55c96b178 100644 --- a/rerun_cpp/src/rerun/archetypes/pinhole.cpp +++ b/rerun_cpp/src/rerun/archetypes/pinhole.cpp @@ -11,43 +11,36 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Pinhole& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(3); + std::vector cells; + cells.reserve(4); { - const size_t size = 1; - auto result = rerun::components::PinholeProjection::to_data_cell( - &archetype.image_from_camera, - size - ); + auto result = + rerun::components::PinholeProjection::to_data_cell(&archetype.image_from_camera, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.resolution.has_value()) { - const size_t size = 1; auto result = - rerun::components::Resolution::to_data_cell(&archetype.resolution.value(), size); + rerun::components::Resolution::to_data_cell(&archetype.resolution.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.camera_xyz.has_value()) { - const size_t size = 1; - auto result = rerun::components::ViewCoordinates::to_data_cell( - &archetype.camera_xyz.value(), - size - ); + auto result = + rerun::components::ViewCoordinates::to_data_cell(&archetype.camera_xyz.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Pinhole::IndicatorComponent(); auto result = Pinhole::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/pinhole.hpp b/rerun_cpp/src/rerun/archetypes/pinhole.hpp index ebb6d08f03ab..5dc81e427ce5 100644 --- a/rerun_cpp/src/rerun/archetypes/pinhole.hpp +++ b/rerun_cpp/src/rerun/archetypes/pinhole.hpp @@ -11,7 +11,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -209,8 +208,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Pinhole& archetype - ); + static Result> serialize(const archetypes::Pinhole& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/points2d.cpp b/rerun_cpp/src/rerun/archetypes/points2d.cpp index aefb2c664143..1d01791a6ad7 100644 --- a/rerun_cpp/src/rerun/archetypes/points2d.cpp +++ b/rerun_cpp/src/rerun/archetypes/points2d.cpp @@ -11,80 +11,80 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Points2D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(8); + std::vector cells; + cells.reserve(9); { - const size_t size = archetype.positions.size(); auto result = rerun::components::Position2D::to_data_cell( archetype.positions.data(), archetype.positions.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.radii.has_value()) { - const size_t size = archetype.radii.value().size(); - auto result = - rerun::components::Radius::to_data_cell(archetype.radii.value().data(), size); + auto result = rerun::components::Radius::to_data_cell( + archetype.radii.value().data(), + archetype.radii.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.colors.has_value()) { - const size_t size = archetype.colors.value().size(); - auto result = - rerun::components::Color::to_data_cell(archetype.colors.value().data(), size); + auto result = rerun::components::Color::to_data_cell( + archetype.colors.value().data(), + archetype.colors.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.labels.has_value()) { - const size_t size = archetype.labels.value().size(); - auto result = - rerun::components::Text::to_data_cell(archetype.labels.value().data(), size); + auto result = rerun::components::Text::to_data_cell( + archetype.labels.value().data(), + archetype.labels.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.draw_order.has_value()) { - const size_t size = 1; auto result = - rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), size); + rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.class_ids.has_value()) { - const size_t size = archetype.class_ids.value().size(); - auto result = - rerun::components::ClassId::to_data_cell(archetype.class_ids.value().data(), size); + auto result = rerun::components::ClassId::to_data_cell( + archetype.class_ids.value().data(), + archetype.class_ids.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.keypoint_ids.has_value()) { - const size_t size = archetype.keypoint_ids.value().size(); auto result = rerun::components::KeypointId::to_data_cell( archetype.keypoint_ids.value().data(), - size + archetype.keypoint_ids.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.instance_keys.has_value()) { - const size_t size = archetype.instance_keys.value().size(); auto result = rerun::components::InstanceKey::to_data_cell( archetype.instance_keys.value().data(), - size + archetype.instance_keys.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Points2D::IndicatorComponent(); auto result = Points2D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/points2d.hpp b/rerun_cpp/src/rerun/archetypes/points2d.hpp index ab065ea187a9..8d0a3df76bfb 100644 --- a/rerun_cpp/src/rerun/archetypes/points2d.hpp +++ b/rerun_cpp/src/rerun/archetypes/points2d.hpp @@ -16,7 +16,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -194,8 +193,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Points2D& archetype - ); + static Result> serialize(const archetypes::Points2D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/points3d.cpp b/rerun_cpp/src/rerun/archetypes/points3d.cpp index 975d37081bf7..c9fb932f8606 100644 --- a/rerun_cpp/src/rerun/archetypes/points3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/points3d.cpp @@ -11,73 +11,74 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Points3D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(7); + std::vector cells; + cells.reserve(8); { - const size_t size = archetype.positions.size(); auto result = rerun::components::Position3D::to_data_cell( archetype.positions.data(), archetype.positions.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.radii.has_value()) { - const size_t size = archetype.radii.value().size(); - auto result = - rerun::components::Radius::to_data_cell(archetype.radii.value().data(), size); + auto result = rerun::components::Radius::to_data_cell( + archetype.radii.value().data(), + archetype.radii.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.colors.has_value()) { - const size_t size = archetype.colors.value().size(); - auto result = - rerun::components::Color::to_data_cell(archetype.colors.value().data(), size); + auto result = rerun::components::Color::to_data_cell( + archetype.colors.value().data(), + archetype.colors.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.labels.has_value()) { - const size_t size = archetype.labels.value().size(); - auto result = - rerun::components::Text::to_data_cell(archetype.labels.value().data(), size); + auto result = rerun::components::Text::to_data_cell( + archetype.labels.value().data(), + archetype.labels.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.class_ids.has_value()) { - const size_t size = archetype.class_ids.value().size(); - auto result = - rerun::components::ClassId::to_data_cell(archetype.class_ids.value().data(), size); + auto result = rerun::components::ClassId::to_data_cell( + archetype.class_ids.value().data(), + archetype.class_ids.value().size() + ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.keypoint_ids.has_value()) { - const size_t size = archetype.keypoint_ids.value().size(); auto result = rerun::components::KeypointId::to_data_cell( archetype.keypoint_ids.value().data(), - size + archetype.keypoint_ids.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.instance_keys.has_value()) { - const size_t size = archetype.instance_keys.value().size(); auto result = rerun::components::InstanceKey::to_data_cell( archetype.instance_keys.value().data(), - size + archetype.instance_keys.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Points3D::IndicatorComponent(); auto result = Points3D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/points3d.hpp b/rerun_cpp/src/rerun/archetypes/points3d.hpp index a9244828ab41..6fed4d19bd92 100644 --- a/rerun_cpp/src/rerun/archetypes/points3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/points3d.hpp @@ -15,7 +15,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -176,8 +175,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Points3D& archetype - ); + static Result> serialize(const archetypes::Points3D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/segmentation_image.cpp b/rerun_cpp/src/rerun/archetypes/segmentation_image.cpp index 65b1175cad78..b1c2e0c24779 100644 --- a/rerun_cpp/src/rerun/archetypes/segmentation_image.cpp +++ b/rerun_cpp/src/rerun/archetypes/segmentation_image.cpp @@ -12,30 +12,29 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents< - archetypes::SegmentationImage>::serialize(const archetypes::SegmentationImage& archetype) { + Result> AsComponents::serialize( + const archetypes::SegmentationImage& archetype + ) { using namespace archetypes; - std::vector cells; - cells.reserve(2); + std::vector cells; + cells.reserve(3); { - const size_t size = 1; - auto result = rerun::components::TensorData::to_data_cell(&archetype.data, size); + auto result = rerun::components::TensorData::to_data_cell(&archetype.data, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.draw_order.has_value()) { - const size_t size = 1; auto result = - rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), size); + rerun::components::DrawOrder::to_data_cell(&archetype.draw_order.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = SegmentationImage::IndicatorComponent(); auto result = SegmentationImage::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/segmentation_image.hpp b/rerun_cpp/src/rerun/archetypes/segmentation_image.hpp index c88954f5fff4..8c2615009ac6 100644 --- a/rerun_cpp/src/rerun/archetypes/segmentation_image.hpp +++ b/rerun_cpp/src/rerun/archetypes/segmentation_image.hpp @@ -10,7 +10,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -126,7 +125,7 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( + static Result> serialize( const archetypes::SegmentationImage& archetype ); }; diff --git a/rerun_cpp/src/rerun/archetypes/tensor.cpp b/rerun_cpp/src/rerun/archetypes/tensor.cpp index 35c1794ed8c2..53c59cc8d5c2 100644 --- a/rerun_cpp/src/rerun/archetypes/tensor.cpp +++ b/rerun_cpp/src/rerun/archetypes/tensor.cpp @@ -11,24 +11,23 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Tensor& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(1); + std::vector cells; + cells.reserve(2); { - const size_t size = 1; - auto result = rerun::components::TensorData::to_data_cell(&archetype.data, size); + auto result = rerun::components::TensorData::to_data_cell(&archetype.data, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Tensor::IndicatorComponent(); auto result = Tensor::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/tensor.hpp b/rerun_cpp/src/rerun/archetypes/tensor.hpp index c8514aa8bee4..f9da139a2ad6 100644 --- a/rerun_cpp/src/rerun/archetypes/tensor.hpp +++ b/rerun_cpp/src/rerun/archetypes/tensor.hpp @@ -8,7 +8,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -93,8 +92,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Tensor& archetype - ); + static Result> serialize(const archetypes::Tensor& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/text_document.cpp b/rerun_cpp/src/rerun/archetypes/text_document.cpp index d20bda2eda15..b0cde4386216 100644 --- a/rerun_cpp/src/rerun/archetypes/text_document.cpp +++ b/rerun_cpp/src/rerun/archetypes/text_document.cpp @@ -11,31 +11,29 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::TextDocument& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(2); + std::vector cells; + cells.reserve(3); { - const size_t size = 1; - auto result = rerun::components::Text::to_data_cell(&archetype.text, size); + auto result = rerun::components::Text::to_data_cell(&archetype.text, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.media_type.has_value()) { - const size_t size = 1; auto result = - rerun::components::MediaType::to_data_cell(&archetype.media_type.value(), size); + rerun::components::MediaType::to_data_cell(&archetype.media_type.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = TextDocument::IndicatorComponent(); auto result = TextDocument::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/text_document.hpp b/rerun_cpp/src/rerun/archetypes/text_document.hpp index 022320953b4a..102f599026be 100644 --- a/rerun_cpp/src/rerun/archetypes/text_document.hpp +++ b/rerun_cpp/src/rerun/archetypes/text_document.hpp @@ -10,7 +10,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -129,8 +128,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::TextDocument& archetype - ); + static Result> serialize(const archetypes::TextDocument& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/text_log.cpp b/rerun_cpp/src/rerun/archetypes/text_log.cpp index 913a2adb76a8..6372b9f21a96 100644 --- a/rerun_cpp/src/rerun/archetypes/text_log.cpp +++ b/rerun_cpp/src/rerun/archetypes/text_log.cpp @@ -11,37 +11,34 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::TextLog& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(3); + std::vector cells; + cells.reserve(4); { - const size_t size = 1; - auto result = rerun::components::Text::to_data_cell(&archetype.text, size); + auto result = rerun::components::Text::to_data_cell(&archetype.text, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.level.has_value()) { - const size_t size = 1; auto result = - rerun::components::TextLogLevel::to_data_cell(&archetype.level.value(), size); + rerun::components::TextLogLevel::to_data_cell(&archetype.level.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.color.has_value()) { - const size_t size = 1; - auto result = rerun::components::Color::to_data_cell(&archetype.color.value(), size); + auto result = rerun::components::Color::to_data_cell(&archetype.color.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = TextLog::IndicatorComponent(); auto result = TextLog::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/text_log.hpp b/rerun_cpp/src/rerun/archetypes/text_log.hpp index 260f02624bf9..ac26dc867f2e 100644 --- a/rerun_cpp/src/rerun/archetypes/text_log.hpp +++ b/rerun_cpp/src/rerun/archetypes/text_log.hpp @@ -11,7 +11,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -135,8 +134,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::TextLog& archetype - ); + static Result> serialize(const archetypes::TextLog& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/time_series_scalar.cpp b/rerun_cpp/src/rerun/archetypes/time_series_scalar.cpp index 9db2b8961d45..a24976bcb148 100644 --- a/rerun_cpp/src/rerun/archetypes/time_series_scalar.cpp +++ b/rerun_cpp/src/rerun/archetypes/time_series_scalar.cpp @@ -12,50 +12,44 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents< - archetypes::TimeSeriesScalar>::serialize(const archetypes::TimeSeriesScalar& archetype) { + Result> AsComponents::serialize( + const archetypes::TimeSeriesScalar& archetype + ) { using namespace archetypes; - std::vector cells; - cells.reserve(5); + std::vector cells; + cells.reserve(6); { - const size_t size = 1; - auto result = rerun::components::Scalar::to_data_cell(&archetype.scalar, size); + auto result = rerun::components::Scalar::to_data_cell(&archetype.scalar, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.radius.has_value()) { - const size_t size = 1; - auto result = rerun::components::Radius::to_data_cell(&archetype.radius.value(), size); + auto result = rerun::components::Radius::to_data_cell(&archetype.radius.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.color.has_value()) { - const size_t size = 1; - auto result = rerun::components::Color::to_data_cell(&archetype.color.value(), size); + auto result = rerun::components::Color::to_data_cell(&archetype.color.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.label.has_value()) { - const size_t size = 1; - auto result = rerun::components::Text::to_data_cell(&archetype.label.value(), size); + auto result = rerun::components::Text::to_data_cell(&archetype.label.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.scattered.has_value()) { - const size_t size = 1; - auto result = rerun::components::ScalarScattering::to_data_cell( - &archetype.scattered.value(), - size - ); + auto result = + rerun::components::ScalarScattering::to_data_cell(&archetype.scattered.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = TimeSeriesScalar::IndicatorComponent(); auto result = TimeSeriesScalar::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/time_series_scalar.hpp b/rerun_cpp/src/rerun/archetypes/time_series_scalar.hpp index e1023183e1d5..05e5fbe97bed 100644 --- a/rerun_cpp/src/rerun/archetypes/time_series_scalar.hpp +++ b/rerun_cpp/src/rerun/archetypes/time_series_scalar.hpp @@ -13,7 +13,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -178,8 +177,7 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::TimeSeriesScalar& archetype + static Result> serialize(const archetypes::TimeSeriesScalar& archetype ); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/transform3d.cpp b/rerun_cpp/src/rerun/archetypes/transform3d.cpp index 5963ebe98cb1..851fe8601c81 100644 --- a/rerun_cpp/src/rerun/archetypes/transform3d.cpp +++ b/rerun_cpp/src/rerun/archetypes/transform3d.cpp @@ -11,24 +11,23 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::Transform3D& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(1); + std::vector cells; + cells.reserve(2); { - const size_t size = 1; - auto result = rerun::components::Transform3D::to_data_cell(&archetype.transform, size); + auto result = rerun::components::Transform3D::to_data_cell(&archetype.transform, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = Transform3D::IndicatorComponent(); auto result = Transform3D::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/transform3d.hpp b/rerun_cpp/src/rerun/archetypes/transform3d.hpp index ef552e14e349..e428d68be43c 100644 --- a/rerun_cpp/src/rerun/archetypes/transform3d.hpp +++ b/rerun_cpp/src/rerun/archetypes/transform3d.hpp @@ -8,7 +8,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -258,8 +257,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::Transform3D& archetype - ); + static Result> serialize(const archetypes::Transform3D& archetype); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/archetypes/view_coordinates.cpp b/rerun_cpp/src/rerun/archetypes/view_coordinates.cpp index a253192dbcce..5f07e86f1413 100644 --- a/rerun_cpp/src/rerun/archetypes/view_coordinates.cpp +++ b/rerun_cpp/src/rerun/archetypes/view_coordinates.cpp @@ -12,23 +12,23 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents< - archetypes::ViewCoordinates>::serialize(const archetypes::ViewCoordinates& archetype) { + Result> AsComponents::serialize( + const archetypes::ViewCoordinates& archetype + ) { using namespace archetypes; - std::vector cells; - cells.reserve(1); + std::vector cells; + cells.reserve(2); { - const size_t size = 1; - auto result = rerun::components::ViewCoordinates::to_data_cell(&archetype.xyz, size); + auto result = rerun::components::ViewCoordinates::to_data_cell(&archetype.xyz, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = ViewCoordinates::IndicatorComponent(); auto result = ViewCoordinates::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/src/rerun/archetypes/view_coordinates.hpp b/rerun_cpp/src/rerun/archetypes/view_coordinates.hpp index 170087566eef..7d2368b0c391 100644 --- a/rerun_cpp/src/rerun/archetypes/view_coordinates.hpp +++ b/rerun_cpp/src/rerun/archetypes/view_coordinates.hpp @@ -8,7 +8,6 @@ #include "../data_cell.hpp" #include "../indicator_component.hpp" #include "../result.hpp" -#include "../serialized_component_batch.hpp" #include #include @@ -146,8 +145,7 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::ViewCoordinates& archetype + static Result> serialize(const archetypes::ViewCoordinates& archetype ); }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/arrow.cpp b/rerun_cpp/src/rerun/arrow.cpp deleted file mode 100644 index ec5b4eb2ff9f..000000000000 --- a/rerun_cpp/src/rerun/arrow.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "arrow.hpp" - -#include -#include -#include -#include - -namespace rerun { - Result> ipc_from_table(const arrow::Table& table) { - ARROW_ASSIGN_OR_RAISE(auto output, arrow::io::BufferOutputStream::Create()) - ARROW_ASSIGN_OR_RAISE(auto writer, arrow::ipc::MakeStreamWriter(output, table.schema())) - ARROW_RETURN_NOT_OK(writer->WriteTable(table)); - ARROW_RETURN_NOT_OK(writer->Close()); - - auto result = output->Finish(); - if (result.ok()) { - return result.ValueOrDie(); - } else { - return result.status(); - } - } -} // namespace rerun diff --git a/rerun_cpp/src/rerun/arrow.hpp b/rerun_cpp/src/rerun/arrow.hpp deleted file mode 100644 index 08726c12f11c..000000000000 --- a/rerun_cpp/src/rerun/arrow.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// Arrow integrations. -#pragma once - -#include -#include "result.hpp" - -namespace arrow { - class Buffer; - class Table; -} // namespace arrow - -namespace rerun { - /// Encode the given arrow table in the Arrow IPC encapsulated message format. - /// - /// * - /// * - Result> ipc_from_table(const arrow::Table& table); -} // namespace rerun diff --git a/rerun_cpp/src/rerun/as_components.hpp b/rerun_cpp/src/rerun/as_components.hpp index 5436c331d881..a6ce1a604581 100644 --- a/rerun_cpp/src/rerun/as_components.hpp +++ b/rerun_cpp/src/rerun/as_components.hpp @@ -1,8 +1,8 @@ #pragma once #include "collection.hpp" +#include "data_cell.hpp" #include "indicator_component.hpp" -#include "serialized_component_batch.hpp" namespace rerun { /// The AsComponents trait is used to convert a type into a list of serialized component. @@ -33,24 +33,18 @@ namespace rerun { /// AsComponents for a Collection of components. template struct AsComponents> { - static Result> serialize( - const Collection& components - ) { + static Result> serialize(const Collection& components) { auto cell_result = TComponent::to_data_cell(components.data(), components.size()); RR_RETURN_NOT_OK(cell_result.error); - return Result>( - {SerializedComponentBatch(std::move(cell_result.value), components.size())} - ); + return Result>({std::move(cell_result.value)}); } }; /// AsComponents for a std::vector of components. template struct AsComponents> { - static Result> serialize( - const std::vector& components - ) { + static Result> serialize(const std::vector& components) { return AsComponents>::serialize(components); } }; @@ -58,8 +52,7 @@ namespace rerun { /// AsComponents for std::initializer_list template struct AsComponents> { - static Result> serialize( - std::initializer_list components + static Result> serialize(std::initializer_list components ) { return AsComponents>::serialize(components); } @@ -68,7 +61,7 @@ namespace rerun { /// AsComponents for an std::array of components. template struct AsComponents> { - static Result> serialize( + static Result> serialize( const std::array& components ) { return AsComponents>::serialize(components); @@ -78,8 +71,8 @@ namespace rerun { /// AsComponents for an c-array of components. template struct AsComponents { - static Result> serialize(const TComponent (&components - )[NumInstances]) { + static Result> serialize(const TComponent (&components)[NumInstances] + ) { return AsComponents>::serialize(components); } }; @@ -87,7 +80,7 @@ namespace rerun { /// AsComponents for single indicators template struct AsComponents> { - static Result> serialize( + static Result> serialize( const components::IndicatorComponent& indicator ) { return AsComponents>>::serialize( diff --git a/rerun_cpp/src/rerun/c/arrow_c_data_interface.h b/rerun_cpp/src/rerun/c/arrow_c_data_interface.h new file mode 100644 index 000000000000..6733ad2934cf --- /dev/null +++ b/rerun_cpp/src/rerun/c/arrow_c_data_interface.h @@ -0,0 +1,111 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ARROW_C_DATA_INTERFACE +#define ARROW_C_DATA_INTERFACE + +#define ARROW_FLAG_DICTIONARY_ORDERED 1 +#define ARROW_FLAG_NULLABLE 2 +#define ARROW_FLAG_MAP_KEYS_SORTED 4 + +struct ArrowSchema { + // Array type description + const char* format; + const char* name; + const char* metadata; + int64_t flags; + int64_t n_children; + struct ArrowSchema** children; + struct ArrowSchema* dictionary; + + // Release callback + void (*release)(struct ArrowSchema*); + // Opaque producer-specific data + void* private_data; +}; + +struct ArrowArray { + // Array data description + int64_t length; + int64_t null_count; + int64_t offset; + int64_t n_buffers; + int64_t n_children; + const void** buffers; + struct ArrowArray** children; + struct ArrowArray* dictionary; + + // Release callback + void (*release)(struct ArrowArray*); + // Opaque producer-specific data + void* private_data; +}; + +#endif // ARROW_C_DATA_INTERFACE + +#ifndef ARROW_C_STREAM_INTERFACE +#define ARROW_C_STREAM_INTERFACE + +struct ArrowArrayStream { + // Callback to get the stream type + // (will be the same for all arrays in the stream). + // + // Return value: 0 if successful, an `errno`-compatible error code otherwise. + // + // If successful, the ArrowSchema must be released independently from the stream. + int (*get_schema)(struct ArrowArrayStream*, struct ArrowSchema* out); + + // Callback to get the next array + // (if no error and the array is released, the stream has ended) + // + // Return value: 0 if successful, an `errno`-compatible error code otherwise. + // + // If successful, the ArrowArray must be released independently from the stream. + int (*get_next)(struct ArrowArrayStream*, struct ArrowArray* out); + + // Callback to get optional detailed error information. + // This must only be called if the last stream operation failed + // with a non-0 return code. + // + // Return value: pointer to a null-terminated character array describing + // the last error, or NULL if no description is available. + // + // The returned pointer is only valid until the next operation on this stream + // (including release). + const char* (*get_last_error)(struct ArrowArrayStream*); + + // Release callback: release the stream's own resources. + // Note that arrays returned by `get_next` must be individually released. + void (*release)(struct ArrowArrayStream*); + + // Opaque producer-specific data + void* private_data; +}; + +#endif // ARROW_C_STREAM_INTERFACE + +#ifdef __cplusplus +} +#endif diff --git a/rerun_cpp/src/rerun/c/rerun.h b/rerun_cpp/src/rerun/c/rerun.h index c7fc87515af3..9103908a353d 100644 --- a/rerun_cpp/src/rerun/c/rerun.h +++ b/rerun_cpp/src/rerun/c/rerun.h @@ -16,6 +16,7 @@ extern "C" { #include #include +#include "arrow_c_data_interface.h" // ---------------------------------------------------------------------------- // Types: @@ -131,22 +132,17 @@ typedef struct rr_store_info { rr_store_kind store_kind; } rr_store_info; -/// Arrow-encoded data of a single component for a single entity. +/// Arrow-encoded data of a single batch components for a single entity. typedef struct rr_data_cell { /// The name of the component, e.g. `position`. rr_string component_name; - /// The number of bytes in the `bytes` field. - /// Must be a multiple of 8. - uint64_t num_bytes; + /// A batch of instances of this component serialized into an arrow array. + ArrowArray array; - /// Data in the Arrow IPC encapsulated message format. - /// - /// There must be exactly one chunk of data. - /// - /// * - /// * - const uint8_t* bytes; + /// The schema used for the arrow array. + /// TODO(andreas): Use a schema registry that identifies this and the component name with a unique schema ID. + ArrowSchema schema; } rr_data_cell; /// Arrow-encoded log data for a single entity. @@ -163,7 +159,7 @@ typedef struct { uint32_t num_data_cells; /// One for each component. - const rr_data_cell* data_cells; + rr_data_cell* data_cells; } rr_data_row; /// Error codes returned by the Rerun C SDK as part of `rr_error`. @@ -190,7 +186,8 @@ enum { // Arrow data processing errors. _RR_ERROR_CODE_CATEGORY_ARROW = 0x000001000, - RR_ERROR_CODE_ARROW_IPC_MESSAGE_PARSING_FAILURE, + RR_ERROR_CODE_ARROW_FFI_SCHEMA_IMPORT_ERROR, + RR_ERROR_CODE_ARROW_FFI_ARRAY_IMPORT_ERROR, RR_ERROR_CODE_ARROW_DATA_CELL_ERROR, // Generic errors. @@ -363,8 +360,12 @@ extern void rr_recording_stream_reset_time(rr_recording_stream stream); /// /// If `inject_time` is set to `true`, the row's timestamp data will be /// overridden using the recording streams internal clock. +/// +/// Takes ownership of the passed data cells and will release underlying +/// arrow data once it is no longer needed. +/// Any pointers passed via `rr_string` can be safely freed after this call. extern void rr_recording_stream_log( - rr_recording_stream stream, const rr_data_row* data_row, bool inject_time, rr_error* error + rr_recording_stream stream, rr_data_row data_row, bool inject_time, rr_error* error ); // ---------------------------------------------------------------------------- diff --git a/rerun_cpp/src/rerun/components/annotation_context.cpp b/rerun_cpp/src/rerun/components/annotation_context.cpp index 10e9435f930c..ee34962e3662 100644 --- a/rerun_cpp/src/rerun/components/annotation_context.cpp +++ b/rerun_cpp/src/rerun/components/annotation_context.cpp @@ -69,10 +69,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AnnotationContext::NAME, - AnnotationContext::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AnnotationContext::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/blob.cpp b/rerun_cpp/src/rerun/components/blob.cpp index 1e4251cc2312..c597440e8ad0 100644 --- a/rerun_cpp/src/rerun/components/blob.cpp +++ b/rerun_cpp/src/rerun/components/blob.cpp @@ -59,6 +59,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create(Blob::NAME, Blob::arrow_datatype(), std::move(array)); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Blob::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/class_id.cpp b/rerun_cpp/src/rerun/components/class_id.cpp index b0628bc54a78..e4ac795e009b 100644 --- a/rerun_cpp/src/rerun/components/class_id.cpp +++ b/rerun_cpp/src/rerun/components/class_id.cpp @@ -44,6 +44,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create(ClassId::NAME, ClassId::arrow_datatype(), std::move(array)); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = ClassId::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/clear_is_recursive.cpp b/rerun_cpp/src/rerun/components/clear_is_recursive.cpp index 5f0d5f7bc8fb..fd11f27c0b60 100644 --- a/rerun_cpp/src/rerun/components/clear_is_recursive.cpp +++ b/rerun_cpp/src/rerun/components/clear_is_recursive.cpp @@ -53,10 +53,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - ClearIsRecursive::NAME, - ClearIsRecursive::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = ClearIsRecursive::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/color.cpp b/rerun_cpp/src/rerun/components/color.cpp index ae25cceed3fb..e31d6cf7146a 100644 --- a/rerun_cpp/src/rerun/components/color.cpp +++ b/rerun_cpp/src/rerun/components/color.cpp @@ -44,6 +44,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create(Color::NAME, Color::arrow_datatype(), std::move(array)); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Color::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/depth_meter.cpp b/rerun_cpp/src/rerun/components/depth_meter.cpp index abc0a6d8953b..ad012956f7e6 100644 --- a/rerun_cpp/src/rerun/components/depth_meter.cpp +++ b/rerun_cpp/src/rerun/components/depth_meter.cpp @@ -52,10 +52,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - DepthMeter::NAME, - DepthMeter::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = DepthMeter::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/disconnected_space.cpp b/rerun_cpp/src/rerun/components/disconnected_space.cpp index 34e13caa771f..3c04ee8f73af 100644 --- a/rerun_cpp/src/rerun/components/disconnected_space.cpp +++ b/rerun_cpp/src/rerun/components/disconnected_space.cpp @@ -53,10 +53,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - DisconnectedSpace::NAME, - DisconnectedSpace::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = DisconnectedSpace::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/draw_order.cpp b/rerun_cpp/src/rerun/components/draw_order.cpp index 02bb328683b2..4c5afd1e8218 100644 --- a/rerun_cpp/src/rerun/components/draw_order.cpp +++ b/rerun_cpp/src/rerun/components/draw_order.cpp @@ -52,10 +52,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - DrawOrder::NAME, - DrawOrder::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = DrawOrder::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/half_sizes2d.cpp b/rerun_cpp/src/rerun/components/half_sizes2d.cpp index d66e5e0f9d41..b8ff9316d696 100644 --- a/rerun_cpp/src/rerun/components/half_sizes2d.cpp +++ b/rerun_cpp/src/rerun/components/half_sizes2d.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - HalfSizes2D::NAME, - HalfSizes2D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = HalfSizes2D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/half_sizes3d.cpp b/rerun_cpp/src/rerun/components/half_sizes3d.cpp index cd8a4314767c..2f018cf55826 100644 --- a/rerun_cpp/src/rerun/components/half_sizes3d.cpp +++ b/rerun_cpp/src/rerun/components/half_sizes3d.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - HalfSizes3D::NAME, - HalfSizes3D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = HalfSizes3D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/instance_key.cpp b/rerun_cpp/src/rerun/components/instance_key.cpp index a62996a2d12e..62ead25adf0e 100644 --- a/rerun_cpp/src/rerun/components/instance_key.cpp +++ b/rerun_cpp/src/rerun/components/instance_key.cpp @@ -52,10 +52,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - InstanceKey::NAME, - InstanceKey::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = InstanceKey::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/keypoint_id.cpp b/rerun_cpp/src/rerun/components/keypoint_id.cpp index ffaddcc1a561..4d7e4350a828 100644 --- a/rerun_cpp/src/rerun/components/keypoint_id.cpp +++ b/rerun_cpp/src/rerun/components/keypoint_id.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - KeypointId::NAME, - KeypointId::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = KeypointId::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/line_strip2d.cpp b/rerun_cpp/src/rerun/components/line_strip2d.cpp index 0795edb081d2..4ec9d446fecc 100644 --- a/rerun_cpp/src/rerun/components/line_strip2d.cpp +++ b/rerun_cpp/src/rerun/components/line_strip2d.cpp @@ -66,10 +66,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - LineStrip2D::NAME, - LineStrip2D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = LineStrip2D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/line_strip3d.cpp b/rerun_cpp/src/rerun/components/line_strip3d.cpp index 95f677a4f792..f1839cf8a3d6 100644 --- a/rerun_cpp/src/rerun/components/line_strip3d.cpp +++ b/rerun_cpp/src/rerun/components/line_strip3d.cpp @@ -66,10 +66,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - LineStrip3D::NAME, - LineStrip3D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = LineStrip3D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/material.cpp b/rerun_cpp/src/rerun/components/material.cpp index 0348b2fb986e..491a689cea65 100644 --- a/rerun_cpp/src/rerun/components/material.cpp +++ b/rerun_cpp/src/rerun/components/material.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - Material::NAME, - Material::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Material::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/media_type.cpp b/rerun_cpp/src/rerun/components/media_type.cpp index 277810d6b618..00474f2e34ff 100644 --- a/rerun_cpp/src/rerun/components/media_type.cpp +++ b/rerun_cpp/src/rerun/components/media_type.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - MediaType::NAME, - MediaType::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = MediaType::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/mesh_properties.cpp b/rerun_cpp/src/rerun/components/mesh_properties.cpp index 7b558c2067c3..3fbdc98df749 100644 --- a/rerun_cpp/src/rerun/components/mesh_properties.cpp +++ b/rerun_cpp/src/rerun/components/mesh_properties.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - MeshProperties::NAME, - MeshProperties::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = MeshProperties::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/out_of_tree_transform3d.cpp b/rerun_cpp/src/rerun/components/out_of_tree_transform3d.cpp index be64612f5f82..61221988a20b 100644 --- a/rerun_cpp/src/rerun/components/out_of_tree_transform3d.cpp +++ b/rerun_cpp/src/rerun/components/out_of_tree_transform3d.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - OutOfTreeTransform3D::NAME, - OutOfTreeTransform3D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = OutOfTreeTransform3D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/pinhole_projection.cpp b/rerun_cpp/src/rerun/components/pinhole_projection.cpp index 7d225b6f3aaf..e6c1b2a22ea0 100644 --- a/rerun_cpp/src/rerun/components/pinhole_projection.cpp +++ b/rerun_cpp/src/rerun/components/pinhole_projection.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - PinholeProjection::NAME, - PinholeProjection::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = PinholeProjection::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/position2d.cpp b/rerun_cpp/src/rerun/components/position2d.cpp index 90540f1aa49d..49427aed5832 100644 --- a/rerun_cpp/src/rerun/components/position2d.cpp +++ b/rerun_cpp/src/rerun/components/position2d.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - Position2D::NAME, - Position2D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Position2D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/position3d.cpp b/rerun_cpp/src/rerun/components/position3d.cpp index ca3ee2546f63..aa8d696ef2a7 100644 --- a/rerun_cpp/src/rerun/components/position3d.cpp +++ b/rerun_cpp/src/rerun/components/position3d.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - Position3D::NAME, - Position3D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Position3D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/radius.cpp b/rerun_cpp/src/rerun/components/radius.cpp index 5451ff49d8c9..2070dc4d9937 100644 --- a/rerun_cpp/src/rerun/components/radius.cpp +++ b/rerun_cpp/src/rerun/components/radius.cpp @@ -50,6 +50,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create(Radius::NAME, Radius::arrow_datatype(), std::move(array)); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Radius::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/resolution.cpp b/rerun_cpp/src/rerun/components/resolution.cpp index c7800d6a2408..b94dfdb1299c 100644 --- a/rerun_cpp/src/rerun/components/resolution.cpp +++ b/rerun_cpp/src/rerun/components/resolution.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - Resolution::NAME, - Resolution::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Resolution::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/rotation3d.cpp b/rerun_cpp/src/rerun/components/rotation3d.cpp index 8dddc0305c96..47ae82d41440 100644 --- a/rerun_cpp/src/rerun/components/rotation3d.cpp +++ b/rerun_cpp/src/rerun/components/rotation3d.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - Rotation3D::NAME, - Rotation3D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Rotation3D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/scalar.cpp b/rerun_cpp/src/rerun/components/scalar.cpp index e048198f5ca1..d63e47852425 100644 --- a/rerun_cpp/src/rerun/components/scalar.cpp +++ b/rerun_cpp/src/rerun/components/scalar.cpp @@ -50,6 +50,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create(Scalar::NAME, Scalar::arrow_datatype(), std::move(array)); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Scalar::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/scalar_scattering.cpp b/rerun_cpp/src/rerun/components/scalar_scattering.cpp index c2cb93b1da5c..5b906a1511d9 100644 --- a/rerun_cpp/src/rerun/components/scalar_scattering.cpp +++ b/rerun_cpp/src/rerun/components/scalar_scattering.cpp @@ -53,10 +53,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - ScalarScattering::NAME, - ScalarScattering::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = ScalarScattering::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/tensor_data.cpp b/rerun_cpp/src/rerun/components/tensor_data.cpp index 1e7ad9493af3..0dc8b6604f54 100644 --- a/rerun_cpp/src/rerun/components/tensor_data.cpp +++ b/rerun_cpp/src/rerun/components/tensor_data.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - TensorData::NAME, - TensorData::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = TensorData::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/text.cpp b/rerun_cpp/src/rerun/components/text.cpp index 1b3ea164b816..92b6079610b7 100644 --- a/rerun_cpp/src/rerun/components/text.cpp +++ b/rerun_cpp/src/rerun/components/text.cpp @@ -44,6 +44,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create(Text::NAME, Text::arrow_datatype(), std::move(array)); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Text::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/text_log_level.cpp b/rerun_cpp/src/rerun/components/text_log_level.cpp index eb80ade9a042..ff8557b7aa60 100644 --- a/rerun_cpp/src/rerun/components/text_log_level.cpp +++ b/rerun_cpp/src/rerun/components/text_log_level.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - TextLogLevel::NAME, - TextLogLevel::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = TextLogLevel::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/transform3d.cpp b/rerun_cpp/src/rerun/components/transform3d.cpp index 5e0158204b6f..6abdb4b72f3a 100644 --- a/rerun_cpp/src/rerun/components/transform3d.cpp +++ b/rerun_cpp/src/rerun/components/transform3d.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - Transform3D::NAME, - Transform3D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Transform3D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/vector3d.cpp b/rerun_cpp/src/rerun/components/vector3d.cpp index 2243fbe44247..bd9c681e8c7a 100644 --- a/rerun_cpp/src/rerun/components/vector3d.cpp +++ b/rerun_cpp/src/rerun/components/vector3d.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - Vector3D::NAME, - Vector3D::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = Vector3D::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/components/view_coordinates.cpp b/rerun_cpp/src/rerun/components/view_coordinates.cpp index c39a2b3735d1..5352546f1018 100644 --- a/rerun_cpp/src/rerun/components/view_coordinates.cpp +++ b/rerun_cpp/src/rerun/components/view_coordinates.cpp @@ -58,10 +58,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - ViewCoordinates::NAME, - ViewCoordinates::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = ViewCoordinates::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/src/rerun/data_cell.cpp b/rerun_cpp/src/rerun/data_cell.cpp index 81d45723704b..a4028c778b7c 100644 --- a/rerun_cpp/src/rerun/data_cell.cpp +++ b/rerun_cpp/src/rerun/data_cell.cpp @@ -1,34 +1,32 @@ #include "data_cell.hpp" -#include "arrow.hpp" +#include "string_utils.hpp" #include +#include -namespace rerun { - - Result DataCell::create( - std::string name, const std::shared_ptr& datatype, - std::shared_ptr array - ) { - // TODO(andreas): This should be lazily created once just like datatypes are right now, saving repeated allocations. - auto schema = arrow::schema({arrow::field(name, datatype, false)}); - - const auto ipc_result = rerun::ipc_from_table(*arrow::Table::Make(schema, {array})); - RR_RETURN_NOT_OK(ipc_result.error); - - rerun::DataCell cell; - cell.component_name = std::move(name); - cell.buffer = std::move(ipc_result.value); - - return cell; - } +#include "c/rerun.h" - Result DataCell::create_indicator_component(std::string indicator_fqname) { +namespace rerun { + Result DataCell::create_indicator_component(std::string_view archetype_name) { arrow::MemoryPool* pool = arrow::default_memory_pool(); auto builder = std::make_shared(pool); ARROW_RETURN_NOT_OK(builder->AppendNulls(1)); std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return create(std::move(indicator_fqname), arrow::null(), std::move(array)); + DataCell cell; + cell.num_instances = 1; + cell.component_name = archetype_name; + cell.array = std::move(array); + return cell; + } + + Error DataCell::to_c_ffi_struct(rr_data_cell& out_cell) const { + if (array == nullptr) { + return Error(ErrorCode::UnexpectedNullArgument, "array is null"); + } + + out_cell.component_name = detail::to_rr_string(component_name); + return arrow::ExportArray(*array, &out_cell.array, &out_cell.schema); } } // namespace rerun diff --git a/rerun_cpp/src/rerun/data_cell.hpp b/rerun_cpp/src/rerun/data_cell.hpp index f2a937802ef0..be2e7fa16e64 100644 --- a/rerun_cpp/src/rerun/data_cell.hpp +++ b/rerun_cpp/src/rerun/data_cell.hpp @@ -5,32 +5,37 @@ #include "result.hpp" namespace arrow { - class Buffer; class Array; class DataType; } // namespace arrow +struct rr_data_cell; + namespace rerun { - /// Equivalent to `rr_data_cell` from the C API. + /// Arrow-encoded data of a single batch components for a single entity. + /// + /// Note that the DataCell doesn't own `datatype` and `component_name`. struct DataCell { - /// Name of the logged component. - std::string component_name; - - /// Data in the Arrow IPC encapsulated message format. - /// - /// There must be exactly one chunk of data. + /// How many instances of the component were serialized in this data cell. /// - /// * - /// * - std::shared_ptr buffer; + /// TODO(andreas): Just like in Rust, make this part of `AsComponents`. + /// This will requiring inlining some things on RecordingStream and have some refactor ripples. + /// But it's worth keeping the language bindings more similar! + size_t num_instances; - /// Create a new data cell from an arrow array. - static Result create( - std::string name, const std::shared_ptr& datatype, - std::shared_ptr array - ); + /// String pointer to a component name valid for the lifetime of the cell. + std::string_view component_name; + /// Arrow-encoded data of the components. + std::shared_ptr array; + + public: /// Create a data cell for an indicator component. - static Result create_indicator_component(std::string arch_name); + static Result create_indicator_component(std::string_view archetype_name); + + /// To rerun C API data cell. + /// + /// The resulting `rr_data_cell` keeps the `arrow::Array` alive until it is released. + Error to_c_ffi_struct(rr_data_cell& out_cell) const; }; } // namespace rerun diff --git a/rerun_cpp/src/rerun/datatypes/tensor_buffer_ext.cpp b/rerun_cpp/src/rerun/datatypes/tensor_buffer_ext.cpp index 651d7b82139e..4d1031826197 100644 --- a/rerun_cpp/src/rerun/datatypes/tensor_buffer_ext.cpp +++ b/rerun_cpp/src/rerun/datatypes/tensor_buffer_ext.cpp @@ -114,9 +114,11 @@ namespace rerun::datatypes { } case detail::TensorBufferTag::NV12: { assert(false && "Can't ask for the number of elements in an NV12 encoded image"); + break; } case detail::TensorBufferTag::JPEG: { assert(false && "Can't ask for the number of elements in a JPEG"); + break; } } assert(false && "Unknown TensorBuffer tag"); diff --git a/rerun_cpp/src/rerun/error.hpp b/rerun_cpp/src/rerun/error.hpp index a6909d68525f..6c679a83ad1f 100644 --- a/rerun_cpp/src/rerun/error.hpp +++ b/rerun_cpp/src/rerun/error.hpp @@ -47,7 +47,8 @@ namespace rerun { // Arrow data processing errors. _CategoryArrow = 0x0000'1000, - ArrowIpcMessageParsingFailure, + ArrowFfiSchemaImportError, + ArrowFfiArrayImportError, ArrowDataCellError, // Errors relating to file IO. diff --git a/rerun_cpp/src/rerun/indicator_component.hpp b/rerun_cpp/src/rerun/indicator_component.hpp index 66ce99167cdf..db23b3d7d8ce 100644 --- a/rerun_cpp/src/rerun/indicator_component.hpp +++ b/rerun_cpp/src/rerun/indicator_component.hpp @@ -1,6 +1,5 @@ #pragma once -#include "arrow.hpp" #include "data_cell.hpp" namespace rerun { diff --git a/rerun_cpp/src/rerun/recording_stream.cpp b/rerun_cpp/src/rerun/recording_stream.cpp index acfc930656a5..3caf8d530eec 100644 --- a/rerun_cpp/src/rerun/recording_stream.cpp +++ b/rerun_cpp/src/rerun/recording_stream.cpp @@ -175,8 +175,7 @@ namespace rerun { } Error RecordingStream::try_log_serialized_batches( - std::string_view entity_path, bool timeless, - const std::vector& batches + std::string_view entity_path, bool timeless, std::vector batches ) const { if (!is_enabled()) { return Error::ok(); @@ -191,9 +190,9 @@ namespace rerun { for (const auto& batch : batches) { if (num_instances_max > 1 && batch.num_instances == 1) { - splatted.push_back(batch.data_cell); + splatted.push_back(std::move(batch)); } else { - instanced.push_back(batch.data_cell); + instanced.push_back(std::move(batch)); } } @@ -227,16 +226,7 @@ namespace rerun { // Map to C API: std::vector c_data_cells(num_data_cells); for (size_t i = 0; i < num_data_cells; i++) { - if (data_cells[i].buffer == nullptr) { - return Error( - ErrorCode::UnexpectedNullArgument, - "DataCell buffer is null for cell " + std::to_string(i) - ); - } - - c_data_cells[i].component_name = detail::to_rr_string(data_cells[i].component_name); - c_data_cells[i].num_bytes = static_cast(data_cells[i].buffer->size()); - c_data_cells[i].bytes = data_cells[i].buffer->data(); + RR_RETURN_NOT_OK(data_cells[i].to_c_ffi_struct(c_data_cells[i])); } rr_data_row c_data_row; @@ -246,7 +236,8 @@ namespace rerun { c_data_row.data_cells = c_data_cells.data(); rr_error status = {}; - rr_recording_stream_log(_id, &c_data_row, inject_time, &status); + rr_recording_stream_log(_id, c_data_row, inject_time, &status); + return status; } } // namespace rerun diff --git a/rerun_cpp/src/rerun/recording_stream.hpp b/rerun_cpp/src/rerun/recording_stream.hpp index 9a975bd8c3ea..d846011edd4b 100644 --- a/rerun_cpp/src/rerun/recording_stream.hpp +++ b/rerun_cpp/src/rerun/recording_stream.hpp @@ -406,7 +406,7 @@ namespace rerun { if (!is_enabled()) { return Error::ok(); } - std::vector serialized_batches; + std::vector serialized_batches; Error err; ( [&] { @@ -414,7 +414,7 @@ namespace rerun { return; } - const Result> serialization_result = + const Result> serialization_result = AsComponents().serialize(archetypes_or_collectiones); if (serialization_result.is_err()) { err = serialization_result.error; @@ -436,7 +436,7 @@ namespace rerun { ); RR_RETURN_NOT_OK(err); - return try_log_serialized_batches(entity_path, timeless, serialized_batches); + return try_log_serialized_batches(entity_path, timeless, std::move(serialized_batches)); } /// Logs several serialized batches batches, returning an error on failure. @@ -456,8 +456,7 @@ namespace rerun { /// /// \see `log`, `try_log`, `log_timeless`, `try_log_timeless`, `try_log_with_timeless` Error try_log_serialized_batches( - std::string_view entity_path, bool timeless, - const std::vector& batches + std::string_view entity_path, bool timeless, std::vector batches ) const; /// Bottom level API that logs raw data cells to the recording stream. diff --git a/rerun_cpp/src/rerun/serialized_component_batch.hpp b/rerun_cpp/src/rerun/serialized_component_batch.hpp deleted file mode 100644 index 0b5580409ad5..000000000000 --- a/rerun_cpp/src/rerun/serialized_component_batch.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "data_cell.hpp" - -namespace rerun { - /// One or more instances of a single component serialized using Apache Arrow. - struct SerializedComponentBatch { - SerializedComponentBatch() = default; - - SerializedComponentBatch(DataCell data_cell_, size_t num_instances_) - : data_cell(std::move(data_cell_)), num_instances(num_instances_) {} - - /// The underlying data. - DataCell data_cell; - - /// How many components were serialized. - size_t num_instances; - }; -} // namespace rerun diff --git a/rerun_cpp/tests/archetypes/archetype_test.hpp b/rerun_cpp/tests/archetypes/archetype_test.hpp index 1dadf2adb4c3..d3a29de173a4 100644 --- a/rerun_cpp/tests/archetypes/archetype_test.hpp +++ b/rerun_cpp/tests/archetypes/archetype_test.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -25,12 +25,9 @@ void test_compare_archetype_serialization(const T& arch_a, const T& arch_b) { for (size_t i = 0; i < arch_b_serialized.size(); ++i) { CHECK(arch_b_serialized[i].num_instances == arch_a_serialized[i].num_instances); CHECK( - arch_b_serialized[i].data_cell.component_name == - arch_a_serialized[i].data_cell.component_name + arch_b_serialized[i].component_name == arch_a_serialized[i].component_name ); - CHECK(arch_b_serialized[i].data_cell.buffer->Equals( - *arch_a_serialized[i].data_cell.buffer - )); + CHECK(arch_b_serialized[i].array->Equals(*arch_a_serialized[i].array)); } } } diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.cpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.cpp index 7408711082c8..275aa0d6532f 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.cpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.cpp @@ -12,144 +12,123 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::AffixFuzzer1& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(21); + std::vector cells; + cells.reserve(22); { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer1::to_data_cell(&archetype.fuzz1001, size); + auto result = rerun::components::AffixFuzzer1::to_data_cell(&archetype.fuzz1001, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer2::to_data_cell(&archetype.fuzz1002, size); + auto result = rerun::components::AffixFuzzer2::to_data_cell(&archetype.fuzz1002, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer3::to_data_cell(&archetype.fuzz1003, size); + auto result = rerun::components::AffixFuzzer3::to_data_cell(&archetype.fuzz1003, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer4::to_data_cell(&archetype.fuzz1004, size); + auto result = rerun::components::AffixFuzzer4::to_data_cell(&archetype.fuzz1004, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer5::to_data_cell(&archetype.fuzz1005, size); + auto result = rerun::components::AffixFuzzer5::to_data_cell(&archetype.fuzz1005, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer6::to_data_cell(&archetype.fuzz1006, size); + auto result = rerun::components::AffixFuzzer6::to_data_cell(&archetype.fuzz1006, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer7::to_data_cell(&archetype.fuzz1007, size); + auto result = rerun::components::AffixFuzzer7::to_data_cell(&archetype.fuzz1007, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer8::to_data_cell(&archetype.fuzz1008, size); + auto result = rerun::components::AffixFuzzer8::to_data_cell(&archetype.fuzz1008, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer9::to_data_cell(&archetype.fuzz1009, size); + auto result = rerun::components::AffixFuzzer9::to_data_cell(&archetype.fuzz1009, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer10::to_data_cell(&archetype.fuzz1010, size); + auto result = rerun::components::AffixFuzzer10::to_data_cell(&archetype.fuzz1010, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer11::to_data_cell(&archetype.fuzz1011, size); + auto result = rerun::components::AffixFuzzer11::to_data_cell(&archetype.fuzz1011, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer12::to_data_cell(&archetype.fuzz1012, size); + auto result = rerun::components::AffixFuzzer12::to_data_cell(&archetype.fuzz1012, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer13::to_data_cell(&archetype.fuzz1013, size); + auto result = rerun::components::AffixFuzzer13::to_data_cell(&archetype.fuzz1013, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer14::to_data_cell(&archetype.fuzz1014, size); + auto result = rerun::components::AffixFuzzer14::to_data_cell(&archetype.fuzz1014, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer15::to_data_cell(&archetype.fuzz1015, size); + auto result = rerun::components::AffixFuzzer15::to_data_cell(&archetype.fuzz1015, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer16::to_data_cell(&archetype.fuzz1016, size); + auto result = rerun::components::AffixFuzzer16::to_data_cell(&archetype.fuzz1016, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer17::to_data_cell(&archetype.fuzz1017, size); + auto result = rerun::components::AffixFuzzer17::to_data_cell(&archetype.fuzz1017, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer18::to_data_cell(&archetype.fuzz1018, size); + auto result = rerun::components::AffixFuzzer18::to_data_cell(&archetype.fuzz1018, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer19::to_data_cell(&archetype.fuzz1019, size); + auto result = rerun::components::AffixFuzzer19::to_data_cell(&archetype.fuzz1019, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer20::to_data_cell(&archetype.fuzz1020, size); + auto result = rerun::components::AffixFuzzer20::to_data_cell(&archetype.fuzz1020, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = 1; - auto result = rerun::components::AffixFuzzer21::to_data_cell(&archetype.fuzz1021, size); + auto result = rerun::components::AffixFuzzer21::to_data_cell(&archetype.fuzz1021, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = AffixFuzzer1::IndicatorComponent(); auto result = AffixFuzzer1::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.hpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.hpp index 690cd8803158..e23228381cd2 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.hpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer1.hpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -139,8 +138,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::AffixFuzzer1& archetype - ); + static Result> serialize(const archetypes::AffixFuzzer1& archetype); }; } // namespace rerun diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer2.cpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer2.cpp index ae9e1cee4bb9..e16a40ede5f7 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer2.cpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer2.cpp @@ -12,180 +12,162 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::AffixFuzzer2& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(18); + std::vector cells; + cells.reserve(19); { - const size_t size = archetype.fuzz1101.size(); auto result = rerun::components::AffixFuzzer1::to_data_cell( archetype.fuzz1101.data(), archetype.fuzz1101.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1102.size(); auto result = rerun::components::AffixFuzzer2::to_data_cell( archetype.fuzz1102.data(), archetype.fuzz1102.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1103.size(); auto result = rerun::components::AffixFuzzer3::to_data_cell( archetype.fuzz1103.data(), archetype.fuzz1103.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1104.size(); auto result = rerun::components::AffixFuzzer4::to_data_cell( archetype.fuzz1104.data(), archetype.fuzz1104.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1105.size(); auto result = rerun::components::AffixFuzzer5::to_data_cell( archetype.fuzz1105.data(), archetype.fuzz1105.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1106.size(); auto result = rerun::components::AffixFuzzer6::to_data_cell( archetype.fuzz1106.data(), archetype.fuzz1106.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1107.size(); auto result = rerun::components::AffixFuzzer7::to_data_cell( archetype.fuzz1107.data(), archetype.fuzz1107.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1108.size(); auto result = rerun::components::AffixFuzzer8::to_data_cell( archetype.fuzz1108.data(), archetype.fuzz1108.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1109.size(); auto result = rerun::components::AffixFuzzer9::to_data_cell( archetype.fuzz1109.data(), archetype.fuzz1109.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1110.size(); auto result = rerun::components::AffixFuzzer10::to_data_cell( archetype.fuzz1110.data(), archetype.fuzz1110.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1111.size(); auto result = rerun::components::AffixFuzzer11::to_data_cell( archetype.fuzz1111.data(), archetype.fuzz1111.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1112.size(); auto result = rerun::components::AffixFuzzer12::to_data_cell( archetype.fuzz1112.data(), archetype.fuzz1112.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1113.size(); auto result = rerun::components::AffixFuzzer13::to_data_cell( archetype.fuzz1113.data(), archetype.fuzz1113.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1114.size(); auto result = rerun::components::AffixFuzzer14::to_data_cell( archetype.fuzz1114.data(), archetype.fuzz1114.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1115.size(); auto result = rerun::components::AffixFuzzer15::to_data_cell( archetype.fuzz1115.data(), archetype.fuzz1115.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1116.size(); auto result = rerun::components::AffixFuzzer16::to_data_cell( archetype.fuzz1116.data(), archetype.fuzz1116.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1117.size(); auto result = rerun::components::AffixFuzzer17::to_data_cell( archetype.fuzz1117.data(), archetype.fuzz1117.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { - const size_t size = archetype.fuzz1118.size(); auto result = rerun::components::AffixFuzzer18::to_data_cell( archetype.fuzz1118.data(), archetype.fuzz1118.size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = AffixFuzzer2::IndicatorComponent(); auto result = AffixFuzzer2::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer2.hpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer2.hpp index b29275cb286f..544a0e225b56 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer2.hpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer2.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -134,8 +133,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::AffixFuzzer2& archetype - ); + static Result> serialize(const archetypes::AffixFuzzer2& archetype); }; } // namespace rerun diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer3.cpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer3.cpp index cf5e3c49704e..3485af7e01fe 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer3.cpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer3.cpp @@ -12,144 +12,126 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::AffixFuzzer3& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(18); + std::vector cells; + cells.reserve(19); if (archetype.fuzz2001.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer1::to_data_cell(&archetype.fuzz2001.value(), size); + rerun::components::AffixFuzzer1::to_data_cell(&archetype.fuzz2001.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2002.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer2::to_data_cell(&archetype.fuzz2002.value(), size); + rerun::components::AffixFuzzer2::to_data_cell(&archetype.fuzz2002.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2003.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer3::to_data_cell(&archetype.fuzz2003.value(), size); + rerun::components::AffixFuzzer3::to_data_cell(&archetype.fuzz2003.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2004.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer4::to_data_cell(&archetype.fuzz2004.value(), size); + rerun::components::AffixFuzzer4::to_data_cell(&archetype.fuzz2004.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2005.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer5::to_data_cell(&archetype.fuzz2005.value(), size); + rerun::components::AffixFuzzer5::to_data_cell(&archetype.fuzz2005.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2006.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer6::to_data_cell(&archetype.fuzz2006.value(), size); + rerun::components::AffixFuzzer6::to_data_cell(&archetype.fuzz2006.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2007.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer7::to_data_cell(&archetype.fuzz2007.value(), size); + rerun::components::AffixFuzzer7::to_data_cell(&archetype.fuzz2007.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2008.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer8::to_data_cell(&archetype.fuzz2008.value(), size); + rerun::components::AffixFuzzer8::to_data_cell(&archetype.fuzz2008.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2009.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer9::to_data_cell(&archetype.fuzz2009.value(), size); + rerun::components::AffixFuzzer9::to_data_cell(&archetype.fuzz2009.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2010.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer10::to_data_cell(&archetype.fuzz2010.value(), size); + rerun::components::AffixFuzzer10::to_data_cell(&archetype.fuzz2010.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2011.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer11::to_data_cell(&archetype.fuzz2011.value(), size); + rerun::components::AffixFuzzer11::to_data_cell(&archetype.fuzz2011.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2012.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer12::to_data_cell(&archetype.fuzz2012.value(), size); + rerun::components::AffixFuzzer12::to_data_cell(&archetype.fuzz2012.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2013.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer13::to_data_cell(&archetype.fuzz2013.value(), size); + rerun::components::AffixFuzzer13::to_data_cell(&archetype.fuzz2013.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2014.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer14::to_data_cell(&archetype.fuzz2014.value(), size); + rerun::components::AffixFuzzer14::to_data_cell(&archetype.fuzz2014.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2015.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer15::to_data_cell(&archetype.fuzz2015.value(), size); + rerun::components::AffixFuzzer15::to_data_cell(&archetype.fuzz2015.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2016.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer16::to_data_cell(&archetype.fuzz2016.value(), size); + rerun::components::AffixFuzzer16::to_data_cell(&archetype.fuzz2016.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2017.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer17::to_data_cell(&archetype.fuzz2017.value(), size); + rerun::components::AffixFuzzer17::to_data_cell(&archetype.fuzz2017.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2018.has_value()) { - const size_t size = 1; auto result = - rerun::components::AffixFuzzer18::to_data_cell(&archetype.fuzz2018.value(), size); + rerun::components::AffixFuzzer18::to_data_cell(&archetype.fuzz2018.value(), 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = AffixFuzzer3::IndicatorComponent(); auto result = AffixFuzzer3::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer3.hpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer3.hpp index c57f88e2ab33..3ea28a4b9762 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer3.hpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer3.hpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -205,8 +204,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::AffixFuzzer3& archetype - ); + static Result> serialize(const archetypes::AffixFuzzer3& archetype); }; } // namespace rerun diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer4.cpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer4.cpp index 2b2dc1999347..667c219ea8fc 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer4.cpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer4.cpp @@ -12,180 +12,162 @@ namespace rerun::archetypes { namespace rerun { - Result> AsComponents::serialize( + Result> AsComponents::serialize( const archetypes::AffixFuzzer4& archetype ) { using namespace archetypes; - std::vector cells; - cells.reserve(18); + std::vector cells; + cells.reserve(19); if (archetype.fuzz2101.has_value()) { - const size_t size = archetype.fuzz2101.value().size(); auto result = rerun::components::AffixFuzzer1::to_data_cell( archetype.fuzz2101.value().data(), - size + archetype.fuzz2101.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2102.has_value()) { - const size_t size = archetype.fuzz2102.value().size(); auto result = rerun::components::AffixFuzzer2::to_data_cell( archetype.fuzz2102.value().data(), - size + archetype.fuzz2102.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2103.has_value()) { - const size_t size = archetype.fuzz2103.value().size(); auto result = rerun::components::AffixFuzzer3::to_data_cell( archetype.fuzz2103.value().data(), - size + archetype.fuzz2103.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2104.has_value()) { - const size_t size = archetype.fuzz2104.value().size(); auto result = rerun::components::AffixFuzzer4::to_data_cell( archetype.fuzz2104.value().data(), - size + archetype.fuzz2104.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2105.has_value()) { - const size_t size = archetype.fuzz2105.value().size(); auto result = rerun::components::AffixFuzzer5::to_data_cell( archetype.fuzz2105.value().data(), - size + archetype.fuzz2105.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2106.has_value()) { - const size_t size = archetype.fuzz2106.value().size(); auto result = rerun::components::AffixFuzzer6::to_data_cell( archetype.fuzz2106.value().data(), - size + archetype.fuzz2106.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2107.has_value()) { - const size_t size = archetype.fuzz2107.value().size(); auto result = rerun::components::AffixFuzzer7::to_data_cell( archetype.fuzz2107.value().data(), - size + archetype.fuzz2107.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2108.has_value()) { - const size_t size = archetype.fuzz2108.value().size(); auto result = rerun::components::AffixFuzzer8::to_data_cell( archetype.fuzz2108.value().data(), - size + archetype.fuzz2108.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2109.has_value()) { - const size_t size = archetype.fuzz2109.value().size(); auto result = rerun::components::AffixFuzzer9::to_data_cell( archetype.fuzz2109.value().data(), - size + archetype.fuzz2109.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2110.has_value()) { - const size_t size = archetype.fuzz2110.value().size(); auto result = rerun::components::AffixFuzzer10::to_data_cell( archetype.fuzz2110.value().data(), - size + archetype.fuzz2110.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2111.has_value()) { - const size_t size = archetype.fuzz2111.value().size(); auto result = rerun::components::AffixFuzzer11::to_data_cell( archetype.fuzz2111.value().data(), - size + archetype.fuzz2111.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2112.has_value()) { - const size_t size = archetype.fuzz2112.value().size(); auto result = rerun::components::AffixFuzzer12::to_data_cell( archetype.fuzz2112.value().data(), - size + archetype.fuzz2112.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2113.has_value()) { - const size_t size = archetype.fuzz2113.value().size(); auto result = rerun::components::AffixFuzzer13::to_data_cell( archetype.fuzz2113.value().data(), - size + archetype.fuzz2113.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2114.has_value()) { - const size_t size = archetype.fuzz2114.value().size(); auto result = rerun::components::AffixFuzzer14::to_data_cell( archetype.fuzz2114.value().data(), - size + archetype.fuzz2114.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2115.has_value()) { - const size_t size = archetype.fuzz2115.value().size(); auto result = rerun::components::AffixFuzzer15::to_data_cell( archetype.fuzz2115.value().data(), - size + archetype.fuzz2115.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2116.has_value()) { - const size_t size = archetype.fuzz2116.value().size(); auto result = rerun::components::AffixFuzzer16::to_data_cell( archetype.fuzz2116.value().data(), - size + archetype.fuzz2116.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2117.has_value()) { - const size_t size = archetype.fuzz2117.value().size(); auto result = rerun::components::AffixFuzzer17::to_data_cell( archetype.fuzz2117.value().data(), - size + archetype.fuzz2117.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } if (archetype.fuzz2118.has_value()) { - const size_t size = archetype.fuzz2118.value().size(); auto result = rerun::components::AffixFuzzer18::to_data_cell( archetype.fuzz2118.value().data(), - size + archetype.fuzz2118.value().size() ); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), size); + cells.emplace_back(std::move(result.value)); } { auto indicator = AffixFuzzer4::IndicatorComponent(); auto result = AffixFuzzer4::IndicatorComponent::to_data_cell(&indicator, 1); RR_RETURN_NOT_OK(result.error); - cells.emplace_back(std::move(result.value), 1); + cells.emplace_back(std::move(result.value)); } return cells; diff --git a/rerun_cpp/tests/generated/archetypes/affix_fuzzer4.hpp b/rerun_cpp/tests/generated/archetypes/affix_fuzzer4.hpp index 671416113215..9ba02909b252 100644 --- a/rerun_cpp/tests/generated/archetypes/affix_fuzzer4.hpp +++ b/rerun_cpp/tests/generated/archetypes/affix_fuzzer4.hpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -205,8 +204,6 @@ namespace rerun { template <> struct AsComponents { /// Serialize all set component batches. - static Result> serialize( - const archetypes::AffixFuzzer4& archetype - ); + static Result> serialize(const archetypes::AffixFuzzer4& archetype); }; } // namespace rerun diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer1.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer1.cpp index e9f26263b612..03dbcf27f9bc 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer1.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer1.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer1::NAME, - AffixFuzzer1::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer1::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer10.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer10.cpp index fad3ba84462f..654c1f74d60c 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer10.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer10.cpp @@ -57,10 +57,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer10::NAME, - AffixFuzzer10::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer10::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer11.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer11.cpp index 0c55ea009dd6..baf9a4fc1794 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer11.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer11.cpp @@ -65,10 +65,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer11::NAME, - AffixFuzzer11::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer11::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer12.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer12.cpp index b6620d1356bd..b4760dc4de7d 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer12.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer12.cpp @@ -60,10 +60,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer12::NAME, - AffixFuzzer12::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer12::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer13.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer13.cpp index 2668f09ab281..828e7211a191 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer13.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer13.cpp @@ -65,10 +65,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer13::NAME, - AffixFuzzer13::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer13::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer14.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer14.cpp index 3510e4054d63..606c58309aed 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer14.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer14.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer14::NAME, - AffixFuzzer14::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer14::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer15.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer15.cpp index 8d02da781fa1..887cceeca9f9 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer15.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer15.cpp @@ -49,10 +49,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer15::NAME, - AffixFuzzer15::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer15::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer16.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer16.cpp index 27a7d5daa0ff..6df81c6e3251 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer16.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer16.cpp @@ -67,10 +67,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer16::NAME, - AffixFuzzer16::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer16::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer17.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer17.cpp index 32b9b61eb458..ab18e9d92101 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer17.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer17.cpp @@ -71,10 +71,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer17::NAME, - AffixFuzzer17::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer17::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer18.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer18.cpp index 5c20355608f5..438f99d4a489 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer18.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer18.cpp @@ -71,10 +71,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer18::NAME, - AffixFuzzer18::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer18::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer19.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer19.cpp index ca40e15f5e76..11c72d992273 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer19.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer19.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer19::NAME, - AffixFuzzer19::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer19::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer2.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer2.cpp index bd230a57e426..0a2d0657fd8f 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer2.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer2.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer2::NAME, - AffixFuzzer2::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer2::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer20.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer20.cpp index b20bc2a29998..0f75405ce6d7 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer20.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer20.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer20::NAME, - AffixFuzzer20::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer20::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer21.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer21.cpp index cfea52118825..cef23a24c11a 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer21.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer21.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer21::NAME, - AffixFuzzer21::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer21::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer3.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer3.cpp index 4d09d88e7179..90286496893e 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer3.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer3.cpp @@ -46,10 +46,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer3::NAME, - AffixFuzzer3::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer3::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer4.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer4.cpp index e9618fcd05e0..18a35fdef3c1 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer4.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer4.cpp @@ -49,10 +49,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer4::NAME, - AffixFuzzer4::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer4::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer5.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer5.cpp index 1bd035058185..9cd6c66c9d9d 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer5.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer5.cpp @@ -49,10 +49,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer5::NAME, - AffixFuzzer5::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer5::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer6.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer6.cpp index 13037adeb13b..724a1aba92a3 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer6.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer6.cpp @@ -49,10 +49,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer6::NAME, - AffixFuzzer6::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer6::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer7.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer7.cpp index 9cd86087d4c7..0e82e7f62df4 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer7.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer7.cpp @@ -71,10 +71,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer7::NAME, - AffixFuzzer7::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer7::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer8.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer8.cpp index 1a13aaddcbbf..635aa6730e33 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer8.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer8.cpp @@ -57,10 +57,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer8::NAME, - AffixFuzzer8::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer8::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/generated/components/affix_fuzzer9.cpp b/rerun_cpp/tests/generated/components/affix_fuzzer9.cpp index 7b5e8c09cd63..5ea3270fc559 100644 --- a/rerun_cpp/tests/generated/components/affix_fuzzer9.cpp +++ b/rerun_cpp/tests/generated/components/affix_fuzzer9.cpp @@ -52,10 +52,10 @@ namespace rerun::components { std::shared_ptr array; ARROW_RETURN_NOT_OK(builder->Finish(&array)); - return rerun::DataCell::create( - AffixFuzzer9::NAME, - AffixFuzzer9::arrow_datatype(), - std::move(array) - ); + DataCell cell; + cell.num_instances = num_instances; + cell.component_name = AffixFuzzer9::NAME; + cell.array = std::move(array); + return cell; } } // namespace rerun::components diff --git a/rerun_cpp/tests/recording_stream.cpp b/rerun_cpp/tests/recording_stream.cpp index 5f67b64f0602..bd8cbd18f35e 100644 --- a/rerun_cpp/tests/recording_stream.cpp +++ b/rerun_cpp/tests/recording_stream.cpp @@ -34,8 +34,7 @@ struct BadArchetype { namespace rerun { template <> struct AsComponents { - static rerun::Result> - serialize(const BadArchetype&) { + static rerun::Result> serialize(const BadArchetype&) { return BadComponent::error; } }; @@ -484,8 +483,8 @@ SCENARIO("Recording stream handles invalid logging gracefully", TEST_TAG) { const char* path = "valid"; AND_GIVEN("a cell with a null buffer") { - rerun::DataCell cell; - cell.buffer = nullptr; + rerun::DataCell cell = {}; + cell.num_instances = 1; cell.component_name = "valid"; THEN("try_log_data_row fails with UnexpectedNullArgument") { @@ -496,39 +495,7 @@ SCENARIO("Recording stream handles invalid logging gracefully", TEST_TAG) { } } - // We changed to taking std::string_view instead of const char* and constructing such from nullptr crashes - // at least on some C++ implementations. - // If we'd want to support this in earnest we'd have to create out own string_view type. - // - // AND_GIVEN("a cell with a null component name") { - // rerun::DataCell cell; - // cell.buffer = std::make_shared(nullptr, 0); - // cell.component_name = nullptr; - - // THEN("try_log_data_row fails with UnexpectedNullArgument") { - // CHECK( - // stream.try_log_data_row(path, 1, 1, &cell, true).code == - // rerun::ErrorCode::UnexpectedNullArgument - // ); - // } - // } - - AND_GIVEN("a cell with a valid component name but invalid data") { - uint8_t invalid_data[1] = {0}; - rerun::DataCell cell; - cell.component_name = "very-valid"; - cell.buffer = std::make_shared(invalid_data, sizeof(invalid_data)); - - THEN("try_log_data_row fails with ArrowIpcMessageParsingFailure") { - CHECK( - stream.try_log_data_row(path, 1, 1, &cell, true).code == - rerun::ErrorCode::ArrowIpcMessageParsingFailure - ); - } - } - - // TODO(andreas): Missing test that provokes `ArrowDataCellError`. It's fairly hard to - // get there which I reckon is a good thing! + // TODO(andreas): Tests missing for various invalid data cell types, provoking the different errors that may occur. } } }