trigger demo
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
all:
|
||||
$(CXX) -include ../server/pch.hpp putdata.cpp ../libaquery.a -shared -fPIC --std=c++2a -Ofast -DNDEBUG -fno-stack-protector -march=native -DTHREADING -D__AQUERY_ITC_USE_SEMPH__ -I/usr/local/opt/monetdb/include/monetdb -flto -s -fno-semantic-interposition -L/usr/local/opt/monetdb/lib -lmonetdbe -lmonetdbsql -lbat -o ../procedures/demoi0.so
|
||||
$(CXX) -include ../server/pch.hpp action.cpp ../libaquery.a -shared -fPIC --std=c++2a -Ofast -DNDEBUG -fno-stack-protector -march=native -DTHREADING -D__AQUERY_ITC_USE_SEMPH__ -I/usr/local/opt/monetdb/include/monetdb -flto -s -fno-semantic-interposition -L/usr/local/opt/monetdb/lib -lmonetdbe -lmonetdbsql -lbat -o ../procedures/democa0.so
|
||||
$(CXX) -include ../server/pch.hpp query.cpp ../libaquery.a -shared -fPIC --std=c++2a -Ofast -DNDEBUG -fno-stack-protector -march=native -DTHREADING -D__AQUERY_ITC_USE_SEMPH__ -I/usr/local/opt/monetdb/include/monetdb -flto -s -fno-semantic-interposition -L/usr/local/opt/monetdb/lib -lmonetdbe -lmonetdbsql -lbat -o ../procedures/democq0.so
|
||||
|
||||
dbg:
|
||||
$(CXX) -include ../server/pch.hpp putdata.cpp -g3 -march=native ../libaquery.a -shared -fPIC --std=c++2a -D_DEBUG -DTHREADING -D__AQUERY_ITC_USE_SEMPH__ -I/usr/local/opt/monetdb/include/monetdb -L/usr/local/opt/monetdb/lib -lmonetdbe -lmonetdbsql -lbat -o ../procedures/demoi0.so
|
||||
$(CXX) -include ../server/pch.hpp action.cpp -g3 -march=native ../libaquery.a -shared -fPIC --std=c++2a -D_DEBUG -DTHREADING -D__AQUERY_ITC_USE_SEMPH__ -I/usr/local/opt/monetdb/include/monetdb -L/usr/local/opt/monetdb/lib -lmonetdbe -lmonetdbsql -lbat -o ../procedures/democa0.so
|
||||
$(CXX) -include ../server/pch.hpp query.cpp -g3 -march=native ../libaquery.a -shared -fPIC --std=c++2a -D_DEBUG -DTHREADING -D__AQUERY_ITC_USE_SEMPH__ -I/usr/local/opt/monetdb/include/monetdb -L/usr/local/opt/monetdb/lib -lmonetdbe -lmonetdbsql -lbat -o ../procedures/democq0.so
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "../server/libaquery.h"
|
||||
|
||||
#ifndef __AQ_USE_THREADEDGC__
|
||||
|
||||
#include "../server/gc.h"
|
||||
__AQEXPORT__(void) __AQ_Init_GC__(Context* cxt) {
|
||||
GC::gc_handle = static_cast<GC*>(cxt->gc);
|
||||
GC::scratch_space = nullptr;
|
||||
}
|
||||
|
||||
#else // __AQ_USE_THREADEDGC__
|
||||
#define __AQ_Init_GC__(x)
|
||||
#endif // __AQ_USE_THREADEDGC__
|
||||
bool (*fit_inc)(vector_type<vector_type<double>> X, vector_type<int64_t> y) = nullptr;
|
||||
|
||||
#include "../server/monetdb_conn.h"
|
||||
__AQEXPORT__(int) action(Context* cxt) {
|
||||
using namespace std;
|
||||
using namespace types;
|
||||
if (fit_inc == nullptr)
|
||||
fit_inc = (decltype(fit_inc))(cxt->get_module_function("fit_inc"));
|
||||
|
||||
auto server = static_cast<Server*>(cxt->alt_server);
|
||||
auto len = uint32_t(monetdbe_get_size(*((void**)server->server), "source"));
|
||||
auto x_1bN = ColRef<vector_type<double>>(len, monetdbe_get_col(*((void**)(server->server)), "source", 0));
|
||||
auto y_6uX = ColRef<int64_t>(len, monetdbe_get_col(*((void**)(server->server)), "source", 1));
|
||||
fit_inc(x_1bN, y_6uX);
|
||||
puts("action done.");
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+13
@@ -0,0 +1,13 @@
|
||||
create table source(x vecdouble, y int64);
|
||||
LOAD MODULE FROM "./libirf.so" FUNCTIONS (
|
||||
newtree(height:int, f:int64, sparse:vecint, forget:double, maxf:int64, noclasses:int64, e:int) -> bool,
|
||||
fit_inc(X:vecvecdouble, y:vecint64) -> bool,
|
||||
predict(X:vecvecdouble) -> vecint
|
||||
);
|
||||
|
||||
create table elec_sparse(v int);
|
||||
|
||||
insert into elec_sparse values (0), (1), (1), (1), (1), (1), (1);
|
||||
|
||||
select newtree(30, 7, elec_sparse.v, 0, 4, 2, 1) from elec_sparse
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "../server/libaquery.h"
|
||||
|
||||
#ifndef __AQ_USE_THREADEDGC__
|
||||
|
||||
#include "../server/gc.h"
|
||||
__AQEXPORT__(void) __AQ_Init_GC__(Context* cxt) {
|
||||
GC::gc_handle = static_cast<GC*>(cxt->gc);
|
||||
GC::scratch_space = nullptr;
|
||||
}
|
||||
|
||||
#else // __AQ_USE_THREADEDGC__
|
||||
#define __AQ_Init_GC__(x)
|
||||
#endif // __AQ_USE_THREADEDGC__
|
||||
#include "../server/monetdb_conn.h"
|
||||
#include "../csv.h"
|
||||
|
||||
__AQEXPORT__(int) ld(Context* cxt) {
|
||||
using namespace std;
|
||||
using namespace types;
|
||||
static int cnt = 0;
|
||||
if (cnt > 700)
|
||||
return 1;
|
||||
else
|
||||
++cnt;
|
||||
char data_name[] = "data/electricity/electricity ";
|
||||
auto server = static_cast<Server*>(cxt->alt_server);
|
||||
const char* names_fZrv[] = {"x", "y"};
|
||||
auto tbl_6erF = new TableInfo<vector_type<double>,int64_t>("source", names_fZrv);
|
||||
decltype(auto) c_31ju0e = tbl_6erF->get_col<0>();
|
||||
decltype(auto) c_4VlzrR = tbl_6erF->get_col<1>();
|
||||
c_31ju0e.init("x");
|
||||
c_4VlzrR.init("y");
|
||||
auto nxt = to_text(data_name + 28, cnt);
|
||||
memcpy(nxt, ".csv", 5);
|
||||
puts(data_name);
|
||||
AQCSVReader<2, ',', ';'> csv_reader_7g0GY7(data_name);
|
||||
csv_reader_7g0GY7.next_line();
|
||||
vector_type<double> tmp_5XMNcBz5;
|
||||
int64_t tmp_5dAHIJ1d;
|
||||
while(csv_reader_7g0GY7.read_row(tmp_5XMNcBz5,tmp_5dAHIJ1d)) {
|
||||
c_31ju0e.emplace_back(tmp_5XMNcBz5);
|
||||
c_4VlzrR.emplace_back(tmp_5dAHIJ1d);
|
||||
}
|
||||
tbl_6erF->monetdb_append_table(cxt->alt_server, "source");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "../server/libaquery.h"
|
||||
|
||||
#ifndef __AQ_USE_THREADEDGC__
|
||||
|
||||
#include "../server/gc.h"
|
||||
__AQEXPORT__(void) __AQ_Init_GC__(Context* cxt) {
|
||||
GC::gc_handle = static_cast<GC*>(cxt->gc);
|
||||
GC::scratch_space = nullptr;
|
||||
}
|
||||
|
||||
#else // __AQ_USE_THREADEDGC__
|
||||
#define __AQ_Init_GC__(x)
|
||||
#endif // __AQ_USE_THREADEDGC__
|
||||
|
||||
#include "../server/monetdb_conn.h"
|
||||
__AQEXPORT__(int) query(Context* cxt) {
|
||||
using namespace std;
|
||||
using namespace types;
|
||||
auto server = static_cast<Server*>(cxt->alt_server);
|
||||
static uint32_t old_sz = 0;
|
||||
constexpr static uint32_t min_delta = 200;
|
||||
auto newsz = monetdbe_get_size(*(void**) server->server, "source");
|
||||
if (newsz > old_sz + min_delta) {
|
||||
puts("query true.");
|
||||
old_sz = uint32_t(newsz);
|
||||
return 1;
|
||||
}
|
||||
puts("query false.");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
create table test(x vecdouble, y int64);
|
||||
load complex data infile "data/electricity/electricity872.csv" into table test fields terminated by ',' element terminated by ';';
|
||||
select predict(x) from test
|
||||
Reference in New Issue
Block a user