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

inforschema, executor, util/kvcache, util/statement_summary : Add STATEMENTS_SUMMARY_EVICTED into information_schema #24513

Merged
merged 69 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
1a96cbb
util/kvcache: enhance LRU Cache
ClSlaid Apr 23, 2021
0c8920a
Merge branch 'master' into master
ClSlaid Apr 23, 2021
25ae806
Merge branch 'master' into master
ClSlaid Apr 23, 2021
529e346
Util/kvcache: Typo fix
ClSlaid Apr 23, 2021
38fa019
util/kvcache/simple_lru.go: typo fix
ClSlaid Apr 25, 2021
d78ca46
util/kvcache: fix test
ClSlaid Apr 25, 2021
1cddd8f
Merge branch 'master' into master
crazycs520 Apr 25, 2021
33d865f
util/kvcache: synced onEvict func -> asynced
ClSlaid Apr 25, 2021
2d75e37
Merge branch 'master' of github.com:ClSlaid/tidb
ClSlaid Apr 25, 2021
05703d8
util/kvcache: formatted
ClSlaid Apr 25, 2021
eaf1caa
Merge branch 'master' into master
crazycs520 Apr 25, 2021
0163613
Merge branch 'master' into master
ti-chi-bot Apr 25, 2021
0935f75
Merge branch 'master' into master
ti-chi-bot Apr 25, 2021
c0227b6
Statements Summary Evicted Prototype Commit
ClSlaid Apr 30, 2021
0a168fe
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid Apr 30, 2021
b447b86
Fix STATEMENTS_SUMMARY_EVICTED
ClSlaid May 8, 2021
8e8792b
util/stmtsummary: Fix evicted.go
ClSlaid May 10, 2021
2a8ed11
Merge branch 'pingcap:master' into master
ClSlaid May 10, 2021
12b6a87
Merge branch 'master' into master
ClSlaid May 10, 2021
373d344
util/stmtsummary: Delete debug code
ClSlaid May 10, 2021
0f24624
util/stmtsummary: add test to EVICTED_COUNT
ClSlaid May 11, 2021
e2a18b1
util/stmtsummary: Add test to evicted count
ClSlaid May 12, 2021
6b7da7e
go.sum: disable fail-point
ClSlaid May 12, 2021
ebad974
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 12, 2021
3fcd196
fix merge problems
ClSlaid May 12, 2021
073ff06
clean up evicted count
ClSlaid May 14, 2021
32e8df9
typo fix
ClSlaid May 14, 2021
1092e72
performance improve and typo fix
ClSlaid May 14, 2021
7e8a8d8
simplify logic in addEvicted
ClSlaid May 17, 2021
252b43a
beautify evicted.go && typo fix
ClSlaid May 17, 2021
015b145
fix nil pointer bug in evicted.go
ClSlaid May 19, 2021
e061027
fix zero quota test for kvcache
ClSlaid May 20, 2021
d3bf818
Add test to evicted.go and some bug fixes
ClSlaid May 20, 2021
f59155b
typo fix in executor and infoschema
ClSlaid May 20, 2021
efcad35
typo fix
ClSlaid May 21, 2021
80167a3
try fix git merge problem
ClSlaid May 21, 2021
dbc94c7
Add more test to evicted count
ClSlaid May 21, 2021
756c53e
evicted test full cover
ClSlaid May 24, 2021
43a4adc
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 24, 2021
be4b4e4
fix merge conflict
ClSlaid May 24, 2021
c6ce248
fix nil pointer problem
ClSlaid May 24, 2021
a8be817
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 24, 2021
fdec81a
test refactoring
ClSlaid May 24, 2021
01a92a4
format and add license.
ClSlaid May 24, 2021
9c503e5
fix empty table error and clean up useless codes.
ClSlaid May 25, 2021
b2278b2
Add test to table and more test to evicted count
ClSlaid May 25, 2021
d3ea973
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 25, 2021
a3ed839
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
9b243a5
typo fix
ClSlaid May 26, 2021
eaffa1c
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
413ed0d
make check
ClSlaid May 26, 2021
c91e5e3
OUTDATED AGAIN???: Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
0bd1f5e
fix go.sum
ClSlaid May 26, 2021
f282833
try fix data racing
ClSlaid May 26, 2021
16c83f9
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
cca919b
try fix data racing.
ClSlaid May 26, 2021
52cb27b
try fix data racing again.
ClSlaid May 26, 2021
a31059d
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 26, 2021
4c9e65f
Merge branch 'master' into master
crazycs520 May 27, 2021
b7a87e1
try fix data racing again again.
ClSlaid May 27, 2021
5725827
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 27, 2021
b0776f5
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 27, 2021
b50b213
revoke change in unrelated files.
ClSlaid May 27, 2021
3b9fa88
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 27, 2021
cafa16a
Merge branch 'master' into master
crazycs520 May 28, 2021
f880324
change interval in tables_test.go
ClSlaid May 28, 2021
f740b34
Merge branch 'master' of github.com:pingcap/tidb
ClSlaid May 28, 2021
6c69920
Merge branch 'master' into master
ti-chi-bot May 28, 2021
caab2da
Merge branch 'master' into master
ti-chi-bot May 28, 2021
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
1 change: 1 addition & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@ func (b *executorBuilder) buildMemTable(v *plannercore.PhysicalMemTable) Executo
strings.ToLower(infoschema.TableTiKVStoreStatus),
strings.ToLower(infoschema.TableStatementsSummary),
strings.ToLower(infoschema.TableStatementsSummaryHistory),
strings.ToLower(infoschema.TableStatementsSummaryEvicted),
strings.ToLower(infoschema.ClusterTableStatementsSummary),
strings.ToLower(infoschema.ClusterTableStatementsSummaryHistory),
strings.ToLower(infoschema.TablePlacementPolicy),
Expand Down
11 changes: 9 additions & 2 deletions executor/infoschema_reader.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ func (e *memtableRetriever) retrieve(ctx context.Context, sctx sessionctx.Contex
infoschema.ClusterTableStatementsSummary,
infoschema.ClusterTableStatementsSummaryHistory:
err = e.setDataForStatementsSummary(sctx, e.table.Name.O)
case infoschema.TableStatementsSummaryEvicted:
e.setDataForStatementsSummaryEvicted(sctx)
case infoschema.TablePlacementPolicy:
err = e.setDataForPlacementPolicy(sctx)
case infoschema.TableClientErrorsSummaryGlobal,
Expand Down Expand Up @@ -1907,11 +1909,11 @@ func (e *memtableRetriever) setDataForPlacementPolicy(ctx sessionctx.Context) er
ptName = part.Name.L
skip = false
}
failpoint.Inject("outputInvalidPlacementRules", func(val failpoint.Value) {
if val, _err_ := failpoint.Eval(_curpkg_("outputInvalidPlacementRules")); _err_ == nil {
if val.(bool) {
skip = false
}
})
}
if skip {
continue
}
Expand Down Expand Up @@ -2049,6 +2051,11 @@ func (e *memtableRetriever) setDataForClusterTiDBTrx(ctx sessionctx.Context) err
return nil
}

func (e *memtableRetriever) setDataForStatementsSummaryEvicted(ctx sessionctx.Context) {
e.rows = stmtsummary.StmtSummaryByDigestMap.ToEvictedCountDatum()
return
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line return is unnecessary😏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A former python user began coding in go, this is what happend to his typo.

}

type hugeMemTableRetriever struct {
dummyCloser
table *model.TableInfo
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shirou/gopsutil v2.19.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.21.2+incompatible h1:U+YvJfjCh6MslYlIAXvPtzhW3YZEtc9uncueUNpD/0A=
Expand Down
26 changes: 18 additions & 8 deletions infoschema/tables.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ const (
TableStatementsSummary = "STATEMENTS_SUMMARY"
// TableStatementsSummaryHistory is the string constant of statements summary history table.
TableStatementsSummaryHistory = "STATEMENTS_SUMMARY_HISTORY"
// TableStatementsSummaryEvicted is the string constant of statements summary evicted table.
TableStatementsSummaryEvicted = "STATEMENTS_SUMMARY_EVICTED"
crazycs520 marked this conversation as resolved.
Show resolved Hide resolved
// TableStorageStats is a table that contains all tables disk usage
TableStorageStats = "TABLE_STORAGE_STATS"
// TableTiFlashTables is the string constant of tiflash tables table.
Expand Down Expand Up @@ -239,6 +241,7 @@ var tableIDMap = map[string]int64{
TableClientErrorsSummaryByHost: autoid.InformationSchemaDBID + 69,
TableTiDBTrx: autoid.InformationSchemaDBID + 70,
ClusterTableTiDBTrx: autoid.InformationSchemaDBID + 71,
TableStatementsSummaryEvicted: autoid.InformationSchemaDBID + 72,
}

type columnInfo struct {
Expand Down Expand Up @@ -1353,6 +1356,12 @@ var tableTiDBTrxCols = []columnInfo{
{name: "DB", tp: mysql.TypeVarchar, size: 64, comment: "The schema this transaction works on"},
}

var tableStatementsSummaryEvictedCols = []columnInfo{
{name: "BEGIN_TIME", tp: mysql.TypeTimestamp, size: 26},
{name: "END_TIME", tp: mysql.TypeTimestamp, size: 26},
{name: "EVICTED_COUNT", tp: mysql.TypeLonglong, size: 64, flag: mysql.NotNullFlag},
}

// GetShardingInfo returns a nil or description string for the sharding information of given TableInfo.
// The returned description string may be:
// - "NOT_SHARDED": for tables that SHARD_ROW_ID_BITS is not specified.
Expand Down Expand Up @@ -1428,7 +1437,7 @@ func (s *ServerInfo) ResolveLoopBackAddr() {

// GetClusterServerInfo returns all components information of cluster
func GetClusterServerInfo(ctx sessionctx.Context) ([]ServerInfo, error) {
failpoint.Inject("mockClusterInfo", func(val failpoint.Value) {
if val, _err_ := failpoint.Eval(_curpkg_("mockClusterInfo")); _err_ == nil {
// The cluster topology is injected by `failpoint` expression and
// there is no extra checks for it. (let the test fail if the expression invalid)
if s := val.(string); len(s) > 0 {
Expand All @@ -1448,9 +1457,9 @@ func GetClusterServerInfo(ctx sessionctx.Context) ([]ServerInfo, error) {
ServerID: serverID,
})
}
failpoint.Return(servers, nil)
return servers, nil
}
})
}

type retriever func(ctx sessionctx.Context) ([]ServerInfo, error)
var servers []ServerInfo
Expand Down Expand Up @@ -1610,11 +1619,11 @@ func GetStoreServerInfo(ctx sessionctx.Context) ([]ServerInfo, error) {
}
var servers []ServerInfo
for _, store := range stores {
failpoint.Inject("mockStoreTombstone", func(val failpoint.Value) {
if val, _err_ := failpoint.Eval(_curpkg_("mockStoreTombstone")); _err_ == nil {
if val.(bool) {
store.State = metapb.StoreState_Tombstone
}
})
}

if store.GetState() == metapb.StoreState_Tombstone {
continue
Expand All @@ -1639,11 +1648,11 @@ func GetStoreServerInfo(ctx sessionctx.Context) ([]ServerInfo, error) {

// GetTiFlashStoreCount returns the count of tiflash server.
func GetTiFlashStoreCount(ctx sessionctx.Context) (cnt uint64, err error) {
failpoint.Inject("mockTiFlashStoreCount", func(val failpoint.Value) {
if val, _err_ := failpoint.Eval(_curpkg_("mockTiFlashStoreCount")); _err_ == nil {
if val.(bool) {
failpoint.Return(uint64(10), nil)
return uint64(10), nil
}
})
}

stores, err := GetStoreServerInfo(ctx)
if err != nil {
Expand Down Expand Up @@ -1715,6 +1724,7 @@ var tableNameToColumns = map[string][]columnInfo{
TableSequences: tableSequencesCols,
TableStatementsSummary: tableStatementsSummaryCols,
TableStatementsSummaryHistory: tableStatementsSummaryCols,
TableStatementsSummaryEvicted: tableStatementsSummaryEvictedCols,
TableStorageStats: tableStorageStatsCols,
TableTiFlashTables: tableTableTiFlashTablesCols,
TableTiFlashSegments: tableTableTiFlashSegmentsCols,
Expand Down
3 changes: 3 additions & 0 deletions util/kvcache/simple_lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ func (l *SimpleLRUCache) Put(key Key, value Value) {
if l.size > l.capacity {
lru := l.cache.Back()
l.cache.Remove(lru)
if l.onEvict != nil {
crazycs520 marked this conversation as resolved.
Show resolved Hide resolved
l.onEvict(lru.Value.(*cacheEntry).key, lru.Value.(*cacheEntry).value)
}
delete(l.elements, string(lru.Value.(*cacheEntry).key.Hash()))
l.size--
}
Expand Down
38 changes: 25 additions & 13 deletions util/kvcache/simple_lru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,47 @@ func (s *testLRUCacheSuite) TestPut(c *C) {
maxMem, err := memory.MemTotal()
c.Assert(err, IsNil)

lru := NewSimpleLRUCache(3, 0, maxMem)
c.Assert(lru.capacity, Equals, uint(3))
lruMaxMem := NewSimpleLRUCache(3, 0, maxMem)
lruZeroQuota := NewSimpleLRUCache(3, 0, 0)
c.Assert(lruMaxMem.capacity, Equals, uint(3))
c.Assert(lruZeroQuota.capacity, Equals, uint(3))

keys := make([]*mockCacheKey, 5)
vals := make([]int64, 5)
droppedKv := make(map[Key]Value)
maxMemDroppedKv := make(map[Key]Value)
zeroQuotaDroppedKv := make(map[Key]Value)

lru.SetOnEvict(func(key Key, value Value) {
droppedKv[key] = value
// test onEvict function
lruMaxMem.SetOnEvict(func(key Key, value Value) {
maxMemDroppedKv[key] = value
})
// test onEvict function on 0 value of quota
lruZeroQuota.SetOnEvict(func(key Key, value Value) {
zeroQuotaDroppedKv[key] = value
})
for i := 0; i < 5; i++ {
keys[i] = newMockHashKey(int64(i))
vals[i] = int64(i)
lru.Put(keys[i], vals[i])
lruMaxMem.Put(keys[i], vals[i])
lruZeroQuota.Put(keys[i], vals[i])
}
c.Assert(lru.size, Equals, lru.capacity)
c.Assert(lru.size, Equals, uint(3))
c.Assert(lruMaxMem.size, Equals, lruMaxMem.capacity)
c.Assert(lruZeroQuota.size, Equals, lruZeroQuota.capacity)
c.Assert(lruMaxMem.size, Equals, uint(3))
c.Assert(lruZeroQuota.size, Equals, lruMaxMem.size)

// test for non-existent elements
c.Assert(len(droppedKv), Equals, 2)
c.Assert(len(maxMemDroppedKv), Equals, 2)
for i := 0; i < 2; i++ {
element, exists := lru.elements[string(keys[i].Hash())]
element, exists := lruMaxMem.elements[string(keys[i].Hash())]
c.Assert(exists, IsFalse)
c.Assert(element, IsNil)
c.Assert(droppedKv[keys[i]], Equals, vals[i])
c.Assert(maxMemDroppedKv[keys[i]], Equals, vals[i])
c.Assert(zeroQuotaDroppedKv[keys[i]], Equals, vals[i])
}

// test for existent elements
root := lru.cache.Front()
root := lruMaxMem.cache.Front()
c.Assert(root, NotNil)
for i := 4; i >= 2; i-- {
entry, ok := root.Value.(*cacheEntry)
Expand All @@ -98,7 +110,7 @@ func (s *testLRUCacheSuite) TestPut(c *C) {
c.Assert(key, NotNil)
c.Assert(key, Equals, keys[i])

element, exists := lru.elements[string(keys[i].Hash())]
element, exists := lruMaxMem.elements[string(keys[i].Hash())]
c.Assert(exists, IsTrue)
c.Assert(element, NotNil)
c.Assert(element, Equals, root)
Expand Down
164 changes: 164 additions & 0 deletions util/stmtsummary/evicted.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package stmtsummary
djshow832 marked this conversation as resolved.
Show resolved Hide resolved

import (
"container/list"
"time"

"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/types"
)

// stmtSummaryByDigestEvicted contents digests evicted from stmtSummaryByDigestMap
type stmtSummaryByDigestEvicted struct {
// record evicted data in intervals
// latest history data is Back()
history *list.List
}

// element being stored in stmtSummaryByDigestEvicted
type stmtSummaryByDigestEvictedElement struct {
// beginTime is the begin time of current interval
beginTime int64
// endTime is the end time of current interval
endTime int64
// *Kinds* of digest being evicted
digestKeyMap map[string]struct{}
}

// spawn a new pointer to stmtSummaryByDigestEvicted
func newStmtSummaryByDigestEvicted() *stmtSummaryByDigestEvicted {
return &stmtSummaryByDigestEvicted{
history: list.New(),
}
}

// spawn a new pointer to stmtSummaryByDigestEvictedElement
func newStmtSummaryByDigestEvictedElement(beginTime int64, endTime int64) *stmtSummaryByDigestEvictedElement {
return &stmtSummaryByDigestEvictedElement{
beginTime: beginTime,
endTime: endTime,
digestKeyMap: make(map[string]struct{}),
}
}

// AddEvicted is used add an evicted record to stmtSummaryByDigestEvicted
func (ssbde *stmtSummaryByDigestEvicted) AddEvicted(evictedKey *stmtSummaryByDigestKey, evictedValue *stmtSummaryByDigest, historySize int) {
crazycs520 marked this conversation as resolved.
Show resolved Hide resolved
evictedValue.Lock()
defer evictedValue.Unlock()
if evictedValue == nil {
return
}

for e, h := evictedValue.history.Back(), ssbde.history.Back(); e != nil; e = e.Prev() {
evictedElement := e.Value.(*stmtSummaryByDigestElement)
eBeginTime := evictedElement.beginTime
eEndTime := evictedElement.endTime

// no record in ssbde.history, direct insert
if ssbde.history.Len() == 0 {
record := newStmtSummaryByDigestEvictedElement(eBeginTime, eEndTime)
record.addEvicted(evictedKey, evictedElement)
ssbde.history.PushFront(record)
continue
}

// prevent exceeding history size
for ssbde.history.Len() >= historySize && ssbde.history.Len() > 1 {
ssbde.history.Remove(ssbde.history.Front())
}

// look for matching history interval
// if there are no records in ssbde.history, following code will not be executed. Such situation will probably lead to a bug.
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment situation seems never to happen? since line71 already handle this case, can we remove this comment now? It looks scary

MATCHING:
for ; h != nil; h = h.Prev() {
historyElement := h.Value.(*stmtSummaryByDigestEvictedElement)

switch historyElement.matchAndAdd(evictedKey, evictedElement) {
case isMatch:
// automatically added
break MATCHING
// not matching, create a new record and insert
case isTooYoung:
{
record := newStmtSummaryByDigestEvictedElement(eBeginTime, eEndTime)
record.addEvicted(evictedKey, evictedElement)
ssbde.history.InsertAfter(record, h)
break MATCHING
}
default: // isTooOld
{
if h == ssbde.history.Front() {
// if digest older than all records in ssbde.history.
record := newStmtSummaryByDigestEvictedElement(eBeginTime, eEndTime)
record.addEvicted(evictedKey, evictedElement)
ssbde.history.PushFront(record)
break MATCHING
}
}
}
}
}
}

// Clear up all records in stmtSummaryByDigestEvicted
func (ssbde *stmtSummaryByDigestEvicted) Clear() {
ssbde.history.Init()
}

// add an evicted record to stmtSummaryByDigestEvictedElement
func (seElement *stmtSummaryByDigestEvictedElement) addEvicted(digestKey *stmtSummaryByDigestKey, digestValue *stmtSummaryByDigestElement) {
if digestKey != nil {
seElement.digestKeyMap[string(digestKey.Hash())] = struct{}{}
}
}

const (
isMatch = 0
isTooOld = 1
isTooYoung = 2
)

// matchAndAdd check time interval of seElement and digestValue.
// if matches, it will add the digest and return enum match
// if digest too old, it will return enum tooOld and do nothing
// if digest too young, it will return enum tooYoung and do nothing
func (seElement *stmtSummaryByDigestEvictedElement) matchAndAdd(digestKey *stmtSummaryByDigestKey, digestValue *stmtSummaryByDigestElement) (statement int) {
if seElement == nil || digestValue == nil {
return isTooYoung
}
sBeginTime, sEndTime := seElement.beginTime, seElement.endTime
eBeginTime, eEndTime := digestValue.beginTime, digestValue.endTime
if sBeginTime <= eBeginTime && eEndTime <= sEndTime {
seElement.addEvicted(digestKey, digestValue)
return isMatch
} else if eEndTime <= sBeginTime {
return isTooOld
} else {
return isTooYoung
}
}

// ToEvictedCountDatum converts history evicted record to `evicted count` record's datum
func (ssbde *stmtSummaryByDigestEvicted) ToEvictedCountDatum() [][]types.Datum {
records := make([][]types.Datum, 0, ssbde.history.Len())
for e := ssbde.history.Front(); e != nil; e = e.Next() {
if record := e.Value.(*stmtSummaryByDigestEvictedElement).toEvictedCountDatum(); record != nil {
records = append(records, record)
}
}
return records
}

// toEvictedCountDatum converts evicted record to `EvictedCount` record's datum
func (seElement *stmtSummaryByDigestEvictedElement) toEvictedCountDatum() []types.Datum {
datum := types.MakeDatums(
types.NewTime(types.FromGoTime(time.Unix(seElement.beginTime, 0)), mysql.TypeTimestamp, 0),
types.NewTime(types.FromGoTime(time.Unix(seElement.endTime, 0)), mysql.TypeTimestamp, 0),
int64(len(seElement.digestKeyMap)),
)
return datum
}

func (ssMap *stmtSummaryByDigestMap) ToEvictedCountDatum() [][]types.Datum {
return ssMap.other.ToEvictedCountDatum()
}
Loading