@@ -20,6 +20,12 @@ impl Chunk {
20
20
///
21
21
/// [concatenable]: [`Chunk::concatenable`]
22
22
pub fn concatenated ( & self , rhs : & Self ) -> ChunkResult < Self > {
23
+ re_tracing:: profile_function!( format!(
24
+ "lhs={} rhs={}" ,
25
+ re_format:: format_uint( self . num_rows( ) ) ,
26
+ re_format:: format_uint( rhs. num_rows( ) )
27
+ ) ) ;
28
+
23
29
let cl = self ;
24
30
let cr = rhs;
25
31
@@ -38,56 +44,76 @@ impl Chunk {
38
44
39
45
let is_sorted = cl. is_sorted && cr. is_sorted && cl1 <= cr0;
40
46
41
- let row_ids = arrow2:: compute:: concatenate:: concatenate ( & [ & cl. row_ids , & cr. row_ids ] ) ?;
42
- #[ allow( clippy:: unwrap_used) ] // concatenating 2 RowId arrays must yield another RowId array
43
- let row_ids = row_ids
44
- . as_any ( )
45
- . downcast_ref :: < ArrowStructArray > ( )
46
- . unwrap ( )
47
- . clone ( ) ;
47
+ let row_ids = {
48
+ re_tracing:: profile_scope!( "row_ids" ) ;
49
+
50
+ let row_ids = arrow2:: compute:: concatenate:: concatenate ( & [ & cl. row_ids , & cr. row_ids ] ) ?;
51
+ #[ allow( clippy:: unwrap_used) ]
52
+ // concatenating 2 RowId arrays must yield another RowId array
53
+ row_ids
54
+ . as_any ( )
55
+ . downcast_ref :: < ArrowStructArray > ( )
56
+ . unwrap ( )
57
+ . clone ( )
58
+ } ;
48
59
49
60
// NOTE: We know they are the same set, and they are in a btree => we can zip them.
50
- let timelines = izip ! ( self . timelines. iter( ) , rhs. timelines. iter( ) )
51
- . filter_map (
52
- |( ( lhs_timeline, lhs_time_chunk) , ( rhs_timeline, rhs_time_chunk) ) | {
53
- debug_assert_eq ! ( lhs_timeline, rhs_timeline) ;
54
- lhs_time_chunk
55
- . concatenated ( rhs_time_chunk)
56
- . map ( |time_chunk| ( * lhs_timeline, time_chunk) )
57
- } ,
58
- )
59
- . collect ( ) ;
61
+ let timelines = {
62
+ re_tracing:: profile_scope!( "timelines" ) ;
63
+ izip ! ( self . timelines. iter( ) , rhs. timelines. iter( ) )
64
+ . filter_map (
65
+ |( ( lhs_timeline, lhs_time_chunk) , ( rhs_timeline, rhs_time_chunk) ) | {
66
+ debug_assert_eq ! ( lhs_timeline, rhs_timeline) ;
67
+ lhs_time_chunk
68
+ . concatenated ( rhs_time_chunk)
69
+ . map ( |time_chunk| ( * lhs_timeline, time_chunk) )
70
+ } ,
71
+ )
72
+ . collect ( )
73
+ } ;
60
74
61
75
// First pass: concat right onto left.
62
- let mut components: BTreeMap < _ , _ > = self
63
- . components
64
- . iter ( )
65
- . filter_map ( |( component_name, lhs_list_array) | {
66
- if let Some ( rhs_list_array) = rhs. components . get ( component_name) {
67
- let list_array = arrow2:: compute:: concatenate:: concatenate ( & [
68
- lhs_list_array,
69
- rhs_list_array,
70
- ] )
71
- . ok ( ) ?;
72
- let list_array = list_array
73
- . as_any ( )
74
- . downcast_ref :: < ArrowListArray < i32 > > ( ) ?
75
- . clone ( ) ;
76
- Some ( ( * component_name, list_array) )
77
- } else {
78
- Some ( (
79
- * component_name,
80
- crate :: util:: pad_list_array_back (
76
+ let mut components: BTreeMap < _ , _ > = {
77
+ re_tracing:: profile_scope!( "components (r2l)" ) ;
78
+ self . components
79
+ . iter ( )
80
+ . filter_map ( |( component_name, lhs_list_array) | {
81
+ re_tracing:: profile_scope!( format!( "{}" , component_name. as_str( ) ) ) ;
82
+ if let Some ( rhs_list_array) = rhs. components . get ( component_name) {
83
+ re_tracing:: profile_scope!( format!(
84
+ "concat (lhs={} rhs={})" ,
85
+ re_format:: format_uint( lhs_list_array. values( ) . len( ) ) ,
86
+ re_format:: format_uint( rhs_list_array. values( ) . len( ) ) ,
87
+ ) ) ;
88
+
89
+ let list_array = arrow2:: compute:: concatenate:: concatenate ( & [
81
90
lhs_list_array,
82
- self . num_rows ( ) + rhs. num_rows ( ) ,
83
- ) ,
84
- ) )
85
- }
86
- } )
87
- . collect ( ) ;
91
+ rhs_list_array,
92
+ ] )
93
+ . ok ( ) ?;
94
+ let list_array = list_array
95
+ . as_any ( )
96
+ . downcast_ref :: < ArrowListArray < i32 > > ( ) ?
97
+ . clone ( ) ;
98
+
99
+ Some ( ( * component_name, list_array) )
100
+ } else {
101
+ re_tracing:: profile_scope!( "pad" ) ;
102
+ Some ( (
103
+ * component_name,
104
+ crate :: util:: pad_list_array_back (
105
+ lhs_list_array,
106
+ self . num_rows ( ) + rhs. num_rows ( ) ,
107
+ ) ,
108
+ ) )
109
+ }
110
+ } )
111
+ . collect ( )
112
+ } ;
88
113
89
114
// Second pass: concat left onto right, where necessary.
90
- components. extend (
115
+ components. extend ( {
116
+ re_tracing:: profile_scope!( "components (l2r)" ) ;
91
117
rhs. components
92
118
. iter ( )
93
119
. filter_map ( |( component_name, rhs_list_array) | {
@@ -96,7 +122,15 @@ impl Chunk {
96
122
return None ;
97
123
}
98
124
125
+ re_tracing:: profile_scope!( component_name. as_str( ) ) ;
126
+
99
127
if let Some ( lhs_list_array) = self . components . get ( component_name) {
128
+ re_tracing:: profile_scope!( format!(
129
+ "concat (lhs={} rhs={})" ,
130
+ re_format:: format_uint( lhs_list_array. values( ) . len( ) ) ,
131
+ re_format:: format_uint( rhs_list_array. values( ) . len( ) ) ,
132
+ ) ) ;
133
+
100
134
let list_array = arrow2:: compute:: concatenate:: concatenate ( & [
101
135
lhs_list_array,
102
136
rhs_list_array,
@@ -106,8 +140,10 @@ impl Chunk {
106
140
. as_any ( )
107
141
. downcast_ref :: < ArrowListArray < i32 > > ( ) ?
108
142
. clone ( ) ;
143
+
109
144
Some ( ( * component_name, list_array) )
110
145
} else {
146
+ re_tracing:: profile_scope!( "pad" ) ;
111
147
Some ( (
112
148
* component_name,
113
149
crate :: util:: pad_list_array_front (
@@ -117,8 +153,8 @@ impl Chunk {
117
153
) )
118
154
}
119
155
} )
120
- . collect_vec ( ) ,
121
- ) ;
156
+ . collect_vec ( )
157
+ } ) ;
122
158
123
159
let chunk = Self {
124
160
id : ChunkId :: new ( ) ,
0 commit comments