Skip to content

Commit

Permalink
Revert "Merge pull request pingcap#2 from sticnarf/all-in-one-dev"
Browse files Browse the repository at this point in the history
This reverts commit 632d861.
  • Loading branch information
ekexium committed Aug 8, 2022
1 parent 7265875 commit cb16192
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 29 deletions.
24 changes: 4 additions & 20 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,40 +236,24 @@ func newFirstChunk(e Executor) *chunk.Chunk {
if ok && len(base.retFieldTypes) == len(e.RetFieldTypes) {
for i := range base.retFieldTypes {
if base.retFieldTypes[i].GetType() != e.RetFieldTypes[i].GetType() {
//logutil.BgLogger().Info("field mismatch")
ok = false
break
}
}
if ok {
for i, c := range e.Chunks {
if c != nil && !e.InUse[i] {
e.InUse[i] = true
c.Reset()
return c
}
if e.Chunks[i] == nil {
e.Chunks[i] = chunk.New(base.retFieldTypes, base.initCap, base.maxChunkSize)
e.InUse[i] = true
//logutil.BgLogger().Info("append chunk")
return e.Chunks[i]
}
}
//logutil.BgLogger().Info("all chunk in use")
return chunk.New(base.retFieldTypes, base.initCap, base.maxChunkSize)
e.Chunk.Reset()
return e.Chunk
}
}
//logutil.BgLogger().Info("hash mismatch")
entry := variable.SmallChunkCacheEntry{
RetFieldTypes: base.retFieldTypes,
InUse: []bool{true, false, false},
Chunks: []*chunk.Chunk{chunk.New(base.retFieldTypes, base.initCap, base.maxChunkSize), nil, nil},
Chunk: chunk.New(base.retFieldTypes, base.initCap, base.maxChunkSize),
}
if len(base.ctx.GetSessionVars().SmallChunkCache) > 100 {
base.ctx.GetSessionVars().SmallChunkCache = make(map[uint64]variable.SmallChunkCacheEntry)
}
base.ctx.GetSessionVars().SmallChunkCache[hv] = entry
return entry.Chunks[0]
return entry.Chunk
}
return chunk.New(base.retFieldTypes, base.initCap, base.maxChunkSize)
}
Expand Down
3 changes: 0 additions & 3 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2114,9 +2114,6 @@ func runStmt(ctx context.Context, se *session, s sqlexec.Statement) (rs sqlexec.
}

sessVars := se.sessionVars
for _, e := range sessVars.SmallChunkCache {
e.InUse = []bool{false, false, false}
}

// Record diagnostic information for DML statements
if stmt, ok := s.(*executor.ExecStmt).StmtNode.(ast.DMLNode); ok {
Expand Down
8 changes: 2 additions & 6 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1358,21 +1358,17 @@ type ResultFieldCacheKey struct {
CurrentDB string
}

func HashFieldTypes(fieldTypes []*types.FieldType, hs ...interface{}) uint64 {
func HashFieldTypes(fieldTypes []*types.FieldType) uint64 {
h := fnv.New64()
for _, t := range fieldTypes {
h.Write([]byte{t.GetType()})
}
for _, v := range hs {
binary.Write(h, binary.LittleEndian, v)
}
return h.Sum64()
}

type SmallChunkCacheEntry struct {
RetFieldTypes []*types.FieldType
InUse []bool
Chunks []*chunk.Chunk
Chunk *chunk.Chunk
}

const (
Expand Down

0 comments on commit cb16192

Please sign in to comment.