Added test cases shrinking down full trees to one-leaf trees
This commit is contained in:
parent
0d26692048
commit
6127a9d6a8
@ -75,6 +75,10 @@ void DataNodeStore::remove(unique_ptr<DataNode> node) {
|
||||
_blockstore->remove(std::move(block));
|
||||
}
|
||||
|
||||
uint64_t DataNodeStore::numNodes() const {
|
||||
return _blockstore->numBlocks();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ public:
|
||||
|
||||
void remove(std::unique_ptr<DataNode> node);
|
||||
|
||||
uint64_t numNodes() const;
|
||||
//TODO Test remove(), overwriteNodeWith(), createNodeAsCopyFrom(), numNodes()
|
||||
|
||||
private:
|
||||
std::unique_ptr<DataNode> load(std::unique_ptr<blockstore::Block> block);
|
||||
|
||||
|
@ -48,5 +48,4 @@ TEST_F(DataTreeShrinkingTest, ShrinkATwoLeafTree_IntermediateBlocksAreDeleted) {
|
||||
EXPECT_EQ(nullptr, nodeStore.load(firstChildKey));
|
||||
}
|
||||
|
||||
//TODO Test Shrinking full trees down to 1-leaf-tree
|
||||
//TODO Test DepthFlags stay intact
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "testutils/DataTreeShrinkingTest.h"
|
||||
|
||||
using blobstore::onblocks::datatreestore::DataTree;
|
||||
using blobstore::onblocks::datanodestore::DataInnerNode;
|
||||
using blockstore::Key;
|
||||
|
||||
class DataTreeShrinkingTest_Structure: public DataTreeShrinkingTest {
|
||||
@ -127,3 +128,21 @@ TEST_F(DataTreeShrinkingTest_Structure, ShrinkAThreeLevelTreeWithThreeChildrenOf
|
||||
Shrink(key);
|
||||
EXPECT_IS_THREELEVEL_TREE_WITH_TWO_FULL_TWOLEVEL_TREES(key);
|
||||
}
|
||||
|
||||
TEST_F(DataTreeShrinkingTest_Structure, ShrinkAFullTwoLevelTreeDownToOneLeaf) {
|
||||
auto key = CreateFullTwoLevel()->key();
|
||||
for (int i = 0; i < DataInnerNode::MAX_STORED_CHILDREN-1; ++i) {
|
||||
Shrink(key);
|
||||
}
|
||||
EXPECT_IS_LEAF_NODE(key);
|
||||
EXPECT_EQ(1, nodeStore.numNodes());
|
||||
}
|
||||
|
||||
TEST_F(DataTreeShrinkingTest_Structure, ShrinkAFullThreeLevelTreeDownToOneLeaf) {
|
||||
auto key = CreateFullThreeLevel()->key();
|
||||
for (int i = 0; i < DataInnerNode::MAX_STORED_CHILDREN*DataInnerNode::MAX_STORED_CHILDREN-1; ++i) {
|
||||
Shrink(key);
|
||||
}
|
||||
EXPECT_IS_LEAF_NODE(key);
|
||||
EXPECT_EQ(1, nodeStore.numNodes());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user