Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: some code refine of hash join v2 #55887

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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