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

Small fixes and nvm evaluation files removed

parent b562c56c
......@@ -153,6 +153,3 @@ add_custom_command(
)
endif()
endif()
......@@ -17,7 +17,7 @@ include(CTest)
set(PIPEFABRIC_DIR "/usr/local/pfabric")
# Set to 1 if you need log output
add_definitions(-DDO_LOG=1)
add_definitions(-DDO_LOG=0)
#The following variables enable or disable additional functionalities, which can be switched off to reduce build time.
......@@ -298,8 +298,6 @@ if(USE_ROCKSDB_TABLE)
${BOOST_LIBRARIES}
${ZEROMQ_LIBRARIES}
${ROCKSDB_LIB})
add_executable(rock_test rock_test.cpp)
target_link_libraries(rock_test pfabric_core ${ROCKSDB_LIB})
endif()
if(USE_NVML_TABLE)
......@@ -317,10 +315,6 @@ if(USE_NVML_TABLE)
${ZEROMQ_LIBRARIES}
${NVML_LIBRARIES})
add_executable(nvm_scan nvm_scan.cpp)
target_link_libraries(nvm_scan pfabric_core)
add_executable(nvm_insert nvm_insert.cpp)
target_link_libraries(nvm_insert pfabric_core)
endif()
#-----------------------------------------------------------------------------------------
......
......@@ -142,11 +142,12 @@ public:
// if found then we return it
return std::static_pointer_cast<Table<RecordType, KeyType>>(it->second);
}
else
else {
// otherwise we just return an empty pointer
// TODO: shouldn't we throw an exception here???
std::cout << "table '" << tblName << "' not found" << std::endl;
return std::shared_ptr<Table<RecordType, KeyType>>();
}
}
bool tableExists(const std::string& tblName) const;
......
......@@ -27,7 +27,7 @@
#include "nvml/include/libpmemobj++/make_persistent.hpp"
#include "nvml/include/libpmemobj++/persistent_ptr.hpp"
#define PLOG(msg) if(false/*DO_LOG*/) std::cout << "[PTable] " << msg << '\n';
#define PLOG(msg) if(DO_LOG) std::cout << "[PTable] " << msg << '\n';
namespace pfabric {
namespace nvm {
......
......@@ -390,7 +390,7 @@ class PTable {
transaction::exec_tx(pop, [&] { newNodes = splitBlock(targetNode); });
else
newNodes = splitBlock(targetNode);
insert(key, rec);
return insert(key, rec);
} catch (std::exception &te) {
std::cerr << te.what() << '\n'
<< "Splitting table block failed. Tuple not inserted: "
......
#include "pfabric.hpp"
using namespace pfabric::nvm;
using nvml::obj::make_persistent;
using nvml::obj::p;
using nvml::obj::persistent_ptr;
using nvml::obj::pool;
using nvml::obj::transaction;
using MyTuple = pfabric::Tuple<int, int, string, double>;
using PTableType = pfabric::PTable<MyTuple, int>;
int main() {
std::chrono::high_resolution_clock::time_point start, end;
std::vector<typename std::chrono::duration<int64_t, micro>::rep> measures;
struct root {
persistent_ptr<PTableType> pTable;
};
pool<root> pop;
const std::string path = "/mnt/pmem/tests/testdb.db";
std::remove(path.c_str());
if (access(path.c_str(), F_OK) != 0) {
pop = pool<root>::create(path, LAYOUT, 1 << 30);
transaction::exec_tx(pop, [&] {
using namespace pfabric;
auto tInfo = TableInfo("MyTable", {
ColumnInfo("a", ColumnInfo::Int_Type),
ColumnInfo("b", ColumnInfo::Int_Type),
ColumnInfo("c", ColumnInfo::String_Type),
ColumnInfo("d", ColumnInfo::Double_Type)
});
pop.get_root()->pTable = make_persistent<PTableType>(tInfo, ColumnIntMap({{0, 10}/*, {3, 10}*/}));
});
} else {
std::cerr << "WARNING: Table already exists" << std::endl;
pop = pool<root>::open(path, LAYOUT);
}
auto pTable = pop.get_root()->pTable;
for (unsigned int i = 0; i < 1000000; i++) {
auto tup = MyTuple(i + 1,
(i + 1) * 100,
fmt::format("String #{0}", i),
i * 12.345);
start = std::chrono::high_resolution_clock::now();
pTable->insert(i + 1, tup);
end = std::chrono::high_resolution_clock::now();
auto diff = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
measures.push_back(diff);
}
auto avg = std::accumulate(measures.begin(), measures.end(), 0) / measures.size();
auto minmax = std::minmax_element(std::begin(measures), std::end(measures));
std::cout << "\nInsert Statistics in µs: "
<< "\n\tAvg: \t" << avg
<< "\n\tMin: \t" << *minmax.first
<< "\n\tMax: \t" << *minmax.second << '\n';
pop.close();
}
#include "pfabric.hpp"
using namespace pfabric::nvm;
using nvml::obj::make_persistent;
using nvml::obj::p;
using nvml::obj::persistent_ptr;
using nvml::obj::pool;
using nvml::obj::transaction;
using MyTuple = pfabric::Tuple<int, int, string, double>;
using PTableType = pfabric::PTable<MyTuple, int>;
int main() {
std::chrono::high_resolution_clock::time_point start, end;
std::vector<typename std::chrono::duration<int64_t, micro>::rep> measures;
start = std::chrono::high_resolution_clock::now();
struct root {
persistent_ptr<PTableType> pTable;
};
pool<root> pop;
const std::string path = "/mnt/pmem/tests/testdb.db";
start = std::chrono::high_resolution_clock::now();
if (access(path.c_str(), F_OK) != 0) {
std::cerr << "ERROR: Table not found" << std::endl;
return 1;
} else {
pop = pool<root>::open(path, LAYOUT);
}
auto pTable = pop.get_root()->pTable;
/* RangeScan using Block iterator */
auto iter = pTable->rangeScan(ColumnRangeMap({{0, std::make_pair<int, int>(1000, 2000)}/*,
{2, std::make_pair<std::string, std::string>("String #1", "String #9")}*/}));
end = std::chrono::high_resolution_clock::now();
std::cout << "Init time in µs: " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count()
<< '\n';
start = std::chrono::high_resolution_clock::now();
for (const auto &tp: iter) {
tp;
}
end = std::chrono::high_resolution_clock::now();
std::cout << "RangeScan in µs: " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count()
<< '\n';
/* Scan via PTuple iterator */
{
start = std::chrono::high_resolution_clock::now();
auto eIter = pTable->end();
auto iter = pTable->select(
[](const PTuple<MyTuple, int> &tp) {
return (tp.get<0>() >= 800) && (tp.get<0>() <= 900);
});
for (; iter != eIter; iter++) {
(*iter).get<0>();
}
end = std::chrono::high_resolution_clock::now();
std::cout << "PTupleScan in µs: " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count()
<< '\n';
}
pop.close();
}
//
// Created by phil on 11.09.17.
//
#include <vector>
#include "pfabric.hpp"
using namespace pfabric;
typedef pfabric::Tuple<int, int, string, double> MyTuple;
template<typename RecordType, typename KeyType>
using LTable = RDBTable<RecordType, KeyType>;
int main() {
std::chrono::high_resolution_clock::time_point start, end;
std::vector<typename std::chrono::duration<int64_t, micro>::rep> measures;
auto testTable = std::make_shared<LTable<MyTuple, int>>("MyTestTable1");
for (int i = 0; i < 10000; i++) {
auto tp = MyTuple(i + 1,
(i + 1) * 100,
fmt::format("String#{}", i),
i * 12.345);
start = std::chrono::high_resolution_clock::now();
testTable->insert(i, tp);
end = std::chrono::high_resolution_clock::now();
auto diff = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
measures.push_back(diff);
}
auto avg = std::accumulate(measures.begin(), measures.end(), 0) / measures.size();
auto minmax = std::minmax_element(std::begin(measures), std::end(measures));
std::cout << "\nInsert Statistics in µs: "
<< "\n\tAverage: " << avg
<< "\n\tMin: " << *minmax.first
<< "\n\tMax: " << *minmax.second << '\n';
auto ptp = testTable->getByKey(5);
std::cout << "Tuple 5: " << ptp << '\n';
/* Clean up */
testTable->drop();
}
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