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

Remove histogram from PTable and some minor fixes

parent 9bded968
Pipeline #462 failed with stages
in 4 minutes and 57 seconds
...@@ -930,7 +930,7 @@ class PTable<KeyType, std::tuple<Types...>> { ...@@ -930,7 +930,7 @@ class PTable<KeyType, std::tuple<Types...>> {
targetNode->keys.get_rw()[cnt - 1] = key; targetNode->keys.get_rw()[cnt - 1] = key;
/* Update histogram */ /* Update histogram */
const auto xtr = static_cast<uint32_t>(getBDCCFromTuple(tp).to_ulong()); const auto xtr = static_cast<uint32_t>(getBDCCFromTuple(tp).to_ulong());
targetNode->histogram.get_rw()[xtr]++; targetNode->bdccSum += xtr;
} catch (std::exception &te) { } catch (std::exception &te) {
std::cerr << te.what() << '\n' << "Inserting Tuple failed: " << tp << '\n'; std::cerr << te.what() << '\n' << "Inserting Tuple failed: " << tp << '\n';
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#define DataNode_hpp_ #define DataNode_hpp_
#include <array> #include <array>
#include <unordered_map>
#include <vector> #include <vector>
#include "config.h" #include "config.h"
...@@ -82,11 +81,12 @@ template<typename KeyType> ...@@ -82,11 +81,12 @@ template<typename KeyType>
struct DataNode { struct DataNode {
using DeletedVector = std::vector<uint16_t, allocator<uint16_t>>; using DeletedVector = std::vector<uint16_t, allocator<uint16_t>>;
using KeyVector = std::array<KeyType, 8192>; using KeyVector = std::array<KeyType, 8192>;
/*
using HistogramType = std::unordered_map<uint32_t, using HistogramType = std::unordered_map<uint32_t,
std::size_t, std::size_t,
std::hash<uint32_t>, std::hash<uint32_t>,
std::equal_to<uint32_t>, std::equal_to<uint32_t>,
allocator<std::pair<const uint32_t, std::size_t>>>; allocator<std::pair<const uint32_t, std::size_t>>>;*/
DataNode() : next(nullptr) {} DataNode() : next(nullptr) {}
DataNode(BDCC_Block _block) : next(nullptr), block(_block) {} DataNode(BDCC_Block _block) : next(nullptr), block(_block) {}
...@@ -95,14 +95,15 @@ struct DataNode { ...@@ -95,14 +95,15 @@ struct DataNode {
p<BDCC_Block> block; p<BDCC_Block> block;
p<KeyVector> keys; p<KeyVector> keys;
p<DeletedVector> deleted; p<DeletedVector> deleted;
p<HistogramType> histogram; //p<HistogramType> histogram;
p<size_t> bdccSum{0};
uint32_t calcAverageBDCC() const { inline uint32_t calcAverageBDCC() const {
auto sum = 0u; //auto sum = 0u;
for(const auto &bdccValue : histogram.get_ro()) { //for(const auto &bdccValue : histogram.get_ro()) {
sum += bdccValue.first * bdccValue.second; // sum += bdccValue.first * bdccValue.second;
} //}
return sum / reinterpret_cast<const uint32_t &>(block.get_ro()[gCountPos]); return bdccSum / reinterpret_cast<const uint32_t &>(block.get_ro()[gCountPos]);
} }
}; };
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "VTableInfo.hpp" #include "VTableInfo.hpp"
#include <libpmemobj++/allocator.hpp> #include <libpmemobj++/allocator.hpp>
#include <libpmemobj++/detail/persistent_ptr_base.hpp> #include <libpmemobj++/persistent_ptr_base.hpp>
#include <libpmemobj++/make_persistent.hpp> #include <libpmemobj++/make_persistent.hpp>
#include <libpmemobj++/make_persistent_array.hpp> #include <libpmemobj++/make_persistent_array.hpp>
#include <libpmemobj++/p.hpp> #include <libpmemobj++/p.hpp>
......
...@@ -50,7 +50,7 @@ TEST_CASE("Testing to create a new BDCCInfo instance", "[BDCCInfo]") { ...@@ -50,7 +50,7 @@ TEST_CASE("Testing to create a new BDCCInfo instance", "[BDCCInfo]") {
transaction::run(pop, [&] { transaction::run(pop, [&] {
for (auto i = 0u; i < 10; ++i) { for (auto i = 0u; i < 10; ++i) {
node->histogram.get_rw()[(i % 2) + 5]++; node->bdccSum += (i % 2) + 5;
node->keys.get_rw()[i] = i; node->keys.get_rw()[i] = i;
node->block.get_rw()[i] = 0xFF; node->block.get_rw()[i] = 0xFF;
} }
......
...@@ -146,7 +146,7 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") { ...@@ -146,7 +146,7 @@ TEST_CASE("Storing tuples in PTable", "[PTable]") {
d += get<3>(ptp); d += get<3>(ptp);
} }
REQUIRE(c == 3); // 5,6,7 REQUIRE(c == 3); // 5,6,7
REQUIRE(d == 5*12.45 + 6*12.45 + 7*12.45); REQUIRE(std::round(d*10)/10 == 5*12.45 + 6*12.45 + 7*12.45);
} }
pTable->print(); pTable->print();
......
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