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: DeleteExec suport NextChunk #5368

Merged
merged 21 commits into from
Dec 21, 2017
Merged

executor: DeleteExec suport NextChunk #5368

merged 21 commits into from
Dec 21, 2017

Conversation

winkyao
Copy link
Contributor

@winkyao winkyao commented Dec 11, 2017

to #5261

@zz-jason zz-jason mentioned this pull request Dec 11, 2017
41 tasks
// NextChunk implements the Executor NextChunk interface.
func (e *DeleteExec) NextChunk(goCtx goctx.Context, chk *chunk.Chunk) error {
chk.Reset()
_, err := e.exec(goCtx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should avoid calling SelectExec.Next when NextChunk is called.

@@ -863,13 +863,15 @@ func (b *executorBuilder) buildDelete(v *plan.Delete) Executor {
b.err = errors.Trace(b.err)
return nil
}
return &DeleteExec{
deleteExec := &DeleteExec{
baseExecutor: newBaseExecutor(nil, b.ctx),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make selExec a child.

@winkyao winkyao added the WIP label Dec 11, 2017
@winkyao winkyao removed the WIP label Dec 14, 2017
@winkyao
Copy link
Contributor Author

winkyao commented Dec 14, 2017

@coocood @zz-jason @XuHuaiyu PTAL

if e.finished {
return nil
}
defer func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.finished = true is ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.finished must set after the exec finished, so use defer is more reasonable.

break
}

for rowIdx := 0; rowIdx < chk.NumRows(); rowIdx++ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for chunkRow := chk.Begin(); chunkRow != chk.End(); chunkRow = chunkRow.Next() {
}

batchDelete := e.ctx.GetSessionVars().BatchDelete && !e.ctx.GetSessionVars().InTxn()
fields := e.children[0].Schema().GetTypes()
for {
chk := chunk.NewChunk(fields)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chk := e.children[0].newChunk()

tblRowMap := make(tableRowMapType)
fields := e.children[0].Schema().GetTypes()
for {
chk := chunk.NewChunk(fields)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

break
}

for rowIdx := 0; rowIdx < chk.NumRows(); rowIdx++ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -901,13 +901,15 @@ func (b *executorBuilder) buildDelete(v *plan.Delete) Executor {
b.err = errors.Trace(b.err)
return nil
}
return &DeleteExec{
baseExecutor: newBaseExecutor(nil, b.ctx),
deleteExec := &DeleteExec{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we un-export SelectExec, Tables and IsMultiTable ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should modify it in another pr.

@winkyao
Copy link
Contributor Author

winkyao commented Dec 20, 2017

@coocood @zz-jason PTAL

break
}

for joinedChunkRow := chk.Begin(); joinedChunkRow != chk.End(); joinedChunkRow = joinedChunkRow.Next() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does joinedChunkRow mean ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete multi tables actually delete the data from joined tables.

type tblColPosInfo struct {
tblID int64
colBeginIndex int
colEndIndex int
handleIndex int
}

// tableRowMapType is a map for unique (Table, Row) pair.
type tableRowMapType map[int64]map[int64][]types.Datum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment to explain what the key(int64) and value(map[int64][]types.Datum) represent for.

}()

if e.IsMultiTable {
return e.deleteMultiTablesByChunk(goCtx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors.Trace(e.deleteMultiTablesByChunk(goCtx))

if e.IsMultiTable {
return e.deleteMultiTablesByChunk(goCtx)
}
return e.deleteSingleTableByChunk(goCtx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason
Copy link
Member

@coocood PTAL

Copy link
Member

@coocood coocood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coocood
Copy link
Member

coocood commented Dec 21, 2017

/run-all-tests

@coocood
Copy link
Member

coocood commented Dec 21, 2017

/run-common-test

@winkyao winkyao merged commit fe7900f into pingcap:master Dec 21, 2017
@winkyao winkyao deleted the support_deleteexec_chunk branch December 21, 2017 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants