Commit 964ef9da authored by Philipp Götze's avatar Philipp Götze

🔨 Updated 'findSplitKey' function to be more versatile

parent ba373bb2
Pipeline #679 passed with stages
in 14 minutes and 31 seconds
...@@ -945,8 +945,7 @@ class BitHPBPTree { ...@@ -945,8 +945,7 @@ class BitHPBPTree {
auto &nodeRef = *node; auto &nodeRef = *node;
/// determine the split position by finding the median in unsorted array of keys /// determine the split position by finding the median in unsorted array of keys
const auto data = nodeRef.keys.get_ro(); auto [b, splitPos] = findSplitKey<KeyType, M>(nodeRef.keys.get_ro().data());
auto [b, splitPos] = findSplitKey(data);
const auto &splitKey = nodeRef.keys.get_ro()[splitPos]; const auto &splitKey = nodeRef.keys.get_ro()[splitPos];
/// copy leaf with flipped bitmap /// copy leaf with flipped bitmap
...@@ -1027,8 +1026,7 @@ class BitHPBPTree { ...@@ -1027,8 +1026,7 @@ class BitHPBPTree {
auto &nodeRef = *node; auto &nodeRef = *node;
/// determine the split position (by finding median in unsorted array of keys) /// determine the split position (by finding median in unsorted array of keys)
auto data = nodeRef.keys; auto [b, splitPos] = findSplitKey<KeyType, N>(nodeRef.keys.data());
auto [b, splitPos] = findSplitKey(data);
const auto &splitKey = nodeRef.keys[splitPos]; const auto &splitKey = nodeRef.keys[splitPos];
/// copy node and flip bits /// copy node and flip bits
......
...@@ -914,9 +914,8 @@ class BitPBPTree { ...@@ -914,9 +914,8 @@ class BitPBPTree {
auto &nodeRef = *node; auto &nodeRef = *node;
/// determine the split position by finding the median in unsorted array of keys /// determine the split position by finding the median in unsorted array of keys
const auto data = nodeRef.keys.get_ro(); const auto [b, splitPos] = findSplitKey<KeyType, M>(nodeRef.keys.get_ro().data());
auto [b, splitPos] = findSplitKey(data); const auto &splitKey = nodeRef.keys.get_ro()[splitPos];
const auto &splitKey = data[splitPos];
/// copy leaf with flipped bitmap /// copy leaf with flipped bitmap
/* /*
...@@ -1004,7 +1003,7 @@ class BitPBPTree { ...@@ -1004,7 +1003,7 @@ class BitPBPTree {
/// determine the split position (by finding median in unsorted array of keys) /// determine the split position (by finding median in unsorted array of keys)
auto data = nodeKeys; auto data = nodeKeys;
auto [b, splitPos] = findSplitKey(data); auto [b, splitPos] = findSplitKey<KeyType, N>(nodeKeys.data());
const auto &splitKey = nodeKeys[splitPos]; const auto &splitKey = nodeKeys[splitPos];
/// copy node and flip bits /// copy node and flip bits
......
...@@ -541,9 +541,8 @@ class FPTree { ...@@ -541,9 +541,8 @@ class FPTree {
auto &nodeRef = *node; auto &nodeRef = *node;
/* determine the split position by finding median in unsorted array of keys*/ /* determine the split position by finding median in unsorted array of keys*/
const auto data = nodeRef.keys.get_ro(); const auto [bitmap, splitPos] = findSplitKey<KeyType, M>(nodeRef.keys.get_ro().data());
auto [bitmap, splitPos] = findSplitKey(data); const auto &splitKey = nodeRef.keys.get_ro()[splitPos];
const auto &splitKey = data[splitPos];
/// copy leaf /// copy leaf
/* /*
......
...@@ -945,9 +945,8 @@ class UnsortedPBPTree { ...@@ -945,9 +945,8 @@ class UnsortedPBPTree {
auto &nodeRef = *node; auto &nodeRef = *node;
/* determine the split position by finding the median in unsorted array of keys */ /* determine the split position by finding the median in unsorted array of keys */
auto data = nodeRef.keys.get_ro(); const auto [__unused__, splitPos] = findSplitKey<KeyType, M>(nodeRef.keys.get_ro().data());
const auto [__unused__, splitPos] = findSplitKey(data); const auto splitKey = nodeRef.keys.get_ro()[splitPos];
const auto splitKey = data[splitPos];
/* move all entries with greater or equal keys to a new sibling node */ /* move all entries with greater or equal keys to a new sibling node */
auto sibling = newLeafNode(); auto sibling = newLeafNode();
......
...@@ -80,8 +80,10 @@ class ElementOfRankK { ...@@ -80,8 +80,10 @@ class ElementOfRankK {
template<typename KeyType, size_t M> template<typename KeyType, size_t M>
std::pair<std::bitset<M>, size_t> std::pair<std::bitset<M>, size_t>
findSplitKey(const std::array<KeyType, M> &data) { findSplitKey(const KeyType * const data) {
auto repData = data; ///TODO: can this be accelerated?
std::array<KeyType, M> repData;
memcpy(repData.begin(), data, M * sizeof(KeyType));
std::bitset<M> b{}; std::bitset<M> b{};
const auto splitKey = ElementOfRankK::elementOfRankK((M+1)/2 + 1, repData.data(), 0, M); const auto splitKey = ElementOfRankK::elementOfRankK((M+1)/2 + 1, repData.data(), 0, M);
size_t splitPos; size_t splitPos;
......
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