diff --git a/.test.cpp.swp b/.test.cpp.swp new file mode 100644 index 0000000..197e973 Binary files /dev/null and b/.test.cpp.swp differ diff --git a/Makefile b/Makefile index 43295fa..81b2645 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,11 @@ MonetDB_LIB = MonetDB_INC = Threading = CXXFLAGS = --std=c++1z -OPTFLAGS = -O3 -DNDEBUG +ifeq ($(AQ_DEBUG), 1) + OPTFLAGS = -g3 +else + OPTFLAGS = -O3 -DNDEBUG -fno-stack-protector +endif LINKFLAGS = -flto # + $(AQ_LINK_FLAG) SHAREDFLAGS = -shared FPIC = -fPIC diff --git a/README.md b/README.md index da5b277..2211e3e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ AQuery++ Database is a cross-platform, In-Memory Column-Store Database that inco - See installation instructions from [docker.com](https://www.docker.com). Run **docker desktop** to start docker engine. - In AQuery root directory, type `make docker` to build the docker image from scratch. - For Arm-based Mac users, you would have to build and run the **x86_64** docker image because MonetDB doesn't offer official binaries for arm64 Linux. (Run `docker buildx build --platform=linux/amd64 -t aquery .` instead of `make docker`) - - Finally run the image in **interactive** mode (`docker run -it aquery --name aquery`) + - Finally run the image in **interactive** mode (`docker run --name aquery -it aquery`) - When you need to access the container again run `docker start -ai aquery` - If there is a need to access the system shell within AQuery, type `dbg` to activate python interpreter and type `os.system('sh')` to launch a shell. diff --git a/aquery_config.py b/aquery_config.py index 4155ea8..cdff3b7 100644 --- a/aquery_config.py +++ b/aquery_config.py @@ -2,7 +2,7 @@ ## GLOBAL CONFIGURATION FLAGS -version_string = '0.4.8a' +version_string = '0.4.9a' add_path_to_ldpath = True rebuild_backend = False run_backend = True diff --git a/build.py b/build.py index f53a467..8cd4b91 100644 --- a/build.py +++ b/build.py @@ -109,7 +109,9 @@ class build_manager: os.environ['CXX'] = mgr.cxx if mgr.cxx else 'c++' else: mgr.cxx = os.environ['CXX'] - + if 'AQ_DEBUG' not in os.environ: + os.environ['AQ_DEBUG'] = '0' if mgr.OptimizationLv else '1' + def libaquery_a(self): self.build_cmd = [['rm', 'libaquery.a'],['make', 'libaquery.a']] return self.build() diff --git a/cims.sh b/cims.sh index e022920..dce0937 100644 --- a/cims.sh +++ b/cims.sh @@ -1,4 +1,4 @@ -#!/usr/bash +#!/bin/bash echo "Don't execute this script if it's not on CIMS servers." echo "run this script with source command. e.g. source ./cims.sh or . ./cims.sh" module load gcc-11.2 diff --git a/engine/types.py b/engine/types.py index 7f6491f..106494a 100644 --- a/engine/types.py +++ b/engine/types.py @@ -226,7 +226,17 @@ def long_return(*_ : Types) -> Types: return LongT.long_type def lfp_return(*_ : Types) -> Types: return LongT.fp_type - +def pack_return(*args : Types) -> Types: + if len(args) == 0: + raise ValueError('0 arguments in pack expression') + inner_ty = args[0] + for a in args: + if a != inner_ty: + raise ValueError('pack expression with different types') + if isinstance(inner_ty, VectorT): + print('warning: packing vector types') + inner_ty = inner_ty.inner_type + return VectorT(args[0]) def as_is (t: Types) -> Types: return t @@ -269,6 +279,15 @@ def windowed_fn_behavor(op: OperatorBase, c_code, *x): else: name = op.cname if len(x) == 1 else op.cname[:-1] + 'w' return f'{name}({", ".join([f"{xx}" for xx in x])})' + +def pack_behavior(op: OperatorBase, c_code, *x): + if len(x) == 0: + raise ValueError('0 arguments in pack expression') + + if not c_code: + return f'{op.sqlname}({", ".join([f"{xx}" for xx in x])})' + else: + return f'decltype({x[0]})::pack(len(x) + 1, {", ".join([f"{xx}.s()" for xx in x])})' # arithmetic opadd = OperatorBase('add', 2, auto_extension, cname = '+', sqlname = '+', call = binary_op_behavior) @@ -307,6 +326,7 @@ fnmins = OperatorBase('mins', [1, 2], ty_clamp(as_is, -1), cname = 'mins', sqlna fnsums = OperatorBase('sums', [1, 2], ext(ty_clamp(auto_extension, -1)), cname = 'sums', sqlname = 'SUMS', call = windowed_fn_behavor) fnavgs = OperatorBase('avgs', [1, 2], fp(ext(ty_clamp(auto_extension, -1))), cname = 'avgs', sqlname = 'AVGS', call = windowed_fn_behavor) fncnt = OperatorBase('count', 1, int_return, cname = 'count', sqlname = 'COUNT', call = count_behavior) +fnpack = OperatorBase('pack', -1, pack_return, cname = 'pack', sqlname = 'PACK', call = pack_behavior) # special def is_null_call_behavior(op:OperatorBase, c_code : bool, x : str): if c_code : @@ -328,12 +348,16 @@ fnpow = OperatorBase('pow', 2, lambda *_ : DoubleT, cname = 'pow', sqlname = 'PO def _op_make_dict(*items : OperatorBase): return { i.name: i for i in items} builtin_binary_arith = _op_make_dict(opadd, opdiv, opmul, opsub, opmod) -builtin_binary_logical = _op_make_dict(opand, opor, opxor, opgt, oplt, opge, oplte, opneq, opeq) +builtin_binary_logical = _op_make_dict(opand, opor, opxor, opgt, oplt, + opge, oplte, opneq, opeq) builtin_unary_logical = _op_make_dict(opnot) builtin_unary_arith = _op_make_dict(opneg) builtin_unary_special = _op_make_dict(spnull, opdistinct) builtin_cstdlib = _op_make_dict(fnsqrt, fnlog, fnsin, fncos, fntan, fnpow) -builtin_func = _op_make_dict(fnmax, fnmin, fnsum, fnavg, fnmaxs, fnmins, fndeltas, fnratios, fnlast, fnfirst, fnsums, fnavgs, fncnt) +builtin_func = _op_make_dict(fnmax, fnmin, fnsum, fnavg, fnmaxs, + fnmins, fndeltas, fnratios, fnlast, + fnfirst, fnsums, fnavgs, fncnt, + fnpack) user_module_func = {} builtin_operators : Dict[str, OperatorBase] = {**builtin_binary_arith, **builtin_binary_logical, **builtin_unary_arith, **builtin_unary_logical, **builtin_unary_special, **builtin_func, **builtin_cstdlib, diff --git a/prompt.py b/prompt.py index acb0376..a495eca 100644 --- a/prompt.py +++ b/prompt.py @@ -497,6 +497,23 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None): elif q == 'exit' or q == 'exit()' or q == 'quit' or q == 'quit()' or q == '\\q': rm(state) exit() + elif q.startswith('sh'): + from distutils.spawn import find_executable + qs = re.split(r'[ \t]', q) + shells = ('zsh', 'bash', 'sh', 'fish', 'cmd', 'pwsh', 'powershell', 'csh', 'tcsh', 'ksh') + shell_path = '' + if len(qs) > 1 and qs[1] in shells: + shell_path = find_executable(qs[1]) + if shell_path: + os.system(shell_path) + else: + for sh in shells: + shell_path = find_executable(sh) + if shell_path: + os.system(shell_path) + break + + continue elif q == 'r': # build and run if state.server_mode == RunType.Threaded: qs = [ctypes.c_char_p(bytes(q, 'utf-8')) for q in cxt.queries if len(q)] diff --git a/server/table.h b/server/table.h index 58691df..107e2ae 100644 --- a/server/table.h +++ b/server/table.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "io.h" #include "hasher.h" @@ -26,6 +27,13 @@ namespace types { struct Coercion; } #endif +struct ColRef_cstorage { + void* container; + unsigned int size, capacity; + const char* name; + int ty; // what if enum is not int? +}; + template