Commit e6867dcb authored by Constantin Pohl's avatar Constantin Pohl
Browse files

Added test files and DEBS main

parent cbdb8c5b
......@@ -542,5 +542,7 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/"
############################################################################################
#
add_subdirectory(DEBS2018)
# show used compiler
message("Using Compiler: ${CMAKE_CXX_COMPILER_ID}.")
add_executable(debs2018 DEBS2018.cpp)
target_link_libraries(debs2018
pfabric_core
)
//This class contains the solution for the DEBS 2018 - Grand Challenge
//Call the executable directly from build folder, e.g. "$ ./DEBS2018/debs2018"
#include "pfabric.hpp"
using namespace pfabric;
//raw input tuple from file
typedef TuplePtr<
std::string, //vessel_ID
short, //speed
int, //longitude
int, //latitude
short, //course
short, //heading
std::string, //timestamp
std::string, //departure port name
std::string //reported draught
> rawInput;
/*
* -----------------------------------------------------------------------------------------------------------------------
* Preprocessing input data
* -----------------------------------------------------------------------------------------------------------------------
*/
//preprocessed tuple
typedef TuplePtr<
size_t, //vessel_ID
short, //speed
int, //longitude
int, //latitude
short, //course
short, //heading
//Timestamp, //timestamp
std::string, //timestamp
std::string, //departure port name
int //reported draught
> preprocInput;
/*
* The following is done in preprocessing:
* - ID is a hex value, initially stored in String because of intense size, hash to size_t for later partitioning
* - Timestamp is initially a String, convert to Timestamp (TODO)
* - Some test data does not have a draught value, replace attribute with 0 and convert to int
*/
inline preprocInput preprocessing(rawInput tp) {
size_t hx = std::hash<std::string>{}(get<0>(tp));
//TODO Parse String to Timestamp
//Timestamp tm = ...
std::string tm = get<6>(tp);
if(get<8>(tp).length() == 1) {
return makeTuplePtr(hx, get<1>(tp), get<2>(tp),
get<3>(tp), get<4>(tp), get<5>(tp),
tm, get<7>(tp), 0);
} else {
return makeTuplePtr(hx, get<1>(tp), get<2>(tp),
get<3>(tp), get<4>(tp), get<5>(tp),
tm, get<7>(tp), stoi(get<8>(tp)));
}
}
/*
* -----------------------------------------------------------------------------------------------------------------------
* Main
* -----------------------------------------------------------------------------------------------------------------------
*/
int main(int argc, char **argv) {
PFabricContext ctx;
auto t = ctx.createTopology();
//Read test file 1
auto s1 = t->newStreamFromFile("../src/DEBS2018/data/vessel24hpublic.csv")
.extract<rawInput>(';')
//preprocessing with map
.map<preprocInput>([](auto tp, bool outdated) -> preprocInput { return preprocessing(tp); })
//.partitionBy([](auto tp) { return get<0>(tp) % 5; }, 5)
//TODO: Do something with the data
//.merge()
.print()
;
//Read test file 2
auto s2 = t->newStreamFromFile("../src/DEBS2018/data/1000rowspublic.csv")
.extract<rawInput>(';')
//preprocessing with map
.map<preprocInput>([](auto tp, bool outdated) -> preprocInput { return preprocessing(tp); })
//.partitionBy([](auto tp) { return get<0>(tp) % 5; }, 5)
//TODO: Do something with the data
//.merge()
.print()
;
t->start(false);
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
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