summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-11-11 15:53:21 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-11-11 15:53:21 +0000
commit3a18235f9930847674501b825e74c7e3efccb41c (patch)
tree85c6e2e646c4163e7bd8beeb1b1e3bfbe1940eeb /searchcore
parent9c5c41e68a5b3166c4d0d8cac98ac5763957878a (diff)
Remove double book keeping of count.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp20
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h15
2 files changed, 4 insertions, 31 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp
index 6bc90033994..49e8d3eb23a 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp
@@ -13,7 +13,6 @@ LidStateVector::LidStateVector(unsigned int newSize, unsigned int newCapacity,
: _bv(newSize, newCapacity, generationHolder),
_lowest(trackLowest ? newSize : 0u),
_highest(0),
- _count(0u),
_trackLowest(trackLowest),
_trackHighest(trackHighest)
{
@@ -29,16 +28,12 @@ LidStateVector::resizeVector(uint32_t newSize, uint32_t newCapacity)
bool nolowest(_lowest == _bv.size());
if (_bv.size() > newSize) {
_bv.shrink(newSize);
- assert(_count >= internalCount());
- _count = internalCount();
}
if (_bv.capacity() < newCapacity) {
_bv.reserve(newCapacity);
- assert(_count == internalCount());
}
if (_bv.size() < newSize) {
_bv.extend(newSize);
- assert(_count == internalCount());
}
if (_trackLowest) {
if (nolowest) {
@@ -57,7 +52,6 @@ LidStateVector::resizeVector(uint32_t newSize, uint32_t newCapacity)
maybeUpdateHighest();
}
-
void
LidStateVector::updateLowest()
{
@@ -70,7 +64,6 @@ LidStateVector::updateLowest()
_lowest = lowest;
}
-
void
LidStateVector::updateHighest()
{
@@ -83,7 +76,6 @@ LidStateVector::updateHighest()
_highest = highest;
}
-
void
LidStateVector::setBit(unsigned int idx)
{
@@ -96,28 +88,16 @@ LidStateVector::setBit(unsigned int idx)
}
assert(!_bv.testBit(idx));
_bv.setBitAndMaintainCount(idx);
- ++_count;
- assert(_count == internalCount());
}
-
void
LidStateVector::clearBit(unsigned int idx)
{
assert(idx < _bv.size());
assert(_bv.testBit(idx));
_bv.clearBitAndMaintainCount(idx);
- --_count;
- assert(_count == internalCount());
maybeUpdateLowest();
maybeUpdateHighest();
}
-uint32_t
-LidStateVector::internalCount()
-{
- // Called by document db executor thread.
- return _bv.countTrueBits();
-}
-
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h
index 20fff60911c..be47676716b 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h
@@ -11,9 +11,8 @@ class LidStateVector
search::GrowableBitVector _bv;
uint32_t _lowest;
uint32_t _highest;
- uint32_t _count;
- bool _trackLowest;
- bool _trackHighest;
+ bool _trackLowest;
+ bool _trackHighest;
void updateLowest();
void updateHighest();
@@ -26,12 +25,6 @@ class LidStateVector
if (_trackHighest && _highest != 0 && !_bv.testBit(_highest))
updateHighest();
}
-
- /**
- * Get number of bits set in vector. Should only be called by
- * write thread.
- */
- uint32_t internalCount();
public:
LidStateVector(unsigned int newSize, unsigned int newCapacity,
@@ -48,7 +41,7 @@ public:
unsigned int byteSize() const {
return _bv.extraByteSize() + sizeof(LidStateVector);
}
- bool empty() const { return _count == 0u; }
+ bool empty() const { return count() == 0u; }
unsigned int getLowest() const { return _lowest; }
unsigned int getHighest() const { return _highest; }
@@ -58,7 +51,7 @@ public:
*/
uint32_t count() const {
// Called by document db executor thread or metrics related threads
- return _count;
+ return _bv.countTrueBits();
}
unsigned int getNextTrueBit(unsigned int idx) const {