@@ -18,6 +18,7 @@ use std::sync::Arc;
1818use std:: sync:: Mutex ;
1919use std:: sync:: RwLock ;
2020
21+ use databend_common_base:: base:: ProgressValues ;
2122use databend_common_exception:: Result ;
2223use databend_common_expression:: BlockEntry ;
2324use databend_common_expression:: DataBlock ;
@@ -28,6 +29,8 @@ use databend_common_pipeline::core::Processor;
2829use databend_common_pipeline:: sinks:: Sink ;
2930use databend_common_sql:: plans:: JoinType ;
3031
32+ use super :: Join ;
33+ use super :: JoinStream ;
3134use crate :: physical_plans:: NestedLoopJoin ;
3235use crate :: pipelines:: executor:: WatchNotify ;
3336use crate :: sessions:: QueryContext ;
@@ -137,7 +140,6 @@ pub struct LoopJoinState {
137140
138141 right_sinker_count : RwLock < usize > ,
139142
140- #[ allow( dead_code) ]
141143 join_type : JoinType ,
142144}
143145
@@ -255,3 +257,49 @@ impl LoopJoinState {
255257 Ok ( iter)
256258 }
257259}
260+
261+ impl Join for LoopJoinState {
262+ fn add_block ( & mut self , data : Option < DataBlock > ) -> Result < ( ) > {
263+ let Some ( right_block) = data else {
264+ return Ok ( ( ) ) ;
265+ } ;
266+
267+ let right = if matches ! ( self . join_type, JoinType :: Left | JoinType :: Full ) {
268+ let rows = right_block. num_rows ( ) ;
269+ let entries = right_block
270+ . take_columns ( )
271+ . into_iter ( )
272+ . map ( |entry| entry. into_nullable ( ) )
273+ . collect :: < Vec < _ > > ( ) ;
274+ DataBlock :: new ( entries, rows)
275+ } else {
276+ right_block
277+ } ;
278+ self . right_table . write ( ) ?. push ( right) ;
279+ Ok ( ( ) )
280+ }
281+
282+ fn final_build ( & mut self ) -> Result < Option < ProgressValues > > {
283+ let progress = self . right_table . read ( ) ?. iter ( ) . fold (
284+ ProgressValues :: default ( ) ,
285+ |mut progress, block| {
286+ progress. rows += block. num_rows ( ) ;
287+ progress. bytes += block. memory_size ( ) ;
288+ progress
289+ } ,
290+ ) ;
291+ Ok ( Some ( progress) )
292+ }
293+
294+ fn probe_block ( & mut self , data : DataBlock ) -> Result < Box < dyn JoinStream + ' _ > > {
295+ todo ! ( ) ;
296+ }
297+ }
298+
299+ struct LoopJoinStream { }
300+
301+ impl JoinStream for LoopJoinStream {
302+ fn next ( & mut self ) -> Result < Option < DataBlock > > {
303+ todo ! ( )
304+ }
305+ }
0 commit comments