1515package rowexec
1616
1717import (
18- "errors"
19- "fmt"
20- "io"
18+ "errors"
19+ "fmt"
20+ "io"
2121
22- "github.com/dolthub/go-mysql-server/sql/plan"
22+ "github.com/dolthub/go-mysql-server/sql/plan"
2323
24- "github.com/dolthub/go-mysql-server/sql"
25- "github.com/dolthub/go-mysql-server/sql/expression"
24+ "github.com/dolthub/go-mysql-server/sql"
25+ "github.com/dolthub/go-mysql-server/sql/expression"
2626)
2727
2828// NewMergeJoin returns a node that performs a presorted merge join on
@@ -47,16 +47,16 @@ func newMergeJoinIter(ctx *sql.Context, b sql.NodeExecBuilder, j *plan.JoinNode,
4747 return nil , err
4848 }
4949
50- ctx .GetLogger ().WithFields (map [string ]any {
51- "joinOp" : fmt .Sprintf ("%v" , j .Op ),
52- "isReversed" : j .IsReversed ,
53- "scopeLen" : j .ScopeLen ,
54- "leftSchemaLen" : len (j .Left ().Schema ()),
55- "rightSchemaLen" : len (j .Right ().Schema ()),
56- "filterIsNil" : j .Filter == nil ,
57- "leftIterType" : fmt .Sprintf ("%T" , l ),
58- "rightIterType" : fmt .Sprintf ("%T" , r ),
59- }).Debug ("constructed merge join child iterators" )
50+ ctx .GetLogger ().WithFields (map [string ]any {
51+ "joinOp" : fmt .Sprintf ("%v" , j .Op ),
52+ "isReversed" : j .IsReversed ,
53+ "scopeLen" : j .ScopeLen ,
54+ "leftSchemaLen" : len (j .Left ().Schema ()),
55+ "rightSchemaLen" : len (j .Right ().Schema ()),
56+ "filterIsNil" : j .Filter == nil ,
57+ "leftIterType" : fmt .Sprintf ("%T" , l ),
58+ "rightIterType" : fmt .Sprintf ("%T" , r ),
59+ }).Debug ("constructed merge join child iterators" )
6060
6161 fullRow := make (sql.Row , len (row )+ len (j .Left ().Schema ())+ len (j .Right ().Schema ()))
6262 fullRow [0 ] = row
@@ -67,23 +67,23 @@ func newMergeJoinIter(ctx *sql.Context, b sql.NodeExecBuilder, j *plan.JoinNode,
6767 // a merge join's first filter provides direction information
6868 // for which iter to update next
6969 filters := expression .SplitConjunction (j .Filter )
70- cmp , ok := filters [0 ].(expression.Comparer )
70+ cmp , ok := filters [0 ].(expression.Comparer )
7171 if ! ok {
7272 if equality , ok := filters [0 ].(expression.Equality ); ok {
7373 cmp , err = equality .ToComparer ()
7474 if err != nil {
7575 return nil , err
7676 }
7777 } else {
78- ctx .GetLogger ().WithField ("firstFilterType" , fmt .Sprintf ("%T" , filters [0 ])).Debug ("merge join expected comparer filter" )
79- return nil , sql .ErrMergeJoinExpectsComparerFilters .New (filters [0 ])
78+ ctx .GetLogger ().WithField ("firstFilterType" , fmt .Sprintf ("%T" , filters [0 ])).Debug ("merge join expected comparer filter" )
79+ return nil , sql .ErrMergeJoinExpectsComparerFilters .New (filters [0 ])
8080 }
8181 }
8282
83- if len (filters ) == 0 {
84- ctx .GetLogger ().Debug ("merge join constructed with zero filters" )
85- return nil , sql .ErrNoJoinFilters .New ()
86- }
83+ if len (filters ) == 0 {
84+ ctx .GetLogger ().Debug ("merge join constructed with zero filters" )
85+ return nil , sql .ErrNoJoinFilters .New ()
86+ }
8787
8888 var iter sql.RowIter = & mergeJoinIter {
8989 left : l ,
@@ -98,7 +98,7 @@ func newMergeJoinIter(ctx *sql.Context, b sql.NodeExecBuilder, j *plan.JoinNode,
9898 rightRowLen : len (j .Right ().Schema ()),
9999 isReversed : j .IsReversed ,
100100 }
101- ctx .GetLogger ().WithField ("iterType" , fmt .Sprintf ("%T" , iter )).Debug ("created merge join iter" )
101+ ctx .GetLogger ().WithField ("iterType" , fmt .Sprintf ("%T" , iter )).Debug ("created merge join iter" )
102102 return iter , nil
103103}
104104
@@ -223,10 +223,10 @@ func (i *mergeJoinIter) Next(ctx *sql.Context) (sql.Row, error) {
223223 } else {
224224 nextState = msCompare
225225 }
226- case msCompare :
227- res , err = i .cmp .Compare (ctx , i .fullRow )
228- if expression .ErrNilOperand .Is (err ) {
229- ctx .GetLogger ().Debug ("merge join comparer produced nil operand; rejecting null" )
226+ case msCompare :
227+ res , err = i .cmp .Compare (ctx , i .fullRow )
228+ if expression .ErrNilOperand .Is (err ) {
229+ ctx .GetLogger ().Debug ("merge join comparer produced nil operand; rejecting null" )
230230 nextState = msRejectNull
231231 break
232232 } else if err != nil {
@@ -450,7 +450,7 @@ func (i *mergeJoinIter) initIters(ctx *sql.Context) error {
450450 }
451451 i .init = true
452452 i .resetMatchState ()
453- ctx .GetLogger ().Debug ("merge join iters initialized" )
453+ ctx .GetLogger ().Debug ("merge join iters initialized" )
454454 return nil
455455}
456456
@@ -526,14 +526,14 @@ func (i *mergeJoinIter) incLeft(ctx *sql.Context) error {
526526 i .leftMatched = false
527527 var row sql.Row
528528 var err error
529- if i .leftPeek != nil {
529+ if i .leftPeek != nil {
530530 row = i .leftPeek
531531 i .leftPeek = nil
532532 } else {
533533 row , err = i .left .Next (ctx )
534534 if errors .Is (err , io .EOF ) {
535535 i .leftExhausted = true
536- ctx .GetLogger ().Trace ("merge join left iterator exhausted" )
536+ ctx .GetLogger ().Trace ("merge join left iterator exhausted" )
537537 return nil
538538 } else if err != nil {
539539 return err
@@ -544,22 +544,22 @@ func (i *mergeJoinIter) incLeft(ctx *sql.Context) error {
544544 for j , v := range row {
545545 i .fullRow [off + j ] = v
546546 }
547- ctx .GetLogger ().Trace ("merge join advanced left iterator" )
547+ ctx .GetLogger ().Trace ("merge join advanced left iterator" )
548548 return nil
549549}
550550
551551// incRight updates |i.fullRow|'s right row
552552func (i * mergeJoinIter ) incRight (ctx * sql.Context ) error {
553553 var row sql.Row
554554 var err error
555- if i .rightPeek != nil {
555+ if i .rightPeek != nil {
556556 row = i .rightPeek
557557 i .rightPeek = nil
558558 } else {
559559 row , err = i .right .Next (ctx )
560560 if errors .Is (err , io .EOF ) {
561561 i .rightExhausted = true
562- ctx .GetLogger ().Trace ("merge join right iterator exhausted" )
562+ ctx .GetLogger ().Trace ("merge join right iterator exhausted" )
563563 return nil
564564 } else if err != nil {
565565 return err
@@ -570,7 +570,7 @@ func (i *mergeJoinIter) incRight(ctx *sql.Context) error {
570570 for j , v := range row {
571571 i .fullRow [off + j ] = v
572572 }
573- ctx .GetLogger ().Trace ("merge join advanced right iterator" )
573+ ctx .GetLogger ().Trace ("merge join advanced right iterator" )
574574 return nil
575575}
576576
0 commit comments