diff --git a/.gitignore b/.gitignore
index 1f17c97..3b53a07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
*.dSYM
+testmain.lib
+testmain.exp
test.lib
test.exp
*.pdb
diff --git a/msc-plugin/server.sln b/msc-plugin/server.sln
index 34f000e..8b021f9 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
@@ -18,6 +21,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "launcher", "launcher.vcxpro
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdk_example", "sdk_example.vcxproj", "{F954797B-C148-4CBF-9FB4-A9A450EFEC38}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testmain", "testmain.vcxproj", "{73BD0DDA-7E66-4318-B46B-B8207AFA6355}"
+ ProjectSection(ProjectDependencies) = postProject
+ {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81} = {8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}
+ {B52AACF7-16A6-4FCA-90AD-867D367BDA4F} = {B52AACF7-16A6-4FCA-90AD-867D367BDA4F}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -116,6 +125,22 @@ Global
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.sharedlib|x64.Build.0 = Debug|x64
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.sharedlib|x86.ActiveCfg = Debug|Win32
{F954797B-C148-4CBF-9FB4-A9A450EFEC38}.sharedlib|x86.Build.0 = Debug|Win32
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.Debug|x64.ActiveCfg = Debug|x64
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.Debug|x64.Build.0 = Debug|x64
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.Debug|x86.ActiveCfg = Debug|Win32
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.Debug|x86.Build.0 = Debug|Win32
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.Release|x64.ActiveCfg = Release|x64
+ {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}.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
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.shared|x86.Build.0 = sharedlib|Win32
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.sharedlib|x64.ActiveCfg = sharedlib|x64
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.sharedlib|x64.Build.0 = sharedlib|x64
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.sharedlib|x86.ActiveCfg = sharedlib|Win32
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}.sharedlib|x86.Build.0 = sharedlib|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/msc-plugin/testmain.vcxproj b/msc-plugin/testmain.vcxproj
new file mode 100644
index 0000000..5b1571a
--- /dev/null
+++ b/msc-plugin/testmain.vcxproj
@@ -0,0 +1,281 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+ sharedlib
+ Win32
+
+
+ sharedlib
+ x64
+
+
+
+
+
+
+ 16.0
+ Win32Proj
+ {73BD0DDA-7E66-4318-B46B-B8207AFA6355}
+ server
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+ false
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+ false
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+ true
+
+
+ Application
+ true
+ v143
+ Unicode
+ false
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+ false
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ .exe
+ $(SolutionDir)..\
+
+
+ false
+ .exe
+ $(SolutionDir)..\
+
+
+ false
+ .exe
+ $(SolutionDir)..\
+
+
+ true
+ .exe
+ $(SolutionDir)..\
+
+
+ false
+ .exe
+ $(SolutionDir)..\
+
+
+ false
+ .exe
+ $(SolutionDir)..\
+
+
+
+ Level3
+ true
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ true
+ true
+ stdcpp17
+ stdc17
+ $(ProjectDir)\..\monetdb\msvc
+
+
+ Console
+ true
+ ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)
+ /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ true
+ true
+ stdcpp17
+ 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
+ stdcpp17
+ stdc17
+ $(ProjectDir)\..\monetdb\msvc
+
+
+ Console
+ true
+ true
+ true
+ $(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)
+ /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions)
+
+
+ copy $(OutDir)$(TargetName)$(TargetExt) $(ProjectDir)\..\server.so /y
+
+
+
+
+ Level3
+ true
+ _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ true
+ true
+ stdcpp17
+ stdc17
+ $(ProjectDir)\..\monetdb\msvc
+
+
+ Console
+ true
+ ..\libaquery.lib;$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)
+ /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions)
+
+
+
+
+ Level3
+ true
+ true
+ true
+ _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ true
+ true
+ stdcpp17
+ 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
+ stdcpp17
+ stdc17
+ $(ProjectDir)\..\monetdb\msvc
+
+
+ Console
+ true
+ true
+ true
+ $(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)
+ /WHOLEARCHIVE:libaquery.lib %(AdditionalOptions)
+
+
+ copy "$(OutDir)$(TargetName)$(TargetExt)" "$(ProjectDir)\..\server.so" /y
+
+
+
+
\ No newline at end of file
diff --git a/server/aggregations.h b/server/aggregations.h
index 7f35e84..e3442d0 100644
--- a/server/aggregations.h
+++ b/server/aggregations.h
@@ -26,8 +26,7 @@ LL_Type sum(const VT& v) {
template class VT>
//types::GetFPType
double avg(const VT& v) {
- return static_cast>(
- sum(v) / static_cast(v.size));
+ return (sum(v) / static_cast(v.size));
}
template class VT>
diff --git a/server/hasher.h b/server/hasher.h
index 780d24c..8e3f510 100644
--- a/server/hasher.h
+++ b/server/hasher.h
@@ -1,18 +1,41 @@
#pragma once
-#include
+#include
#include
+#include "types.h"
+// only works for 64 bit systems
+constexpr size_t _FNV_offset_basis = 14695981039346656037ULL;
+constexpr size_t _FNV_prime = 1099511628211ULL;
+
+inline size_t append_bytes(const unsigned char* _First) noexcept {
+ size_t _Val = _FNV_offset_basis;
+ for (; *_First; ++_First) {
+ _Val ^= static_cast(*_First);
+ _Val *= _FNV_prime;
+ }
+
+ return _Val;
+}
+
+inline size_t append_bytes(const astring_view& view) noexcept {
+ return append_bytes(view.str);
+}
+
+
template
struct hasher {
template typename std::enable_if< i == sizeof...(Types),
size_t>::type hashi(const std::tuple& record) const {
- return 0;
+ return 534235245539ULL;
}
template typename std::enable_if< i < sizeof ...(Types),
size_t>::type hashi(const std::tuple& record) const {
using current_type = typename std::decay>::type>::type;
- return std::hash()(std::get(record)) ^ hashi(record);
+ if constexpr (is_cstr())
+ return append_bytes((const unsigned char*)std::get(record)) ^ hashi(record);
+ else
+ return std::hash()(std::get(record)) ^ hashi(record);
}
size_t operator()(const std::tuple& record) const {
return hashi(record);
diff --git a/server/server.cpp b/server/server.cpp
index b10f5e4..d128abc 100644
--- a/server/server.cpp
+++ b/server/server.cpp
@@ -333,9 +333,9 @@ int test_main()
//printf("sibal: %p %p\n", aa, bb);
const char* qs[]= {
- "CREATE TABLE test(a INT, b INT, c INT, d INT);",
- "COPY OFFSET 2 INTO test FROM 'c:/Users/sunyi/Desktop/AQuery2/data/test2.csv' ON SERVER USING DELIMITERS ',';",
- "SELECT (a + b), a,b,c FROM test ;",
+ "CREATE TABLE network(src VARCHAR(3), dst VARCHAR(3), len INT, _time INT);",
+ "COPY OFFSET 2 INTO network FROM 'c:/Users/sunyi/Desktop/AQuery2/data/network.csv' ON SERVER USING DELIMITERS ',';",
+ "SELECT src, dst, len, _time FROM network ORDER BY src, dst, _time",
};
n_recv = sizeof(qs)/(sizeof (char*));
n_recvd = const_cast(qs);
@@ -354,7 +354,7 @@ int test_main()
cxt->log("handle: %p\n", handle);
if (handle) {
cxt->log("inner\n");
- code_snippet c = reinterpret_cast(dlsym(handle, "dll_ZF5Shg"));
+ code_snippet c = reinterpret_cast(dlsym(handle, "dll_54aqwy"));
cxt->log("routine: %p\n", c);
if (c) {
cxt->log("inner\n");
diff --git a/server/types.h b/server/types.h
index e93f083..db79abe 100644
--- a/server/types.h
+++ b/server/types.h
@@ -169,6 +169,51 @@ namespace types {
using GetLongType = typename GetLongTypeImpl::type>::type;
}
+struct astring_view {
+ const unsigned char* str = 0;
+ constexpr astring_view(const char* str) :
+ str((const unsigned char*)(str)) {}
+ constexpr astring_view(const signed char* str) :
+ str((const unsigned char*)(str)) {}
+ constexpr astring_view(const unsigned char* str) :
+ str(str) {}
+ constexpr astring_view() = default;
+
+ bool operator==(const astring_view& r) const {
+ auto this_str = str;
+ auto other_str = r.str;
+ while (*this_str && *other_str) {
+ if (*this_str != *other_str)
+ return false;
+ this_str++;
+ other_str++;
+ }
+ return !(*this_str || *other_str);
+ }
+ operator const char* () const {
+ return reinterpret_cast(str);
+ }
+ operator const unsigned char* () const {
+ return reinterpret_cast(str);
+ }
+ operator const signed char* () const {
+ return reinterpret_cast(str);
+ }
+};
+
+template
+constexpr bool is_cstr() {
+ using namespace std;
+ typedef decay_t dT;
+ return is_same_v ||
+ is_same_v ||
+ is_same_v ||
+ is_same_v ||
+ is_same_v ||
+ is_same_v ||
+ is_same_v;
+}
+
#define getT(i, t) std::tuple_element_t>
template class T, typename ...Types>
struct applyTemplates {
diff --git a/server/vector_type.hpp b/server/vector_type.hpp
index 79cfdf6..c56d7c2 100644
--- a/server/vector_type.hpp
+++ b/server/vector_type.hpp
@@ -47,7 +47,7 @@ public:
_Ty* container;
uint32_t size, capacity;
typedef _Ty* iterator_t;
- typedef _Ty value_t;
+ typedef std::conditional_t(), astring_view, _Ty> value_t;
vector_type(const uint32_t& size) : size(size), capacity(size) {
container = (_Ty*)malloc(size * sizeof(_Ty));
}