wip: string/date/time

dev
Bill 2 years ago
parent 41f51bacc5
commit 32a41545de

@ -3,12 +3,15 @@ MonetDB_LIB =
MonetDB_INC = MonetDB_INC =
Threading = Threading =
CXXFLAGS = --std=c++1z CXXFLAGS = --std=c++1z
OPTFLAGS = -O3 OPTFLAGS = -O3 -fno-semantic-interposition
LINKFLAGS = -flto LINKFLAGS = -flto
SHAREDFLAGS = -shared -fPIC SHAREDFLAGS = -shared
LIBTOOL = $(shell $(CXX) --version | grep -q 'clang' && echo "libtool -static -o"|| echo "ar rcs") FPIC = -fPIC
USELIB_FLAG = $(shell $(CXX) --version | grep -q 'clang' && echo "-Wl,-force_load"|| echo "-Wl,--whole-archive") COMPILER = $(shell $(CXX) --version | grep -q 'clang' && echo "clang"|| echo "gcc")
LIBTOOL =
USELIB_FLAG = -Wl,--whole-archive,libaquery.a -Wl,-no-whole-archive
LIBAQ_SRC = server/server.cpp server/monetdb_conn.cpp server/io.cpp LIBAQ_SRC = server/server.cpp server/monetdb_conn.cpp server/io.cpp
ifeq ($(PCH), 1) ifeq ($(PCH), 1)
PCHFLAGS = -include server/pch.hpp PCHFLAGS = -include server/pch.hpp
else else
@ -20,14 +23,20 @@ ifeq ($(OS),Windows_NT)
OS_SUPPORT += server/winhelper.cpp OS_SUPPORT += server/winhelper.cpp
MonetDB_LIB += msc-plugin/monetdbe.dll MonetDB_LIB += msc-plugin/monetdbe.dll
MonetDB_INC += -Imonetdb/msvc MonetDB_INC += -Imonetdb/msvc
LIBTOOL = gcc-ar rcs
else else
UNAME_S = $(shell uname -s) UNAME_S = $(shell uname -s)
UNAME_M = $(shell uname -m) UNAME_M = $(shell uname -m)
NULL_DEVICE = /dev/null NULL_DEVICE = /dev/null
MonetDB_LIB = MonetDB_LIB =
LIBTOOL = ar rcs
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
USELIB_FLAG = -Wl,-force_load
MonetDB_LIB += -L$(shell brew --prefix monetdb)/lib MonetDB_LIB += -L$(shell brew --prefix monetdb)/lib
MonetDB_INC += -I$(shell brew --prefix monetdb)/include/monetdb MonetDB_INC += -I$(shell brew --prefix monetdb)/include/monetdb
ifeq ($(COMPILER), clang)
LIBTOOL = libtool -static -o
endif
ifneq ($(UNAME_M),arm64) ifneq ($(UNAME_M),arm64)
OPTFLAGS += -march=native OPTFLAGS += -march=native
endif endif
@ -43,6 +52,8 @@ ifeq ($(THREADING),1)
Threading += -DTHREADING Threading += -DTHREADING
endif endif
SHAREDFLAGS += $(FPIC)
info: info:
$(info $(OS_SUPPORT)) $(info $(OS_SUPPORT))
$(info $(OS)) $(info $(OS))
@ -52,9 +63,9 @@ info:
$(info $(MonetDB_INC)) $(info $(MonetDB_INC))
$(info $(CXX)) $(info $(CXX))
pch: pch:
$(CXX) -x c++-header server/pch.hpp $(MonetDB_INC) $(OPTFLAGS) $(CXXFLAGS) $(Threading) $(CXX) -x c++-header server/pch.hpp $(FPIC) $(MonetDB_INC) $(OPTFLAGS) $(CXXFLAGS) $(Threading)
libaquery.a: libaquery.a:
$(CXX) -c $(PCHFLAGS) $(LIBAQ_SRC) $(MonetDB_INC) $(MonetDB_LIB) $(OS_SUPPORT) $(Threading) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) &&\ $(CXX) -c $(FPIC) $(PCHFLAGS) $(LIBAQ_SRC) $(MonetDB_INC) $(MonetDB_LIB) $(OS_SUPPORT) $(Threading) $(OPTFLAGS) $(LINKFLAGS) $(CXXFLAGS) &&\
$(LIBTOOL) libaquery.a *.o &&\ $(LIBTOOL) libaquery.a *.o &&\
ranlib libaquery.a ranlib libaquery.a
@ -77,6 +88,6 @@ docker:
docker build -t aquery . docker build -t aquery .
clean: clean:
rm *.shm *.o dll.so server.so server.bin -rf 2> $(NULL_DEVICE) || true rm *.shm *.o dll.so server.so server.bin libaquery.a .cached -rf 2> $(NULL_DEVICE) || true

@ -320,7 +320,7 @@ def save(q:str, cxt: xengine.Context):
savefile('udf', 'udf', '.hpp') savefile('udf', 'udf', '.hpp')
savefile('sql', 'sql') savefile('sql', 'sql')
def prompt(running = lambda:True, next = input, state = None): def prompt(running = lambda:True, next = lambda:input('> '), state = None):
if state is None: if state is None:
state = init_prompt() state = init_prompt()
q = '' q = ''
@ -333,7 +333,6 @@ def prompt(running = lambda:True, next = input, state = None):
state.init() state.init()
while state.get_ready(): while state.get_ready():
time.sleep(.00001) time.sleep(.00001)
print("> ", end="")
og_q : str = next() og_q : str = next()
q = og_q.lower().strip() q = og_q.lower().strip()
if q == 'exec': # generate build and run (AQuery Engine) if q == 'exec': # generate build and run (AQuery Engine)

@ -71,7 +71,8 @@ typedef void (*deallocator_t) (void*);
extern void* Aalloc(unsigned long long sz); extern void* Aalloc(unsigned long long sz);
extern void Afree(void * mem); extern void Afree(void * mem);
extern void register_memory(void* ptr, deallocator_t deallocator); extern void register_memory(void* ptr, deallocator_t deallocator);
extern void init_session(Context* cxt);
__AQEXPORT__(void) init_session(Context* cxt);
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {} #define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
#endif #endif

@ -0,0 +1,4 @@
example:
g++-9 -shared -fPIC example.cpp aquery_mem.cpp -fno-semantic-interposition -Ofast -march=native -flto --std=c++1z -o ../test.so
all: example

@ -51,8 +51,6 @@ namespace types {
using namespace chrono; using namespace chrono;
string date_t::toString() const { string date_t::toString() const {
uint32_t curr_v = val; uint32_t curr_v = val;
tm;
time_t;
return string() + string("/") + string() + string("/") + string(); return string() + string("/") + string() + string("/") + string();
} }
string time_t::toString() const { string time_t::toString() const {
@ -71,7 +69,7 @@ string base62uuid(int l = 8) {
static mt19937_64 engine(chrono::system_clock::now().time_since_epoch().count()); static mt19937_64 engine(chrono::system_clock::now().time_since_epoch().count());
static uniform_int_distribution<uint64_t> u(0x10000, 0xfffff); static uniform_int_distribution<uint64_t> u(0x10000, 0xfffff);
uint64_t uuid = (u(engine) << 32ull) + (chrono::system_clock::now().time_since_epoch().count() & 0xffffffff); uint64_t uuid = (u(engine) << 32ull) + (chrono::system_clock::now().time_since_epoch().count() & 0xffffffff);
printf("%p\n", uuid); printf("%llu\n", uuid);
string ret; string ret;
while (uuid && l-- >= 0) { while (uuid && l-- >= 0) {
ret = string("") + base62alp[uuid % 62] + ret; ret = string("") + base62alp[uuid % 62] + ret;

@ -1,4 +1,5 @@
#pragma once #ifndef __AQ_PCH_H__
#define __AQ_PCH_H__
#include "libaquery.h" #include "libaquery.h"
#include "aggregations.h" #include "aggregations.h"
@ -15,3 +16,5 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
#endif

@ -227,12 +227,25 @@ int dll_main(int argc, char** argv, Context* cxt){
} }
int launcher(int argc, char** argv){ int launcher(int argc, char** argv){
#ifdef _WIN32
constexpr char sep = '\\';
#else
constexpr char sep = '/';
#endif
std::string str = " "; std::string str = " ";
std::string pwd = "";
if (argc > 0)
pwd = argv[0];
auto pos = pwd.find_last_of(sep);
if (pos == std::string::npos)
pos = 0;
pwd = pwd.substr(0, pos);
for (int i = 1; i < argc; i++){ for (int i = 1; i < argc; i++){
str += argv[i]; str += argv[i];
str += " "; str += " ";
} }
str = std::string("python3 prompt.py ") + str; str = std::string("cd ") + pwd + std::string("&& python3 ./prompt.py ") + str;
return system(str.c_str()); return system(str.c_str());
} }

@ -105,7 +105,7 @@ ThreadPool::ThreadPool(uint32_t n_threads)
current_payload = new payload_t[n_threads]; current_payload = new payload_t[n_threads];
for (uint32_t i = 0; i < n_threads; ++i){ for (uint32_t i = 0; i < n_threads; ++i){
atomic_init(tf + i, 0b10); atomic_init(tf + i, static_cast<unsigned char>(0b10));
th[i] = thread(&ThreadPool::daemon_proc, this, i); th[i] = thread(&ThreadPool::daemon_proc, this, i);
} }

Loading…
Cancel
Save