@@ -85,13 +85,13 @@ type Data struct {
85
85
//
86
86
// It means as long as we can find an item in it, the item is available, even through the
87
87
// schema version maybe smaller than required.
88
- byName * btree.BTreeG [tableItem ]
88
+ byName * btree.BTreeG [* tableItem ]
89
89
90
90
// For the TableByID API, sorted by {tableID, schemaVersion} => dbID
91
91
// To reload model.TableInfo, we need both table ID and database ID for meta kv API.
92
92
// It provides the tableID => databaseID mapping.
93
93
// This mapping MUST be synced with byName.
94
- byID * btree.BTreeG [tableItem ]
94
+ byID * btree.BTreeG [* tableItem ]
95
95
96
96
// For the SchemaByName API, sorted by {dbName, schemaVersion} => model.DBInfo
97
97
// Stores the full data in memory.
@@ -186,8 +186,8 @@ type tableCacheKey struct {
186
186
// NewData creates an infoschema V2 data struct.
187
187
func NewData () * Data {
188
188
ret := & Data {
189
- byID : btree.NewBTreeG [tableItem ](compareByID ),
190
- byName : btree.NewBTreeG [tableItem ](compareByName ),
189
+ byID : btree.NewBTreeG [* tableItem ](compareByID ),
190
+ byName : btree.NewBTreeG [* tableItem ](compareByName ),
191
191
schemaMap : btree.NewBTreeG [schemaItem ](compareSchemaItem ),
192
192
schemaID2Name : btree.NewBTreeG [schemaIDName ](compareSchemaByID ),
193
193
tableCache : newSieve [tableCacheKey , table.Table ](1024 * 1024 * size .MB ),
@@ -209,8 +209,8 @@ func (isd *Data) SetCacheCapacity(capacity uint64) {
209
209
}
210
210
211
211
func (isd * Data ) add (item tableItem , tbl table.Table ) {
212
- isd .byID .Set (item )
213
- isd .byName .Set (item )
212
+ isd .byID .Set (& item )
213
+ isd .byName .Set (& item )
214
214
isd .tableCache .Set (tableCacheKey {item .tableID , item .schemaVersion }, tbl )
215
215
ti := tbl .Meta ()
216
216
if pi := ti .GetPartitionInfo (); pi != nil {
@@ -240,8 +240,8 @@ func (isd *Data) addDB(schemaVersion int64, dbInfo *model.DBInfo) {
240
240
241
241
func (isd * Data ) remove (item tableItem ) {
242
242
item .tomb = true
243
- isd .byID .Set (item )
244
- isd .byName .Set (item )
243
+ isd .byID .Set (& item )
244
+ isd .byName .Set (& item )
245
245
isd .tableInfoResident .Set (tableInfoItem {
246
246
dbName : item .dbName ,
247
247
tableID : item .tableID ,
@@ -271,7 +271,7 @@ func (isd *Data) resetBeforeFullLoad(schemaVersion int64) {
271
271
resetPID2TIDBeforeFullLoad (isd .pid2tid , schemaVersion )
272
272
}
273
273
274
- func resetByIDBeforeFullLoad (bt * btree.BTreeG [tableItem ], schemaVersion int64 ) {
274
+ func resetByIDBeforeFullLoad (bt * btree.BTreeG [* tableItem ], schemaVersion int64 ) {
275
275
pivot , ok := bt .Max ()
276
276
if ! ok {
277
277
return
@@ -281,10 +281,10 @@ func resetByIDBeforeFullLoad(bt *btree.BTreeG[tableItem], schemaVersion int64) {
281
281
if bt .Len () < batchSize {
282
282
batchSize = bt .Len ()
283
283
}
284
- items := make ([]tableItem , 0 , batchSize )
284
+ items := make ([]* tableItem , 0 , batchSize )
285
285
items = append (items , pivot )
286
286
for {
287
- bt .Descend (pivot , func (item tableItem ) bool {
287
+ bt .Descend (pivot , func (item * tableItem ) bool {
288
288
if pivot .tableID == item .tableID {
289
289
return true // skip MVCC version
290
290
}
@@ -296,7 +296,7 @@ func resetByIDBeforeFullLoad(bt *btree.BTreeG[tableItem], schemaVersion int64) {
296
296
break
297
297
}
298
298
for _ , item := range items {
299
- bt .Set (tableItem {
299
+ bt .Set (& tableItem {
300
300
dbName : item .dbName ,
301
301
dbID : item .dbID ,
302
302
tableName : item .tableName ,
@@ -309,7 +309,7 @@ func resetByIDBeforeFullLoad(bt *btree.BTreeG[tableItem], schemaVersion int64) {
309
309
}
310
310
}
311
311
312
- func resetByNameBeforeFullLoad (bt * btree.BTreeG [tableItem ], schemaVersion int64 ) {
312
+ func resetByNameBeforeFullLoad (bt * btree.BTreeG [* tableItem ], schemaVersion int64 ) {
313
313
pivot , ok := bt .Max ()
314
314
if ! ok {
315
315
return
@@ -319,10 +319,10 @@ func resetByNameBeforeFullLoad(bt *btree.BTreeG[tableItem], schemaVersion int64)
319
319
if bt .Len () < batchSize {
320
320
batchSize = bt .Len ()
321
321
}
322
- items := make ([]tableItem , 0 , batchSize )
322
+ items := make ([]* tableItem , 0 , batchSize )
323
323
items = append (items , pivot )
324
324
for {
325
- bt .Descend (pivot , func (item tableItem ) bool {
325
+ bt .Descend (pivot , func (item * tableItem ) bool {
326
326
if pivot .dbName == item .dbName && pivot .tableName == item .tableName {
327
327
return true // skip MVCC version
328
328
}
@@ -334,7 +334,7 @@ func resetByNameBeforeFullLoad(bt *btree.BTreeG[tableItem], schemaVersion int64)
334
334
break
335
335
}
336
336
for _ , item := range items {
337
- bt .Set (tableItem {
337
+ bt .Set (& tableItem {
338
338
dbName : item .dbName ,
339
339
dbID : item .dbID ,
340
340
tableName : item .tableName ,
@@ -457,7 +457,7 @@ func resetPID2TIDBeforeFullLoad(bt *btree.BTreeG[partitionItem], schemaVersion i
457
457
}
458
458
}
459
459
460
- func compareByID (a , b tableItem ) bool {
460
+ func compareByID (a , b * tableItem ) bool {
461
461
if a .tableID < b .tableID {
462
462
return true
463
463
}
@@ -468,7 +468,7 @@ func compareByID(a, b tableItem) bool {
468
468
return a .schemaVersion < b .schemaVersion
469
469
}
470
470
471
- func compareByName (a , b tableItem ) bool {
471
+ func compareByName (a , b * tableItem ) bool {
472
472
if a .dbName .L < b .dbName .L {
473
473
return true
474
474
}
@@ -553,12 +553,12 @@ func NewInfoSchemaV2(r autoid.Requirement, factory func() (pools.Resource, error
553
553
}
554
554
}
555
555
556
- func search (bt * btree.BTreeG [tableItem ], schemaVersion int64 , end tableItem , matchFn func (a , b * tableItem ) bool ) (tableItem , bool ) {
556
+ func search (bt * btree.BTreeG [* tableItem ], schemaVersion int64 , end tableItem , matchFn func (a , b * tableItem ) bool ) (* tableItem , bool ) {
557
557
var ok bool
558
- var target tableItem
558
+ var target * tableItem
559
559
// Iterate through the btree, find the query item whose schema version is the largest one (latest).
560
- bt .Descend (end , func (item tableItem ) bool {
561
- if ! matchFn (& end , & item ) {
560
+ bt .Descend (& end , func (item * tableItem ) bool {
561
+ if ! matchFn (& end , item ) {
562
562
return false
563
563
}
564
564
if item .schemaVersion > schemaVersion {
@@ -594,7 +594,7 @@ func (is *infoschemaV2) CloneAndUpdateTS(startTS uint64) *infoschemaV2 {
594
594
return & tmp
595
595
}
596
596
597
- func (is * infoschemaV2 ) searchTableItemByID (tableID int64 ) (tableItem , bool ) {
597
+ func (is * infoschemaV2 ) searchTableItemByID (tableID int64 ) (* tableItem , bool ) {
598
598
eq := func (a , b * tableItem ) bool { return a .tableID == b .tableID }
599
599
return search (
600
600
is .byID ,
@@ -679,7 +679,7 @@ func (is *infoschemaV2) IterateAllTableItems(visit func(TableItem) bool) {
679
679
return
680
680
}
681
681
var pivot * tableItem
682
- is .byName .Descend (maxv , func (item tableItem ) bool {
682
+ is .byName .Descend (maxv , func (item * tableItem ) bool {
683
683
if item .schemaVersion > is .schemaMetaVersion {
684
684
// skip MVCC version, those items are not visible to the queried schema version
685
685
return true
@@ -688,7 +688,7 @@ func (is *infoschemaV2) IterateAllTableItems(visit func(TableItem) bool) {
688
688
// skip MVCC version, this db.table has been visited already
689
689
return true
690
690
}
691
- pivot = & item
691
+ pivot = item
692
692
if ! item .tomb {
693
693
return visit (TableItem {DBName : item .dbName , TableName : item .tableName })
694
694
}
@@ -743,10 +743,10 @@ type tableByNameHelper struct {
743
743
end tableItem
744
744
schemaVersion int64
745
745
found bool
746
- res tableItem
746
+ res * tableItem
747
747
}
748
748
749
- func (h * tableByNameHelper ) onItem (item tableItem ) bool {
749
+ func (h * tableByNameHelper ) onItem (item * tableItem ) bool {
750
750
if item .dbName .L != h .end .dbName .L || item .tableName .L != h .end .tableName .L {
751
751
h .found = false
752
752
return false
@@ -779,7 +779,7 @@ func (is *infoschemaV2) TableByName(ctx context.Context, schema, tbl pmodel.CISt
779
779
var h tableByNameHelper
780
780
h .end = tableItem {dbName : schema , tableName : tbl , schemaVersion : math .MaxInt64 }
781
781
h .schemaVersion = is .infoSchema .schemaMetaVersion
782
- is .byName .Descend (h .end , h .onItem )
782
+ is .byName .Descend (& h .end , h .onItem )
783
783
784
784
if ! h .found {
785
785
return nil , ErrTableNotExists .FastGenByArgs (schema , tbl )
@@ -907,8 +907,8 @@ func (is *infoschemaV2) SchemaSimpleTableInfos(ctx context.Context, schema pmode
907
907
908
908
// Ascend is much more difficult than Descend.
909
909
// So the data is taken out first and then dedup in Descend order.
910
- var tableItems []tableItem
911
- is .byName .Ascend (tableItem {dbName : schema }, func (item tableItem ) bool {
910
+ var tableItems []* tableItem
911
+ is .byName .Ascend (& tableItem {dbName : schema }, func (item * tableItem ) bool {
912
912
if item .dbName .L != schema .L {
913
913
return false
914
914
}
@@ -923,7 +923,7 @@ func (is *infoschemaV2) SchemaSimpleTableInfos(ctx context.Context, schema pmode
923
923
tblInfos := make ([]* model.TableNameInfo , 0 , len (tableItems ))
924
924
var curr * tableItem
925
925
for i := len (tableItems ) - 1 ; i >= 0 ; i -- {
926
- item := & tableItems [i ]
926
+ item := tableItems [i ]
927
927
if curr == nil || curr .tableName != tableItems [i ].tableName {
928
928
curr = item
929
929
if ! item .tomb {
0 commit comments