From c20af2e5ff4add08a759957105d4a60622f24c0c Mon Sep 17 00:00:00 2001 From: xuhuaiyu <391585975@qq.com> Date: Mon, 26 Dec 2022 12:06:21 +0800 Subject: [PATCH] Revert "executor: introduce hashRowContainer.GetMatchedRows method (#36848)" This reverts commit 3a74656a5a4ad0f04c40e3694caf68b90370f94d. --- executor/hash_table.go | 14 ++------------ executor/hash_table_test.go | 2 +- executor/join.go | 8 ++++---- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/executor/hash_table.go b/executor/hash_table.go index b7c875148bffa..d3adf323bb21e 100644 --- a/executor/hash_table.go +++ b/executor/hash_table.go @@ -143,14 +143,6 @@ func (c *hashRowContainer) ShallowCopy() *hashRowContainer { return &newHRC } -// GetMatchedRows get matched rows from probeRow. It can be called -// in multiple goroutines while each goroutine should keep its own -// h and buf. -func (c *hashRowContainer) GetMatchedRows(probeKey uint64, probeRow chunk.Row, hCtx *hashContext, matched []chunk.Row) ([]chunk.Row, error) { - matchedRows, _, err := c.GetMatchedRowsAndPtrs(probeKey, probeRow, hCtx, matched, nil, false) - return matchedRows, err -} - func (c *hashRowContainer) GetAllMatchedRows(probeHCtx *hashContext, probeSideRow chunk.Row, probeKeyNullBits *bitmap.ConcurrentBitmap, matched []chunk.Row, needCheckBuildRowPos, needCheckProbeRowPos []int) ([]chunk.Row, error) { // for NAAJ probe row with null, we should match them with all build rows. @@ -216,7 +208,7 @@ func (c *hashRowContainer) GetAllMatchedRows(probeHCtx *hashContext, probeSideRo // GetMatchedRowsAndPtrs get matched rows and Ptrs from probeRow. It can be called // in multiple goroutines while each goroutine should keep its own // h and buf. -func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk.Row, hCtx *hashContext, matched []chunk.Row, matchedPtrs []chunk.RowPtr, needPtr bool) ([]chunk.Row, []chunk.RowPtr, error) { +func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk.Row, hCtx *hashContext, matched []chunk.Row, matchedPtrs []chunk.RowPtr) ([]chunk.Row, []chunk.RowPtr, error) { var err error innerPtrs := c.hashTable.Get(probeKey) if len(innerPtrs) == 0 { @@ -240,9 +232,7 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk continue } matched = append(matched, matchedRow) - if needPtr { - matchedPtrs = append(matchedPtrs, ptr) - } + matchedPtrs = append(matchedPtrs, ptr) } return matched, matchedPtrs, err } diff --git a/executor/hash_table_test.go b/executor/hash_table_test.go index 3b4a4acee5284..fee9d037e13ae 100644 --- a/executor/hash_table_test.go +++ b/executor/hash_table_test.go @@ -157,7 +157,7 @@ func testHashRowContainer(t *testing.T, hashFunc func() hash.Hash64, spill bool) } probeCtx.hasNull = make([]bool, 1) probeCtx.hashVals = append(hCtx.hashVals, hashFunc()) - matched, _, err := rowContainer.GetMatchedRowsAndPtrs(hCtx.hashVals[1].Sum64(), probeRow, probeCtx, nil, nil, false) + matched, _, err := rowContainer.GetMatchedRowsAndPtrs(hCtx.hashVals[1].Sum64(), probeRow, probeCtx, nil, nil) require.NoError(t, err) require.Equal(t, 2, len(matched)) require.Equal(t, chk0.GetRow(1).GetDatumRow(colTypes), matched[0].GetDatumRow(colTypes)) diff --git a/executor/join.go b/executor/join.go index 710f8c5f676fe..b6dcbb4bdb44d 100644 --- a/executor/join.go +++ b/executor/join.go @@ -517,7 +517,7 @@ func (e *HashJoinExec) runJoinWorker(workerID uint, probeKeyColIdx, probeNAKeyCo func (e *HashJoinExec) joinMatchedProbeSideRow2ChunkForOuterHashJoin(workerID uint, probeKey uint64, probeSideRow chunk.Row, hCtx *hashContext, rowContainer *hashRowContainer, joinResult *hashjoinWorkerResult) (bool, *hashjoinWorkerResult) { var err error - e.buildSideRows[workerID], e.buildSideRowPtrs[workerID], err = rowContainer.GetMatchedRowsAndPtrs(probeKey, probeSideRow, hCtx, e.buildSideRows[workerID], e.buildSideRowPtrs[workerID], true) + e.buildSideRows[workerID], e.buildSideRowPtrs[workerID], err = rowContainer.GetMatchedRowsAndPtrs(probeKey, probeSideRow, hCtx, e.buildSideRows[workerID], e.buildSideRowPtrs[workerID]) buildSideRows, rowsPtrs := e.buildSideRows[workerID], e.buildSideRowPtrs[workerID] if err != nil { joinResult.err = err @@ -566,7 +566,7 @@ func (e *HashJoinExec) joinNAALOSJMatchProbeSideRow2Chunk(workerID uint, probeKe // because AntiLeftOuterSemiJoin cares about the scalar value. If we both have a match from null // bucket and same key bucket, we should return the result as from same-key bucket // rather than from null bucket. - e.buildSideRows[workerID], err = rowContainer.GetMatchedRows(probeKey, probeSideRow, hCtx, e.buildSideRows[workerID]) + e.buildSideRows[workerID], _, err = rowContainer.GetMatchedRowsAndPtrs(probeKey, probeSideRow, hCtx, e.buildSideRows[workerID], nil) buildSideRows := e.buildSideRows[workerID] if err != nil { joinResult.err = err @@ -751,7 +751,7 @@ func (e *HashJoinExec) joinNAASJMatchProbeSideRow2Chunk(workerID uint, probeKey } } // step2: then same key bucket. - e.buildSideRows[workerID], err = rowContainer.GetMatchedRows(probeKey, probeSideRow, hCtx, e.buildSideRows[workerID]) + e.buildSideRows[workerID], _, err = rowContainer.GetMatchedRowsAndPtrs(probeKey, probeSideRow, hCtx, e.buildSideRows[workerID], nil) buildSideRows = e.buildSideRows[workerID] if err != nil { joinResult.err = err @@ -902,7 +902,7 @@ func (e *HashJoinExec) joinNAAJMatchProbeSideRow2Chunk(workerID uint, probeKey u func (e *HashJoinExec) joinMatchedProbeSideRow2Chunk(workerID uint, probeKey uint64, probeSideRow chunk.Row, hCtx *hashContext, rowContainer *hashRowContainer, joinResult *hashjoinWorkerResult) (bool, *hashjoinWorkerResult) { var err error - e.buildSideRows[workerID], err = rowContainer.GetMatchedRows(probeKey, probeSideRow, hCtx, e.buildSideRows[workerID]) + e.buildSideRows[workerID], e.buildSideRowPtrs[workerID], err = rowContainer.GetMatchedRowsAndPtrs(probeKey, probeSideRow, hCtx, e.buildSideRows[workerID], e.buildSideRowPtrs[workerID]) buildSideRows := e.buildSideRows[workerID] if err != nil { joinResult.err = err