From d5382c36e93be08bb0df504b199b088fbf40a01c Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 21 Oct 2022 14:52:01 +0800 Subject: [PATCH] bug fixes --- .gitignore | 1 + Dockerfile | 2 +- data/test_complex.csv | 6 ++++++ reconstruct/ast.py | 2 +- server/table_ext_monetdb.hpp | 12 ++++++------ server/vector_type.hpp | 3 +++ tests/dt2.a | 26 ++++++++++++++++++++++++++ tests/q1.sql | 4 +++- 8 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 data/test_complex.csv create mode 100644 tests/dt2.a diff --git a/.gitignore b/.gitignore index 4807b2c..644be8b 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,7 @@ test*.c* !moving_avg.csv !nyctx100.csv !network.csv +!test_complex.csv *.out *.asm !mmw.so diff --git a/Dockerfile b/Dockerfile index aac0a4f..953d89f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:latest -RUN cp /bin/bash /bin/sh +# RUN cp /bin/bash /bin/sh RUN apt update && apt install -y wget diff --git a/data/test_complex.csv b/data/test_complex.csv new file mode 100644 index 0000000..efd7b3e --- /dev/null +++ b/data/test_complex.csv @@ -0,0 +1,6 @@ +a,b,c +5e-3, 3;4 ;5e-3;6.32,7 +1,2,3 +4,5;6;7;8;9, 0 + 3 ,2 ; 4; 5.7; -.3; 5., 6 +-3.12312,-4E+7;67456746744567;75,4 diff --git a/reconstruct/ast.py b/reconstruct/ast.py index 90615ac..d82ebce 100644 --- a/reconstruct/ast.py +++ b/reconstruct/ast.py @@ -1068,7 +1068,7 @@ class load(ast_node): self.context.emitc(f'{t} {n};') self.context.emitc(f'while({csv_reader_name}.read_row({",".join(col_tmp_names)})) {{ \n') for i, c in enumerate(table.columns): - self.context.emitc(f'print({col_tmp_names[i]});') + # self.context.emitc(f'print({col_tmp_names[i]});') self.context.emitc(f'{c.cxt_name}.emplace_back({col_tmp_names[i]});') self.context.emitc('}') diff --git a/server/table_ext_monetdb.hpp b/server/table_ext_monetdb.hpp index c128559..3c93c3f 100644 --- a/server/table_ext_monetdb.hpp +++ b/server/table_ext_monetdb.hpp @@ -45,16 +45,16 @@ void TableInfo::monetdb_append_table(void* srv, const char* alt_name) { puts("getcols..."); uint32_t cnt = 0; const auto get_col = [&monetdbe_cols, &i, *this, &gc_vecs, &cnt](auto v) { - printf("%d %d\n", i, (ColRef*)v - colrefs); + // printf("%d %d\n", i, (ColRef*)v - colrefs); monetdbe_cols[i++] = (monetdbe_column*)v->monetdb_get_col(gc_vecs, cnt); }; (get_col((ColRef*)(colrefs + i)), ...); puts("getcols done"); - for(int i = 0; i < sizeof...(Ts); ++i) - { - printf("no:%d name: %s count:%d data: %p type:%d \n", - i, monetdbe_cols[i]->name, monetdbe_cols[i]->count, monetdbe_cols[i]->data, monetdbe_cols[i]->type); - } + // for(int i = 0; i < sizeof...(Ts); ++i) + // { + // printf("no:%d name: %s count:%d data: %p type:%d \n", + // i, monetdbe_cols[i]->name, monetdbe_cols[i]->count, monetdbe_cols[i]->data, monetdbe_cols[i]->type); + // } std::string create_table_str = "CREATE TABLE IF NOT EXISTS "; create_table_str += alt_name; create_table_str += " ("; diff --git a/server/vector_type.hpp b/server/vector_type.hpp index f0d4cc6..620e14d 100644 --- a/server/vector_type.hpp +++ b/server/vector_type.hpp @@ -71,6 +71,9 @@ public: constexpr explicit vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) { _copy(vt); } + constexpr vector_type(vector_type<_Ty>& vt) noexcept : capacity(0) { + _move(std::move(vt)); + } constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) { _move(std::move(vt)); } diff --git a/tests/dt2.a b/tests/dt2.a new file mode 100644 index 0000000..0f9dc7f --- /dev/null +++ b/tests/dt2.a @@ -0,0 +1,26 @@ +LOAD MODULE FROM "./libirf.so" +FUNCTIONS ( + newtree(height:int, f:int64, sparse:vecint64, forget:double, maxf:int64, noclasses:int64, e:int, r:int64, rb:int64) -> bool, + fit(X:vecvecdouble, y:vecint64) -> bool, + predict(X:vecvecdouble) -> vecint64 +); + +create table source(x1 double, x2 double, x3 double, x4 double, x5 int64); +load data infile "data/benchmark" into table source fields terminated by ","; + +create table sparse(x int64); +insert into sparse values (1); +insert into sparse values (1); +insert into sparse values (1); +insert into sparse values (1); + +select * from source; + +select newtree(6, 4, sparse.x, 0, 4, 2, 0, 400, 2147483647) from sparse; + +select fit(pack(x1, x2, x3, x4), x5) from source limit 100; +select fit(pack(x1, x2, x3, x4), x5) from source limit 100; +select fit(pack(x1, x2, x3, x4), x5) from source limit 100; +select fit(pack(x1, x2, x3, x4), x5) from source limit 100; + +select predict(pack(x1, x2, x3, x4)) from source limit 100; \ No newline at end of file diff --git a/tests/q1.sql b/tests/q1.sql index 747b83b..eab8904 100644 --- a/tests/q1.sql +++ b/tests/q1.sql @@ -7,4 +7,6 @@ FIELDS TERMINATED BY "," SELECT sum(c), b, d FROM testq1 group by a,b,d -order by d DESC, b ASC +order by d DESC, b ASC; + +-- aaaa \ No newline at end of file