File tree 5 files changed +16
-7
lines changed
sql/src/executor/physical_plans
5 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -420,6 +420,10 @@ pub trait TableContext: Send + Sync {
420
420
}
421
421
422
422
fn get_next_broadcast_id ( & self ) -> u32 ;
423
+
424
+ fn reset_broadcast_id ( & self ) {
425
+ unimplemented ! ( )
426
+ }
423
427
}
424
428
425
429
pub type AbortChecker = Arc < dyn CheckAbort + Send + Sync > ;
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ pub async fn build_distributed_pipeline(
101
101
plan : & PhysicalPlan ,
102
102
) -> Result < PipelineBuildResult > {
103
103
let mut fragments_actions = QueryFragmentsActions :: create ( ctx. clone ( ) ) ;
104
- for plan in build_broadcast_plans ( ctx. get_next_broadcast_id ( ) ) ?
104
+ for plan in build_broadcast_plans ( ctx. as_ref ( ) ) ?
105
105
. iter ( )
106
106
. chain ( std:: iter:: once ( plan) )
107
107
{
Original file line number Diff line number Diff line change @@ -1861,7 +1861,13 @@ impl TableContext for QueryContext {
1861
1861
}
1862
1862
1863
1863
fn get_next_broadcast_id ( & self ) -> u32 {
1864
- self . shared . get_next_broadcast_id ( )
1864
+ self . shared
1865
+ . next_broadcast_id
1866
+ . fetch_add ( 1 , Ordering :: Acquire )
1867
+ }
1868
+
1869
+ fn reset_broadcast_id ( & self ) {
1870
+ self . shared . next_broadcast_id . store ( 0 , Ordering :: Release ) ;
1865
1871
}
1866
1872
}
1867
1873
Original file line number Diff line number Diff line change @@ -256,10 +256,6 @@ impl QueryContextShared {
256
256
} ) )
257
257
}
258
258
259
- pub fn get_next_broadcast_id ( & self ) -> u32 {
260
- self . next_broadcast_id . fetch_add ( 1 , Ordering :: AcqRel )
261
- }
262
-
263
259
pub fn broadcast_source_receiver ( & self , broadcast_id : u32 ) -> Receiver < BlockMetaInfoPtr > {
264
260
let mut broadcast_channels = self . broadcast_channels . lock ( ) ;
265
261
let entry = broadcast_channels. entry ( broadcast_id) . or_default ( ) ;
Original file line number Diff line number Diff line change 12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ use databend_common_catalog:: table_context:: TableContext ;
15
16
use databend_common_exception:: Result ;
16
17
17
18
use super :: Exchange ;
@@ -52,8 +53,10 @@ pub fn build_broadcast_plan(broadcast_id: u32) -> Result<PhysicalPlan> {
52
53
Ok ( broadcast_sink)
53
54
}
54
55
55
- pub fn build_broadcast_plans ( next_broadcast_id : u32 ) -> Result < Vec < PhysicalPlan > > {
56
+ pub fn build_broadcast_plans ( ctx : & dyn TableContext ) -> Result < Vec < PhysicalPlan > > {
56
57
let mut plans = vec ! [ ] ;
58
+ let next_broadcast_id = ctx. get_next_broadcast_id ( ) ;
59
+ ctx. reset_broadcast_id ( ) ;
57
60
for broadcast_id in 0 ..next_broadcast_id {
58
61
plans. push ( build_broadcast_plan ( broadcast_id) ?) ;
59
62
}
You can’t perform that action at this time.
0 commit comments