diff --git a/datagen.cpp b/datagen.cpp index c96b480..41fbfc0 100644 --- a/datagen.cpp +++ b/datagen.cpp @@ -80,7 +80,7 @@ int gen_trade_data(int argc, char* argv[]) memmove(p + lens[i], p + lens[0], (lens[i - 1] - lens[i]) * sizeof(int)); permutation(p, lens[0] + N); // for (int i = 0; i < lens[0] + N; ++i) printf("%d ", p[i]); - FILE* fp = fopen("trade.csv", "w"); + FILE* fp = fopen("trade.csv", "wb"); int* last_price = new int[N]; memset(last_price, -1, sizeof(int) * N); fprintf(fp, "stocksymbol, time, quantity, price\n"); @@ -131,7 +131,7 @@ int gen_stock_data(int argc, char* argv[]){ } IDs[n_stocks] = "S"; names[n_stocks] = "x"; - FILE* fp = fopen("./data/stock.csv", "w"); + FILE* fp = fopen("./data/stock.csv", "wb"); fprintf(fp, "ID, timestamp, tradeDate, price\n"); char date_str_buf [types::date_t::string_length()]; int* timestamps = new int[n_data]; @@ -142,7 +142,7 @@ int gen_stock_data(int argc, char* argv[]){ fprintf(fp, "%s,%d,%s,%d\n", IDs[ui(engine)%(n_stocks + 1)].c_str(), timestamps[i], date, ui(engine) % 1000); } fclose(fp); - fp = fopen("./data/base.csv", "w"); + fp = fopen("./data/base.csv", "wb"); fprintf(fp, "ID, name\n"); for(int i = 0; i < n_stocks + 1; ++ i){ fprintf(fp, "%s,%s\n", IDs[i].c_str(), names[i].c_str()); diff --git a/engine/ddl.py b/engine/ddl.py index 9ba41db..06eb9f0 100644 --- a/engine/ddl.py +++ b/engine/ddl.py @@ -110,7 +110,7 @@ class outfile(ast_node): filename = node['loc']['literal'] if 'loc' in node else node['literal'] sep = ',' if 'term' not in node else node['term']['literal'] file_pointer = 'fp_' + base62uuid(6) - self.emit(f'FILE* {file_pointer} = fopen("{filename}", "w");') + self.emit(f'FILE* {file_pointer} = fopen("{filename}", "wb");') self.emit(f'{out_table.cxt_name}->printall("{sep}", "\\n", nullptr, {file_pointer});') self.emit(f'fclose({file_pointer});') # self.context.headers.add('fstream') diff --git a/mem_opt.cpp b/mem_opt.cpp new file mode 100644 index 0000000..452fedd --- /dev/null +++ b/mem_opt.cpp @@ -0,0 +1,72 @@ +#include "./server/libaquery.h" + +#ifndef __AQ_USE_THREADEDGC__ + +#include "./server/gc.h" +__AQEXPORT__(void) __AQ_Init_GC__(Context* cxt) { + GC::gc_handle = static_cast(cxt->gc); +} + +#else // __AQ_USE_THREADEDGC__ +#define __AQ_Init_GC__(x) +#endif // __AQ_USE_THREADEDGC__ +#include "./server/hasher.h" +#include "./server/monetdb_conn.h" +#include "./server/aggregations.h" + +__AQEXPORT__(int) dll_2Cxoox(Context* cxt) { + using namespace std; + using namespace types; + auto server = static_cast(cxt->alt_server); +auto len_4ycjiV = server->cnt; +auto mont_8AE = ColRef(len_4ycjiV, server->getCol(0)); +auto sales_2RB = ColRef(len_4ycjiV, server->getCol(1)); +const char* names_6pIt[] = {"mont", "minw2ysales"}; +auto out_2LuaMH = new TableInfo>("out_2LuaMH", names_6pIt); +decltype(auto) col_EeW23s = out_2LuaMH->get_col<0>(); +decltype(auto) col_5gY1Dm = out_2LuaMH->get_col<1>(); +typedef record> record_typegj3e8Xf; +ankerl::unordered_dense::map> gMzMTEvd; +gMzMTEvd.reserve(mont_8AE.size); +uint32_t* reversemap = new uint32_t[mont_8AE.size<<1], + *mapbase = reversemap + mont_8AE.size; +for (uint32_t i2E = 0; i2E < mont_8AE.size; ++i2E){ + reversemap[i2E] = gMzMTEvd.hashtable_push(forward_as_tuple(mont_8AE[i2E])); +} +auto arr_values = gMzMTEvd.values().data(); +auto arr_len = gMzMTEvd.size(); +uint32_t* seconds = new uint32_t[gMzMTEvd.size()]; + +auto vecs = static_cast*>(malloc(sizeof(vector_type) * arr_len)); +vecs[0].init_from(arr_values[0].second, mapbase); +for (uint32_t i = 1; i < arr_len; ++i) { + vecs[i].init_from(arr_values[i].second, mapbase + arr_values[i - 1].second); + arr_values[i].second += arr_values[i - 1].second; +} +for (uint32_t i = 0; i < mont_8AE.size; ++i) { + auto id = reversemap[i]; + mapbase[--arr_values[id].second] = i; +} + +col_EeW23s.reserve(gMzMTEvd.size()); +col_5gY1Dm.reserve(gMzMTEvd.size()); +auto buf_col_5gY1Dm = new double[mont_8AE.size]; +for (uint32_t i = 0; i < arr_len; ++i) { + col_5gY1Dm[i].init_from(vecs[i].size, buf_col_5gY1Dm + arr_values[i].second); +} +for (uint32_t i = 0; i < arr_len; ++i) { + +auto &key_3iNX3qG = arr_values[i].first; +auto &val_7jjv8Mo = arr_values[i].second; +col_EeW23s.emplace_back(get<0>(key_3iNX3qG)); + +avgw(10, sales_2RB[vecs[i]], col_5gY1Dm[i]); + +} +//print(*out_2LuaMH); +//FILE* fp_5LQeym = fopen("flatten.csv", "wb"); +out_2LuaMH->printall(",", "\n", nullptr, nullptr, 10); +//fclose(fp_5LQeym); +puts("done."); +return 0; +} \ No newline at end of file diff --git a/msc-plugin/launcher.vcxproj b/msc-plugin/launcher.vcxproj index d107496..0b0d90b 100644 --- a/msc-plugin/launcher.vcxproj +++ b/msc-plugin/launcher.vcxproj @@ -17,6 +17,14 @@ Release x64 + + RelWDbgInf + Win32 + + + RelWDbgInf + x64 + sharedlib Win32 @@ -52,6 +60,14 @@ Unicode false + + Application + false + v143 + true + Unicode + false + Application false @@ -75,6 +91,14 @@ Unicode false + + Application + false + v143 + true + Unicode + false + Application false @@ -94,6 +118,9 @@ + + + @@ -103,6 +130,9 @@ + + + @@ -117,6 +147,11 @@ .exe $(SolutionDir)..\ + + false + .exe + $(SolutionDir)..\ + false .exe @@ -132,6 +167,11 @@ .exe $(SolutionDir)..\ + + false + .exe + $(SolutionDir)..\ + false .exe @@ -145,7 +185,7 @@ true true true - stdcpp17 + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc @@ -166,7 +206,32 @@ true true true - stdcpp17 + stdcpplatest + stdc17 + $(ProjectDir)\..\monetdb\msvc + None + + + Console + true + true + false + ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) + false + /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + true + true + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc None @@ -215,9 +280,10 @@ true true true - stdcpp17 + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc + true Console @@ -225,6 +291,9 @@ ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + true + @@ -236,7 +305,32 @@ true true true - stdcpp17 + stdcpplatest + stdc17 + $(ProjectDir)\..\monetdb\msvc + None + + + Console + true + true + false + ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) + false + /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + true + true + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc None diff --git a/msc-plugin/libaquery.vcxproj b/msc-plugin/libaquery.vcxproj index 82162c9..85cb9f2 100644 --- a/msc-plugin/libaquery.vcxproj +++ b/msc-plugin/libaquery.vcxproj @@ -1,4 +1,4 @@ - + @@ -17,6 +17,14 @@ Release x64 + + RelWDbgInf + Win32 + + + RelWDbgInf + x64 + 16.0 @@ -39,6 +47,13 @@ true Unicode + + StaticLibrary + false + v143 + true + Unicode + StaticLibrary true @@ -52,6 +67,13 @@ true Unicode + + StaticLibrary + false + v143 + true + Unicode + @@ -63,12 +85,18 @@ + + + + + + true @@ -79,6 +107,11 @@ .lib $(SolutionDir)..\ + + false + .lib + $(SolutionDir)..\ + true $(SolutionDir)..\ @@ -88,13 +121,18 @@ .lib $(SolutionDir)..\ + + false + .lib + $(SolutionDir)..\ + Level3 true _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest stdc17 Create pch_msc.hpp @@ -120,7 +158,7 @@ false _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest stdc17 Create pch_msc.hpp @@ -153,13 +191,54 @@ $(ProjectDir)\..\monetdb\msvc\monetdbe.lib; + + + Level3 + true + true + false + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + stdc17 + Create + pch_msc.hpp + ProgramDatabase + Full + AnySuitable + Speed + true + true + AdvancedVectorExtensions2 + true + true + false + false + false + true + false + $(ProjectDir)\..\monetdb\msvc + $(SolutionDir)..\msc-plugin\pch_msc.pch + $(IntDir)vc$(PlatformToolsetVersion).pdb + + + Console + true + true + false + false + + + $(ProjectDir)\..\monetdb\msvc\monetdbe.lib; + + Level3 true _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest stdc17 Create pch_msc.hpp @@ -168,6 +247,7 @@ true true $(IntDir)vc$(PlatformToolsetVersion).pdb + true Console @@ -176,6 +256,9 @@ $(ProjectDir)\..\monetdb\msvc\monetdbe.lib; + + true + @@ -185,7 +268,7 @@ false _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest stdc17 Create pch_msc.hpp @@ -218,6 +301,47 @@ $(ProjectDir)\..\monetdb\msvc\monetdbe.lib; + + + Level3 + true + true + false + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + stdc17 + Create + pch_msc.hpp + ProgramDatabase + Full + AnySuitable + Speed + true + true + AdvancedVectorExtensions2 + true + true + false + false + false + true + false + $(ProjectDir)\..\monetdb\msvc + $(SolutionDir)..\msc-plugin\pch_msc.pch + $(IntDir)vc$(PlatformToolsetVersion).pdb + + + Console + true + true + false + false + + + $(ProjectDir)\..\monetdb\msvc\monetdbe.lib; + + diff --git a/msc-plugin/msc-plugin.vcxproj b/msc-plugin/msc-plugin.vcxproj index cec60b3..d7c27c3 100644 --- a/msc-plugin/msc-plugin.vcxproj +++ b/msc-plugin/msc-plugin.vcxproj @@ -1,4 +1,4 @@ - + @@ -17,6 +17,14 @@ Release x64 + + RelWDbgInf + Win32 + + + RelWDbgInf + x64 + 16.0 @@ -42,6 +50,14 @@ Unicode false + + DynamicLibrary + false + v143 + true + Unicode + false + DynamicLibrary true @@ -58,6 +74,14 @@ Unicode false + + DynamicLibrary + false + v143 + true + Unicode + false + @@ -69,12 +93,18 @@ + + + + + + @@ -84,6 +114,10 @@ dll.so + + + dll.so + dll.so @@ -92,13 +126,17 @@ dll.so + + + dll.so + Level3 true _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest Guard false $(ProjectDir)\..\monetdb\msvc @@ -112,6 +150,7 @@ true $(IntDir)vc$(PlatformToolsetVersion).pdb pch_msc.hpp + MaxSpeed Console @@ -129,7 +168,7 @@ false _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest $(ProjectDir)\..\monetdb\msvc stdc17 Use @@ -164,31 +203,85 @@ false + + + Level3 + true + true + false + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + $(ProjectDir)\..\monetdb\msvc + stdc17 + Use + pch_msc.hpp + ProgramDatabase + Full + AnySuitable + Speed + true + true + AdvancedVectorExtensions2 + true + true + false + false + false + true + false + + + false + $(IntDir)vc$(PlatformToolsetVersion).pdb + pch_msc.hpp + + + Console + true + true + false + $(ProjectDir)\..\dll.so + $(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) + false + + Level3 true - _ALLOW_RTCc_IN_STL;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + _ALLOW_RTCc_IN_STL;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 - Guard + stdcpplatest + false false ProgramDatabase - Disabled - false - true + AnySuitable + true + false false $(ProjectDir)\..\monetdb\msvc /WL %(AdditionalOptions) stdc17 - Use + NotUsing pch_msc.hpp true true $(IntDir)vc$(PlatformToolsetVersion).pdb - pch_msc.hpp + + + true + MaxSpeed + Default + MultiThreadedDLL + AdvancedVectorExtensions2 + true + Speed + true + true + false Console @@ -197,6 +290,9 @@ true $(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) + + true + @@ -206,7 +302,7 @@ false _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpplatest $(ProjectDir)\..\monetdb\msvc stdc17 Use @@ -241,6 +337,49 @@ false + + + Level3 + true + true + false + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + $(ProjectDir)\..\monetdb\msvc + stdc17 + Use + pch_msc.hpp + ProgramDatabase + Full + AnySuitable + Speed + true + true + AdvancedVectorExtensions2 + true + true + false + false + false + true + false + + + false + $(IntDir)vc$(PlatformToolsetVersion).pdb + pch_msc.hpp + + + Console + true + true + false + $(ProjectDir)\..\dll.so + $(ProjectDir)\..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) + false + + diff --git a/msc-plugin/sdk_example.vcxproj b/msc-plugin/sdk_example.vcxproj index f55e7a9..8ddc9a5 100644 --- a/msc-plugin/sdk_example.vcxproj +++ b/msc-plugin/sdk_example.vcxproj @@ -17,6 +17,14 @@ Release x64 + + RelWDbgInf + Win32 + + + RelWDbgInf + x64 + 16.0 @@ -39,6 +47,13 @@ true Unicode + + DynamicLibrary + false + v143 + true + Unicode + DynamicLibrary true @@ -52,6 +67,13 @@ true Unicode + + DynamicLibrary + false + v143 + true + Unicode + @@ -63,12 +85,18 @@ + + + + + + $(SolutionDir)..\ @@ -80,6 +108,11 @@ test .so + + $(SolutionDir)..\ + test + .so + $(SolutionDir)..\ test @@ -90,6 +123,11 @@ test .so + + $(SolutionDir)..\ + test + .so + Level3 @@ -124,6 +162,24 @@ true + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + stdc17 + + + Console + true + true + true + + Level3 @@ -134,11 +190,15 @@ stdc17 true true + true Console true + + true + @@ -158,6 +218,24 @@ true + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + stdc17 + + + Console + true + true + true + + diff --git a/msc-plugin/server.sln b/msc-plugin/server.sln index 84fb37c..6e2e70f 100644 --- a/msc-plugin/server.sln +++ b/msc-plugin/server.sln @@ -9,6 +9,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "server.vcxproj", EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msc-plugin", "msc-plugin.vcxproj", "{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}" + ProjectSection(ProjectDependencies) = postProject + {B52AACF7-16A6-4FCA-90AD-867D367BDA4F} = {B52AACF7-16A6-4FCA-90AD-867D367BDA4F} + EndProjectSection EndProject Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "msvs-py", "..\msvs-py\msvs-py.pyproj", "{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}" EndProject @@ -30,6 +33,8 @@ Global Debug|x86 = Debug|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 + RelWDbgInf|x64 = RelWDbgInf|x64 + RelWDbgInf|x86 = RelWDbgInf|x86 shared|x64 = shared|x64 shared|x86 = shared|x86 sharedlib|x64 = sharedlib|x64 @@ -44,6 +49,10 @@ Global {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|x64.Build.0 = Release|x64 {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|x86.ActiveCfg = Release|Win32 {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Release|x86.Build.0 = Release|Win32 + {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.RelWDbgInf|x64.ActiveCfg = RelWDbgInf|x64 + {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.RelWDbgInf|x64.Build.0 = RelWDbgInf|x64 + {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.RelWDbgInf|x86.ActiveCfg = RelWDbgInf|Win32 + {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.RelWDbgInf|x86.Build.0 = RelWDbgInf|Win32 {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.shared|x64.ActiveCfg = sharedlib|x64 {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.shared|x86.ActiveCfg = sharedlib|Win32 {031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.sharedlib|x64.ActiveCfg = sharedlib|x64 @@ -58,6 +67,10 @@ Global {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|x64.Build.0 = Release|x64 {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|x86.ActiveCfg = Release|Win32 {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Release|x86.Build.0 = Release|Win32 + {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.RelWDbgInf|x64.ActiveCfg = RelWDbgInf|x64 + {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.RelWDbgInf|x64.Build.0 = RelWDbgInf|x64 + {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.RelWDbgInf|x86.ActiveCfg = RelWDbgInf|Win32 + {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.RelWDbgInf|x86.Build.0 = RelWDbgInf|Win32 {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.shared|x64.ActiveCfg = Release|x64 {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.shared|x64.Build.0 = Release|x64 {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.shared|x86.ActiveCfg = Release|Win32 @@ -70,6 +83,8 @@ Global {CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Debug|x86.ActiveCfg = Debug|Any CPU {CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Release|x64.ActiveCfg = Release|Any CPU {CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Release|x86.ActiveCfg = Release|Any CPU + {CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.RelWDbgInf|x64.ActiveCfg = RelWDbgInf|Any CPU + {CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.RelWDbgInf|x86.ActiveCfg = RelWDbgInf|Any CPU {CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.shared|x64.ActiveCfg = Release|Any CPU {CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.shared|x86.ActiveCfg = Release|Any CPU {CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.sharedlib|x64.ActiveCfg = Release|Any CPU @@ -82,6 +97,10 @@ Global {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.Release|x64.Build.0 = Release|x64 {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.Release|x86.ActiveCfg = Release|Win32 {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.Release|x86.Build.0 = Release|Win32 + {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.RelWDbgInf|x64.ActiveCfg = RelWDbgInf|x64 + {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.RelWDbgInf|x64.Build.0 = RelWDbgInf|x64 + {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.RelWDbgInf|x86.ActiveCfg = RelWDbgInf|Win32 + {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.RelWDbgInf|x86.Build.0 = RelWDbgInf|Win32 {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.shared|x64.ActiveCfg = Debug|x64 {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.shared|x64.Build.0 = Debug|x64 {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}.shared|x86.ActiveCfg = Debug|Win32 @@ -98,6 +117,10 @@ Global {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.Release|x64.Build.0 = Release|x64 {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.Release|x86.ActiveCfg = Release|Win32 {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.Release|x86.Build.0 = Release|Win32 + {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.RelWDbgInf|x64.ActiveCfg = RelWDbgInf|x64 + {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.RelWDbgInf|x64.Build.0 = RelWDbgInf|x64 + {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.RelWDbgInf|x86.ActiveCfg = RelWDbgInf|Win32 + {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.RelWDbgInf|x86.Build.0 = RelWDbgInf|Win32 {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.shared|x64.ActiveCfg = sharedlib|x64 {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.shared|x64.Build.0 = sharedlib|x64 {C8E25628-0B46-4CBE-90DF-5228F79A5A64}.shared|x86.ActiveCfg = sharedlib|Win32 @@ -114,6 +137,10 @@ Global {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Release|x64.Build.0 = Release|x64 {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Release|x86.ActiveCfg = Release|Win32 {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.Release|x86.Build.0 = Release|Win32 + {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.RelWDbgInf|x64.ActiveCfg = RelWDbgInf|x64 + {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.RelWDbgInf|x64.Build.0 = RelWDbgInf|x64 + {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.RelWDbgInf|x86.ActiveCfg = RelWDbgInf|Win32 + {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.RelWDbgInf|x86.Build.0 = RelWDbgInf|Win32 {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.shared|x64.ActiveCfg = Debug|x64 {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.shared|x64.Build.0 = Debug|x64 {F954797B-C148-4CBF-9FB4-A9A450EFEC38}.shared|x86.ActiveCfg = Debug|Win32 @@ -130,6 +157,10 @@ Global {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.Release|x64.Build.0 = Release|x64 {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.Release|x86.ActiveCfg = Release|Win32 {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.Release|x86.Build.0 = Release|Win32 + {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.RelWDbgInf|x64.ActiveCfg = RelWDbgInf|x64 + {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.RelWDbgInf|x64.Build.0 = RelWDbgInf|x64 + {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.RelWDbgInf|x86.ActiveCfg = RelWDbgInf|Win32 + {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.RelWDbgInf|x86.Build.0 = RelWDbgInf|Win32 {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.shared|x64.ActiveCfg = sharedlib|x64 {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.shared|x64.Build.0 = sharedlib|x64 {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.shared|x86.ActiveCfg = sharedlib|Win32 diff --git a/msc-plugin/server.vcxproj b/msc-plugin/server.vcxproj index cf517b3..ac53f6f 100644 --- a/msc-plugin/server.vcxproj +++ b/msc-plugin/server.vcxproj @@ -17,6 +17,14 @@ Release x64 + + RelWDbgInf + Win32 + + + RelWDbgInf + x64 + sharedlib Win32 @@ -52,6 +60,14 @@ Unicode false + + DynamicLibrary + false + v143 + true + Unicode + false + DynamicLibrary false @@ -75,6 +91,14 @@ Unicode false + + DynamicLibrary + false + v143 + true + Unicode + false + DynamicLibrary false @@ -94,6 +118,9 @@ + + + @@ -103,6 +130,9 @@ + + + @@ -117,6 +147,11 @@ .so $(SolutionDir)..\ + + false + .so + $(SolutionDir)..\ + false .so @@ -132,6 +167,11 @@ .so $(SolutionDir)..\ + + false + .so + $(SolutionDir)..\ + false .so @@ -145,7 +185,7 @@ true true true - stdcpp17 + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc @@ -166,7 +206,32 @@ true true true - stdcpp17 + stdcpplatest + stdc17 + $(ProjectDir)\..\monetdb\msvc + None + + + Console + true + true + false + ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) + false + /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + true + true + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc None @@ -215,9 +280,10 @@ true true true - stdcpp17 + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc + true Console @@ -225,6 +291,9 @@ ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + true + @@ -236,7 +305,32 @@ true true true - stdcpp17 + stdcpplatest + stdc17 + $(ProjectDir)\..\monetdb\msvc + None + + + Console + true + true + false + ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) + false + /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + true + true + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc None diff --git a/msc-plugin/testmain.vcxproj b/msc-plugin/testmain.vcxproj index 353cb78..b89ef43 100644 --- a/msc-plugin/testmain.vcxproj +++ b/msc-plugin/testmain.vcxproj @@ -17,6 +17,14 @@ Release x64 + + RelWDbgInf + Win32 + + + RelWDbgInf + x64 + sharedlib Win32 @@ -52,6 +60,14 @@ Unicode false + + Application + false + v143 + true + Unicode + false + Application false @@ -75,6 +91,14 @@ Unicode false + + Application + false + v143 + true + Unicode + false + Application false @@ -94,6 +118,9 @@ + + + @@ -103,6 +130,9 @@ + + + @@ -117,6 +147,11 @@ .exe $(SolutionDir)..\ + + false + .exe + $(SolutionDir)..\ + false .exe @@ -132,6 +167,11 @@ .exe $(SolutionDir)..\ + + false + .exe + $(SolutionDir)..\ + false .exe @@ -145,7 +185,7 @@ true true true - stdcpp17 + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc @@ -166,7 +206,7 @@ true true true - stdcpp17 + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc None @@ -181,6 +221,32 @@ /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + true + true + stdcpplatest + stdc17 + $(ProjectDir)\..\monetdb\msvc + ProgramDatabase + + + Console + true + true + DebugFull + ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) + false + /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + true + + Level3 @@ -215,9 +281,10 @@ true true true - stdcpp17 + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc + true Console @@ -225,6 +292,9 @@ ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + true + @@ -236,7 +306,7 @@ true true true - stdcpp17 + stdcpplatest stdc17 $(ProjectDir)\..\monetdb\msvc None @@ -251,6 +321,32 @@ /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + true + true + stdcpplatest + stdc17 + $(ProjectDir)\..\monetdb\msvc + ProgramDatabase + + + Console + true + true + DebugFull + ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies) + false + /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions) + true + + Level3 diff --git a/msvs-py/msvs-py.pyproj b/msvs-py/msvs-py.pyproj index c17a7f4..be50d88 100644 --- a/msvs-py/msvs-py.pyproj +++ b/msvs-py/msvs-py.pyproj @@ -23,6 +23,11 @@ true false + + true + false + bin\RelWDbgInf\ + diff --git a/proctool.py b/proctool.py new file mode 100644 index 0000000..81035bf --- /dev/null +++ b/proctool.py @@ -0,0 +1,51 @@ +import struct +import readline +from typing import List + +name : str = input() + +def write(): + s : str = input() + qs : List[str] = [] + + while(len(s) and not s.startswith('S')): + qs.append(s) + s = input() + + ms : int = int(input()) + + with open(f'./procedures/{name}.aqp', 'wb') as fp: + fp.write(struct.pack("I", len(qs) + (ms > 0))) + fp.write(struct.pack("I", ms)) + if (ms > 0): + fp.write(b'N\x00') + + for q in qs: + fp.write(q.encode('utf-8')) + if q.startswith('Q'): + fp.write(b'\n ') + fp.write(b'\x00') + + +def read(): + with open(f'./procedures/{name}.aqp', 'rb') as fp: + nq = struct.unpack("I", fp.read(4))[0] + ms = struct.unpack("I", fp.read(4))[0] + qs = fp.read().split(b'\x00') + print(f'Procedure {name}, {nq} queries, {ms} modules:') + for q in qs: + print(' ' + q.decode('utf-8')) + + +if __name__ == '__main__': + while True: + cmd = input("r for read, w for write: ") + if cmd.lower().startswith('r'): + read() + break + elif cmd.lower().startswith('w'): + write() + break + elif cmd.lower().startswith('q'): + break + \ No newline at end of file diff --git a/reconstruct/ast.py b/reconstruct/ast.py index 870df5b..e9348ac 100644 --- a/reconstruct/ast.py +++ b/reconstruct/ast.py @@ -1300,7 +1300,7 @@ class outfile(ast_node): filename = self.node['loc']['literal'] if 'loc' in self.node else self.node['literal'] sep = ',' if 'term' not in self.node else self.node['term']['literal'] file_pointer = 'fp_' + base62uuid(6) - self.addc(f'FILE* {file_pointer} = fopen("{filename}", "w");') + self.addc(f'FILE* {file_pointer} = fopen("{filename}", "wb");') self.addc(f'{self.parent.out_table.contextname_cpp}->printall("{sep}", "\\n", nullptr, {file_pointer});') self.addc(f'fclose({file_pointer});') self.context.ccode += self.ccode diff --git a/server/aggregations.h b/server/aggregations.h index bb8ca0e..ccd5c25 100644 --- a/server/aggregations.h +++ b/server/aggregations.h @@ -187,8 +187,7 @@ decayed_t> sumw(uint32_t w, const VT& arr) { } template class VT> -void avgw(uint32_t w, const VT& arr, - decayed_t>>& ret) { +void avgw(uint32_t w, const VT& arr, decayed_t>>& ret) { typedef types::GetFPType> FPType; const uint32_t& len = arr.size; uint32_t i = 0; diff --git a/server/hasher.h b/server/hasher.h index 0675f96..b632319 100644 --- a/server/hasher.h +++ b/server/hasher.h @@ -132,7 +132,7 @@ namespace ankerl::unordered_dense{ struct hash> : public hasher{ }; } -struct aq_hashtable_value_t{ +struct aq_hashtable_value_t { uint32_t id; uint32_t cnt; }; \ No newline at end of file diff --git a/server/io.h b/server/io.h index e8ff02a..3c3bf68 100644 --- a/server/io.h +++ b/server/io.h @@ -4,6 +4,7 @@ #include #include #include +#include template std::string generate_printf_string(const char* sep = " ", const char* end = "\n") { std::string str; @@ -25,6 +26,11 @@ inline decltype(auto) print_hook(const bool& v) { return v? "true" : "false"; } +template<> +inline decltype(auto) print_hook(const std::string_view& v) { + return v.data(); +} + extern char* gbuf; void setgbuf(char* buf = 0); diff --git a/server/libaquery.cpp b/server/libaquery.cpp index 9521ce9..a97d6e8 100644 --- a/server/libaquery.cpp +++ b/server/libaquery.cpp @@ -55,6 +55,7 @@ void print(const bool&v, const char* delimiter){ std::cout<< (v?"true":"false") << delimiter; } + template T getInt(const char*& buf){ T ret = 0; @@ -537,4 +538,11 @@ aq_to_chars(void* value, char* buffer) { return buffer; } +template<> +char* +aq_to_chars(void* value, char* buffer){ + const auto& src = *static_cast(value); + memcpy(buffer, src.data(), src.size()); + return buffer + src.size(); +} diff --git a/server/libaquery.h b/server/libaquery.h index e5b9516..7635310 100644 --- a/server/libaquery.h +++ b/server/libaquery.h @@ -161,6 +161,7 @@ template<> char* aq_to_chars(void* , char*); template<> char* aq_to_chars(void* , char*); template<> char* aq_to_chars(void* , char*); template<> char* aq_to_chars(void* , char*); +template<> char* aq_to_chars(void* , char*); typedef int (*code_snippet)(void*); template diff --git a/server/server.cpp b/server/server.cpp index 0176e5b..507e944 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -1,5 +1,5 @@ #include "pch_msc.hpp" - +//#define TESTMAIN #include #include #include @@ -668,7 +668,7 @@ int launcher(int argc, char** argv){ str = std::string("cd ") + pwd + std::string("&& python3 ./prompt.py ") + str; return system(str.c_str()); } -#if true || !( defined(_MSC_VER) && defined(_DEBUG) ) +#if !defined(TESTMAIN) && !( defined(_MSC_VER) && defined(_DEBUG) ) extern "C" int __DLLEXPORT__ main(int argc, char** argv) { #ifdef __AQ_BUILD_LAUNCHER__ return launcher(argc, argv); diff --git a/server/table.h b/server/table.h index 9de4487..c2b3400 100644 --- a/server/table.h +++ b/server/table.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "io.h" #include "hasher.h" @@ -147,18 +148,18 @@ public: return *this; } - // ColView<_Ty> operator [](vector_type& idxs) const { - // return ColView<_Ty>(*this, std::move(idxs)); - // } - // ColView<_Ty> operator [](const vector_type& idxs) const { - // return ColView<_Ty>(*this, idxs); - // } - vector_type<_Ty> operator[](vector_type& idxs) const { - vector_type<_Ty> ret(idxs.size); - for (uint32_t i = 0; i < idxs.size; ++i) - ret.container[i] = this->container[idxs[i]]; - return ret; - } + ColView<_Ty> operator [](vector_type& idxs) const { + return ColView<_Ty>(*this, std::move(idxs)); + } + ColView<_Ty> operator [](const vector_type& idxs) const { + return ColView<_Ty>(*this, idxs); + } + //vector_type<_Ty> operator[](vector_type& idxs) const { + // vector_type<_Ty> ret(idxs.size); + // for (uint32_t i = 0; i < idxs.size; ++i) + // ret.container[i] = this->container[idxs[i]]; + // return ret; + //} vector_type<_Ty> operator [](const std::vector& idxs) const { vector_type<_Ty> ret (this->size); uint32_t i = 0; @@ -474,7 +475,7 @@ struct TableInfo { std::string printf_string = generate_printf_string::type ...>(sep, end); - // puts(printf_string.c_str()); + puts(printf_string.c_str()); std::string header_string = std::string(); constexpr static int a_cols[] = { cols... }; if (fp == nullptr){ @@ -488,6 +489,7 @@ struct TableInfo { if (header_string.size() - l_sep >= 0) header_string.resize(header_string.size() - l_sep); } + const auto& prt_loop = [&fp, &view, &printf_string, *this, &limit](const auto& f) { #ifdef __AQ__HAS__INT128__ constexpr auto num_hge = count_type<__int128_t, __uint128_t>((tuple_type*)(0)); @@ -920,6 +922,7 @@ template void print(const TableView& v, const char* delimiter = " ", const char* endline = "\n") { v.print(delimiter, endline); } + template void print(const T& v, const char* delimiter = " ") { std::cout << v << delimiter; @@ -934,7 +937,6 @@ void print<__uint128_t>(const __uint128_t& v, const char* delimiter); #endif template <> void print(const bool& v, const char* delimiter); - template void inline print_impl(const T& v, const char* delimiter, const char* endline) { for (const auto& vi : v) { diff --git a/server/tests/thread_pool.hpp b/server/tests/thread_pool.hpp index b43bd8a..dfed503 100644 --- a/server/tests/thread_pool.hpp +++ b/server/tests/thread_pool.hpp @@ -13,7 +13,7 @@ long long testing_throughput(uint32_t n_jobs, bool prompt = true){ auto tp = ThreadPool(thread::hardware_concurrency()); getchar(); auto i = 0u; - fp = fopen("tmp.tmp", "w"); + fp = fopen("tmp.tmp", "wb"); auto time = chrono::high_resolution_clock::now(); while(i++ < n_jobs) tp.enqueue_task({ [](void* f) {fprintf(fp, "%d ", *(int*)f); free(f); }, new int(i) }); puts("done dispatching."); @@ -53,7 +53,7 @@ long long testing_transaction(uint32_t n_burst, uint32_t n_batch, } long long testing_destruction(bool prompt = true){ - fp = fopen("tmp.tmp", "w"); + fp = fopen("tmp.tmp", "wb"); if (prompt) { puts("Press any key to start."); getchar(); diff --git a/server/types.h b/server/types.h index ff2b85b..f9ad100 100644 --- a/server/types.h +++ b/server/types.h @@ -3,6 +3,9 @@ #include #include #include +#include +#include +#include using std::size_t; #if defined(__SIZEOF_INT128__) and not defined(_WIN32) @@ -13,6 +16,9 @@ using std::size_t; #define __restrict__ __restrict #endif +template +struct vector_base {}; + template constexpr static inline bool is_vector(const T&) { return false; @@ -32,23 +38,23 @@ struct aqis_same_impl { std::conditional_t< std::is_same_v || std::is_same_v, + std::bool_constant && std::is_same_v>, Cond( - (std::is_same_v && std::is_same_v), - std::true_type, - std::false_type - ), - Cond( - std::is_signed_v == std::is_signed_v, - Cond( - std::is_floating_point_v == std::is_floating_point_v, - Cond( - aq_szof == aq_szof, // deal with sizeof(void) - std::true_type, - std::false_type - ), - std::false_type - ), - std::false_type + !(std::is_class_v || std::is_class_v), + Cond( + std::is_signed_v == std::is_signed_v, + Cond( + std::is_floating_point_v == std::is_floating_point_v, + std::bool_constant == aq_szof>, // deal with sizeof(void) + std::false_type + ), + std::false_type + ), + Cond( + (std::is_class_v && std::is_class_v), + std::bool_constant<(std::is_base_of_v || std::is_base_of_v)>, + std::false_type + ) ) >::value; }; @@ -63,12 +69,12 @@ constexpr bool aqis_same = aqis_same_impl::value; namespace types { enum Type_t { AINT32, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, AINT64, AINT128, AINT16, ADATE, ATIME, AINT8, - AUINT32, AUINT64, AUINT128, AUINT16, AUINT8, ABOOL, VECTOR, ATIMESTAMP, ACHAR, NONE, ERROR + AUINT32, AUINT64, AUINT128, AUINT16, AUINT8, ABOOL, VECTOR, ATIMESTAMP, ACHAR, ASV, NONE, ERROR }; - static constexpr const char* printf_str[] = { "%d", "%f", "%s", "%lf", "%Lf", "%ld", "%d", "%hi", "%s", "%s", "%hhd", - "%u", "%lu", "%s", "%hu", "%hhu", "%s", "%s", "Vector<%s>", "%s", "%c", "NULL", "ERROR" }; + static constexpr const char* printf_str[] = { "%d", "%f", "%s", "%lf", "%Lf", "%ld", "%s", "%hi", "%s", "%s", "%hhd", + "%u", "%lu", "%s", "%hu", "%hhu", "%s", "Vector<%s>", "%s", "%c", "%s", "NULL", "ERROR" }; static constexpr const char* SQL_Type[] = { "INT", "REAL", "TEXT", "DOUBLE", "DOUBLE", "BIGINT", "HUGEINT", "SMALLINT", "DATE", "TIME", "TINYINT", - "INT", "BIGINT", "HUGEINT", "SMALLINT", "TINYINT", "BOOL", "HUGEINT", "TIMESTAMP", "CHAR", "NULL", "ERROR"}; + "INT", "BIGINT", "HUGEINT", "SMALLINT", "TINYINT", "BOOL", "HUGEINT", "TIMESTAMP", "CHAR", "TEXT", "NULL", "ERROR"}; // TODO: deal with data/time <=> str/uint conversion @@ -169,6 +175,8 @@ namespace types { f(unsigned short, AUINT16) \ f(bool, ABOOL) \ f(timestamp_t, ATIMESTAMP) \ + f(std::string_view, ASV) \ + f(std::string, ASV) \ F_INT128(f) inline constexpr static Type_t getType() { @@ -399,7 +407,6 @@ struct transValues_s, vT, rT> { using type = rT; }; -#include template class rT> using transValues = typename transValues_s, vT, rT>::type; template class rT> @@ -427,8 +434,17 @@ template using get_first = typename get_first_impl::first; template struct value_type_rec_impl { typedef T type; }; + template