Fix two bugs in DataTree::resizeNumBytes()
This commit is contained in:
parent
68182e523f
commit
13a76bd42a
@ -167,10 +167,10 @@ void DataTree::resizeNumBytes(uint64_t newNumBytes) {
|
||||
uint64_t currentNumBytes = numStoredBytes();
|
||||
assert(currentNumBytes % _nodeStore->layout().maxBytesPerLeaf() == 0);
|
||||
uint32_t currentNumLeaves = currentNumBytes / _nodeStore->layout().maxBytesPerLeaf();
|
||||
uint32_t newNumLeaves = utils::ceilDivision(newNumBytes, _nodeStore->layout().maxBytesPerLeaf());
|
||||
uint32_t newNumLeaves = std::max(1u, utils::ceilDivision(newNumBytes, _nodeStore->layout().maxBytesPerLeaf()));
|
||||
|
||||
for(uint32_t i = currentNumLeaves; i < newNumLeaves; ++i) {
|
||||
addDataLeaf();
|
||||
addDataLeaf()->resize(_nodeStore->layout().maxBytesPerLeaf());
|
||||
}
|
||||
for(uint32_t i = currentNumLeaves; i > newNumLeaves; --i) {
|
||||
removeLastDataLeaf();
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
const blockstore::Key &key() const;
|
||||
uint32_t maxBytesPerLeaf() const;
|
||||
|
||||
//TODO Remove flush() and instead call it implicitly on traverseLeaves()/resizeNumBytes()
|
||||
void flush() const;
|
||||
|
||||
void traverseLeaves(uint32_t beginIndex, uint32_t endIndex, std::function<void (datanodestore::DataLeafNode*, uint32_t)> func);
|
||||
|
Loading…
Reference in New Issue
Block a user