dev
Bill 2 years ago
parent 09e5f7dbc9
commit 5a163a6af9

5
.gitignore vendored

@ -1,3 +1,8 @@
*.json
!sample_ast.json
*.o
*.pch
*.gch
a.out.* a.out.*
*.log *.log
*.pyc *.pyc

@ -1,6 +1,7 @@
OS_SUPPORT = OS_SUPPORT =
MonetDB_LIB = MonetDB_LIB =
Threading = Threading =
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
OS_SUPPORT += server/winhelper.cpp OS_SUPPORT += server/winhelper.cpp
MonetDB_LIB += -Imonetdb/msvc msc-plugin/monetdbe.dll MonetDB_LIB += -Imonetdb/msvc msc-plugin/monetdbe.dll
@ -11,6 +12,7 @@ endif
ifeq ($(THREADING),1) ifeq ($(THREADING),1)
Threading += server/threading.cpp -DTHREADING Threading += server/threading.cpp -DTHREADING
endif endif
info: info:
$(info $(OS_SUPPORT)) $(info $(OS_SUPPORT))
$(info $(OS)) $(info $(OS))
@ -22,6 +24,6 @@ server.so:
# $(CXX) server/server.cpp server/monetdb_conn.cpp -fPIC -shared $(OS_SUPPORT) monetdb/msvc/monetdbe.dll --std=c++1z -O3 -march=native -o server.so -I./monetdb/msvc # $(CXX) server/server.cpp server/monetdb_conn.cpp -fPIC -shared $(OS_SUPPORT) monetdb/msvc/monetdbe.dll --std=c++1z -O3 -march=native -o server.so -I./monetdb/msvc
$(CXX) -shared -fPIC -flto server/server.cpp server/io.cpp server/table.cpp $(OS_SUPPORT) server/monetdb_conn.cpp $(Threading) $(MonetDB_LIB) --std=c++1z -o server.so -O3 $(CXX) -shared -fPIC -flto server/server.cpp server/io.cpp server/table.cpp $(OS_SUPPORT) server/monetdb_conn.cpp $(Threading) $(MonetDB_LIB) --std=c++1z -o server.so -O3
snippet: snippet:
$(CXX) -shared -fPIC -flto --std=c++1z out.cpp server/monetdb_conn.cpp server/table.cpp server/io.cpp $(MonetDB_LIB) -O3 -march=native -o dll.so $(CXX) -shared -fPIC -flto --std=c++1z -include server/aggregations.h out.cpp server/monetdb_conn.cpp server/table.cpp server/io.cpp $(MonetDB_LIB) -O3 -march=native -o dll.so
clean: clean:
rm *.shm -rf rm *.shm -rf

@ -104,7 +104,7 @@ class PromptState():
th = None th = None
send = None send = None
test_parser = True test_parser = True
server_mode : RunType = RunType.Threaded server_mode: RunType = RunType.Threaded
server_bin = 'server.bin' if server_mode == RunType.IPC else 'server.so' server_bin = 'server.bin' if server_mode == RunType.IPC else 'server.so'
set_ready = lambda: None set_ready = lambda: None
get_ready = lambda: None get_ready = lambda: None
@ -381,6 +381,9 @@ def main(running = lambda:True, next = input, state = None):
print(e) print(e)
except (KeyboardInterrupt): except (KeyboardInterrupt):
break break
except SystemExit:
print("\nBye.")
raise
except: except:
import code, traceback import code, traceback
sh = code.InteractiveConsole({**globals(), **locals()}) sh = code.InteractiveConsole({**globals(), **locals()})

@ -30,10 +30,10 @@ class ast_node:
def add(self, code): def add(self, code):
self.sql += code + ' ' self.sql += code + ' '
def addc(self, code): def addc(self, code):
self.ccode += code + '\n' self.ccode += code + '\n'
name = 'null' name = 'null'
def init(self, _): def init(self, _):
if self.parent is None: if self.parent is None:
self.context.sql_begin() self.context.sql_begin()
@ -43,7 +43,7 @@ class ast_node:
pass pass
def spawn(self, _): def spawn(self, _):
pass pass
def consume(self, _): def consume(self, _):
if self.parent is None: if self.parent is None:
self.emit(self.sql+';\n') self.emit(self.sql+';\n')
@ -245,7 +245,7 @@ class projection(ast_node):
if type(val[1]) is int: if type(val[1]) is int:
self.context.emitc(f'{self.outtable_name}->get_col<{key}>().initfrom({vid2cname[val[1]]});') self.context.emitc(f'{self.outtable_name}->get_col<{key}>().initfrom({vid2cname[val[1]]});')
else: else:
# for funcs evaluate f_i(x, ...) # for funcs evaluate f_i(x, ...)
self.context.emitc(f'{self.outtable_name}->get_col<{key}>() = {val[1]};') self.context.emitc(f'{self.outtable_name}->get_col<{key}>() = {val[1]};')
# print out col_is # print out col_is
self.context.emitc(f'print(*{self.outtable_name});') self.context.emitc(f'print(*{self.outtable_name});')

@ -139,4 +139,12 @@ void* Server::getCol(int col_idx){
Server::~Server(){ Server::~Server(){
close(); close();
} }
bool Server::havehge() {
#if defined(_MONETDBE_LIB_) and defined(HAVE_HGE)
return HAVE_HGE;
#else
return false;
#endif
}

@ -1,3 +1,5 @@
#ifndef __MONETDB_CONN_H__
#define __MONETDB_CONN_H__
struct Context; struct Context;
@ -19,5 +21,8 @@ struct Server{
void *getCol(int col_idx); void *getCol(int col_idx);
void close(); void close();
bool haserror(); bool haserror();
static bool havehge();
~Server(); ~Server();
}; };
#endif

@ -65,8 +65,8 @@ extern "C" int __DLLEXPORT__ binary_info() {
} }
__AQEXPORT__(bool) have_hge(){ __AQEXPORT__(bool) have_hge(){
#if defined(_MONETDBE_LIB_) and defined(HAVE_HGE) #if defined(__MONETDB_CONN_H__)
return HAVE_HGE; return Server::havehge();
#else #else
return false; return false;
#endif #endif
@ -105,10 +105,10 @@ int dll_main(int argc, char** argv, Context* cxt){
} }
for(int i = 0; i < n_recv; ++i) for(int i = 0; i < n_recv; ++i)
{ {
printf("%s, %d\n", n_recvd[i], n_recvd[i][0] == 'Q'); //printf("%s, %d\n", n_recvd[i], n_recvd[i][0] == 'Q');
if (n_recvd[i][0] == 'Q'){ if (n_recvd[i][0] == 'Q'){
server->exec(n_recvd[i] + 1); server->exec(n_recvd[i] + 1);
printf("Exec Q%d: %s\n", i, n_recvd[i]); printf("Exec Q%d: %s", i, n_recvd[i]);
} }
else if (n_recvd[i][0] == 'P' && handle && !server->haserror()) { else if (n_recvd[i][0] == 'P' && handle && !server->haserror()) {
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, n_recvd[i]+1)); code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, n_recvd[i]+1));

@ -1,10 +1,10 @@
#ifndef _TYPES_H #ifndef _TYPES_H
#define _TYPES_H #define _TYPES_H
#include <typeinfo> #include <typeinfo>
#include <functional>
#include <cstdint> #include <cstdint>
#include <type_traits> #include <type_traits>
#include <string> #include <string>
#include <tuple>
#ifdef _MSC_VER #ifdef _MSC_VER
#define __restrict__ __restrict #define __restrict__ __restrict

Loading…
Cancel
Save