@@ -24,18 +24,17 @@ use crate::expression::ScalarExpression;
2424use crate :: planner:: operator:: join:: { JoinCondition , JoinOperator , JoinType } ;
2525use crate :: planner:: LogicalPlan ;
2626use crate :: storage:: Transaction ;
27- use crate :: types:: tuple:: { Schema , SchemaRef , SplitTupleRef , Tuple } ;
27+ use crate :: types:: tuple:: { Schema , SplitTupleRef , Tuple } ;
2828use crate :: types:: value:: DataValue ;
2929use fixedbitset:: FixedBitSet ;
3030use itertools:: Itertools ;
31- use std:: sync:: Arc ;
3231
3332/// Equivalent condition
3433struct EqualCondition {
3534 on_left_keys : Vec < ScalarExpression > ,
3635 on_right_keys : Vec < ScalarExpression > ,
37- left_schema : SchemaRef ,
38- right_schema : SchemaRef ,
36+ left_len : usize ,
37+ right_len : usize ,
3938}
4039
4140impl EqualCondition {
@@ -45,17 +44,17 @@ impl EqualCondition {
4544 fn new (
4645 on_left_keys : Vec < ScalarExpression > ,
4746 on_right_keys : Vec < ScalarExpression > ,
48- left_schema : Arc < Schema > ,
49- right_schema : Arc < Schema > ,
47+ left_schema : & Schema ,
48+ right_schema : & Schema ,
5049 ) -> EqualCondition {
5150 if !on_left_keys. is_empty ( ) && on_left_keys. len ( ) != on_right_keys. len ( ) {
5251 unreachable ! ( "Unexpected join on condition." )
5352 }
5453 EqualCondition {
5554 on_left_keys,
5655 on_right_keys,
57- left_schema,
58- right_schema,
56+ left_len : left_schema. len ( ) ,
57+ right_len : right_schema. len ( ) ,
5958 }
6059 }
6160
@@ -66,10 +65,8 @@ impl EqualCondition {
6665 if self . on_left_keys . is_empty ( ) {
6766 return Ok ( true ) ;
6867 }
69- let left_values =
70- Projection :: projection ( left_tuple, & self . on_left_keys , & self . left_schema ) ?;
71- let right_values =
72- Projection :: projection ( right_tuple, & self . on_right_keys , & self . right_schema ) ?;
68+ let left_values = Projection :: projection ( left_tuple, & self . on_left_keys ) ?;
69+ let right_values = Projection :: projection ( right_tuple, & self . on_right_keys ) ?;
7370
7471 Ok ( left_values == right_values)
7572 }
@@ -141,12 +138,7 @@ impl From<(JoinOperator, LogicalPlan, LogicalPlan)> for NestedLoopJoin {
141138 std:: mem:: swap ( & mut left_schema, & mut right_schema) ;
142139 }
143140
144- let eq_cond = EqualCondition :: new (
145- on_left_keys,
146- on_right_keys,
147- left_schema. clone ( ) ,
148- right_schema. clone ( ) ,
149- ) ;
141+ let eq_cond = EqualCondition :: new ( on_left_keys, on_right_keys, & left_schema, & right_schema) ;
150142
151143 NestedLoopJoin {
152144 left_input_plan : left_input,
@@ -330,7 +322,7 @@ impl NestedLoopJoin {
330322 right_bitmap = Some ( bits) ;
331323 }
332324 }
333- let right_schema_len = self . eq_cond . right_schema . len ( ) ;
325+ let right_schema_len = self . eq_cond . right_len ;
334326 let tuple = match self . ty {
335327 JoinType :: LeftOuter | JoinType :: RightOuter | JoinType :: Full
336328 if !active_left. has_matched =>
@@ -374,7 +366,7 @@ impl NestedLoopJoin {
374366 right_emit_index += 1 ;
375367
376368 if !right_bitmap. contains ( idx) {
377- let mut values = vec ! [ DataValue :: Null ; self . eq_cond. left_schema . len ( ) ] ;
369+ let mut values = vec ! [ DataValue :: Null ; self . eq_cond. left_len ] ;
378370 values. append ( & mut right_tuple. values ) ;
379371 self . state = NestedLoopJoinState :: EmitRightUnmatched {
380372 right_input,
0 commit comments