Skip to content

Commit

Permalink
executor: some code refine of hash join v2 (#55887)
Browse files Browse the repository at this point in the history
ref #53127
  • Loading branch information
windtalker authored Sep 6, 2024
1 parent 59040d0 commit 181c37a
Show file tree
Hide file tree
Showing 8 changed files with 970 additions and 902 deletions.
3 changes: 3 additions & 0 deletions pkg/executor/join/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ go_library(
"index_lookup_merge_join.go",
"inner_join_probe.go",
"join_row_table.go",
"join_table_meta.go",
"joiner.go",
"merge_join.go",
"outer_join_probe.go",
"row_table_builder.go",
"tagged_ptr.go",
],
importpath = "github.com/pingcap/tidb/pkg/executor/join",
Expand Down Expand Up @@ -73,6 +75,7 @@ go_test(
"inner_join_probe_test.go",
"join_row_table_test.go",
"join_stats_test.go",
"join_table_meta_test.go",
"joiner_test.go",
"left_outer_join_probe_test.go",
"merge_join_test.go",
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/join/base_join_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (j *baseJoinProbe) buildResultAfterOtherCondition(chk *chunk.Chunk, joinedC
return
}

func isKeyMatched(keyMode keyMode, serializedKey []byte, rowStart unsafe.Pointer, meta *TableMeta) bool {
func isKeyMatched(keyMode keyMode, serializedKey []byte, rowStart unsafe.Pointer, meta *joinTableMeta) bool {
switch keyMode {
case OneInt64:
return *(*int64)(unsafe.Pointer(&serializedKey[0])) == *(*int64)(unsafe.Add(rowStart, meta.nullMapLength+sizeOfNextPtr))
Expand Down
6 changes: 3 additions & 3 deletions pkg/executor/join/hash_join_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (htc *hashTableContext) lookup(partitionIndex int, hashValue uint64) tagged
return htc.hashTable.tables[partitionIndex].lookup(hashValue, htc.tagHelper)
}

func (htc *hashTableContext) getCurrentRowSegment(workerID, partitionID int, tableMeta *TableMeta, allowCreate bool, firstSegSizeHint uint) *rowTableSegment {
func (htc *hashTableContext) getCurrentRowSegment(workerID, partitionID int, tableMeta *joinTableMeta, allowCreate bool, firstSegSizeHint uint) *rowTableSegment {
if htc.rowTables[workerID][partitionID] == nil {
htc.rowTables[workerID][partitionID] = newRowTable(tableMeta)
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func (htc *hashTableContext) finalizeCurrentSeg(workerID, partitionID int, build
htc.memoryTracker.Consume(seg.totalUsedBytes())
}

func (htc *hashTableContext) mergeRowTablesToHashTable(tableMeta *TableMeta, partitionNumber uint) int {
func (htc *hashTableContext) mergeRowTablesToHashTable(tableMeta *joinTableMeta, partitionNumber uint) int {
rowTables := make([]*rowTable, partitionNumber)
for i := 0; i < int(partitionNumber); i++ {
rowTables[i] = newRowTable(tableMeta)
Expand Down Expand Up @@ -157,7 +157,7 @@ type HashJoinCtxV2 struct {
ProbeFilter expression.CNFExprs
OtherCondition expression.CNFExprs
hashTableContext *hashTableContext
hashTableMeta *TableMeta
hashTableMeta *joinTableMeta
needScanRowTableAfterProbeDone bool

LUsed, RUsed []int
Expand Down
Loading

0 comments on commit 181c37a

Please sign in to comment.