From 826c156d9f48004c6e8c5a67a02c59ca7c9ff721 Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 11 Oct 2022 21:54:20 +0800 Subject: [PATCH] bug fixes --- README.md | 13 ++++++------ prompt.py | 15 ++++++++++++++ reconstruct/ast.py | 5 +++-- reconstruct/expr.py | 8 +++++++- reconstruct/storage.py | 7 ++++--- server/types.h | 46 +++++++++++++++++++++--------------------- 6 files changed, 58 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index b993728..da5b277 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ AQuery++ Database is a cross-platform, In-Memory Column-Store Database that incorporates compiled query execution. (**Note**: If you encounter any problems, feel free to contact me via ys3540@nyu.edu) -## Docker (Recommended): +`## Docker (Recommended): - 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`) @@ -57,12 +57,11 @@ There're multiple options to run AQuery on Windows. But for better consistency I - Copy or link `mingw64/libexec/gcc///liblto-plugin.dll` to `mingw64/lib/bfd-plugins/` For Link time optimization support on gcc-ar and gcc-ranlib - For Visual Studio: -1. Install python3.6 or above from [official website](https://www.python.org/downloads/windows/) or Microsoft Store. - 1. Install Microsoft Visual Studio 2022 or later with **Desktop development with C++** selected. - 2. Clone AQuery repo from [Github](https://github.com/sunyinqi0508/AQuery2) - 3. Install python requirements with pip `python3 -m pip install -r requirements.txt` - 4. Change the build_driver variable in aquery_config.py to "MSBuild" - 5. The libraries and headers for Monetdb are already included in msc-plugins, however you can also choose to download them from [Monetdb Easy Setup](https://www.monetdb.org/easy-setup/) and put them in the same place. + 1. Install python3.6 or above from [official website](https://www.python.org/downloads/windows/) or Microsoft Store. + 2. Install Microsoft Visual Studio 2022 or later with **Desktop development with C++** selected. + 3. Clone AQuery repo from [Github](https://github.com/sunyinqi0508/AQuery2) + 4. Install python requirements with pip `python3 -m pip install -r requirements.txt` + 5. The libraries and headers for Monetdb are already included in msc-plugins, however you can also choose to download them from [Monetdb Easy Setup](https://www.monetdb.org/easy-setup/) and put them in the same place. - For CygWin/MinGW: 1. Install gcc and python3 using its **builtin package manager** instead of the one from python.org or windows store. (For Msys2, `pacman -S gcc python3`). Otherwise, ABI breakage may happen. diff --git a/prompt.py b/prompt.py index 6883198..acb0376 100644 --- a/prompt.py +++ b/prompt.py @@ -401,6 +401,15 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None): elif q.startswith('echo '): print(og_q[5:].lstrip()) continue + elif q.startswith('list '): + qs = re.split(r'[ \t]', q) + if len(qs) > 1 and qs[1].startswith('table'): + for t in cxt.tables: + lst_cols = [] + for c in t.columns: + lst_cols.append(f'{c.name} : {c.type}') + print(f'{t.table_name} ({", ".join(lst_cols)})') + continue elif q.startswith('help'): qs = re.split(r'[ \t]', q) if len(qs) > 1 and qs[1].startswith('c'): @@ -511,12 +520,18 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None): with open(qs) as file: qs = file.readline() from engine.utils import _Counter + lst_tell = -1 while(qs): while(not ws.sub('', qs) or qs.strip().startswith('#')): qs = file.readline() + if lst_tell == file.tell(): + break + else: + lst_tell = file.tell() cnt = _Counter(1) prompt(lambda : cnt.inc(-1) > 0, lambda:qs.strip(), state) qs = file.readline() + continue elif q.startswith('save2'): filename = re.split(r'[ \t]', q) if (len(filename) > 1): diff --git a/reconstruct/ast.py b/reconstruct/ast.py index 3f56048..31ae861 100644 --- a/reconstruct/ast.py +++ b/reconstruct/ast.py @@ -882,10 +882,11 @@ class drop(ast_node): for a in tbl_obj.alias: self.context.tables_byname.pop(a, None) # TODO: delete in postproc engine - self.context.tables_byname.pop(tbl_name) - self.context.tables.remove(tbl_obj) + self.context.tables_byname.pop(tbl_name, None) + self.context.tables.discard(tbl_obj) self.sql += 'TABLE IF EXISTS ' + tbl_name return + elif 'if_exists' not in node or not node['if_exists']: print(f'Error: table {tbl_name} not found.') self.sql = '' diff --git a/reconstruct/expr.py b/reconstruct/expr.py index c82712c..4f1e9e3 100644 --- a/reconstruct/expr.py +++ b/reconstruct/expr.py @@ -307,9 +307,15 @@ class expr(ast_node): self.opname = node if type(node) is int: if (node >= 2**63 - 1 or node <= -2**63): + self.type = HgeT + elif (node >= 2**31 - 1 or node <= -2**31): self.type = LongT - else: + elif node >= 2**15 - 1 or node <= -2**15: self.type = IntT + elif node >= 2**7 - 1 or node <= -2**7: + self.type = ShortT + else: + self.type = ByteT elif type(node) is float: self.type = DoubleT diff --git a/reconstruct/storage.py b/reconstruct/storage.py index 9c9ddb5..d54db52 100644 --- a/reconstruct/storage.py +++ b/reconstruct/storage.py @@ -67,7 +67,8 @@ class TableInfo: self.order = [] # assumptions cxt.tables_byname[self.table_name] = self # construct reverse map - + cxt.tables.add(self) + def add_cols(self, cols, new = True): for c in enlist(cols): self.add_col(c, new) @@ -137,7 +138,7 @@ class Context: def __init__(self): self.tables_byname = dict() self.col_byname = dict() - self.tables : List[TableInfo] = [] + self.tables : Set[TableInfo] = set() self.cols = [] self.datasource = None self.module_stubs = '' @@ -166,7 +167,7 @@ class Context: self.ccode += c + '\n' def add_table(self, table_name, cols): tbl = TableInfo(table_name, cols, self) - self.tables.append(tbl) + self.tables.add(tbl) return tbl def remove_scan(self, scan, str_scan): self.emitc(str_scan) diff --git a/server/types.h b/server/types.h index 78be49a..831ff27 100644 --- a/server/types.h +++ b/server/types.h @@ -21,7 +21,27 @@ template struct is_vector_impl : std::false_type {}; template constexpr static bool is_vector_type = is_vector_impl::value; +#define Cond(c, x, y) typename std::conditional::type +template +struct aqis_same_impl { + constexpr static bool value = + std::conditional_t< + std::is_signed_v == std::is_signed_v, + Cond( + std::is_floating_point_v == std::is_floating_point_v, + Cond( + sizeof(T1) == sizeof(T2), + std::true_type, + std::false_type + ), + std::false_type + ), + std::false_type + >::value; +}; +template +constexpr bool aqis_same = aqis_same_impl::value; namespace types { enum Type_t { AINT32, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, AINT64, AINT128, AINT16, ADATE, ATIME, AINT8, @@ -124,17 +144,17 @@ namespace types { f(short, AINT16) \ f(date_t, ADATE) \ f(time_t, ATIME) \ - f(unsigned char, AINT8) \ + f(unsigned char, AUINT8) \ + f(char, AINT8) \ f(unsigned int, AUINT32) \ f(unsigned long, AUINT64) \ f(unsigned short, AUINT16) \ - f(unsigned char, AUINT8) \ f(bool, ABOOL) \ f(timestamp_t, ATIMESTAMP) \ F_INT128(f) inline constexpr static Type_t getType() { -#define TypeConnect(x, y) if constexpr(std::is_same::value) return y; else +#define TypeConnect(x, y) if constexpr(aqis_same) return y; else ConnectTypes(TypeConnect) if constexpr (is_vector_type) return VECTOR; @@ -144,7 +164,6 @@ namespace types { }; #define ATypeSize(t, at) sizeof(t), static constexpr size_t AType_sizes[] = { ConnectTypes(ATypeSize) 1 }; -#define Cond(c, x, y) typename std::conditional::type #define Comp(o) (sizeof(T1) o sizeof(T2)) #define Same(x, y) (std::is_same_v) #define __U(x) std::is_unsigned::value @@ -297,26 +316,7 @@ template using decays = typename decayS::type>::type; template using decay_inner = typename decayS::type; -template -struct aqis_same_impl { - constexpr static bool value = - std::conditional_t< - std::is_signed_v == std::is_signed_v, - Cond( - std::is_floating_point_v == std::is_floating_point_v, - Cond( - sizeof(T1) == sizeof(T2), - std::true_type, - std::false_type - ), - std::false_type - ), - std::false_type - >::value; -}; -template -constexpr bool aqis_same = aqis_same_impl::value; template class T> struct instance_of_impl : std::false_type {};