Commit 58d93ce4 authored by Philipp Götze's avatar Philipp Götze

🔨 Changed allocation and alignment +++ some other changes

parent 02444c98
......@@ -21,19 +21,21 @@
#include <array>
#include <iostream>
#include <libpmemobj/ctl.h>
#include <libpmemobj++/make_persistent.hpp>
#include <libpmemobj++/p.hpp>
#include <libpmemobj++/persistent_ptr.hpp>
#include <libpmemobj++/transaction.hpp>
#include <libpmemobj++/utils.hpp>
#include "config.h"
#include "utils/BitOperations.hpp"
#include "utils/SearchFunctions.hpp"
#include "utils/PersistEmulation.hpp"
#include "config.h"
#include "utils/SearchFunctions.hpp"
namespace dbis::pbptrees {
using pmem::obj::allocation_flag;
using pmem::obj::delete_persistent;
using pmem::obj::make_persistent;
using pmem::obj::p;
......@@ -122,11 +124,15 @@ class BitHPBPTree {
*/
LeafNode() : nextLeaf(nullptr), prevLeaf(nullptr) {}
p<std::bitset<M>> bits; ///< bitset for valid entries
p<std::array<KeyType, M>> keys; ///< the actual keys
p<std::array<ValueType, M>> values; ///< the actual values
pptr<LeafNode> nextLeaf; ///< pointer to the subsequent sibling
pptr<LeafNode> prevLeaf; ///< pointer to the preceeding sibling
static constexpr auto BitsetSize = ((M + 63) / 64) * 8; ///< number * size of words
static constexpr auto PaddingSize = (64 - (BitsetSize + 32) % 64) % 64;
p<std::bitset<M>> bits; ///< bitset for valid entries
pptr<LeafNode> nextLeaf; ///< pointer to the subsequent sibling
pptr<LeafNode> prevLeaf; ///< pointer to the preceeding sibling
char padding[PaddingSize]; ///< padding to align keys to 64 bytes
p<std::array<KeyType, M>> keys; ///< the actual keys
p<std::array<ValueType, M>> values; ///< the actual values
};
/**
......@@ -154,14 +160,18 @@ class BitHPBPTree {
pptr<LeafNode> newLeafNode() {
auto pop = pmem::obj::pool_by_vptr(this);
pptr<LeafNode> newNode = nullptr;
transaction::run(pop, [&] { newNode = make_persistent<LeafNode>(); });
transaction::run(pop, [&] {
newNode = make_persistent<LeafNode>(allocation_flag::class_id(alloc_class.class_id));
});
return newNode;
}
pptr<LeafNode> newLeafNode(const pptr<LeafNode> &other) {
auto pop = pmem::obj::pool_by_vptr(this);
pptr<LeafNode> newNode = nullptr;
transaction::run(pop, [&] { newNode = make_persistent<LeafNode>(*other); });
transaction::run(pop, [&] {
newNode = make_persistent<LeafNode>(allocation_flag::class_id(alloc_class.class_id), *other);
});
return newNode;
}
......@@ -204,16 +214,16 @@ class BitHPBPTree {
Node rightChild; ///< the resulting rhs child node
};
static constexpr pobj_alloc_class_desc AllocClass{256, 64, 1, POBJ_HEADER_COMPACT};
pobj_alloc_class_desc alloc_class;
unsigned int depth; /**< the depth of the tree, i.e. the number of levels
(0 => rootNode is LeafNode) */
Node rootNode; /**< pointer to the root node (an instance of @c LeafNode or @c BranchNode).
This pointer is never @c nullptr. */
Node rootNode; /**< pointer to the root node (an instance of @c LeafNode or @c BranchNode).
This pointer is never @c nullptr. */
pptr<LeafNode> leafList; /**< Pointer to the leaf at the most left position.
Neccessary for recovery */
public:
public:
/**
* Iterator for iterating over the leaf nodes.
*/
......@@ -286,11 +296,12 @@ class BitHPBPTree {
/**
* Constructor for creating a new B+ tree.
*/
BitHPBPTree() : depth(0) {
explicit BitHPBPTree(struct pobj_alloc_class_desc _alloc) : depth(0), alloc_class(_alloc) {
// BitHPBPTree() : depth(0) {
rootNode = newLeafNode();
leafList = rootNode.leaf;
LOG("created new tree with sizeof(BranchNode) = " << sizeof(BranchNode) <<
", sizeof(LeafNode) = " << sizeof(LeafNode));
LOG("created new tree with sizeof(BranchNode) = "
<< sizeof(BranchNode) << ", sizeof(LeafNode) = " << sizeof(LeafNode));
}
/**
......@@ -486,9 +497,23 @@ class BitHPBPTree {
*/
bool eraseFromLeafNode(const pptr<LeafNode> &node, const KeyType &key) {
auto pos = lookupPositionInLeafNode(node, key);
return eraseFromLeafNodeAtPosition(node, pos, key);
}
/**
* Delete the element with the given position and key from the given leaf node.
*
* @param node the leaf node from which the element is deleted
* @param pos the position of the key in the node
* @param key the key of the element to be deleted
* @return true of the element was deleted
*/
bool eraseFromLeafNodeAtPosition(const pptr<LeafNode> &node, const unsigned int pos,
const KeyType &key) {
if (pos < M) {
/// simply reset bit
node->bits.get_rw().reset(pos);
PersistEmulation::writeBytes<1>();
return true;
}
return false;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -21,18 +21,20 @@
#include <array>
#include <iostream>
#include <libpmemobj/ctl.h>
#include <libpmemobj++/make_persistent.hpp>
#include <libpmemobj++/p.hpp>
#include <libpmemobj++/persistent_ptr.hpp>
#include <libpmemobj++/transaction.hpp>
#include <libpmemobj++/utils.hpp>
#include "config.h"
#include "utils/PersistEmulation.hpp"
#include "utils/SearchFunctions.hpp"
#include "config.h"
namespace dbis::pbptrees {
using pmem::obj::allocation_flag;
using pmem::obj::delete_persistent;
using pmem::obj::make_persistent;
using pmem::obj::p;
......@@ -69,32 +71,33 @@ class PBPTree {
struct BranchNode;
struct Node {
Node() : tag(BLANK){};
Node(const pptr<LeafNode> &leaf_) : tag(LEAF), leaf(leaf_) {};
Node(const pptr<BranchNode> &branch_) : tag(BRANCH), branch(branch_) {};
Node(const Node& other) { copy(other); };
Node(const pptr<LeafNode> &leaf_) : tag(LEAF), leaf(leaf_){};
Node(const pptr<BranchNode> &branch_) : tag(BRANCH), branch(branch_){};
Node(const Node &other) { copy(other); };
void copy (const Node& other) throw() {
void copy(const Node &other) throw() {
tag = other.tag;
switch (tag) {
case LEAF: {
leaf = other.leaf;
break;
}
case BRANCH: {
branch = other.branch;
break;
}
default: break;
case LEAF: {
leaf = other.leaf;
break;
}
case BRANCH: {
branch = other.branch;
break;
}
default:
break;
}
}
Node& operator=(Node other) {
Node &operator=(Node other) {
copy(other);
return *this;
}
enum NodeType {BLANK, LEAF, BRANCH} tag;
enum NodeType { BLANK, LEAF, BRANCH } tag;
union {
pptr<LeafNode> leaf;
pptr<BranchNode> branch;
......@@ -110,6 +113,7 @@ class PBPTree {
Node rightChild; ///< the resulting rhs child node
};
pobj_alloc_class_desc alloc_class;
p<unsigned int> depth; /**< the depth of the tree, i.e. the number of levels
(0 => rootNode is LeafNode) */
Node rootNode; /**< pointer to the root node (an instance of @c LeafNode or
......@@ -118,6 +122,8 @@ class PBPTree {
/* -------------------------------------------------------------------------------------------- */
public:
static constexpr pobj_alloc_class_desc AllocClass{256, 64, 1, POBJ_HEADER_COMPACT};
/**
* Iterator for iterating over the leaf nodes
*/
......@@ -180,7 +186,8 @@ class PBPTree {
/**
* Constructor for creating a new B+ tree.
*/
PBPTree() : depth(0) {
explicit PBPTree(struct pobj_alloc_class_desc _alloc) : depth(0), alloc_class(_alloc) {
//PBPTree() : depth(0) {
rootNode = newLeafNode();
LOG("created new tree with sizeof(BranchNode) = " << sizeof(BranchNode) <<
", sizeof(LeafNode) = " << sizeof(LeafNode));
......@@ -342,7 +349,7 @@ class PBPTree {
}
#ifndef UNIT_TESTS
private:
private:
#endif
/* -------------------------------------------------------------------------------------------- */
/* DELETE AT LEAF LEVEL */
......@@ -357,6 +364,19 @@ class PBPTree {
*/
bool eraseFromLeafNode(const pptr<LeafNode> &node, const KeyType &key) {
auto pos = lookupPositionInLeafNode(node, key);
return eraseFromLeafNodeAtPosition(node, pos, key);
}
/**
* Delete the element with the given position and key from the given leaf node.
*
* @param node the leaf node from which the element is deleted
* @param pos the position of the key in the node
* @param key the key of the element to be deleted
* @return true of the element was deleted
*/
bool eraseFromLeafNodeAtPosition(const pptr<LeafNode> &node, const unsigned int pos,
const KeyType &key) {
auto &nodeRef = *node;
if (nodeRef.keys.get_ro()[pos] == key) {
auto &numKeys = nodeRef.numKeys.get_rw();
......@@ -367,6 +387,8 @@ class PBPTree {
nodeValues[i] = nodeValues[i + 1];
}
--numKeys;
PersistEmulation::writeBytes((numKeys - pos) * (sizeof(KeyType) + sizeof(ValueType)) +
sizeof(size_t));
return true;
}
return false;
......@@ -448,7 +470,7 @@ class PBPTree {
auto &node1Ref = *node1;
auto &node2Ref = *node2;
auto &n1NumKeys = node1Ref.numKeys.get_rw();
auto &n2NumKeys = node2Ref.numKeys.get_rw();
const auto &n2NumKeys = node2Ref.numKeys.get_ro();
assert(n1NumKeys + n2NumKeys <= M);
/// we move all keys/values from node2 to node1
......@@ -462,8 +484,16 @@ class PBPTree {
}
n1NumKeys = n1NumKeys + n2NumKeys;
node1Ref.nextLeaf = node2Ref.nextLeaf;
n2NumKeys = 0;
if (node2Ref.nextLeaf != nullptr) node2Ref.nextLeaf->prevLeaf = node1;
// n2NumKeys = 0; ///< node2 is deleted anyway
if (node2Ref.nextLeaf != nullptr) {
node2Ref.nextLeaf->prevLeaf = node1;
PersistEmulation::writeBytes<16>();
}
PersistEmulation::writeBytes(
n2NumKeys * (sizeof(KeyType) + sizeof(ValueType)) + ///< moved keys, vals
sizeof(unsigned int) + 16 ///< numKeys + nextpointer
);
return node1;
}
......@@ -504,6 +534,9 @@ class PBPTree {
receiverValues[j] = donorValues[i];
++rNumKeys;
}
PersistEmulation::writeBytes((rNumKeys + dNumKeys - balancedNum) *
(sizeof(KeyType) + sizeof(ValueType)) +
sizeof(unsigned int));
} else {
/// move from one node to a node with smaller keys
unsigned int i = 0;
......@@ -516,12 +549,15 @@ class PBPTree {
/// on donor node move all keys and values to the left
auto &donorKeysW = donorRef.keys.get_rw();
auto &donorValuesW = donorRef.values.get_rw();
for (i = 0; i < dNumKeys - toMove; ++i) {
for (i = 0; i < balancedNum; ++i) {
donorKeysW[i] = donorKeys[toMove + i];
donorValuesW[i] = donorValues[toMove + i];
}
PersistEmulation::writeBytes(dNumKeys * (sizeof(KeyType) + sizeof(ValueType)) +
sizeof(unsigned int));
}
dNumKeys -= toMove;
PersistEmulation::writeBytes<sizeof(unsigned int)>();
}
/* -------------------------------------------------------------------------------------------- */
......@@ -902,11 +938,12 @@ class PBPTree {
if(nodeRef.nextLeaf != nullptr) {
sibRef.nextLeaf = nodeRef.nextLeaf;
nodeRef.nextLeaf->prevLeaf = sibling;
PersistEmulation::writeBytes<2*16>();
}
nodeRef.nextLeaf = sibling;
sibRef.prevLeaf = node;
/// 2 numKeys + half entries + pointers
PersistEmulation::writeBytes(2*4 + sNumKeys*(sizeof(KeyType) + sizeof(ValueType)) + 2*16);
PersistEmulation::writeBytes(2*8 + sNumKeys*(sizeof(KeyType) + sizeof(ValueType)) + 2*16);
auto &splitInfoRef = *splitInfo;
splitInfoRef.leftChild = node;
......@@ -945,8 +982,8 @@ class PBPTree {
keysRef[pos] = key;
valuesRef[pos] = val;
++numKeys;
PersistEmulation::writeBytes((numKeys-pos+1)*(sizeof(KeyType) + sizeof(ValueType)) +
sizeof(unsigned int));
PersistEmulation::writeBytes((numKeys-pos)*(sizeof(KeyType) + sizeof(ValueType)) +
sizeof(size_t));
}
/**
......@@ -1112,11 +1149,18 @@ class PBPTree {
pptr<LeafNode> newLeafNode() {
auto pop = pmem::obj::pool_by_vptr(this);
pptr<LeafNode> newNode = nullptr;
if (pmemobj_tx_stage() == TX_STAGE_NONE) {
transaction::run(pop, [&] { newNode = make_persistent<LeafNode>(); });
} else {
newNode = make_persistent<LeafNode>();
}
transaction::run(pop, [&] {
newNode = make_persistent<LeafNode>(allocation_flag::class_id(alloc_class.class_id));
});
return newNode;
}
pptr<LeafNode> newLeafNode(const pptr<LeafNode> &other) {
auto pop = pmem::obj::pool_by_vptr(this);
pptr<LeafNode> newNode = nullptr;
transaction::run(pop, [&] {
newNode = make_persistent<LeafNode>(allocation_flag::class_id(alloc_class.class_id), *other);
});
return newNode;
}
......@@ -1137,9 +1181,11 @@ class PBPTree {
auto pop = pmem::obj::pool_by_vptr(this);
pptr<BranchNode> newNode = nullptr;
if (pmemobj_tx_stage() == TX_STAGE_NONE) {
transaction::run(pop, [&] { newNode = make_persistent<BranchNode>(); });
transaction::run(pop, [&] {
newNode = make_persistent<BranchNode>(allocation_flag::class_id(alloc_class.class_id));
});
} else {
newNode = make_persistent<BranchNode>();
newNode = make_persistent<BranchNode>(allocation_flag::class_id(alloc_class.class_id));
}
return newNode;
}
......@@ -1165,11 +1211,13 @@ class PBPTree {
*/
LeafNode() : numKeys(0), nextLeaf(nullptr), prevLeaf(nullptr) {}
p<unsigned int> numKeys; ///< the number of currently stored keys
p<std::array<KeyType, M>> keys; ///< the actual keys
/// pmdk header 16 Byte - 0x00
p<size_t> numKeys; ///< the number of currently stored keys - 0x10
pptr<LeafNode> nextLeaf; ///< pointer to the subsequent sibling - 0x18
pptr<LeafNode> prevLeaf; ///< pointer to the preceding sibling - 0x28
char padding[24]; ///< padding to align keys to 64 byte - 0x38
p<std::array<KeyType, M>> keys; ///< the actual keys - 0x40
p<std::array<ValueType, M>> values; ///< the actual values
pptr<LeafNode> nextLeaf; ///< pointer to the subsequent sibling
pptr<LeafNode> prevLeaf; ///< pointer to the preceding sibling
};
/**
......
......@@ -21,17 +21,20 @@
#include <array>
#include <iostream>
#include <libpmemobj/ctl.h>
#include <libpmemobj++/make_persistent.hpp>
#include <libpmemobj++/p.hpp>
#include <libpmemobj++/persistent_ptr.hpp>
#include <libpmemobj++/transaction.hpp>
#include <libpmemobj++/utils.hpp>
#include "utils/SearchFunctions.hpp"
#include "utils/PersistEmulation.hpp"
#include "config.h"
#include "utils/PersistEmulation.hpp"
#include "utils/SearchFunctions.hpp"
namespace dbis::pbptrees {
using pmem::obj::allocation_flag;
using pmem::obj::delete_persistent;
using pmem::obj::make_persistent;
using pmem::obj::p;
......@@ -115,13 +118,14 @@ class UnsortedPBPTree {
Node rightChild; ///< the resulting rhs child node
};
static constexpr pobj_alloc_class_desc AllocClass{256, 64, 1, POBJ_HEADER_COMPACT};
pobj_alloc_class_desc alloc_class;
p<unsigned int> depth; /**< the depth of the tree, i.e. the number of levels
(0 => rootNode is LeafNode) */
Node rootNode; /**< pointer to the root node (an instance of @c LeafNode or @c BranchNode).
This pointer is never @c nullptr. */
public:
public:
/**
* Iterator for iterating over the leaf nodes
......@@ -193,7 +197,8 @@ class UnsortedPBPTree {
/**
* Constructor for creating a new B+ tree.
*/
UnsortedPBPTree() : depth(0) {
explicit UnsortedPBPTree(struct pobj_alloc_class_desc _alloc) : depth(0), alloc_class(_alloc) {
// UnsortedPBPTree() : depth(0) {
rootNode = newLeafNode();
LOG("created new tree with sizeof(BranchNode) = " << sizeof(BranchNode)
<< ", sizeof(LeafNode) = " << sizeof(LeafNode));
......@@ -364,16 +369,33 @@ class UnsortedPBPTree {
* @return true of the element was deleted
*/
bool eraseFromLeafNode(const pptr<LeafNode> &node, const KeyType &key) {
auto &nodeRef = *node;
auto pos = lookupPositionInLeafNode(node, key);
return eraseFromLeafNodeAtPosition(node, pos, key);
}
/**
* Delete the element with the given position and key from the given leaf node.
*
* @param node the leaf node from which the element is deleted
* @param pos the position of the key in the node
* @param key the key of the element to be deleted
* @return true of the element was deleted
*/
bool eraseFromLeafNodeAtPosition(const pptr<LeafNode> &node, const unsigned int pos,
const KeyType &key) {
auto &nodeRef = *node;
if (nodeRef.keys.get_ro()[pos] == key) {
auto &numKeys = nodeRef.numKeys.get_rw();
auto &nodeKeys = nodeRef.keys.get_rw();
auto &nodeVals = nodeRef.values.get_rw();
/// simply copy the last object on the node to the position of the erased object
--numKeys;
nodeKeys[pos] = nodeKeys[numKeys];
nodeVals[pos] = nodeVals[numKeys];
if (pos != numKeys) {
nodeKeys[pos] = nodeKeys[numKeys];
nodeVals[pos] = nodeVals[numKeys];
}
PersistEmulation::writeBytes(sizeof(size_t) +
(pos != numKeys ? sizeof(KeyType) + sizeof(ValueType) : 0));
return true;
}
return false;
......@@ -468,7 +490,14 @@ class UnsortedPBPTree {
}
n1NumKeys += n2NumKeys;
node1Ref.nextLeaf = node2Ref.nextLeaf;
if (node2Ref.nextLeaf != nullptr) node2Ref.nextLeaf->prevLeaf = node1;
if (node2Ref.nextLeaf != nullptr) {
node2Ref.nextLeaf->prevLeaf = node1;
PersistEmulation::writeBytes<16>();
}
PersistEmulation::writeBytes(
n2NumKeys * (sizeof(KeyType) + sizeof(ValueType)) + ///< moved keys, vals
sizeof(unsigned int) + 16 ///< numKeys + nextpointer
);
return node1;
}
......@@ -527,6 +556,8 @@ class UnsortedPBPTree {
--dNumKeys;
}
}
PersistEmulation::writeBytes(2 * toMove * (sizeof(KeyType) + sizeof(ValueType)) +
2* sizeof(unsigned int));
}
/* -------------------------------------------------------------------------------------------- */
......@@ -944,7 +975,7 @@ class UnsortedPBPTree {
}
nodeRef.nextLeaf = sibling;
sibRef.prevLeaf = node;
PersistEmulation::writeBytes<M * (sizeof(KeyType) + sizeof(ValueType)) + 2*4 + 2*16>(); //M entries moved + 2 numKeys + 2 pointers
PersistEmulation::writeBytes<M * (sizeof(KeyType) + sizeof(ValueType)) + 2*8 + 2*16>(); //M entries moved + 2 numKeys + 2 pointers
auto &splitInfoRef = *splitInfo;
splitInfoRef.leftChild = node;
......@@ -969,7 +1000,7 @@ class UnsortedPBPTree {
nodeRef.keys.get_rw()[numKeys] = key;
nodeRef.values.get_rw()[numKeys] = val;
++numKeys;
PersistEmulation::writeBytes<sizeof(KeyType) + sizeof(ValueType) + sizeof(unsigned int)>();
PersistEmulation::writeBytes<sizeof(KeyType) + sizeof(ValueType) + sizeof(size_t)>();
}
/**
......@@ -1139,7 +1170,18 @@ class UnsortedPBPTree {
pptr<LeafNode> newLeafNode() {
auto pop = pmem::obj::pool_by_vptr(this);
pptr<LeafNode> newNode = nullptr;
transaction::run(pop, [&] { newNode = make_persistent<LeafNode>(); });
transaction::run(pop, [&] {
newNode = make_persistent<LeafNode>(allocation_flag::class_id(alloc_class.class_id));
});
return newNode;
}
pptr<LeafNode> newLeafNode(const pptr<LeafNode> &other) {
auto pop = pmem::obj::pool_by_vptr(this);
pptr<LeafNode> newNode = nullptr;
transaction::run(pop, [&] {
newNode = make_persistent<LeafNode>(allocation_flag::class_id(alloc_class.class_id), *other);
});
return newNode;
}
......@@ -1154,7 +1196,9 @@ class UnsortedPBPTree {
pptr<BranchNode> newBranchNode() {
auto pop = pmem::obj::pool_by_vptr(this);
pptr<BranchNode> newNode = nullptr;
transaction::run(pop, [&] { newNode = make_persistent<BranchNode>(); });
transaction::run(pop, [&] {
newNode = make_persistent<BranchNode>(/*allocation_flag::class_id(alloc_class.class_id)*/);
});
return newNode;
}
......@@ -1173,11 +1217,13 @@ class UnsortedPBPTree {
*/
LeafNode() : numKeys(0), nextLeaf(nullptr), prevLeaf(nullptr) {}
p<unsigned int> numKeys; ///< the number of currently stored keys
p<std::array<KeyType, M>> keys; ///< the actual keys
/// pmdk header 16 Byte - 0x00
p<size_t> numKeys; ///< the number of currently stored keys - 0x10
pptr<LeafNode> nextLeaf; ///< pointer to the subsequent sibling - 0x18
pptr<LeafNode> prevLeaf; ///< pointer to the preceding sibling - 0x28
char padding[24]; ///< padding to align keys to 64 byte - 0x38
p<std::array<KeyType, M>> keys; ///< the actual keys - 0x40
p<std::array<ValueType, M>> values; ///< the actual values
pptr<LeafNode> nextLeaf; ///< pointer to the subsequent sibling
pptr<LeafNode> prevLeaf; ///< pointer to the preceeding sibling
};
/**
......
This diff is collapsed.
This diff is collapsed.
......@@ -64,7 +64,7 @@ class PTable<KeyType, std::tuple<Types...>> {
using VTableInfoType = VTableInfo<KeyType, Tuple>;
using PTableInfoType = PTableInfo<KeyType, Tuple>;
using ColumnIntMap = std::map<uint16_t, uint16_t>;
using IndexType = pbptrees::PBPTree<KeyType, PTuple<KeyType, Tuple>, BRANCHKEYS, LEAFKEYS>;
/// IndexType in public
using DataNodePtr = persistent_ptr<DataNode<KeyType>>;
/************************************************************************//**
......@@ -198,6 +198,8 @@ class PTable<KeyType, std::tuple<Types...>> {
};
public:
using IndexType = pbptrees::PBPTree<KeyType, PTuple<KeyType, Tuple>, BRANCHKEYS, LEAFKEYS>;
/************************************************************************//**
* \brief Public Iterator to iterate over all inserted tuples using the index.
***************************************************************************/
......@@ -234,7 +236,7 @@ class PTable<KeyType, std::tuple<Types...>> {
return retval;
}
inline const bool isValid() const {
inline bool isValid() const {
return treeIter != end;
}
......@@ -264,7 +266,7 @@ class PTable<KeyType, std::tuple<Types...>> {
/************************************************************************//**
* \brief Default Constructor.
***************************************************************************/
explicit PTable() {
explicit PTable(struct pobj_alloc_class_desc _alloc) : index_alloc_class(_alloc) {
auto pop = pool_by_vptr(this);
if (pmemobj_tx_stage() == TX_STAGE_NONE) {
transaction::run(pop, [&] { init("", {}, Dimensions()); });
......@@ -276,8 +278,9 @@ class PTable<KeyType, std::tuple<Types...>> {
/************************************************************************//**
* \brief Constructor for a given schema and dimension clustering.
***************************************************************************/
explicit PTable(const std::string &tName, ColumnInitList columns,
const Dimensions &_bdccInfo = Dimensions()) {
explicit PTable(struct pobj_alloc_class_desc _alloc, const std::string &tName,
ColumnInitList columns, const Dimensions &_bdccInfo = Dimensions())
: index_alloc_class(_alloc) {
auto pop = pool_by_vptr(this);
if (pmemobj_tx_stage() == TX_STAGE_NONE) {
transaction::run(pop, [&] { init(tName, columns, _bdccInfo); });
......@@ -289,7 +292,9 @@ class PTable<KeyType, std::tuple<Types...>> {
/************************************************************************//**
* \brief Constructor for a given schema (using TableInfo) and dimension clustering.
***************************************************************************/
explicit PTable(const VTableInfoType &tInfo, const Dimensions &_bdccInfo = Dimensions()) {
explicit PTable(struct pobj_alloc_class_desc _alloc, const VTableInfoType &tInfo,
const Dimensions &_bdccInfo = Dimensions())
: index_alloc_class(_alloc) {
auto pop = pool_by_vptr(this);
if (pmemobj_tx_stage() == TX_STAGE_NONE) {
transaction::run(pop, [&] { init(tInfo, _bdccInfo); });
......@@ -570,7 +575,7 @@ class PTable<KeyType, std::tuple<Types...>> {
const auto smas = cAttributes::smaPos(b, gSmaOffsetPos + idx * gAttrOffsetSize);
const auto &dataPos = reinterpret_cast<const uint16_t &>(b[gDataOffsetPos + idx * gAttrOffsetSize]);
const auto &data = reinterpret_cast<const int (&)[cnt]>(b[dataPos]);
const int (&data)[cnt] = reinterpret_cast