Commit 8da32c15 authored by Philipp Götze's avatar Philipp Götze

🐛 Fixed a bug (alignment was calculated wrong) +++ minor changes

parent 62d776be
......@@ -39,7 +39,7 @@ else()
endif()
# C++ compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wno-deprecated -g -O2 -Wsign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -g -O2 -Wsign-compare")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs -Wno-#pragma-messages")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
......
......@@ -74,7 +74,7 @@ class PTable<KeyType, std::tuple<Types...>> {
***************************************************************************/
class BlockIterator {
using DataNodeVector = std::vector<persistent_ptr<DataNode<KeyType>>>;
const PTable<KeyType, Tuple> parent;
const PTable<KeyType, Tuple>& parent;
const ColumnRangeMap predicates;
const DataNodeVector candidates;
typename DataNodeVector::const_iterator currentNode;
......@@ -82,16 +82,12 @@ class PTable<KeyType, std::tuple<Types...>> {
uint16_t currentPos = 0u;
public:
BlockIterator(const PTable<KeyType, Tuple> &_parent, const ColumnRangeMap &_predicates) :
parent(_parent),
predicates(_predicates),
candidates(parent.getCandidateBlocks(predicates)),
currentNode(candidates.cbegin()),
currentCnt(
candidates.size() > 0 ? reinterpret_cast<const uint32_t &>((*currentNode)->block.get_ro()[gCountPos]) : 0) {
if (candidates.size() > 0) ++(*this);
else currentPos = 1; // --> setting to end()
}
BlockIterator(const PTable<KeyType, Tuple> &_parent) :
parent(_parent), currentNode(nullptr), currentPos(1) {}
BlockIterator(const PTable<KeyType, Tuple> &_parent,
const ColumnRangeMap &_predicates) :
BlockIterator(_parent, _predicates, _parent.getCandidateBlocks(_predicates)) {}
BlockIterator(const PTable<KeyType, Tuple> &_parent,
const ColumnRangeMap &_predicates,
......@@ -100,14 +96,12 @@ class PTable<KeyType, std::tuple<Types...>> {
predicates(_predicates),
candidates(_candidates),
currentNode(candidates.cbegin()),
currentCnt(
candidates.size() > 0 ? reinterpret_cast<const uint32_t &>((*currentNode)->block.get_ro()[gCountPos]) : 0) {
currentCnt(candidates.size() > 0 ?
reinterpret_cast<const uint32_t &>((*currentNode)->block.get_ro()[gCountPos]) : 0) {
if (candidates.size() > 0) ++(*this);
else currentPos = 1; // --> setting to end()
}
BlockIterator(const PTable<KeyType, Tuple> &_parent) :
parent(_parent), currentNode(nullptr), currentPos(1) {}
BlockIterator &operator++() {
if (++currentPos > currentCnt) {
......@@ -150,8 +144,7 @@ class PTable<KeyType, std::tuple<Types...>> {
bool operator==(BlockIterator other) const {
return (
// currentBlock == other.currentBlock && // This prevents the comparison with end()
currentPos == other.currentPos &&
currentCnt == other.currentCnt);
currentPos == other.currentPos && currentCnt == other.currentCnt);
}
bool operator!=(BlockIterator other) const { return !(*this == other); }
......@@ -1038,7 +1031,7 @@ class PTable<KeyType, std::tuple<Types...>> {
callForIndex(std::get<0>(dim), tp, [&dim, &xtr](auto &value) {
const auto &nBits = std::get<1>(dim);
const auto &mapping = std::get<2>(dim);
const auto alignment = nBits - std::get<3>(dim);
const auto alignment = std::get<3>(dim) - nBits;
const auto &mask = ((1L << nBits) - 1) << alignment; // based on maximum inserted value
/* Calculate tuples bin for current dimension and realign bits */
......@@ -1187,7 +1180,7 @@ class PTable<KeyType, std::tuple<Types...>> {
}
}
return true;
*/
*/
}
const bool findInsertNodeOrSplit(DataNodePtr &node, const Tuple &tp) const {
......@@ -1213,7 +1206,7 @@ class PTable<KeyType, std::tuple<Types...>> {
/* set results */
node = splitNode;
return enoughSpace ? false : true;
return enoughSpace ? false : true; // split or not
}
const bool hasEnoughSpace(const DataNodePtr &node, const Tuple &tp) const {
......
include(../../cmake/Testing.cmake.in)
if (BUILD_BENCHMARKS)
do_bench(insert)
do_bench(scan)
do_bench(point)
endif()
......@@ -36,7 +36,7 @@ using PTableType = ptable::PTable<MyKey, MyTuple>;
using Vector = std::vector<int>;
using VectorVector = std::vector<Vector>;
const int hibit(int n) noexcept;
const int hibit_pos(int n) noexcept;
template <size_t SIZE>
static inline VectorVector *createPointVector(VectorVector *v);
......@@ -47,9 +47,9 @@ struct root {
const std::string path = ptable::gPmemPath + "benchdb.db";
const auto NUM_TUPLES = 1000 * 1000;
const auto POOL_SIZE = 1024 * 1024 * 1024 * 1ull; // 1GB
const auto POOL_SIZE = 1024 * 1024 * 1024 * 2ull; // 2GB
const auto ALIGNMENT = hibit(NUM_TUPLES) + 1;
const auto ALIGNMENT = hibit_pos(NUM_TUPLES) + 1;
VectorVector pv;
const auto POINT_ACCESS = *createPointVector<NUM_TUPLES>(&pv);
......@@ -76,13 +76,13 @@ const VectorVector NON_KEY_RANGES = {
Vector{0, NUM_TUPLES - 1, 0, NUM_TUPLES - 1} //100,0%
};
const int hibit(int n) noexcept {
n |= (n >> 1);
n |= (n >> 2);
n |= (n >> 4);
n |= (n >> 8);
n |= (n >> 16);
return n - (n >> 1);
const int hibit_pos(int n) noexcept {
int c = 0;
while (n>>1 != 0) {
c++;
n>>=1;
}
return c;
}
template<size_t SIZE>
......
/*
* Copyright (C) 2017 DBIS Group - TU Ilmenau, All Rights Reserved.
*
* This file is part of PTable.
*
* PTable is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PTable is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PTable. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include "fmt/format.h"
#include "common.h"
using namespace ptable;
int main() {
pool<root> pop;
std::remove(path.c_str());
if (access(path.c_str(), F_OK) != 0) {
insert(pop, path, NUM_TUPLES);
} else {
std::cerr << "Table already exists" << std::endl;
}
auto pTable = pop.get_root()->pTable;
pop.close();
}
\ No newline at end of file
......@@ -30,10 +30,10 @@ static void BM_PointQuery(benchmark::State& state) {
const std::string path = ptable::gPmemPath + "benchdb" + std::to_string(state.range(0)) + ".db";
std::remove(path.c_str());
//std::remove(path.c_str());
if (access(path.c_str(), F_OK) != 0) {
insert(pop, path, state.range(1));
insert(pop, path, state.range(0));
} else {
std::cerr << "WARNING: Table already exists" << std::endl;
pop = pool<root>::open(path, LAYOUT);
......
......@@ -77,7 +77,7 @@ static void BM_NonKeyRangeScan(benchmark::State &state) {
static void NonKeyRangeArguments(benchmark::internal::Benchmark* b) {
for (const auto &arg : NON_KEY_RANGES) b->Args(arg);
}
//BENCHMARK(BM_NonKeyRangeScan)->Apply(NonKeyRangeArguments);
BENCHMARK(BM_NonKeyRangeScan)->Apply(NonKeyRangeArguments);
static void BM_PBPTreeKeyScan(benchmark::State &state) {
......@@ -100,7 +100,7 @@ static void BM_PBPTreeKeyScan(benchmark::State &state) {
pop.close();
//std::remove(path.c_str());
}
BENCHMARK(BM_PBPTreeKeyScan)->Apply(KeyRangeArguments);
//BENCHMARK(BM_PBPTreeKeyScan)->Apply(KeyRangeArguments);
static void BM_PBPTreeScan(benchmark::State &state) {
......@@ -132,7 +132,7 @@ static void BM_PBPTreeScan(benchmark::State &state) {
pop.close();
//std::remove(path.c_str());
}
BENCHMARK(BM_PBPTreeScan)->Apply(NonKeyRangeArguments);
//BENCHMARK(BM_PBPTreeScan)->Apply(NonKeyRangeArguments);
BENCHMARK_MAIN();
......@@ -37,8 +37,7 @@ using pmem::obj::p;
/**************************************************************************//**
* \brief This type is used for defining the dimensions for the table.
*
* key: Column ID
* value: <number of BDCC bits , bit alignment when applying mask on value>
* entry: <ColumnID, number of BDCC bits , bit alignment when applying mask on value>
*****************************************************************************/
using Dimensions = std::vector<std::tuple<uint16_t, uint16_t, uint16_t>>;
......
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