@@ -94,7 +94,7 @@ const (
94
94
ReadFromLeaseholder = kvpb .READ_UNCOMMITTED
95
95
)
96
96
97
- // UnknownClosedTimestampPolicy is used to mark on a CacheEntry that the closed
97
+ // UnknownClosedTimestampPolicy is used to mark on a cacheEntry that the closed
98
98
// timestamp policy is not known. This value is never serialized into
99
99
// RangeInfo or any other message which uses the type.
100
100
const UnknownClosedTimestampPolicy roachpb.RangeClosedTimestampPolicy = - 1
@@ -275,18 +275,18 @@ type EvictionToken struct {
275
275
// compatible descriptor, with the same range id and key bounds. If the
276
276
// descriptor changes in a non-compatible way, this EvictionToken must be
277
277
// discarded and a new one retrieved from the RangeCache.
278
- entry * CacheEntry
278
+ entry * cacheEntry
279
279
}
280
280
281
- func (rc * RangeCache ) makeEvictionToken (entry * CacheEntry ) EvictionToken {
281
+ func (rc * RangeCache ) makeEvictionToken (entry * cacheEntry ) EvictionToken {
282
282
return EvictionToken {
283
283
rdc : rc ,
284
284
entry : entry ,
285
285
}
286
286
}
287
287
288
288
// MakeEvictionToken is the exported ctor. For tests only.
289
- func (rc * RangeCache ) MakeEvictionToken (entry * CacheEntry ) EvictionToken {
289
+ func (rc * RangeCache ) MakeEvictionToken (entry * cacheEntry ) EvictionToken {
290
290
return rc .makeEvictionToken (entry )
291
291
}
292
292
@@ -375,7 +375,7 @@ func (et EvictionToken) ClosedTimestampPolicy(
375
375
// entry for the start key any more.
376
376
func (et * EvictionToken ) syncRLocked (
377
377
ctx context.Context ,
378
- ) (stillValid bool , cachedEntry * CacheEntry , rawEntry * cache.Entry ) {
378
+ ) (stillValid bool , cachedEntry * cacheEntry , rawEntry * cache.Entry ) {
379
379
cachedEntry , rawEntry = et .rdc .getCachedRLocked (ctx , et .entry .desc .StartKey , false /* inverted */ )
380
380
if cachedEntry == nil || ! descsCompatible (cachedEntry .Desc (), et .Desc ()) {
381
381
et .clear ()
@@ -622,11 +622,11 @@ func (rc *RangeCache) Lookup(ctx context.Context, key roachpb.RKey) (roachpb.Ran
622
622
623
623
// GetCachedOverlapping returns all the cached entries which overlap a given
624
624
// span [Key, EndKey). The results are sorted ascendingly.
625
- func (rc * RangeCache ) GetCachedOverlapping (ctx context.Context , span roachpb.RSpan ) []* CacheEntry {
625
+ func (rc * RangeCache ) GetCachedOverlapping (ctx context.Context , span roachpb.RSpan ) []* cacheEntry {
626
626
rc .rangeCache .RLock ()
627
627
defer rc .rangeCache .RUnlock ()
628
628
rawEntries := rc .getCachedOverlappingRLocked (ctx , span )
629
- entries := make ([]* CacheEntry , len (rawEntries ))
629
+ entries := make ([]* cacheEntry , len (rawEntries ))
630
630
for i , e := range rawEntries {
631
631
entries [i ] = rc .getValue (e )
632
632
}
@@ -906,10 +906,10 @@ func tryLookupImpl(
906
906
rc .rangeCache .Lock ()
907
907
defer rc .rangeCache .Unlock ()
908
908
909
- // We want to insert a new CacheEntry , possibly with a speculativeDesc.
909
+ // We want to insert a new cacheEntry , possibly with a speculativeDesc.
910
910
// Create the entry based on the lookup and try and insert it into the
911
911
// cache.
912
- newEntry := CacheEntry {
912
+ newEntry := cacheEntry {
913
913
desc : rs [0 ],
914
914
// We don't have any lease information.
915
915
lease : roachpb.Lease {},
@@ -930,10 +930,10 @@ func tryLookupImpl(
930
930
// rs[0]'s eviction token. Note that ranges for which the cache has more
931
931
// up-to-date information will not be clobbered - for example ranges for
932
932
// which the cache has the prefetched descriptor already plus a lease.
933
- newEntries := make ([]* CacheEntry , len (preRs )+ 1 )
933
+ newEntries := make ([]* cacheEntry , len (preRs )+ 1 )
934
934
newEntries [0 ] = & newEntry
935
935
for i , preR := range preRs {
936
- newEntries [i + 1 ] = & CacheEntry {desc : preR , closedts : UnknownClosedTimestampPolicy }
936
+ newEntries [i + 1 ] = & cacheEntry {desc : preR , closedts : UnknownClosedTimestampPolicy }
937
937
}
938
938
insertedEntries := rc .insertLockedInner (ctx , newEntries )
939
939
// entry corresponds to rs[0], which is the descriptor covering the key
@@ -1051,7 +1051,7 @@ func (rc *RangeCache) TestingGetCached(
1051
1051
// used for descriptor eviction.
1052
1052
func (rc * RangeCache ) getCachedRLocked (
1053
1053
ctx context.Context , key roachpb.RKey , inverted bool ,
1054
- ) (* CacheEntry , * cache.Entry ) {
1054
+ ) (* cacheEntry , * cache.Entry ) {
1055
1055
// rawEntry will be the range containing key, or the first cached entry around
1056
1056
// key, in the direction indicated by inverted.
1057
1057
var rawEntry * cache.Entry
@@ -1117,10 +1117,10 @@ func (rc *RangeCache) Insert(ctx context.Context, rs ...roachpb.RangeInfo) {
1117
1117
// for putting in eviction tokens. Any element in the returned array can be nil
1118
1118
// if inserting the respective RangeInfo failed because it was found to be
1119
1119
// stale.
1120
- func (rc * RangeCache ) insertLocked (ctx context.Context , rs ... roachpb.RangeInfo ) []* CacheEntry {
1121
- entries := make ([]* CacheEntry , len (rs ))
1120
+ func (rc * RangeCache ) insertLocked (ctx context.Context , rs ... roachpb.RangeInfo ) []* cacheEntry {
1121
+ entries := make ([]* cacheEntry , len (rs ))
1122
1122
for i , r := range rs {
1123
- entries [i ] = & CacheEntry {
1123
+ entries [i ] = & cacheEntry {
1124
1124
desc : r .Desc ,
1125
1125
lease : r .Lease ,
1126
1126
closedts : r .ClosedTimestampPolicy ,
@@ -1129,10 +1129,10 @@ func (rc *RangeCache) insertLocked(ctx context.Context, rs ...roachpb.RangeInfo)
1129
1129
return rc .insertLockedInner (ctx , entries )
1130
1130
}
1131
1131
1132
- func (rc * RangeCache ) insertLockedInner (ctx context.Context , rs []* CacheEntry ) []* CacheEntry {
1132
+ func (rc * RangeCache ) insertLockedInner (ctx context.Context , rs []* cacheEntry ) []* cacheEntry {
1133
1133
// entries will have the same element as rs, except the ones that couldn't be
1134
1134
// inserted for which the slots will remain nil.
1135
- entries := make ([]* CacheEntry , len (rs ))
1135
+ entries := make ([]* cacheEntry , len (rs ))
1136
1136
for i , ent := range rs {
1137
1137
if ! ent .desc .IsInitialized () {
1138
1138
log .Fatalf (ctx , "inserting uninitialized desc: %s" , ent )
@@ -1170,13 +1170,13 @@ func (rc *RangeCache) insertLockedInner(ctx context.Context, rs []*CacheEntry) [
1170
1170
return entries
1171
1171
}
1172
1172
1173
- func (rc * RangeCache ) getValue (entry * cache.Entry ) * CacheEntry {
1174
- return entry .Value .(* CacheEntry )
1173
+ func (rc * RangeCache ) getValue (entry * cache.Entry ) * cacheEntry {
1174
+ return entry .Value .(* cacheEntry )
1175
1175
}
1176
1176
1177
1177
func (rc * RangeCache ) clearOlderOverlapping (
1178
- ctx context.Context , newEntry * CacheEntry ,
1179
- ) (ok bool , newerEntry * CacheEntry ) {
1178
+ ctx context.Context , newEntry * cacheEntry ,
1179
+ ) (ok bool , newerEntry * cacheEntry ) {
1180
1180
rc .rangeCache .Lock ()
1181
1181
defer rc .rangeCache .Unlock ()
1182
1182
return rc .clearOlderOverlappingLocked (ctx , newEntry )
@@ -1193,11 +1193,11 @@ func (rc *RangeCache) clearOlderOverlapping(
1193
1193
// Note that even if false is returned, older descriptors are still cleared from
1194
1194
// the cache.
1195
1195
func (rc * RangeCache ) clearOlderOverlappingLocked (
1196
- ctx context.Context , newEntry * CacheEntry ,
1197
- ) (ok bool , newerEntry * CacheEntry ) {
1196
+ ctx context.Context , newEntry * cacheEntry ,
1197
+ ) (ok bool , newerEntry * cacheEntry ) {
1198
1198
log .VEventf (ctx , 2 , "clearing entries overlapping %s" , newEntry .Desc ())
1199
1199
newest := true
1200
- var newerFound * CacheEntry
1200
+ var newerFound * cacheEntry
1201
1201
overlapping := rc .getCachedOverlappingRLocked (ctx , newEntry .Desc ().RSpan ())
1202
1202
for _ , e := range overlapping {
1203
1203
entry := rc .getValue (e )
@@ -1226,7 +1226,7 @@ func (rc *RangeCache) clearOlderOverlappingLocked(
1226
1226
// swapEntryLocked swaps oldEntry for newEntry. If newEntry is nil, oldEntry is
1227
1227
// simply removed.
1228
1228
func (rc * RangeCache ) swapEntryLocked (
1229
- ctx context.Context , oldEntry * cache.Entry , newEntry * CacheEntry ,
1229
+ ctx context.Context , oldEntry * cache.Entry , newEntry * cacheEntry ,
1230
1230
) {
1231
1231
if newEntry != nil {
1232
1232
old := rc .getValue (oldEntry )
@@ -1243,7 +1243,7 @@ func (rc *RangeCache) swapEntryLocked(
1243
1243
}
1244
1244
}
1245
1245
1246
- func (rc * RangeCache ) addEntryLocked (entry * CacheEntry ) {
1246
+ func (rc * RangeCache ) addEntryLocked (entry * cacheEntry ) {
1247
1247
key := newRangeCacheKey (entry .Desc ().StartKey )
1248
1248
rc .rangeCache .cache .Add (key , entry )
1249
1249
}
@@ -1269,12 +1269,12 @@ func (rc *RangeCache) NumInFlight(name string) int {
1269
1269
return rc .lookupRequests .NumCalls (name )
1270
1270
}
1271
1271
1272
- // CacheEntry represents one cache entry.
1272
+ // cacheEntry represents one cache entry.
1273
1273
//
1274
- // The cache stores *CacheEntry . Entries are immutable: cache lookups
1275
- // returns the same *CacheEntry to multiple queriers for efficiency, but
1274
+ // The cache stores *cacheEntry . Entries are immutable: cache lookups
1275
+ // returns the same *cacheEntry to multiple queriers for efficiency, but
1276
1276
// nobody should modify the lookup result.
1277
- type CacheEntry struct {
1277
+ type cacheEntry struct {
1278
1278
// desc is always populated.
1279
1279
desc roachpb.RangeDescriptor
1280
1280
// speculativeDesc, if not nil, is the descriptor that should replace desc if
@@ -1300,20 +1300,20 @@ type CacheEntry struct {
1300
1300
closedts roachpb.RangeClosedTimestampPolicy
1301
1301
}
1302
1302
1303
- func (e CacheEntry ) String () string {
1303
+ func (e cacheEntry ) String () string {
1304
1304
return fmt .Sprintf ("desc:%s, lease:%s" , e .Desc (), e .lease )
1305
1305
}
1306
1306
1307
1307
// Desc returns the cached descriptor. Note that, besides being possibly stale,
1308
1308
// this descriptor also might not represent a descriptor that was ever
1309
1309
// committed. See DescSpeculative().
1310
- func (e * CacheEntry ) Desc () * roachpb.RangeDescriptor {
1310
+ func (e * cacheEntry ) Desc () * roachpb.RangeDescriptor {
1311
1311
return & e .desc
1312
1312
}
1313
1313
1314
1314
// Leaseholder returns the cached leaseholder replica, if known. Returns nil if
1315
1315
// the leaseholder is not known.
1316
- func (e * CacheEntry ) Leaseholder () * roachpb.ReplicaDescriptor {
1316
+ func (e * cacheEntry ) Leaseholder () * roachpb.ReplicaDescriptor {
1317
1317
if e .lease .Empty () {
1318
1318
return nil
1319
1319
}
@@ -1323,7 +1323,7 @@ func (e *CacheEntry) Leaseholder() *roachpb.ReplicaDescriptor {
1323
1323
// Lease returns the cached lease, if known. Returns nil if no lease is known.
1324
1324
// It's possible for a leaseholder to be known, but not a full lease, in which
1325
1325
// case Leaseholder() returns non-nil but Lease() returns nil.
1326
- func (e * CacheEntry ) Lease () * roachpb.Lease {
1326
+ func (e * cacheEntry ) Lease () * roachpb.Lease {
1327
1327
if e .lease .Empty () {
1328
1328
return nil
1329
1329
}
@@ -1335,7 +1335,7 @@ func (e *CacheEntry) Lease() *roachpb.Lease {
1335
1335
1336
1336
// ClosedTimestampPolicy returns the cached understanding of the range's closed
1337
1337
// timestamp policy. If no policy is known, LAG_BY_CLUSTER_SETTING is returned.
1338
- func (e * CacheEntry ) ClosedTimestampPolicy () roachpb.RangeClosedTimestampPolicy {
1338
+ func (e * cacheEntry ) ClosedTimestampPolicy () roachpb.RangeClosedTimestampPolicy {
1339
1339
return e .closedts
1340
1340
}
1341
1341
@@ -1344,21 +1344,21 @@ func (e *CacheEntry) ClosedTimestampPolicy() roachpb.RangeClosedTimestampPolicy
1344
1344
// inserted in the cache with Generation=0.
1345
1345
//
1346
1346
// Speculative descriptors come from (not-yet-committed) intents.
1347
- func (e * CacheEntry ) DescSpeculative () bool {
1347
+ func (e * cacheEntry ) DescSpeculative () bool {
1348
1348
return e .desc .Generation == 0
1349
1349
}
1350
1350
1351
1351
// LeaseSpeculative returns true if the lease in the entry is "speculative"
1352
1352
// - i.e. it doesn't correspond to a committed lease. Such leases have been
1353
1353
// inserted in the cache with Sequence=0.
1354
- func (e * CacheEntry ) LeaseSpeculative () bool {
1354
+ func (e * cacheEntry ) LeaseSpeculative () bool {
1355
1355
if e .lease .Empty () {
1356
1356
panic (fmt .Sprintf ("LeaseSpeculative called on entry with empty lease: %s" , e ))
1357
1357
}
1358
1358
return e .lease .Speculative ()
1359
1359
}
1360
1360
1361
- func (e * CacheEntry ) toRangeInfo () roachpb.RangeInfo {
1361
+ func (e * cacheEntry ) toRangeInfo () roachpb.RangeInfo {
1362
1362
return roachpb.RangeInfo {
1363
1363
Desc : e .desc ,
1364
1364
Lease : e .lease ,
@@ -1379,7 +1379,7 @@ func (e *CacheEntry) toRangeInfo() roachpb.RangeInfo {
1379
1379
// can't be determined what information is newer is when at least one of the
1380
1380
// descriptors is "speculative" (generation=0), or when the lease information is
1381
1381
// "speculative" (sequence=0).
1382
- func (e * CacheEntry ) overrides (o * CacheEntry ) bool {
1382
+ func (e * cacheEntry ) overrides (o * cacheEntry ) bool {
1383
1383
if util .RaceEnabled {
1384
1384
if _ , err := e .Desc ().RSpan ().Intersect (o .Desc ().RSpan ()); err != nil {
1385
1385
panic (fmt .Sprintf ("descriptors don't intersect: %s vs %s" , e .Desc (), o .Desc ()))
@@ -1419,7 +1419,7 @@ func (e *CacheEntry) overrides(o *CacheEntry) bool {
1419
1419
//
1420
1420
// In case at least one of the descriptors is "speculative", a is considered
1421
1421
// older; this matches the semantics of b.overrides(a).
1422
- func compareEntryDescs (a , b * CacheEntry ) int {
1422
+ func compareEntryDescs (a , b * cacheEntry ) int {
1423
1423
if util .RaceEnabled {
1424
1424
if _ , err := a .Desc ().RSpan ().Intersect (b .Desc ().RSpan ()); err != nil {
1425
1425
panic (fmt .Sprintf ("descriptors don't intersect: %s vs %s" , a .Desc (), b .Desc ()))
@@ -1450,7 +1450,7 @@ func compareEntryDescs(a, b *CacheEntry) int {
1450
1450
// An empty lease is considered older than any other. In case at least one of
1451
1451
// the leases is "speculative", a is considered older; this matches the
1452
1452
// semantics of b.overrides(a).
1453
- func compareEntryLeases (a , b * CacheEntry ) int {
1453
+ func compareEntryLeases (a , b * cacheEntry ) int {
1454
1454
if aEmpty , bEmpty := a .lease .Empty (), b .lease .Empty (); aEmpty || bEmpty {
1455
1455
if aEmpty && ! bEmpty {
1456
1456
return - 1
@@ -1476,7 +1476,7 @@ func compareEntryLeases(a, b *CacheEntry) int {
1476
1476
return 0
1477
1477
}
1478
1478
1479
- // maybeUpdate returns a new CacheEntry which contains the freshest lease/range
1479
+ // maybeUpdate returns a new cacheEntry which contains the freshest lease/range
1480
1480
// descriptor by comparing the receiver's fields to the passed-in parameters.
1481
1481
//
1482
1482
// The updated retval indicates if either the passed-in lease or the range
@@ -1499,15 +1499,15 @@ func compareEntryLeases(a, b *CacheEntry) int {
1499
1499
//
1500
1500
// It's expected that the supplied rangeDesc is compatible with the descriptor
1501
1501
// on the cache entry.
1502
- func (e * CacheEntry ) maybeUpdate (
1502
+ func (e * cacheEntry ) maybeUpdate (
1503
1503
ctx context.Context , l * roachpb.Lease , rangeDesc * roachpb.RangeDescriptor ,
1504
- ) (updated , updatedLease bool , newEntry * CacheEntry ) {
1504
+ ) (updated , updatedLease bool , newEntry * cacheEntry ) {
1505
1505
if ! descsCompatible (e .Desc (), rangeDesc ) {
1506
1506
log .Fatalf (ctx , "attempting to update by comparing non-compatible descs: %s vs %s" ,
1507
1507
e .Desc (), rangeDesc )
1508
1508
}
1509
1509
1510
- newEntry = & CacheEntry {
1510
+ newEntry = & cacheEntry {
1511
1511
lease : e .lease ,
1512
1512
desc : e .desc ,
1513
1513
closedts : e .closedts ,
@@ -1571,13 +1571,13 @@ func (e *CacheEntry) maybeUpdate(
1571
1571
return updatedLease || updatedDesc , updatedLease , newEntry
1572
1572
}
1573
1573
1574
- func (e * CacheEntry ) evictLeaseholder (
1574
+ func (e * cacheEntry ) evictLeaseholder (
1575
1575
lh roachpb.ReplicaDescriptor ,
1576
- ) (updated bool , newEntry * CacheEntry ) {
1576
+ ) (updated bool , newEntry * cacheEntry ) {
1577
1577
if e .lease .Replica != lh {
1578
1578
return false , e
1579
1579
}
1580
- return true , & CacheEntry {
1580
+ return true , & cacheEntry {
1581
1581
desc : e .desc ,
1582
1582
closedts : e .closedts ,
1583
1583
}
0 commit comments