Repository: pingcap/tidb
File: pkg/executor/join/base_join_probe.go (Go)

Code before:
				srcCol := probeChk.Column(colIndex)
				dstCol := chk.Column(colIndex + collOffset)

				preAllocMemForCol(srcCol, dstCol)

				nullBitmapCapBefore := 0
				offsetCapBefore := 0
				dataCapBefore := 0
				if intest.InTest {
					nullBitmapCapBefore = dstCol.GetNullBitmapCap()
					offsetCapBefore = dstCol.GetOffsetCap()
					dataCapBefore = dstCol.GetDataCap()
				}

				for _, offsetAndLength := range j.offsetAndLengthArray {
					dstCol.AppendCellNTimes(srcCol, offsetAndLength.offset, offsetAndLength.length)
				}
				usedColumnMap[colIndex] = struct{}{}

				if intest.InTest {
					if nullBitmapCapBefore != dstCol.GetNullBitmapCap() {
						panic("Can't reserve enough memory")
					}

					if offsetCapBefore != dstCol.GetOffsetCap() {
						panic("Can't reserve enough memory")
					}

					if dataCapBefore != dstCol.GetDataCap() {
						panic("Can't reserve enough memory")
					}
				}
			}
		}
	} else {
		for index, colIndex := range used {
			srcCol := probeChk.Column(colIndex)
			dstCol := chk.Column(index + collOffset)

			preAllocMemForCol(srcCol, dstCol)

			for _, offsetAndLength := range j.offsetAndLengthArray {
				dstCol.AppendCellNTimes(srcCol, offsetAndLength.offset, offsetAndLength.length)
			}
		}
	}
}

func (j *baseJoinProbe) buildResultAfterOtherCondition(chk *chunk.Chunk, joinedChk *chunk.Chunk) (err error) {
	// construct the return chunk based on joinedChk and selected, there are 3 kinds of columns
	// 1. columns already in joinedChk

Review comment (suggestion):
```suggestion
						panic("Don't reserve enough memory")
```

Code after:
				preAllocMemForCol(srcCol, dstCol)

				nullBitmapCapBefore := 0
				offsetCapBefore := 0
				dataCapBefore := 0
				if intest.InTest {
					nullBitmapCapBefore = dstCol.GetNullBitmapCap()
					offsetCapBefore = dstCol.GetOffsetCap()
					dataCapBefore = dstCol.GetDataCap()
				}

				for _, offsetAndLength := range j.offsetAndLengthArray {
					dstCol.AppendCellNTimes(srcCol, offsetAndLength.offset, offsetAndLength.length)
				}
				usedColumnMap[colIndex] = struct{}{}

				if intest.InTest {
					if nullBitmapCapBefore != dstCol.GetNullBitmapCap() {
						panic("Don't reserve enough memory")
					}

					if offsetCapBefore != dstCol.GetOffsetCap() {
						panic("Don't reserve enough memory")
					}

					if dataCapBefore != dstCol.GetDataCap() {
						panic("Don't reserve enough memory")
					}
				}
			}
		}
	} else {
		for index, colIndex := range used {
			srcCol := probeChk.Column(colIndex)
			dstCol := chk.Column(index + collOffset)

			preAllocMemForCol(srcCol, dstCol)

			for _, offsetAndLength := range j.offsetAndLengthArray {
				dstCol.AppendCellNTimes(srcCol, offsetAndLength.offset, offsetAndLength.length)
			}
		}
	}
}

func (j *baseJoinProbe) buildResultAfterOtherCondition(chk *chunk.Chunk, joinedChk *chunk.Chunk) (err error) {
	// construct the return chunk based on joinedChk and selected, there are 3 kinds of columns
	// 1. columns already in joinedChk
	// 2. columns from build side, but not in joinedChk
	// 3. columns from probe side, but not in joinedChk
	rowCount := chk.NumRows()