|
|
@ -21,50 +21,68 @@ INSTANTIATE_TEST_CASE_P(EmptyLastLeaf, DataTreeTest_NumStoredBytes_P, Values(0u)
|
|
|
|
INSTANTIATE_TEST_CASE_P(HalfFullLastLeaf, DataTreeTest_NumStoredBytes_P, Values(5u, 10u));
|
|
|
|
INSTANTIATE_TEST_CASE_P(HalfFullLastLeaf, DataTreeTest_NumStoredBytes_P, Values(5u, 10u));
|
|
|
|
INSTANTIATE_TEST_CASE_P(FullLastLeaf, DataTreeTest_NumStoredBytes_P, Values(static_cast<uint32_t>(DataNodeLayout(DataTreeTest_NumStoredBytes::BLOCKSIZE_BYTES).maxBytesPerLeaf())));
|
|
|
|
INSTANTIATE_TEST_CASE_P(FullLastLeaf, DataTreeTest_NumStoredBytes_P, Values(static_cast<uint32_t>(DataNodeLayout(DataTreeTest_NumStoredBytes::BLOCKSIZE_BYTES).maxBytesPerLeaf())));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO Test numLeaves() and numNodes() also two configurations with same number of bytes but different number of leaves (last leaf has 0 bytes)
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, SingleLeaf) {
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, SingleLeaf) {
|
|
|
|
BlockId blockId = CreateLeafWithSize(GetParam())->blockId();
|
|
|
|
BlockId blockId = CreateLeafWithSize(GetParam())->blockId();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
EXPECT_EQ(GetParam(), tree->numBytes());
|
|
|
|
EXPECT_EQ(GetParam(), tree->numBytes());
|
|
|
|
|
|
|
|
EXPECT_EQ(1, tree->numLeaves());
|
|
|
|
|
|
|
|
EXPECT_EQ(1, tree->numNodes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, TwoLeafTree) {
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, TwoLeafTree) {
|
|
|
|
BlockId blockId = CreateTwoLeafWithSecondLeafSize(GetParam())->blockId();
|
|
|
|
BlockId blockId = CreateTwoLeafWithSecondLeafSize(GetParam())->blockId();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf() + GetParam(), tree->numBytes());
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf() + GetParam(), tree->numBytes());
|
|
|
|
|
|
|
|
EXPECT_EQ(2, tree->numLeaves());
|
|
|
|
|
|
|
|
EXPECT_EQ(3, tree->numNodes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, FullTwolevelTree) {
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, FullTwolevelTree) {
|
|
|
|
BlockId blockId = CreateFullTwoLevelWithLastLeafSize(GetParam())->blockId();
|
|
|
|
BlockId blockId = CreateFullTwoLevelWithLastLeafSize(GetParam())->blockId();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf()*(nodeStore->layout().maxChildrenPerInnerNode()-1) + GetParam(), tree->numBytes());
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf()*(nodeStore->layout().maxChildrenPerInnerNode()-1) + GetParam(), tree->numBytes());
|
|
|
|
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxChildrenPerInnerNode(), tree->numLeaves());
|
|
|
|
|
|
|
|
EXPECT_EQ(1 + nodeStore->layout().maxChildrenPerInnerNode(), tree->numNodes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, ThreeLevelTreeWithOneChild) {
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, ThreeLevelTreeWithOneChild) {
|
|
|
|
BlockId blockId = CreateThreeLevelWithOneChildAndLastLeafSize(GetParam())->blockId();
|
|
|
|
BlockId blockId = CreateThreeLevelWithOneChildAndLastLeafSize(GetParam())->blockId();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf() + GetParam(), tree->numBytes());
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf() + GetParam(), tree->numBytes());
|
|
|
|
|
|
|
|
EXPECT_EQ(2, tree->numLeaves());
|
|
|
|
|
|
|
|
EXPECT_EQ(4, tree->numNodes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, ThreeLevelTreeWithTwoChildren) {
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, ThreeLevelTreeWithTwoChildren) {
|
|
|
|
BlockId blockId = CreateThreeLevelWithTwoChildrenAndLastLeafSize(GetParam())->blockId();
|
|
|
|
BlockId blockId = CreateThreeLevelWithTwoChildrenAndLastLeafSize(GetParam())->blockId();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf()*nodeStore->layout().maxChildrenPerInnerNode() + nodeStore->layout().maxBytesPerLeaf() + GetParam(), tree->numBytes());
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf()*nodeStore->layout().maxChildrenPerInnerNode() + nodeStore->layout().maxBytesPerLeaf() + GetParam(), tree->numBytes());
|
|
|
|
|
|
|
|
EXPECT_EQ(2 + nodeStore->layout().maxChildrenPerInnerNode(), tree->numLeaves());
|
|
|
|
|
|
|
|
EXPECT_EQ(5 + nodeStore->layout().maxChildrenPerInnerNode(), tree->numNodes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, ThreeLevelTreeWithThreeChildren) {
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, ThreeLevelTreeWithThreeChildren) {
|
|
|
|
BlockId blockId = CreateThreeLevelWithThreeChildrenAndLastLeafSize(GetParam())->blockId();
|
|
|
|
BlockId blockId = CreateThreeLevelWithThreeChildrenAndLastLeafSize(GetParam())->blockId();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
EXPECT_EQ(2*nodeStore->layout().maxBytesPerLeaf()*nodeStore->layout().maxChildrenPerInnerNode() + nodeStore->layout().maxBytesPerLeaf() + GetParam(), tree->numBytes());
|
|
|
|
EXPECT_EQ(2*nodeStore->layout().maxBytesPerLeaf()*nodeStore->layout().maxChildrenPerInnerNode() + nodeStore->layout().maxBytesPerLeaf() + GetParam(), tree->numBytes());
|
|
|
|
|
|
|
|
EXPECT_EQ(2 + 2*nodeStore->layout().maxChildrenPerInnerNode(), tree->numLeaves());
|
|
|
|
|
|
|
|
EXPECT_EQ(6 + 2*nodeStore->layout().maxChildrenPerInnerNode(), tree->numNodes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, FullThreeLevelTree) {
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, FullThreeLevelTree) {
|
|
|
|
BlockId blockId = CreateFullThreeLevelWithLastLeafSize(GetParam())->blockId();
|
|
|
|
BlockId blockId = CreateFullThreeLevelWithLastLeafSize(GetParam())->blockId();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf()*nodeStore->layout().maxChildrenPerInnerNode()*(nodeStore->layout().maxChildrenPerInnerNode()-1) + nodeStore->layout().maxBytesPerLeaf()*(nodeStore->layout().maxChildrenPerInnerNode()-1) + GetParam(), tree->numBytes());
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf()*nodeStore->layout().maxChildrenPerInnerNode()*(nodeStore->layout().maxChildrenPerInnerNode()-1) + nodeStore->layout().maxBytesPerLeaf()*(nodeStore->layout().maxChildrenPerInnerNode()-1) + GetParam(), tree->numBytes());
|
|
|
|
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxChildrenPerInnerNode()*nodeStore->layout().maxChildrenPerInnerNode(), tree->numLeaves());
|
|
|
|
|
|
|
|
EXPECT_EQ(1 + nodeStore->layout().maxChildrenPerInnerNode() + nodeStore->layout().maxChildrenPerInnerNode()*nodeStore->layout().maxChildrenPerInnerNode(), tree->numNodes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, FourLevelMinDataTree) {
|
|
|
|
TEST_P(DataTreeTest_NumStoredBytes_P, FourLevelMinDataTree) {
|
|
|
|
BlockId blockId = CreateFourLevelMinDataWithLastLeafSize(GetParam())->blockId();
|
|
|
|
BlockId blockId = CreateFourLevelMinDataWithLastLeafSize(GetParam())->blockId();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
auto tree = treeStore.load(blockId).value();
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf()*nodeStore->layout().maxChildrenPerInnerNode()*nodeStore->layout().maxChildrenPerInnerNode() + GetParam(), tree->numBytes());
|
|
|
|
EXPECT_EQ(nodeStore->layout().maxBytesPerLeaf()*nodeStore->layout().maxChildrenPerInnerNode()*nodeStore->layout().maxChildrenPerInnerNode() + GetParam(), tree->numBytes());
|
|
|
|
|
|
|
|
EXPECT_EQ(1 + nodeStore->layout().maxChildrenPerInnerNode()*nodeStore->layout().maxChildrenPerInnerNode(), tree->numLeaves());
|
|
|
|
|
|
|
|
EXPECT_EQ(5 + nodeStore->layout().maxChildrenPerInnerNode() + nodeStore->layout().maxChildrenPerInnerNode()*nodeStore->layout().maxChildrenPerInnerNode(), tree->numNodes());
|
|
|
|
}
|
|
|
|
}
|
|
|
|