Skip to content

Commit e02bd2c

Browse files
committed
MB-16181: Rename 'diskCount' to 'itemCount'
Both ephemeral and persistent buckets use this field for collection counting - it's not really just the disk count but our canonical place for a collection's item count. Change-Id: Ib3107fd6331357ddbae943a00b04d2da0c3647f7 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/137394 Reviewed-by: Dave Rigby <[email protected]> Tested-by: Jim Walker <[email protected]>
1 parent cc80b16 commit e02bd2c

File tree

11 files changed

+60
-62
lines changed

11 files changed

+60
-62
lines changed

engines/ep/src/collections/flush.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ class StatsUpdate {
6262
bool isLogicallyDeleted(uint64_t seqno) const;
6363

6464
/**
65-
* Increment the 'disk' count for the collection associated with the key
65+
* Increment the item count for the collection associated with the key
6666
*/
67-
void incrementDiskCount();
67+
void incrementItemCount();
6868

6969
/**
70-
* Decrement the 'disk' count for the collection associated with the key
70+
* Decrement the item count for the collection associated with the key
7171
*/
72-
void decrementDiskCount();
72+
void decrementItemCount();
7373

7474
/**
7575
* Update the on disk size (bytes) for the collection associated with
@@ -86,15 +86,15 @@ bool StatsUpdate::isLogicallyDeleted(uint64_t seqno) const {
8686
return handle.isLogicallyDeleted(seqno);
8787
}
8888

89-
void StatsUpdate::incrementDiskCount() {
89+
void StatsUpdate::incrementItemCount() {
9090
if (!handle.getKey().isInSystemCollection()) {
91-
handle.incrementDiskCount();
91+
handle.incrementItemCount();
9292
}
9393
}
9494

95-
void StatsUpdate::decrementDiskCount() {
95+
void StatsUpdate::decrementItemCount() {
9696
if (!handle.getKey().isInSystemCollection()) {
97-
handle.decrementDiskCount();
97+
handle.decrementItemCount();
9898
}
9999
}
100100

@@ -146,7 +146,7 @@ void StatsUpdate::insert(bool isCommitted,
146146
bool isDelete,
147147
ssize_t diskSizeDelta) {
148148
if (!isDelete && isCommitted) {
149-
incrementDiskCount();
149+
incrementItemCount();
150150
} // else inserting a tombstone or it's a prepare
151151

152152
if (isCommitted) {
@@ -162,7 +162,7 @@ void StatsUpdate::update(bool isCommitted, ssize_t diskSizeDelta) {
162162

163163
void StatsUpdate::remove(bool isCommitted, ssize_t diskSizeDelta) {
164164
if (isCommitted) {
165-
decrementDiskCount();
165+
decrementItemCount();
166166
} // else inserting a tombstone or it's a prepare
167167

168168
if (isCommitted) {

engines/ep/src/collections/vbucket_manifest.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,7 @@ uint64_t Manifest::getItemCount(CollectionID collection) const {
739739
__FUNCTION__,
740740
"failed find of collection:" + collection.to_string());
741741
}
742-
// For now link through to disk count
743-
// @todo: ephemeral support
744-
return itr->second.getDiskCount();
742+
return itr->second.getItemCount();
745743
}
746744

747745
uint64_t Manifest::getHighSeqno(CollectionID collection) const {
@@ -789,24 +787,24 @@ void Manifest::setPersistedHighSeqno(CollectionID collection,
789787
itr->second.setPersistedHighSeqno(value);
790788
}
791789

792-
void Manifest::incrementDiskCount(CollectionID collection) const {
790+
void Manifest::incrementItemCount(CollectionID collection) const {
793791
auto itr = map.find(collection);
794792
if (itr == map.end()) {
795793
throwException<std::invalid_argument>(
796794
__FUNCTION__,
797795
"failed find of collection:" + collection.to_string());
798796
}
799-
return itr->second.incrementDiskCount();
797+
return itr->second.incrementItemCount();
800798
}
801799

802-
void Manifest::decrementDiskCount(CollectionID collection) const {
800+
void Manifest::decrementItemCount(CollectionID collection) const {
803801
auto itr = map.find(collection);
804802
if (itr == map.end()) {
805803
throwException<std::invalid_argument>(
806804
__FUNCTION__,
807805
"failed find of collection:" + collection.to_string());
808806
}
809-
return itr->second.decrementDiskCount();
807+
return itr->second.decrementItemCount();
810808
}
811809

812810
bool Manifest::addCollectionStats(Vbid vbid,
@@ -874,7 +872,7 @@ bool Manifest::addScopeStats(Vbid vbid,
874872
vbid.get(),
875873
entry.getScopeID().to_string().c_str(),
876874
cid.to_string().c_str());
877-
add_casted_stat(buffer, entry.getDiskCount(), add_stat, cookie);
875+
add_casted_stat(buffer, entry.getItemCount(), add_stat, cookie);
878876
}
879877

880878
return true;

engines/ep/src/collections/vbucket_manifest.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,22 +436,22 @@ class Manifest {
436436
bool isLogicallyDeleted(const container::const_iterator entry,
437437
int64_t seqno) const;
438438

439-
void incrementDiskCount(const container::const_iterator entry) const {
439+
void incrementItemCount(const container::const_iterator entry) const {
440440
if (entry == map.end()) {
441441
throwException<std::invalid_argument>(__FUNCTION__,
442442
"iterator is invalid");
443443
}
444444

445-
entry->second.incrementDiskCount();
445+
entry->second.incrementItemCount();
446446
}
447447

448-
void decrementDiskCount(const container::const_iterator entry) const {
448+
void decrementItemCount(const container::const_iterator entry) const {
449449
if (entry == map.end()) {
450450
throwException<std::invalid_argument>(__FUNCTION__,
451451
"iterator is invalid");
452452
}
453453

454-
entry->second.decrementDiskCount();
454+
entry->second.decrementItemCount();
455455
}
456456

457457
void updateDiskSize(const container::const_iterator entry,
@@ -570,14 +570,14 @@ class Manifest {
570570
* called via a ReadHandle because the read lock only ensures the map
571571
* does not change.
572572
*/
573-
void incrementDiskCount(CollectionID collection) const;
573+
void incrementItemCount(CollectionID collection) const;
574574

575575
/**
576576
* Decrement the item count for the given collection. Const and can be
577577
* called via a ReadHandle because the read lock only ensures the map
578578
* does not change.
579579
*/
580-
void decrementDiskCount(CollectionID collection) const;
580+
void decrementItemCount(CollectionID collection) const;
581581

582582
container::const_iterator end() const {
583583
return map.end();

engines/ep/src/collections/vbucket_manifest_entry.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Collections::VB::ManifestEntry& Collections::VB::ManifestEntry::operator=(
3131
startSeqno = other.startSeqno;
3232
scopeID = other.scopeID;
3333
maxTtl = other.maxTtl;
34-
diskCount = other.diskCount;
34+
itemCount = other.itemCount;
3535
diskSize = other.diskSize;
3636
highSeqno.reset(other.highSeqno);
3737
persistedHighSeqno.store(other.persistedHighSeqno,
@@ -46,7 +46,7 @@ bool Collections::VB::ManifestEntry::operator==(
4646
const ManifestEntry& other) const {
4747
return scopeID == other.scopeID && startSeqno == other.startSeqno &&
4848
maxTtl == other.maxTtl && highSeqno == other.highSeqno &&
49-
diskCount == other.diskCount && diskSize == other.diskSize &&
49+
itemCount == other.itemCount && diskSize == other.diskSize &&
5050
persistedHighSeqno == other.persistedHighSeqno &&
5151
numOpsGet == other.numOpsGet && numOpsDelete == other.numOpsDelete &&
5252
numOpsStore == other.numOpsStore;
@@ -84,7 +84,7 @@ bool Collections::VB::ManifestEntry::addStats(const std::string& cid,
8484
add_casted_stat(buffer, getPersistedHighSeqno(), add_stat, cookie);
8585
checked_snprintf(
8686
buffer, bsize, "vb_%d:%s:items", vbid.get(), cid.c_str());
87-
add_casted_stat(buffer, getDiskCount(), add_stat, cookie);
87+
add_casted_stat(buffer, getItemCount(), add_stat, cookie);
8888

8989
if (getMaxTtl()) {
9090
checked_snprintf(
@@ -109,7 +109,7 @@ std::ostream& Collections::VB::operator<<(
109109
<< ", startSeqno:" << manifestEntry.getStartSeqno()
110110
<< ", highSeqno:" << manifestEntry.getHighSeqno()
111111
<< ", persistedHighSeqno:" << manifestEntry.getPersistedHighSeqno()
112-
<< ", diskCount:" << manifestEntry.getDiskCount();
112+
<< ", itemCount:" << manifestEntry.getItemCount();
113113

114114
if (manifestEntry.getMaxTtl()) {
115115
os << ", maxTtl:" << manifestEntry.getMaxTtl().value().count();

engines/ep/src/collections/vbucket_manifest_entry.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ManifestEntry {
4242
: startSeqno(startSeqno),
4343
scopeID(scopeID),
4444
maxTtl(std::move(maxTtl)),
45-
diskCount(0),
45+
itemCount(0),
4646
highSeqno(startSeqno),
4747
persistedHighSeqno(startSeqno) {
4848
}
@@ -81,24 +81,24 @@ class ManifestEntry {
8181
return maxTtl;
8282
}
8383

84-
/// increment how many items are stored on disk for this collection
85-
void incrementDiskCount() const {
86-
diskCount++;
84+
/// increment how many items are stored for this collection
85+
void incrementItemCount() const {
86+
itemCount++;
8787
}
8888

89-
/// decrement how many items are stored on disk for this collection
90-
void decrementDiskCount() const {
91-
diskCount--;
89+
/// decrement how many items are stored for this collection
90+
void decrementItemCount() const {
91+
itemCount--;
9292
}
9393

9494
/// set how many items this collection has stored
95-
void setDiskCount(uint64_t value) {
96-
diskCount = value;
95+
void setItemCount(uint64_t value) {
96+
itemCount = value;
9797
}
9898

99-
/// @return how many items are stored on disk for this collection
100-
uint64_t getDiskCount() const {
101-
return diskCount;
99+
/// @return how many items are stored for this collection
100+
uint64_t getItemCount() const {
101+
return itemCount;
102102
}
103103

104104
/// decrement the tracked total size (bytes) on disk for this collection
@@ -180,7 +180,7 @@ class ManifestEntry {
180180
return numOpsGet.load();
181181
}
182182
AccumulatedStats getStatsForSummary() const {
183-
return {getDiskCount(),
183+
return {getItemCount(),
184184
getDiskSize(),
185185
getOpsStore(),
186186
getOpsDelete(),
@@ -231,7 +231,7 @@ class ManifestEntry {
231231
* we can do stats updates as long as the read lock is held.
232232
* The write lock is really for the Manifest map being changed.
233233
*/
234-
mutable cb::NonNegativeCounter<uint64_t> diskCount;
234+
mutable cb::NonNegativeCounter<uint64_t> itemCount;
235235

236236
/**
237237
* The total size (bytes) of items in this collection on disk

engines/ep/src/collections/vbucket_manifest_handles.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace Collections::VB {
2424

2525
PersistedStats StatsReadHandle::getPersistedStats() const {
26-
return {itr->second.getDiskCount(),
26+
return {itr->second.getItemCount(),
2727
itr->second.getPersistedHighSeqno(),
2828
itr->second.getDiskSize()};
2929
}

engines/ep/src/collections/vbucket_manifest_handles.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ class ReadHandle {
153153
manifest->setHighSeqno(collection, value);
154154
}
155155

156-
void incrementDiskCount(CollectionID collection) const {
157-
manifest->incrementDiskCount(collection);
156+
void incrementItemCount(CollectionID collection) const {
157+
manifest->incrementItemCount(collection);
158158
}
159159

160-
void decrementDiskCount(CollectionID collection) const {
161-
manifest->decrementDiskCount(collection);
160+
void decrementItemCount(CollectionID collection) const {
161+
manifest->decrementItemCount(collection);
162162
}
163163

164164
bool addCollectionStats(Vbid vbid,
@@ -295,13 +295,13 @@ class CachingReadHandle : private ReadHandle {
295295
*
296296
* increment the key's collection item count by 1
297297
*/
298-
void incrementDiskCount() const {
298+
void incrementItemCount() const {
299299
// We may be flushing keys written to a dropped collection so can
300300
// have an invalid iterator or the id is not mapped (system)
301301
if (!valid()) {
302302
return;
303303
}
304-
return manifest->incrementDiskCount(itr);
304+
return manifest->incrementItemCount(itr);
305305
}
306306

307307
/**
@@ -313,13 +313,13 @@ class CachingReadHandle : private ReadHandle {
313313
*
314314
* decrement the key's collection item count by 1
315315
*/
316-
void decrementDiskCount() const {
316+
void decrementItemCount() const {
317317
// We may be flushing keys written to a dropped collection so can
318318
// have an invalid iterator or the id is not mapped (system)
319319
if (!valid()) {
320320
return;
321321
}
322-
return manifest->decrementDiskCount(itr);
322+
return manifest->decrementItemCount(itr);
323323
}
324324

325325
/**

engines/ep/src/ep_bucket.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ class EPDiskRollbackCB : public RollbackCB {
15261526
vb->incrNumTotalItems();
15271527
vb->getManifest()
15281528
.lock(preRbSeqnoItem->getKey())
1529-
.incrementDiskCount();
1529+
.incrementItemCount();
15301530
}
15311531
}
15321532
} else if (preRbSeqnoGetValue.getStatus() == ENGINE_KEY_ENOENT) {
@@ -1557,7 +1557,7 @@ class EPDiskRollbackCB : public RollbackCB {
15571557
// Irrespective of if the in-memory delete succeeded; the document
15581558
// doesn't exist on disk; so decrement the item count.
15591559
vb.decrNumTotalItems();
1560-
vb.getManifest().lock(item.getKey()).decrementDiskCount();
1560+
vb.getManifest().lock(item.getKey()).decrementItemCount();
15611561
}
15621562
}
15631563

engines/ep/src/vbucket.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,7 +3071,7 @@ void VBucket::collectionsRolledBack(KVStore& kvstore) {
30713071
auto stats =
30723072
kvstore.getCollectionStats(*kvstoreContext, collection.first);
30733073
if (stats) {
3074-
collection.second.setDiskCount(stats->itemCount);
3074+
collection.second.setItemCount(stats->itemCount);
30753075
collection.second.setDiskSize(stats->diskSize);
30763076
collection.second.resetPersistedHighSeqno(stats->highSeqno);
30773077
collection.second.resetHighSeqno(
@@ -3763,9 +3763,9 @@ void VBucket::doCollectionsStats(
37633763
cHandle.setHighSeqno(notifyCtx.bySeqno);
37643764

37653765
if (notifyCtx.itemCountDifference == 1) {
3766-
cHandle.incrementDiskCount();
3766+
cHandle.incrementItemCount();
37673767
} else if (notifyCtx.itemCountDifference == -1) {
3768-
cHandle.decrementDiskCount();
3768+
cHandle.decrementItemCount();
37693769
}
37703770
}
37713771

@@ -3775,9 +3775,9 @@ void VBucket::doCollectionsStats(const Collections::VB::ReadHandle& readHandle,
37753775
readHandle.setHighSeqno(collection, notifyCtx.bySeqno);
37763776

37773777
if (notifyCtx.itemCountDifference == 1) {
3778-
readHandle.incrementDiskCount(collection);
3778+
readHandle.incrementItemCount(collection);
37793779
} else if (notifyCtx.itemCountDifference == -1) {
3780-
readHandle.decrementDiskCount(collection);
3780+
readHandle.decrementItemCount(collection);
37813781
}
37823782
}
37833783

engines/ep/src/warmup.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ void Warmup::loadCollectionStatsForShard(uint16_t shardId) {
11671167
auto stats = kvstore->getCollectionStats(*kvstoreContext,
11681168
collection.first);
11691169
if (stats) {
1170-
collection.second.setDiskCount(stats->itemCount);
1170+
collection.second.setItemCount(stats->itemCount);
11711171
collection.second.setPersistedHighSeqno(stats->highSeqno);
11721172
collection.second.setDiskSize(stats->diskSize);
11731173
// Set the in memory high seqno - might be 0 in the case of the

0 commit comments

Comments
 (0)