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]") {
auto q = pop.root();
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)
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(); });
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(alloc_class); });
if (!rootRef.btree6)
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(); });
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(alloc_class); });
if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(); });
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(alloc_class); });
if (!rootRef.btree12)
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(); });
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(alloc_class); });
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") {
......@@ -932,7 +934,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") {
auto btree = rootRef.btree10;
transaction::run(pop, [&] {
if(btree) delete_persistent<PBPTreeType10>(btree);
btree = make_persistent<PBPTreeType10>();
btree = make_persistent<PBPTreeType10>(alloc_class);
auto &btreeRef = *btree;
for (int i = 0; i < 50; i++) {
btreeRef.insert(i, i * 2);
......@@ -956,7 +958,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") {
transaction::run(pop, [&] {
if (btree) delete_persistent<PBPTreeType4>(btree);
btree = make_persistent<PBPTreeType4>();
btree = make_persistent<PBPTreeType4>(alloc_class);
auto &btreeRef = *btree;
......@@ -1005,7 +1007,6 @@ TEST_CASE("Finding the leaf node containing a key", "[BitHPBPTree]") {
REQUIRE(leafRef.bits.get_ro().all());
}
}
}
......
......@@ -55,21 +55,23 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") {
auto q = pop.root();
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)
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(); });
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(alloc_class); });
if (!rootRef.btree6)
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(); });
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(alloc_class); });
if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(); });
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(alloc_class); });
if (!rootRef.btree12)
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(); });
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(alloc_class); });
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") {
......@@ -873,7 +875,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") {
REQUIRE(std::equal(std::begin(expectedKeys), std::end(expectedKeys),
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;
auto &leaf3Ref = *leaf3;
std::vector<int> leaf3Keys{};
......@@ -932,7 +934,7 @@ TEST_CASE("Finding the leaf node containing a key", "[BitPBPTree]") {
auto btree = rootRef.btree10;
transaction::run(pop, [&] {
if(btree) delete_persistent<PBPTreeType10>(btree);
btree = make_persistent<PBPTreeType10>();
btree = make_persistent<PBPTreeType10>(alloc_class);
auto &btreeRef = *btree;
for (int i = 0; i < 50; i++) {
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
......
......@@ -55,21 +55,23 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
auto q = pop.root();
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)
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<FPTreeType4>(); });
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<FPTreeType4>(alloc_class); });
if (!rootRef.btree6)
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<FPTreeType6>(); });
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<FPTreeType6>(alloc_class); });
if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<FPTreeType10>(); });
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<FPTreeType10>(alloc_class); });
if (!rootRef.btree12)
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<FPTreeType12>(); });
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<FPTreeType12>(alloc_class); });
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") {
......@@ -95,8 +97,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
auto &nodeRef = *node;
for (auto i = 0; i < 10; i++) {
nodeRef.keys.get_rw()[i] = i + 1;
nodeRef.search.get_rw().b.set(i);
nodeRef.search.get_rw().fp[i] = btree.fpHash(i + 1);
nodeRef.bits.get_rw().set(i);
nodeRef.fp.get_rw()[i] = btree.fpHash(i + 1);
}
REQUIRE(btree.lookupPositionInLeafNode(node, 1) == 0);
......@@ -396,22 +398,22 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto i = 0; i < 4; i++) {
node1Ref.keys.get_rw()[i] = i;
node1Ref.values.get_rw()[i] = i + 100;
node1Ref.search.get_rw().b.set(i);
node1Ref.search.get_rw().fp[i] = btree.fpHash(i);
node1Ref.bits.get_rw().set(i);
node1Ref.fp.get_rw()[i] = btree.fpHash(i);
}
for (auto i = 0; i < 4; i++) {
node2Ref.keys.get_rw()[i] = i + 10;
node2Ref.values.get_rw()[i] = i + 200;
node2Ref.search.get_rw().b.set(i);
node2Ref.search.get_rw().fp[i] = btree.fpHash(i + 10);
node2Ref.bits.get_rw().set(i);
node2Ref.fp.get_rw()[i] = btree.fpHash(i + 10);
}
node1Ref.nextLeaf = node2;
btree.mergeLeafNodes(node1, node2);
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> expectedValues{{100, 101, 102, 103, 200, 201, 202, 203}};
......@@ -433,20 +435,20 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto i = 0; i < 8; i++) {
node1Ref.keys.get_rw()[i] = i + 1;
node1Ref.values.get_rw()[i] = i * 100;
node1Ref.search.get_rw().b.set(i);
node1Ref.search.get_rw().fp[i] = btree.fpHash(i+1);
node1Ref.bits.get_rw().set(i);
node1Ref.fp.get_rw()[i] = btree.fpHash(i+1);
}
for (auto i = 0; i < 4; i++) {
node2Ref.keys.get_rw()[i] = i + 11;
node2Ref.values.get_rw()[i] = i * 200;
node2Ref.search.get_rw().b.set(i);
node2Ref.search.get_rw().fp[i] = btree.fpHash(i+11);
node2Ref.bits.get_rw().set(i);
node2Ref.fp.get_rw()[i] = btree.fpHash(i+11);
}
btree.balanceLeafNodes(node1, node2);
REQUIRE(node2Ref.search.get_ro().b.count() == 6);
REQUIRE(node1Ref.search.get_ro().b.count() == 6);
REQUIRE(node2Ref.bits.get_ro().count() == 6);
REQUIRE(node1Ref.bits.get_ro().count() == 6);
std::array<int, 6> expectedKeys1{{1, 2, 3, 4, 5, 6}};
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]") {
btree.depth = 1;
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);
std::array<int, 5> expectedKeys{{1, 2, 3, 4, 5}};
......@@ -545,7 +547,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
btree.rootNode = parent;
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(parent->numKeys == 1);
}
......@@ -577,8 +579,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
parentRef.children[1] = leaf2;
btree.underflowAtLeafLevel(parent, 1, leaf2);
REQUIRE(leaf1Ref.search.get_ro().b.count() == 3);
REQUIRE(leaf2Ref.search.get_ro().b.count() == 3);
REQUIRE(leaf1Ref.bits.get_ro().count() == 3);
REQUIRE(leaf2Ref.bits.get_ro().count() == 3);
std::array<int, 3> expectedKeys1{{1, 2, 3}};
std::array<int, 3> expectedValues1{{10, 20, 30}};
......@@ -707,21 +709,21 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto i = 0; i < 9; i++) {
nodeRef.keys.get_rw()[i] = (i + 1) * 2;
nodeRef.values.get_rw()[i] = (i * 2) + 100;
nodeRef.search.get_rw().b.set(i);
nodeRef.search.get_rw().fp[i] = btree.fpHash((i + 1) * 2);
nodeRef.bits.get_rw().set(i);
nodeRef.fp.get_rw()[i] = btree.fpHash((i + 1) * 2);
}
res = btree.insertInLeafNode(node, 5, 5000, &splitInfo);
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);
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);
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> 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]") {
for (auto i = 0; i < 9; i++) {
nodeRef.keys.get_rw()[i] = (i + 1) * 2;
nodeRef.values.get_rw()[i] = (i * 2) + 100;
nodeRef.search.get_rw().b.set(i);
nodeRef.search.get_rw().fp[i] = btree.fpHash((i + 1) * 2);
nodeRef.bits.get_rw().set(i);
nodeRef.fp.get_rw()[i] = btree.fpHash((i + 1) * 2);
}
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);
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> 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]") {
btree.depth = 2;
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]") {
btree.depth = 2;
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);
std::array<int, 2> expectedKeys{{10, 12}};
......@@ -843,7 +845,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
auto &leaf3Ref = *nodeRef.children[2].leaf;
std::vector<int> actualKeys{};
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]);
std::sort(std::begin(actualKeys), std::end(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]") {
for (auto i = 0; i < 9; i++) {
nodeRef.keys.get_rw()[i] = i + 1;
nodeRef.values.get_rw()[i] = i + 100;
nodeRef.search.get_rw().b.set(i);
nodeRef.search.get_rw().fp[i] = btree.fpHash(i + 1);
nodeRef.bits.get_rw().set(i);
nodeRef.fp.get_rw()[i] = btree.fpHash(i + 1);
}
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(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> expectedValues{
......@@ -899,7 +901,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
auto btree = rootRef.btree10;
transaction::run(pop, [&] {
delete_persistent<FPTreeType10>(btree);
btree = make_persistent<FPTreeType10>();
btree = make_persistent<FPTreeType10>(alloc_class);
auto &btreeRef = *btree;
for (int i = 0; i < 50; ++i)
btreeRef.insert(i, i * 2);
......@@ -922,7 +924,7 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
transaction::run(pop, [&] {
if (btree) delete_persistent<FPTreeType4>(btree);
btree = make_persistent<FPTreeType4>();
btree = make_persistent<FPTreeType4>(alloc_class);
auto &btreeRef = *btree;
......@@ -931,8 +933,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto k = 0u; k < 4; ++k) {
pLeafRef.keys.get_rw()[k] = k + 1;
pLeafRef.values.get_rw()[k] = k + 1;
pLeafRef.search.get_rw().fp[k] = btreeRef.fpHash(k+1);
pLeafRef.search.get_rw().b.set(k);
pLeafRef.fp.get_rw()[k] = btreeRef.fpHash(k+1);
pLeafRef.bits.get_rw().set(k);
}
btreeRef.leafList = prevLeaf;
......@@ -943,8 +945,8 @@ TEST_CASE("Finding the leaf node containing a key", "[FPTree]") {
for (auto k = 0u; k < 4; ++k) {
leafRef.keys.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.search.get_rw().b.set(k);
leafRef.fp.get_rw()[k] = btreeRef.fpHash(k+1+l*4);
leafRef.bits.get_rw().set(k);
}
prevLeaf = newLeaf;
}
......@@ -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::transform(expectedHashes.begin(), expectedHashes.end(), expectedHashes.begin(),
[b1, b2, &btreeRef](int k) { return btreeRef.fpHash(k + b2 * 4 + b1 * 20); });
REQUIRE(leafRef.search.get_ro().fp == expectedHashes);
REQUIRE(leafRef.search.get_ro().b.all());
REQUIRE(leafRef.fp.get_ro() == expectedHashes);
REQUIRE(leafRef.bits.get_ro().all());
}
}
}
......
......@@ -60,21 +60,23 @@ TEST_CASE("Finding the leaf node containing a key", "[HPBPTree]") {
}
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)
transaction::run(pop, [&] { q->btree1 = make_persistent<HPBPTreeType>(); });
transaction::run(pop, [&] { q->btree1 = make_persistent<HPBPTreeType>(alloc_class); });
if (!q->btree2)
transaction::run(pop, [&] { q->btree2 = make_persistent<HPBPTreeType2>(); });
transaction::run(pop, [&] { q->btree2 = make_persistent<HPBPTreeType2>(alloc_class); });
if (!q->btree3)
transaction::run(pop, [&] { q->btree3 = make_persistent<HPBPTreeType3>(); });
transaction::run(pop, [&] { q->btree3 = make_persistent<HPBPTreeType3>(alloc_class); });
if (!q->btree4)
transaction::run(pop, [&] { q->btree4 = make_persistent<HPBPTreeType4>(); });
transaction::run(pop, [&] { q->btree4 = make_persistent<HPBPTreeType4>(alloc_class); });
if (!q->btree5)
transaction::run(pop, [&] { q->btree5 = make_persistent<HPBPTreeType5>(); });
transaction::run(pop, [&] { q->btree5 = make_persistent<HPBPTreeType5>(alloc_class); });
/* ------------------------------------------------------------------ */
......@@ -840,7 +842,7 @@ TEST_CASE("Finding the leaf node containing a key", "[HPBPTree]") {
auto btree = q->btree1;
transaction::run(pop, [&] {
if(btree) delete_persistent<HPBPTreeType>(btree);
btree = make_persistent<HPBPTreeType>();
btree = make_persistent<HPBPTreeType>(alloc_class);
for (int i = 0; i < 50; i++) {
btree->insert(i, i * 2);
}
......
......@@ -61,21 +61,23 @@ TEST_CASE("Finding the leaf node containing a key", "[PBPTree]") {
auto q = pop.root();
auto &rootRef = *q;
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>("heap.alloc_class.new.desc",
PBPTreeType4::AllocClass);
if (!rootRef.btree4)
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(); });
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(alloc_class); });
if (!rootRef.btree6)
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(); });
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(alloc_class); });
if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(); });
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(alloc_class); });
if (!rootRef.btree12)
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(); });
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(alloc_class); });
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") {
......@@ -877,7 +879,7 @@ TEST_CASE("Finding the leaf node containing a key", "[PBPTree]") {
auto btree = rootRef.btree10;
transaction::run(pop, [&] {
if(btree) delete_persistent<PBPTreeType10>(btree);
btree = make_persistent<PBPTreeType10>();
btree = make_persistent<PBPTreeType10>(alloc_class);
auto &btreeRef = *btree;
for (int i = 0; i < 50; i++) {
btreeRef.insert(i, i * 2);
......@@ -901,7 +903,7 @@ TEST_CASE("Finding the leaf node containing a key", "[PBPTree]") {
auto &btreeRef = *rootRef.btree10;
transaction::run(pop, [&] {
if(btree) delete_persistent<PBPTreeType10>(btree);
btree = make_persistent<PBPTreeType10>();
btree = make_persistent<PBPTreeType10>(alloc_class);
});
for (auto i = 60; i >= 0; --i) {
......
......@@ -40,10 +40,12 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") {
if (access(path.c_str(), F_OK) != 0) {
pop = pool<root>::create(path, LAYOUT, 16 * 1024 * 1024);
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>(
"heap.alloc_class.128.desc", PTableType::IndexType::AllocClass);
transaction::run(pop, [&] {
auto tInfo = VTableInfo<int, MyTuple>("MyTable", {"a","b","c","d"});
auto tInfo = VTableInfo<int, MyTuple>("MyTable", {"a", "b", "c", "d"});
auto dims = Dimensions({{0, 4, 4}, {3, 6, 6}});
pop.root()->pTable = make_persistent<PTableType>(tInfo, dims);
pop.root()->pTable = make_persistent<PTableType>(alloc_class, tInfo, dims);
});
} else {
std::cerr << "WARNING: Table already exists" << std::endl;
......@@ -58,7 +60,7 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") {
auto tup = MyTuple(i + 1,
(i + 1) * 100,
fmt::format("String #{0}", i),
(i + 1) * 12.345);
(i + 1) * 12.45);
c += pTable->insert(i + 1, tup);
}
REQUIRE(c == 10);
......@@ -70,7 +72,7 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") {
REQUIRE(get<0>(tp) == i + 1);
REQUIRE(get<1>(tp) == (i + 1) * 100);
REQUIRE(get<2>(tp) == fmt::format("String #{0}", i));
REQUIRE(get<3>(tp) == (i + 1) * 12.345);
REQUIRE(get<3>(tp) == (i + 1) * 12.45);
}
auto c = 0u;
......@@ -85,7 +87,7 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") {
REQUIRE(get<0>(tp) == i + 1);
REQUIRE(get<1>(tp) == (i + 1) * 100);
REQUIRE(get<2>(tp) == fmt::format("String #{0}", i));
REQUIRE(get<3>(tp) == (i + 1) * 12.345);
REQUIRE(get<3>(tp) == (i + 1) * 12.45);
}
for (auto i = 0u; i < 5; i++) {
......@@ -116,7 +118,7 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") {
auto tup = MyTuple(i + 1,
(i + 1) * 100,
fmt::format("String #{0}", i),
(i + 1) * 12.345);
(i + 1) * 12.45);
try {
pTable->updateComplete(i + 1, tup);
REQUIRE(false);
......@@ -144,7 +146,7 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") {
d += get<3>(ptp);
}
REQUIRE(c == 3); // 5,6,7
REQUIRE(d == 5*12.345 + 6*12.345 + 7*12.345);
REQUIRE(d == 5*12.45 + 6*12.45 + 7*12.45);
}
pTable->print();
......
......@@ -54,21 +54,23 @@ TEST_CASE("Finding the leaf node containing a key", "[PBPTree]") {
auto q = pop.root();
auto &rootRef = *q;
if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(); });
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>("heap.alloc_class.128.desc",
PBPTreeType4::AllocClass);
if (!rootRef.btree4)
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(); });
transaction::run(pop, [&] { rootRef.btree4 = make_persistent<PBPTreeType4>(alloc_class); });
if (!rootRef.btree6)
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(); });
transaction::run(pop, [&] { rootRef.btree6 = make_persistent<PBPTreeType6>(alloc_class); });
if (!rootRef.btree10)
transaction::run(pop, [&] { rootRef.btree10 = make_persistent<PBPTreeType10>(alloc_class); });
if (!rootRef.btree12)
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(); });
transaction::run(pop, [&] { rootRef.btree12 = make_persistent<PBPTreeType12>(alloc_class); });
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") {
......@@ -882,7 +884,7 @@ TEST_CASE("Finding the leaf node containing a key", "[PBPTree]") {
auto btree = rootRef.btree10;
transaction::run(pop, [&] {
if(btree) delete_persistent<PBPTreeType10>(btree);
btree = make_persistent<PBPTreeType10>();
btree = make_persistent<PBPTreeType10>(alloc_class);
auto &btreeRef = *btree;
for (int i = 0; i < 50; i++) {
btreeRef.insert(i, i * 2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment