@@ -26,14 +26,11 @@ use databend_common_pipeline_transforms::processors::TransformPipelineHelper;
26
26
use databend_common_sql:: executor:: physical_plans:: CompactSource as PhysicalCompactSource ;
27
27
use databend_common_sql:: executor:: physical_plans:: MutationKind ;
28
28
use databend_common_sql:: StreamContext ;
29
- use databend_common_storages_fuse:: io:: read:: ColumnOrientedSegmentReader ;
30
- use databend_common_storages_fuse:: io:: read:: RowOrientedSegmentReader ;
31
- use databend_common_storages_fuse:: operations:: add_table_mutation_aggregator;
32
29
use databend_common_storages_fuse:: operations:: BlockCompactMutator ;
33
- use databend_common_storages_fuse:: operations:: ColumnOrientedSegmentsWithIndices ;
34
- use databend_common_storages_fuse:: operations:: CompactSegmentsWithIndices ;
30
+ use databend_common_storages_fuse:: operations:: CompactLazyPartInfo ;
35
31
use databend_common_storages_fuse:: operations:: CompactSource ;
36
32
use databend_common_storages_fuse:: operations:: CompactTransform ;
33
+ use databend_common_storages_fuse:: operations:: TableMutationAggregator ;
37
34
use databend_common_storages_fuse:: operations:: TransformSerializeBlock ;
38
35
use databend_common_storages_fuse:: FuseTable ;
39
36
@@ -57,60 +54,39 @@ impl PipelineBuilder {
57
54
let thresholds = table. get_block_thresholds ( ) ;
58
55
let cluster_key_id = table. cluster_key_id ( ) ;
59
56
let mut max_threads = self . ctx . get_settings ( ) . get_max_threads ( ) ? as usize ;
60
- let partitions = compact_block. parts . partitions . clone ( ) ;
61
57
62
58
if is_lazy {
63
59
let query_ctx = self . ctx . clone ( ) ;
64
- let column_ids = compact_block. column_ids . clone ( ) ;
65
- let is_column_oriented = table. is_column_oriented ( ) ;
66
60
61
+ let lazy_parts = compact_block
62
+ . parts
63
+ . partitions
64
+ . iter ( )
65
+ . map ( |v| {
66
+ v. as_any ( )
67
+ . downcast_ref :: < CompactLazyPartInfo > ( )
68
+ . unwrap ( )
69
+ . clone ( )
70
+ } )
71
+ . collect :: < Vec < _ > > ( ) ;
72
+
73
+ let column_ids = compact_block. column_ids . clone ( ) ;
67
74
self . main_pipeline . set_on_init ( move || {
68
75
let ctx = query_ctx. clone ( ) ;
69
- let partitions = Runtime :: with_worker_threads (
70
- 2 ,
71
- Some ( "build_compact_tasks" . to_string ( ) ) ,
72
- ) ?
73
- . block_on ( async move {
74
- let partitions = if is_column_oriented {
75
- let lazy_parts = partitions
76
- . iter ( )
77
- . map ( |v| {
78
- v. as_any ( )
79
- . downcast_ref :: < ColumnOrientedSegmentsWithIndices > ( )
80
- . unwrap ( )
81
- . clone ( )
82
- } )
83
- . collect :: < Vec < _ > > ( ) ;
84
- BlockCompactMutator :: < ColumnOrientedSegmentReader > :: build_compact_tasks (
85
- ctx. clone ( ) ,
86
- column_ids. clone ( ) ,
87
- cluster_key_id,
88
- thresholds,
89
- lazy_parts,
90
- )
91
- . await ?
92
- } else {
93
- let lazy_parts = partitions
94
- . iter ( )
95
- . map ( |v| {
96
- v. as_any ( )
97
- . downcast_ref :: < CompactSegmentsWithIndices > ( )
98
- . unwrap ( )
99
- . clone ( )
100
- } )
101
- . collect :: < Vec < _ > > ( ) ;
102
- BlockCompactMutator :: < RowOrientedSegmentReader > :: build_compact_tasks (
103
- ctx. clone ( ) ,
104
- column_ids. clone ( ) ,
105
- cluster_key_id,
106
- thresholds,
107
- lazy_parts,
108
- )
109
- . await ?
110
- } ;
76
+ let partitions =
77
+ Runtime :: with_worker_threads ( 2 , Some ( "build_compact_tasks" . to_string ( ) ) ) ?
78
+ . block_on ( async move {
79
+ let partitions = BlockCompactMutator :: build_compact_tasks (
80
+ ctx. clone ( ) ,
81
+ column_ids. clone ( ) ,
82
+ cluster_key_id,
83
+ thresholds,
84
+ lazy_parts,
85
+ )
86
+ . await ?;
111
87
112
- Result :: < _ > :: Ok ( partitions)
113
- } ) ?;
88
+ Result :: < _ > :: Ok ( partitions)
89
+ } ) ?;
114
90
115
91
let partitions = Partitions :: create ( PartitionsShuffleKind :: Mod , partitions) ;
116
92
query_ctx. set_partitions ( partitions) ?;
@@ -179,17 +155,18 @@ impl PipelineBuilder {
179
155
180
156
if is_lazy {
181
157
self . main_pipeline . try_resize ( 1 ) ?;
182
- add_table_mutation_aggregator (
183
- & mut self . main_pipeline ,
184
- table,
185
- self . ctx . clone ( ) ,
186
- vec ! [ ] ,
187
- vec ! [ ] ,
188
- vec ! [ ] ,
189
- Default :: default ( ) ,
190
- MutationKind :: Compact ,
191
- compact_block. table_meta_timestamps ,
192
- ) ;
158
+ self . main_pipeline . add_async_accumulating_transformer ( || {
159
+ TableMutationAggregator :: create (
160
+ table,
161
+ self . ctx . clone ( ) ,
162
+ vec ! [ ] ,
163
+ vec ! [ ] ,
164
+ vec ! [ ] ,
165
+ Default :: default ( ) ,
166
+ MutationKind :: Compact ,
167
+ compact_block. table_meta_timestamps ,
168
+ )
169
+ } ) ;
193
170
}
194
171
Ok ( ( ) )
195
172
}
0 commit comments