@@ -20,10 +20,10 @@ use once_cell::sync::Lazy;
20
20
use arrow_utils:: arrow_array_from_c_ffi;
21
21
use re_sdk:: {
22
22
external:: nohash_hasher:: IntMap ,
23
- log:: { Chunk , ChunkComponents , ChunkId , PendingRow , TimeColumn } ,
23
+ log:: { Chunk , ChunkId , PendingRow , TimeColumn } ,
24
24
time:: TimeType ,
25
- ComponentDescriptor , ComponentName , EntityPath , RecordingStream , RecordingStreamBuilder ,
26
- StoreKind , TimePoint , Timeline ,
25
+ ComponentDescriptor , EntityPath , RecordingStream , RecordingStreamBuilder , StoreKind , TimePoint ,
26
+ Timeline ,
27
27
} ;
28
28
use recording_streams:: { recording_stream, RECORDING_STREAMS } ;
29
29
@@ -161,10 +161,18 @@ pub struct CStoreInfo {
161
161
pub store_kind : CStoreKind ,
162
162
}
163
163
164
+ /// See `rr_component_descriptor` in the C header.
165
+ #[ repr( C ) ]
166
+ pub struct CComponentDescriptor {
167
+ pub archetype_name : CStringView ,
168
+ pub archetype_field_name : CStringView ,
169
+ pub component_name : CStringView ,
170
+ }
171
+
164
172
/// See `rr_component_type` in the C header.
165
173
#[ repr( C ) ]
166
174
pub struct CComponentType {
167
- pub name : CStringView ,
175
+ pub descriptor : CComponentDescriptor ,
168
176
pub schema : arrow2:: ffi:: ArrowSchema ,
169
177
}
170
178
@@ -341,8 +349,30 @@ pub extern "C" fn rr_spawn(spawn_opts: *const CSpawnOptions, error: *mut CError)
341
349
fn rr_register_component_type_impl (
342
350
component_type : & CComponentType ,
343
351
) -> Result < CComponentTypeHandle , CError > {
344
- let component_name = component_type. name . as_str ( "component_type.name" ) ?;
345
- let component_name = ComponentName :: from ( component_name) ;
352
+ let CComponentDescriptor {
353
+ archetype_name,
354
+ archetype_field_name,
355
+ component_name,
356
+ } = & component_type. descriptor ;
357
+
358
+ let archetype_name = if !archetype_name. is_null ( ) {
359
+ Some ( archetype_name. as_str ( "component_type.descriptor.archetype_name" ) ?)
360
+ } else {
361
+ None
362
+ } ;
363
+ let archetype_field_name = if !archetype_field_name. is_null ( ) {
364
+ Some ( archetype_field_name. as_str ( "component_type.descriptor.archetype_field_name" ) ?)
365
+ } else {
366
+ None
367
+ } ;
368
+ let component_name = component_name. as_str ( "component_type.descriptor.component_name" ) ?;
369
+
370
+ let component_descr = ComponentDescriptor {
371
+ archetype_name : archetype_name. map ( Into :: into) ,
372
+ archetype_field_name : archetype_field_name. map ( Into :: into) ,
373
+ component_name : component_name. into ( ) ,
374
+ } ;
375
+
346
376
let schema =
347
377
unsafe { arrow2:: ffi:: import_field_from_c ( & component_type. schema ) } . map_err ( |err| {
348
378
CError :: new (
@@ -353,7 +383,7 @@ fn rr_register_component_type_impl(
353
383
354
384
Ok ( COMPONENT_TYPES
355
385
. write ( )
356
- . register ( component_name , schema. data_type ) )
386
+ . register ( component_descr , schema. data_type ) )
357
387
}
358
388
359
389
#[ allow( unsafe_code) ]
@@ -790,7 +820,7 @@ fn rr_recording_stream_log_impl(
790
820
let component_type = component_type_registry. get ( * component_type) ?;
791
821
let datatype = component_type. datatype . clone ( ) ;
792
822
let values = unsafe { arrow_array_from_c_ffi ( array, datatype) } ?;
793
- components. insert ( ComponentDescriptor :: new ( component_type. name ) , values) ;
823
+ components. insert ( component_type. descriptor . clone ( ) , values) ;
794
824
}
795
825
}
796
826
@@ -978,20 +1008,23 @@ fn rr_recording_stream_send_columns_impl(
978
1008
)
979
1009
} ) ?;
980
1010
981
- Ok ( ( ComponentDescriptor :: new ( component_type. name ) , component_values. clone ( ) ) )
1011
+ Ok ( ( component_type. descriptor . clone ( ) , component_values. clone ( ) ) )
982
1012
} )
983
1013
. collect :: < Result < _ , CError > > ( ) ?
984
1014
} ;
985
1015
986
- let components: ChunkComponents = components. into_iter ( ) . collect ( ) ;
987
-
988
- let chunk = Chunk :: from_auto_row_ids ( id, entity_path. into ( ) , time_columns, components)
989
- . map_err ( |err| {
990
- CError :: new (
991
- CErrorCode :: RecordingStreamChunkValidationFailure ,
992
- & format ! ( "Failed to create chunk: {err}" ) ,
993
- )
994
- } ) ?;
1016
+ let chunk = Chunk :: from_auto_row_ids (
1017
+ id,
1018
+ entity_path. into ( ) ,
1019
+ time_columns,
1020
+ components. into_iter ( ) . collect ( ) ,
1021
+ )
1022
+ . map_err ( |err| {
1023
+ CError :: new (
1024
+ CErrorCode :: RecordingStreamChunkValidationFailure ,
1025
+ & format ! ( "Failed to create chunk: {err}" ) ,
1026
+ )
1027
+ } ) ?;
995
1028
996
1029
stream. send_chunk ( chunk) ;
997
1030
0 commit comments