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

Switched back to persistent index for PTable to avoid recovery

parent fa48efed
Pipeline #967 passed with stages
in 6 minutes and 34 seconds
......@@ -45,7 +45,7 @@ struct root {
};
const std::string path = dbis::gPmemPath + "benchdb" + std::to_string(dbis::ptable::gBlockSize) + "B.db";
const auto NUM_TUPLES = 1000 * 1000;
const auto NUM_TUPLES = 1000 * 10;
const auto POOL_SIZE = 1024 * 1024 * 1024 * 4ull; // 4GB
const auto ALIGNMENT = hibit_pos(NUM_TUPLES) + 1;
......@@ -131,15 +131,15 @@ void insert (pool<root> &pop, const std::string &path, size_t entries) {
pop = pool<root>::create(path, LAYOUT, POOL_SIZE);
/// Only if index is persistent version
//const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>(
// "heap.alloc_class.128.desc", PTableType::IndexType::AllocClass);
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>(
"heap.alloc_class.128.desc", PTableType::IndexType::AllocClass);
transaction::run(pop, [&] {
const auto tInfo = VTableInfo<MyKey, MyTuple>("MyTable", {"a","b","c","d"});
const auto dims = Dimensions({
{0, 10, ALIGNMENT},
{3, 10, ALIGNMENT}
});
pop.root()->pTable = make_persistent<PTableType>(/*alloc_class,*/ tInfo, dims);
pop.root()->pTable = make_persistent<PTableType>(alloc_class, tInfo, dims);
});
auto &pTable = pop.root()->pTable;
......
......@@ -204,8 +204,8 @@ class PTable<KeyType, std::tuple<Types...>> {
};
public:
//using IndexType = pbptrees::PBPTree<KeyType, PTuple<KeyType, Tuple>, BRANCHKEYS, LEAFKEYS>;
using IndexType = pbptrees::BPTree<KeyType, PTuple<KeyType, Tuple>, BRANCHKEYS, LEAFKEYS>;
using IndexType = pbptrees::PBPTree<KeyType, PTuple<KeyType, Tuple>, BRANCHKEYS, LEAFKEYS>;
//using IndexType = pbptrees::BPTree<KeyType, PTuple<KeyType, Tuple>, BRANCHKEYS, LEAFKEYS>;
/************************************************************************//**
* \brief Public Iterator to iterate over all inserted tuples using the index.
......@@ -717,7 +717,7 @@ class PTable<KeyType, std::tuple<Types...>> {
this->root = make_persistent<struct root>();
this->root->tInfo.get_rw() = make_persistent<PTableInfoType>(_tName, _columns, _keyIndex);
this->root->bdccInfo = make_persistent<BDCCInfo>(_bdccInfo);
this->root->index = make_persistent<IndexType>(/*index_alloc_class*/);
this->root->index = make_persistent<IndexType>(index_alloc_class);
this->root->dataNodes = make_persistent<DataNode<KeyType>>();
this->root->dataNodes->block.get_rw() = initBlock(0, ((1L << this->root->bdccInfo->numBins()) - 1));
}
......@@ -734,7 +734,7 @@ class PTable<KeyType, std::tuple<Types...>> {
this->root = make_persistent<struct root>();
this->root->tInfo = make_persistent<PTableInfoType>(_tInfo);
this->root->bdccInfo = make_persistent<BDCCInfo>(_bdccInfo);
this->root->index = make_persistent<IndexType>(/*index_alloc_class*/);
this->root->index = make_persistent<IndexType>(index_alloc_class);
this->root->dataNodes = make_persistent<struct DataNode<KeyType>>();
this->root->dataNodes->block.get_rw() = initBlock(0, ((1L << this->root->bdccInfo->numBins()) - 1));
}
......
......@@ -80,7 +80,6 @@ using BDCC_Block = typename std::array<uint8_t, gBlockSize>;
template<typename KeyType>
struct DataNode {
using DeletedVector = std::vector<uint16_t, allocator<uint16_t>>;
using KeyVector = std::array<KeyType, 8192>;
/*
using HistogramType = std::unordered_map<uint32_t,
std::size_t,
......@@ -93,7 +92,6 @@ struct DataNode {
persistent_ptr<DataNode> next;
p<BDCC_Block> block;
//p<KeyVector> keys;
p<DeletedVector> deleted;
//p<HistogramType> histogram;
p<size_t> bdccSum{0};
......
......@@ -51,16 +51,13 @@ TEST_CASE("Testing to create a new BDCCInfo instance", "[BDCCInfo]") {
transaction::run(pop, [&] {
for (auto i = 0u; i < 10; ++i) {
node->bdccSum += (i % 2) + 5;
node->keys.get_rw()[i] = i;
node->block.get_rw()[i] = 0xFF;
}
reinterpret_cast<uint16_t &>(node->block.get_rw()[gCountPos]) = 10;
});
REQUIRE(node->keys.get_ro().size() == 8 * 1024);
REQUIRE(node->calcAverageBDCC() == 5); /* 5.5 */
for (auto i = 0u; i < 10; ++i) {
REQUIRE(node->keys.get_ro()[i] == i);
if (i != gCountPos && i != gCountPos + 1)
REQUIRE(node->block.get_ro()[i] == 0xFF);
}
......
......@@ -40,6 +40,7 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") {
if (access(path.c_str(), F_OK) != 0) {
pop = pool<root>::create(path, LAYOUT, 16 * 1024 * 1024);
/// Only needed for persistent index
const auto alloc_class = pop.ctl_set<struct pobj_alloc_class_desc>(
"heap.alloc_class.128.desc", PTableType::IndexType::AllocClass);
transaction::run(pop, [&] {
......
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