bill 2 years ago
parent c39ec80e1d
commit 10a7b7eafa

@ -1,14 +0,0 @@
## Windows
- clang-msvc:
- "%CXX%" -D_CRT_SECURE_NO_WARNINGS -shared server/server.cpp server/winhelper.cpp server/monetdb_conn.cpp -Imonetdb/msvc -Lmonetdb/msvc -lmonetdbe.lib --std=c++2a -o server.so
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
- gcc-mingw (link w/ msvc monetdb):
- "%CXX%" -shared -fPIC server/server.cpp server/winhelper.cpp server/monetdb_conn.cpp -Imonetdb/msvc msc-plugin/monetdbe.dll --std=c++2a -o server.so
- os.add_dll_directory('c:/msys64/usr/bin')
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))
- gcc-mingw (link w/ mingw monetdb, can only load under mingw python):
- $(CXX) server/server.cpp server/monetdb_conn.cpp -fPIC -shared $(OS_SUPPORT) --std=c++1z -O3 -march=native -o server.so -I./monetdb/msys64 -L./lib -lmonetdbe
- add_dll_dir(os.path.abspath('./lib'))
- msvc:
- D:\gg\vs22\MSBuild\Current\Bin\msbuild "d:\gg\AQuery++\server\server.vcxproj" /p:configuration=Release /p:platform=x64
- os.add_dll_directory(os.path.abspath('./monetdb/msvc'))

@ -100,6 +100,8 @@
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -161,6 +163,8 @@
<PrecompiledHeaderFile>pch.hpp</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

@ -108,6 +108,7 @@
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -178,6 +179,7 @@
<PrecompiledHeaderFile>./server/pch.hpp</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>../libaquery.pch</PrecompiledHeaderOutputFile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

@ -98,6 +98,8 @@
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -130,6 +132,8 @@
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>

@ -75,7 +75,13 @@ extern void register_memory(void* ptr, deallocator_t deallocator);
__AQEXPORT__(void) init_session(Context* cxt);
#define __AQ_NO_SESSION__ __AQEXPORT__(void) init_session(Context*) {}
#ifdef _MSC_VER
void* _cdecl memcpy(void*, void*, size_t);
#else
void* memcpy(void*, const void*, unsigned long long);
#endif
struct ColRef_storage {
void* container;
unsigned int capacity, size;

@ -106,6 +106,19 @@ decayed_t<VT,T> maxw(uint32_t w, const VT<T>& arr) {
return ret;
}
template<class T, template<typename ...> class VT>
decayed_t<VT, types::GetFPType<T>> ratios(const VT<T>& arr) {
uint32_t len = arr.size - 1;
if (!arr.size)
len = 1;
decayed_t<VT, types::GetFPType<T>> ret(len);
ret[0] = 0;
for (uint32_t i = 1; i < arr.size; ++i)
ret[i - 1] = arr[i] / arr[i - 1];
return ret;
}
template<class T, template<typename ...> class VT>
decayed_t<VT, types::GetLongType<T>> sums(const VT<T>& arr) {
const uint32_t& len = arr.size;
@ -171,10 +184,21 @@ decayed_t<VT, T> deltas(const VT<T>& arr) {
template<class T, template<typename ...> class VT>
T last(const VT<T>& arr) {
if (!arr.size) return 0;
const uint32_t& len = arr.size;
return arr[arr.size - 1];
}
template<class T, template<typename ...> class VT>
T first(const VT<T>& arr) {
if (!arr.size) return 0;
const uint32_t& len = arr.size;
return arr[0];
}
#define __DEFAULT_AGGREGATE_FUNCTION__(NAME, RET) \
template <class T> constexpr inline T NAME(const T& v) { return RET; }
// wrong behavior with count(0)
template <class T> constexpr inline T count(const T& v) { return 1; }
template <class T> constexpr inline T max(const T& v) { return v; }
@ -191,3 +215,4 @@ template <class T> constexpr inline T avgs(const T& v) { return v; }
template <class T> constexpr inline T sums(const T& v) { return v; }
template <class T> constexpr inline T last(const T& v) { return v; }
template <class T> constexpr inline T daltas(const T& v) { return 0; }
template <class T> constexpr inline T ratios(const T& v) { return 1; }

@ -320,35 +320,44 @@ int test_main()
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
const char* qs[]= {
"CREATE TABLE test1(a INT, b INT, c INT, d INT);",
"COPY OFFSET 2 INTO test1 FROM 'w:/gg/AQuery++/data/test.csv' ON SERVER USING DELIMITERS ',';",
"SELECT sum(a), b, d, c FROM test1 GROUP BY c, b, d ORDER BY b ;",
"QCREATE TABLE trade(stocksymbol INT, time INT, quantity INT, price INT);",
"QCOPY OFFSET 2 INTO trade FROM 'w:/gg/AQuery++/data/trade_numerical.csv' ON SERVER USING DELIMITERS ',';",
"QSELECT stocksymbol, (SUM((quantity * price)) / SUM(quantity)) AS weighted_average FROM trade GROUP BY stocksymbol ;",
"Pdll_5lYrMY",
"QSELECT stocksymbol, price FROM trade ORDER BY time ;",
"Pdll_4Sg6Ri",
"QSELECT stocksymbol, quantity, price FROM trade ORDER BY time ;",
"Pdll_5h4kL2",
"QSELECT stocksymbol, price FROM trade ORDER BY time ;",
"Pdll_7tEWCO",
"QSELECT query_c.weighted_moving_averages, query_c.stocksymbol FROM query_c;",
"Pdll_7FCPnF"
};
n_recv = sizeof(qs)/(sizeof (char*));
n_recvd = const_cast<char**>(qs);
if (n_recv > 0) {
void* handle = 0;
handle = dlopen("./dll.so", RTLD_LAZY);
cxt->init_session();
for (int i = 0; i < n_recv; ++i)
{
server->exec(n_recvd[i]);
//printf("%s, %d\n", n_recvd[i], n_recvd[i][0] == 'Q');
switch (n_recvd[i][0]) {
case 'Q': // SQL query for monetdbe
{
server->exec(n_recvd[i] + 1);
printf("Exec Q%d: %s\n", i, n_recvd[i]);
}
n_recv = 0;
break;
case 'P': // Postprocessing procedure
if (handle && !server->haserror()) {
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, n_recvd[i] + 1));
c(cxt);
}
cxt->log_level = LOG_INFO;
puts(cpp_17 ?"true":"false");
void* handle = dlopen("./dll.so", RTLD_LAZY);
cxt->log("handle: %p\n", handle);
if (handle) {
cxt->log("inner\n");
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dll_C4nJZu"));
cxt->log("routine: %p\n", c);
if (c) {
cxt->log("inner\n");
cxt->log("return: %d\n", c(cxt));
break;
}
dlclose(handle);
}
n_recv = 0;
//static_assert(std::is_same_v<decltype(fill_integer_array<5, 1>()), std::integer_sequence<bool, 1,1,1,1,1>>, "");
return 0;

@ -395,6 +395,7 @@ struct TableInfo {
+ num_time * types::time_t::string_length()
+ num_date * types::date_t::string_length()
+ num_timestamp * types::timestamp_t::string_length()
+ 1
];
setgbuf(cbuf);
if (view)
@ -422,7 +423,10 @@ struct TableInfo {
template <int ...vals> struct applier {
inline constexpr static void apply(const TableInfo<Types...>& t, const char* __restrict sep = ",", const char* __restrict end = "\n",
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr)
{ t.template print2<vals ...>(sep, end, view, fp); }};
{
t.template print2<vals ...>(sep, end, view, fp);
}
};
inline void printall(const char* __restrict sep = ",", const char* __restrict end = "\n",
const vector_type<uint32_t>* __restrict view = nullptr, FILE* __restrict fp = nullptr) {

@ -29,7 +29,7 @@ namespace types {
static constexpr const char* printf_str[] = { "%d", "%f", "%s", "%lf", "%Lf", "%ld", "%d", "%hi", "%s", "%s", "%c",
"%u", "%lu", "%s", "%hu", "%hhu", "%s", "%s", "Vector<%s>", "%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", "BIGINT", "BOOL", "BIGINT", "TIMESTAMP", "NULL", "ERROR"};
"INT", "BIGINT", "HUGEINT", "SMALLINT", "TINYINT", "BOOL", "BLOB", "TIMESTAMP", "NULL", "ERROR" };
// TODO: deal with data/time <=> str/uint conversion
@ -167,17 +167,51 @@ namespace types {
};
template<class T>
using GetLongType = typename GetLongTypeImpl<typename std::decay<T>::type>::type;
template<class T>
struct GetLongerTypeImpl {
using type = Cond(
__U(T), Cond(__Eq(char), unsigned short,
Cond(__Eq(short), unsigned int,
Cond(__Eq(int), unsigned long long,
ULL_Type
))),
Cond(Fp(T), double,
Cond(__Eq(char), short,
Cond(__Eq(short), int,
Cond(__Eq(int), long,
LL_Type
))))
);
};
template<class T>
using GetLongerType = typename GetLongerTypeImpl<typename std::decay<T>::type>::type;
}
struct astring_view {
const unsigned char* str = 0;
constexpr astring_view(const char* str) :
#if defined(__clang__) || !defined(__GNUC__)
constexpr
#endif
astring_view(const char* str) noexcept :
str((const unsigned char*)(str)) {}
constexpr astring_view(const signed char* str) :
#if defined(__clang__) || !defined(__GNUC__)
constexpr
#endif
astring_view(const signed char* str) noexcept :
str((const unsigned char*)(str)) {}
constexpr astring_view(const unsigned char* str) :
constexpr
astring_view(const unsigned char* str) noexcept :
str(str) {}
constexpr astring_view() = default;
constexpr astring_view() noexcept = default;
bool operator==(const astring_view& r) const {
auto this_str = str;

Loading…
Cancel
Save