Commit d39bda09 authored by Philipp Götze's avatar Philipp Götze
Browse files

🚚 Moved test cases from src/test to test +++ some adaptions

parent dbd200ea
...@@ -55,21 +55,23 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") { ...@@ -55,21 +55,23 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") {
auto q = pop.root(); auto q = pop.root();
auto &rootRef = *q; auto &rootRef = *q;
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>("heap.alloc_class.128.desc",
PBPTreeType4::AllocClass);
if (!rootRef.btree4) if (!rootRef.btree4)
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(); }); transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(alloc_class); });
if (!rootRef.btree6) if (!rootRef.btree6)
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(); }); transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(alloc_class); });
if (!rootRef.btree10) if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(); }); transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(alloc_class); });
if (!rootRef.btree12) if (!rootRef.btree12)
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(); }); transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(alloc_class); });
if (!rootRef.btree20) if (!rootRef.btree20)
transaction::run(pop, [&] { rootRef.btree20 = make_persistent<PBPTreeType20>(); }); transaction::run(pop, [&] { rootRef.btree20 = make_persistent<PBPTreeType20>(alloc_class); });
/* -------------------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------------------- */
SECTION("Looking up a key in an inner node") { SECTION("Looking up a key in an inner node") {
...@@ -932,7 +934,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") { ...@@ -932,7 +934,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") {
auto btree = rootRef.btree10; auto btree = rootRef.btree10;
transaction::run(pop, [&] { transaction::run(pop, [&] {
if(btree) delete_persistent<PBPTreeType10>(btree); if(btree) delete_persistent<PBPTreeType10>(btree);
btree = make_persistent<PBPTreeType10>(); btree = make_persistent<PBPTreeType10>(alloc_class);
auto &btreeRef = *btree; auto &btreeRef = *btree;
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
btreeRef.insert(i, i * 2); btreeRef.insert(i, i * 2);
...@@ -956,7 +958,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") { ...@@ -956,7 +958,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") {
transaction::run(pop, [&] { transaction::run(pop, [&] {
if (btree) delete_persistent<PBPTreeType4>(btree); if (btree) delete_persistent<PBPTreeType4>(btree);
btree = make_persistent<PBPTreeType4>(); btree = make_persistent<PBPTreeType4>(alloc_class);
auto &btreeRef = *btree; auto &btreeRef = *btree;
...@@ -1005,7 +1007,6 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") { ...@@ -1005,7 +1007,6 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") {
REQUIRE(leafRef.bits.get_ro().all()); REQUIRE(leafRef.bits.get_ro().all());
} }
} }
} }
......
...@@ -55,21 +55,23 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") { ...@@ -55,21 +55,23 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") {
auto q = pop.root(); auto q = pop.root();
auto &rootRef = *q; auto &rootRef = *q;
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>("heap.alloc_class.128.desc",
PBPTreeType4::AllocClass);
if (!rootRef.btree4) if (!rootRef.btree4)
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(); }); transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(alloc_class); });
if (!rootRef.btree6) if (!rootRef.btree6)
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(); }); transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(alloc_class); });
if (!rootRef.btree10) if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(); }); transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(alloc_class); });
if (!rootRef.btree12) if (!rootRef.btree12)
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(); }); transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(alloc_class); });
if (!rootRef.btree20) if (!rootRef.btree20)
transaction::run(pop, [&] { rootRef.btree20 = make_persistent<PBPTreeType20>(); }); transaction::run(pop, [&] { rootRef.btree20 = make_persistent<PBPTreeType20>(alloc_class); });
/* -------------------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------------------- */
SECTION("Looking up a key in an inner node") { SECTION("Looking up a key in an inner node") {
...@@ -873,7 +875,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") { ...@@ -873,7 +875,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") {
REQUIRE(std::equal(std::begin(expectedKeys), std::end(expectedKeys), REQUIRE(std::equal(std::begin(expectedKeys), std::end(expectedKeys),
std::begin(nodeRef.keys.get_ro()))); std::begin(nodeRef.keys.get_ro())));
std::array<int, 3> expectedKeys2{{12, 13, 14}}; std::array<int, 3> expectedKeys2{{13, 14, 12}};
const auto leaf3 = nodeRef.children.get_ro()[4].leaf; const auto leaf3 = nodeRef.children.get_ro()[4].leaf;
auto &leaf3Ref = *leaf3; auto &leaf3Ref = *leaf3;
std::vector<int> leaf3Keys{}; std::vector<int> leaf3Keys{};
...@@ -932,7 +934,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") { ...@@ -932,7 +934,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") {
auto btree = rootRef.btree10; auto btree = rootRef.btree10;
transaction::run(pop, [&] { transaction::run(pop, [&] {
if(btree) delete_persistent<PBPTreeType10>(btree); if(btree) delete_persistent<PBPTreeType10>(btree);
btree = make_persistent<PBPTreeType10>(); btree = make_persistent<PBPTreeType10>(alloc_class);
auto &btreeRef = *btree; auto &btreeRef = *btree;
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
btreeRef.insert(i, i * 2); btreeRef.insert(i, i * 2);
......
include(../../cmake/Testing.cmake.in) include(../cmake/Testing.cmake.in)
#============================================= #=============================================
# define the test data directory for the input and output # define the test data directory for the input and output
......
...@@ -55,21 +55,23 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -55,21 +55,23 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
auto q = pop.root(); auto q = pop.root();
auto &rootRef = *q; auto &rootRef = *q;
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>("heap.alloc_class.128.desc",
FPTreeType4::AllocClass);
if (!rootRef.btree4) if (!rootRef.btree4)
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<FPTreeType4>(); }); transaction::run(pop, [&] { rootRef.btree4 = make_persistent<FPTreeType4>(alloc_class); });
if (!rootRef.btree6) if (!rootRef.btree6)
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<FPTreeType6>(); }); transaction::run(pop, [&] { rootRef.btree6 = make_persistent<FPTreeType6>(alloc_class); });
if (!rootRef.btree10) if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<FPTreeType10>(); }); transaction::run(pop, [&] { rootRef.btree10 = make_persistent<FPTreeType10>(alloc_class); });
if (!rootRef.btree12) if (!rootRef.btree12)
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<FPTreeType12>(); }); transaction::run(pop, [&] { rootRef.btree12 = make_persistent<FPTreeType12>(alloc_class); });
if (!rootRef.btree20) if (!rootRef.btree20)
transaction::run(pop, [&] { rootRef.btree20 = make_persistent<FPTreeType20>(); }); transaction::run(pop, [&] { rootRef.btree20 = make_persistent<FPTreeType20>(alloc_class); });
/* -------------------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------------------- */
SECTION("Looking up a key in an inner node") { SECTION("Looking up a key in an inner node") {
...@@ -95,8 +97,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -95,8 +97,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
auto &nodeRef = *node; auto &nodeRef = *node;
for (auto i = 0; i < 10; i++) { for (auto i = 0; i < 10; i++) {
nodeRef.keys.get_rw()[i] = i + 1; nodeRef.keys.get_rw()[i] = i + 1;
nodeRef.search.get_rw().b.set(i); nodeRef.bits.get_rw().set(i);
nodeRef.search.get_rw().fp[i] = btree.fpHash(i + 1); nodeRef.fp.get_rw()[i] = btree.fpHash(i + 1);
} }
REQUIRE(btree.lookupPositionInLeafNode(node, 1) == 0); REQUIRE(btree.lookupPositionInLeafNode(node, 1) == 0);
...@@ -396,22 +398,22 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -396,22 +398,22 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto i = 0; i < 4; i++) { for (auto i = 0; i < 4; i++) {
node1Ref.keys.get_rw()[i] = i; node1Ref.keys.get_rw()[i] = i;
node1Ref.values.get_rw()[i] = i + 100; node1Ref.values.get_rw()[i] = i + 100;
node1Ref.search.get_rw().b.set(i); node1Ref.bits.get_rw().set(i);
node1Ref.search.get_rw().fp[i] = btree.fpHash(i); node1Ref.fp.get_rw()[i] = btree.fpHash(i);
} }
for (auto i = 0; i < 4; i++) { for (auto i = 0; i < 4; i++) {
node2Ref.keys.get_rw()[i] = i + 10; node2Ref.keys.get_rw()[i] = i + 10;
node2Ref.values.get_rw()[i] = i + 200; node2Ref.values.get_rw()[i] = i + 200;
node2Ref.search.get_rw().b.set(i); node2Ref.bits.get_rw().set(i);
node2Ref.search.get_rw().fp[i] = btree.fpHash(i + 10); node2Ref.fp.get_rw()[i] = btree.fpHash(i + 10);
} }
node1Ref.nextLeaf = node2; node1Ref.nextLeaf = node2;
btree.mergeLeafNodes(node1, node2); btree.mergeLeafNodes(node1, node2);
REQUIRE(node1Ref.nextLeaf == nullptr); REQUIRE(node1Ref.nextLeaf == nullptr);
REQUIRE(node1Ref.search.get_ro().b.count() == 8); REQUIRE(node1Ref.bits.get_ro().count() == 8);
std::array<int, 8> expectedKeys{{0, 1, 2, 3, 10, 11, 12, 13}}; std::array<int, 8> expectedKeys{{0, 1, 2, 3, 10, 11, 12, 13}};
std::array<int, 8> expectedValues{{100, 101, 102, 103, 200, 201, 202, 203}}; std::array<int, 8> expectedValues{{100, 101, 102, 103, 200, 201, 202, 203}};
...@@ -433,20 +435,20 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -433,20 +435,20 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto i = 0; i < 8; i++) { for (auto i = 0; i < 8; i++) {
node1Ref.keys.get_rw()[i] = i + 1; node1Ref.keys.get_rw()[i] = i + 1;
node1Ref.values.get_rw()[i] = i * 100; node1Ref.values.get_rw()[i] = i * 100;
node1Ref.search.get_rw().b.set(i); node1Ref.bits.get_rw().set(i);
node1Ref.search.get_rw().fp[i] = btree.fpHash(i+1); node1Ref.fp.get_rw()[i] = btree.fpHash(i+1);
} }
for (auto i = 0; i < 4; i++) { for (auto i = 0; i < 4; i++) {
node2Ref.keys.get_rw()[i] = i + 11; node2Ref.keys.get_rw()[i] = i + 11;
node2Ref.values.get_rw()[i] = i * 200; node2Ref.values.get_rw()[i] = i * 200;
node2Ref.search.get_rw().b.set(i); node2Ref.bits.get_rw().set(i);
node2Ref.search.get_rw().fp[i] = btree.fpHash(i+11); node2Ref.fp.get_rw()[i] = btree.fpHash(i+11);
} }
btree.balanceLeafNodes(node1, node2); btree.balanceLeafNodes(node1, node2);
REQUIRE(node2Ref.search.get_ro().b.count() == 6); REQUIRE(node2Ref.bits.get_ro().count() == 6);
REQUIRE(node1Ref.search.get_ro().b.count() == 6); REQUIRE(node1Ref.bits.get_ro().count() == 6);
std::array<int, 6> expectedKeys1{{1, 2, 3, 4, 5, 6}}; std::array<int, 6> expectedKeys1{{1, 2, 3, 4, 5, 6}};
std::array<int, 6> expectedValues1{{0, 100, 200, 300, 400, 500}}; std::array<int, 6> expectedValues1{{0, 100, 200, 300, 400, 500}};
...@@ -497,7 +499,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -497,7 +499,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
btree.depth = 1; btree.depth = 1;
btree.underflowAtLeafLevel(parent, 1, leaf2); btree.underflowAtLeafLevel(parent, 1, leaf2);
REQUIRE(leaf1Ref.search.get_ro().b.count() == 5); REQUIRE(leaf1Ref.bits.get_ro().count() == 5);
REQUIRE(btree.rootNode.leaf == leaf1); REQUIRE(btree.rootNode.leaf == leaf1);
std::array<int, 5> expectedKeys{{1, 2, 3, 4, 5}}; std::array<int, 5> expectedKeys{{1, 2, 3, 4, 5}};
...@@ -545,7 +547,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -545,7 +547,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
btree.rootNode = parent; btree.rootNode = parent;
btree.underflowAtLeafLevel(parent, 1, leaf2); btree.underflowAtLeafLevel(parent, 1, leaf2);
REQUIRE(leaf1Ref.search.get_ro().b.count() == 5); REQUIRE(leaf1Ref.bits.get_ro().count() == 5);
REQUIRE(btree.rootNode.branch == parent); REQUIRE(btree.rootNode.branch == parent);
REQUIRE(parent->numKeys == 1); REQUIRE(parent->numKeys == 1);
} }
...@@ -577,8 +579,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -577,8 +579,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
parentRef.children[1] = leaf2; parentRef.children[1] = leaf2;
btree.underflowAtLeafLevel(parent, 1, leaf2); btree.underflowAtLeafLevel(parent, 1, leaf2);
REQUIRE(leaf1Ref.search.get_ro().b.count() == 3); REQUIRE(leaf1Ref.bits.get_ro().count() == 3);
REQUIRE(leaf2Ref.search.get_ro().b.count() == 3); REQUIRE(leaf2Ref.bits.get_ro().count() == 3);
std::array<int, 3> expectedKeys1{{1, 2, 3}}; std::array<int, 3> expectedKeys1{{1, 2, 3}};
std::array<int, 3> expectedValues1{{10, 20, 30}}; std::array<int, 3> expectedValues1{{10, 20, 30}};
...@@ -707,21 +709,21 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -707,21 +709,21 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto i = 0; i < 9; i++) { for (auto i = 0; i < 9; i++) {
nodeRef.keys.get_rw()[i] = (i + 1) * 2; nodeRef.keys.get_rw()[i] = (i + 1) * 2;
nodeRef.values.get_rw()[i] = (i * 2) + 100; nodeRef.values.get_rw()[i] = (i * 2) + 100;
nodeRef.search.get_rw().b.set(i); nodeRef.bits.get_rw().set(i);
nodeRef.search.get_rw().fp[i] = btree.fpHash((i + 1) * 2); nodeRef.fp.get_rw()[i] = btree.fpHash((i + 1) * 2);
} }
res = btree.insertInLeafNode(node, 5, 5000, &splitInfo); res = btree.insertInLeafNode(node, 5, 5000, &splitInfo);
REQUIRE(res == false); REQUIRE(res == false);
REQUIRE(nodeRef.search.get_ro().b.count() == 10); REQUIRE(nodeRef.bits.get_ro().count() == 10);
res = btree.insertInLeafNode(node, 1, 1, &splitInfo); res = btree.insertInLeafNode(node, 1, 1, &splitInfo);
REQUIRE(res == false); REQUIRE(res == false);
REQUIRE(nodeRef.search.get_ro().b.count() == 11); REQUIRE(nodeRef.bits.get_ro().count() == 11);
res = btree.insertInLeafNode(node, 2, 1000, &splitInfo); res = btree.insertInLeafNode(node, 2, 1000, &splitInfo);
REQUIRE(res == false); REQUIRE(res == false);
REQUIRE(nodeRef.search.get_ro().b.count() == 11); REQUIRE(nodeRef.bits.get_ro().count() == 11);
std::array<int, 11> expectedKeys{{1, 2, 4, 5, 6, 8, 10, 12, 14, 16, 18}}; std::array<int, 11> expectedKeys{{1, 2, 4, 5, 6, 8, 10, 12, 14, 16, 18}};
std::array<int, 11> expectedValues{{1, 102, 104, 106, 108, 110, 112, 114, 116, 1000, 5000}}; std::array<int, 11> expectedValues{{1, 102, 104, 106, 108, 110, 112, 114, 116, 1000, 5000}};
...@@ -754,14 +756,14 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -754,14 +756,14 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto i = 0; i < 9; i++) { for (auto i = 0; i < 9; i++) {
nodeRef.keys.get_rw()[i] = (i + 1) * 2; nodeRef.keys.get_rw()[i] = (i + 1) * 2;
nodeRef.values.get_rw()[i] = (i * 2) + 100; nodeRef.values.get_rw()[i] = (i * 2) + 100;
nodeRef.search.get_rw().b.set(i); nodeRef.bits.get_rw().set(i);
nodeRef.search.get_rw().fp[i] = btree.fpHash((i + 1) * 2); nodeRef.fp.get_rw()[i] = btree.fpHash((i + 1) * 2);
} }
btree.insertInLeafNodeAtPosition(node, 9, 5, 5000); btree.insertInLeafNodeAtPosition(node, 9, 5, 5000);
REQUIRE(nodeRef.search.get_ro().b.count() == 10); REQUIRE(nodeRef.bits.get_ro().count() == 10);
btree.insertInLeafNodeAtPosition(node, 10, 1, 1); btree.insertInLeafNodeAtPosition(node, 10, 1, 1);
REQUIRE(nodeRef.search.get_ro().b.count() == 11); REQUIRE(nodeRef.bits.get_ro().count() == 11);
std::array<int, 11> expectedKeys{{1, 2, 4, 5, 6, 8, 10, 12, 14, 16, 18}}; std::array<int, 11> expectedKeys{{1, 2, 4, 5, 6, 8, 10, 12, 14, 16, 18}};
std::array<int, 11> expectedValues{{1, 100, 102,104, 106, 108, 110, 112, 114, 116, 5000}}; std::array<int, 11> expectedValues{{1, 100, 102,104, 106, 108, 110, 112, 114, 116, 5000}};
...@@ -803,7 +805,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -803,7 +805,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
btree.depth = 2; btree.depth = 2;
btree.insertInBranchNode(node, 1, 11, 112, &splitInfo); btree.insertInBranchNode(node, 1, 11, 112, &splitInfo);
REQUIRE(leaf2->search.get_ro().b.count() == 3); REQUIRE(leaf2->bits.get_ro().count() == 3);
} }
/* -------------------------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------------------------- */
...@@ -833,7 +835,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -833,7 +835,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
btree.depth = 2; btree.depth = 2;
btree.insertInBranchNode(node, 1, 12, 112, &splitInfo); btree.insertInBranchNode(node, 1, 12, 112, &splitInfo);
REQUIRE(leaf2->search.get_ro().b.count() == 2); REQUIRE(leaf2->bits.get_ro().count() == 2);
REQUIRE(node->numKeys == 2); REQUIRE(node->numKeys == 2);
std::array<int, 2> expectedKeys{{10, 12}}; std::array<int, 2> expectedKeys{{10, 12}};
...@@ -843,7 +845,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -843,7 +845,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
auto &leaf3Ref = *nodeRef.children[2].leaf; auto &leaf3Ref = *nodeRef.children[2].leaf;
std::vector<int> actualKeys{}; std::vector<int> actualKeys{};
for(auto i = 0u; i < 4; i++) for(auto i = 0u; i < 4; i++)
if(leaf3Ref.search.get_ro().b.test(i)) if(leaf3Ref.bits.get_ro().test(i))
actualKeys.push_back(leaf3Ref.keys.get_ro()[i]); actualKeys.push_back(leaf3Ref.keys.get_ro()[i]);
std::sort(std::begin(actualKeys), std::end(actualKeys)); std::sort(std::begin(actualKeys), std::end(actualKeys));
REQUIRE(std::equal(std::begin(expectedKeys2), std::end(expectedKeys2), std::begin(actualKeys))); REQUIRE(std::equal(std::begin(expectedKeys2), std::end(expectedKeys2), std::begin(actualKeys)));
...@@ -858,14 +860,14 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -858,14 +860,14 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto i = 0; i < 9; i++) { for (auto i = 0; i < 9; i++) {
nodeRef.keys.get_rw()[i] = i + 1; nodeRef.keys.get_rw()[i] = i + 1;
nodeRef.values.get_rw()[i] = i + 100; nodeRef.values.get_rw()[i] = i + 100;
nodeRef.search.get_rw().b.set(i); nodeRef.bits.get_rw().set(i);
nodeRef.search.get_rw().fp[i] = btree.fpHash(i + 1); nodeRef.fp.get_rw()[i] = btree.fpHash(i + 1);
} }
REQUIRE(btree.eraseFromLeafNode(node, 5) == true); REQUIRE(btree.eraseFromLeafNode(node, 5) == true);
REQUIRE(nodeRef.search.get_ro().b.count() == 8); REQUIRE(nodeRef.bits.get_ro().count() == 8);
REQUIRE(btree.eraseFromLeafNode(node, 15) == false); REQUIRE(btree.eraseFromLeafNode(node, 15) == false);
REQUIRE(nodeRef.search.get_ro().b.count() == 8); REQUIRE(nodeRef.bits.get_ro().count() == 8);
std::array<int, 8> expectedKeys{{1, 2, 3, 4, 6, 7, 8, 9 }}; std::array<int, 8> expectedKeys{{1, 2, 3, 4, 6, 7, 8, 9 }};
std::array<int, 8> expectedValues{ std::array<int, 8> expectedValues{
...@@ -899,7 +901,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -899,7 +901,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
auto btree = rootRef.btree10; auto btree = rootRef.btree10;
transaction::run(pop, [&] { transaction::run(pop, [&] {
delete_persistent<FPTreeType10>(btree); delete_persistent<FPTreeType10>(btree);
btree = make_persistent<FPTreeType10>(); btree = make_persistent<FPTreeType10>(alloc_class);
auto &btreeRef = *btree; auto &btreeRef = *btree;
for (int i = 0; i < 50; ++i) for (int i = 0; i < 50; ++i)
btreeRef.insert(i, i * 2); btreeRef.insert(i, i * 2);
...@@ -922,7 +924,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -922,7 +924,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
transaction::run(pop, [&] { transaction::run(pop, [&] {
if (btree) delete_persistent<FPTreeType4>(btree); if (btree) delete_persistent<FPTreeType4>(btree);
btree = make_persistent<FPTreeType4>(); btree = make_persistent<FPTreeType4>(alloc_class);
auto &btreeRef = *btree; auto &btreeRef = *btree;
...@@ -931,8 +933,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -931,8 +933,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto k = 0u; k < 4; ++k) { for (auto k = 0u; k < 4; ++k) {
pLeafRef.keys.get_rw()[k] = k + 1; pLeafRef.keys.get_rw()[k] = k + 1;
pLeafRef.values.get_rw()[k] = k + 1; pLeafRef.values.get_rw()[k] = k + 1;
pLeafRef.search.get_rw().fp[k] = btreeRef.fpHash(k+1); pLeafRef.fp.get_rw()[k] = btreeRef.fpHash(k+1);
pLeafRef.search.get_rw().b.set(k); pLeafRef.bits.get_rw().set(k);
} }
btreeRef.leafList = prevLeaf; btreeRef.leafList = prevLeaf;
...@@ -943,8 +945,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -943,8 +945,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto k = 0u; k < 4; ++k) { for (auto k = 0u; k < 4; ++k) {
leafRef.keys.get_rw()[k] = k + 1 + l * 4; leafRef.keys.get_rw()[k] = k + 1 + l * 4;
leafRef.values.get_rw()[k] = k + 1 + l * 4; leafRef.values.get_rw()[k] = k + 1 + l * 4;
leafRef.search.get_rw().fp[k] = btreeRef.fpHash(k+1+l*4); leafRef.fp.get_rw()[k] = btreeRef.fpHash(k+1+l*4);
leafRef.search.get_rw().b.set(k); leafRef.bits.get_rw().set(k);
} }
prevLeaf = newLeaf; prevLeaf = newLeaf;
} }
...@@ -973,8 +975,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") { ...@@ -973,8 +975,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
std::array<uint8_t, 4> expectedHashes {{1, 2, 3, 4}}; std::array<uint8_t, 4> expectedHashes {{1, 2, 3, 4}};
std::transform(expectedHashes.begin(), expectedHashes.end(), expectedHashes.begin(), std::transform(expectedHashes.begin(), expectedHashes.end(), expectedHashes.begin(),
[b1, b2, &btreeRef](int k) { return btreeRef.fpHash(k + b2 * 4 + b1 * 20); }); [b1, b2, &btreeRef](int k) { return btreeRef.fpHash(k + b2 * 4 + b1 * 20); });
REQUIRE(leafRef.search.get_ro().fp == expectedHashes); REQUIRE(leafRef.fp.get_ro() == expectedHashes);
REQUIRE(leafRef.search.get_ro().b.all()); REQUIRE(leafRef.bits.get_ro().all());
} }
} }
} }
......
...@@ -60,21 +60,23 @@ TEST_CASE("Finding the leaf node containing a key", "[HPBPTree]") { ...@@ -60,21 +60,23 @@ TEST_CASE("Finding the leaf node containing a key", "[HPBPTree]") {
} }
auto q = pop.root(); auto q = pop.root();
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>("heap.alloc_class.128.desc",
HPBPTreeType4::AllocClass);
if (!q->btree1) if (!q->btree1)
transaction::run(pop, [&] { q->btree1 = make_persistent<HPBPTreeType>(); }); transaction::run(pop, [&] { q->btree1 = make_persistent<HPBPTreeType>(alloc_class); });
if (!q->btree2) if (!q->btree2)
transaction::run(pop, [&] { q->btree2 = make_persistent<HPBPTreeType2>(); }); transaction::run(pop, [&] { q->btree2 = make_persistent<HPBPTreeType2>(alloc_class); });
if (!q->btree3) if (!q->btree3)
transaction::run(pop, [&] { q->btree3 = make_persistent<HPBPTreeType3>(); }); transaction::run(pop, [&] { q->btree3 = make_persistent<HPBPTreeType3>(alloc_class); });
if (!q->btree4)