udf support for monetdbe backend
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#TargetFrameworkVersion=:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.19041.0
|
||||
Release|Win32|d:\gg\AQuery++\server\|
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+15
-2
@@ -3,6 +3,9 @@
|
||||
#include <utility>
|
||||
#include <limits>
|
||||
#include <deque>
|
||||
#include <cmath>
|
||||
#undef max
|
||||
#undef min
|
||||
template <class T, template<typename ...> class VT>
|
||||
size_t count(const VT<T>& v) {
|
||||
return v.size;
|
||||
@@ -24,6 +27,16 @@ types::GetFPType<T> avg(const VT<T>& v) {
|
||||
return static_cast<types::GetFPType<T>>(
|
||||
sum<T>(v) / static_cast<long double>(v.size));
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
VT<double> sqrt(const VT<T>& v) {
|
||||
VT<double> ret {v.size};
|
||||
for (uint32_t i = 0; i < v.size; ++i){
|
||||
ret[i] = sqrt(v[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T, template<typename ...> class VT>
|
||||
T max(const VT<T>& v) {
|
||||
T max_v = std::numeric_limits<T>::min();
|
||||
@@ -128,8 +141,8 @@ decayed_t<VT, types::GetLongType<T>> sumw(uint32_t w, const VT<T>& arr) {
|
||||
return ret;
|
||||
}
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetFPType<T>> avgw(uint32_t w, const VT<T>& arr) {
|
||||
typedef types::GetFPType<T> FPType;
|
||||
decayed_t<VT, types::GetFPType<types::GetLongType<T>>> avgw(uint32_t w, const VT<T>& arr) {
|
||||
typedef types::GetFPType<types::GetLongType<T>> FPType;
|
||||
const uint32_t& len = arr.size;
|
||||
decayed_t<VT, FPType> ret(len);
|
||||
uint32_t i = 0;
|
||||
|
||||
+3
-2
@@ -16,7 +16,8 @@ enum Backend_Type {
|
||||
BACKEND_MariaDB
|
||||
};
|
||||
struct Config{
|
||||
int running, new_query, server_mode, backend_type, n_buffers;
|
||||
int running, new_query, server_mode,
|
||||
backend_type, has_dll, n_buffers;
|
||||
int buffer_sizes[];
|
||||
};
|
||||
|
||||
@@ -31,7 +32,7 @@ struct Context{
|
||||
void **buffers;
|
||||
|
||||
void* alt_server;
|
||||
Log_level log_level = LOG_SILENT;
|
||||
Log_level log_level = LOG_INFO;
|
||||
printf_type print = printf;
|
||||
|
||||
template <class ...Types>
|
||||
|
||||
@@ -1,466 +0,0 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||
*/
|
||||
/* monetdb_config.h.in. Generated from CMakeLists.txt */
|
||||
|
||||
#ifndef MT_SEEN_MONETDB_CONFIG_H
|
||||
#define MT_SEEN_MONETDB_CONFIG_H 1
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if _MSC_VER < 1900
|
||||
#error Versions below Visual Studio 2015 are no longer supported
|
||||
#endif
|
||||
|
||||
/* Prevent pollution through excessive inclusion of include files by Windows.h. */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
|
||||
/* Visual Studio 8 has deprecated lots of stuff: suppress warnings */
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
#define _CRT_RAND_S /* for Windows rand_s, before stdlib.h */
|
||||
#define HAVE_RAND_S 1
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(_XOPEN_SOURCE) && defined(__CYGWIN__)
|
||||
#define _XOPEN_SOURCE 700
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#if defined(_MSC_VER) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
|
||||
/* In this case, malloc and friends are redefined in crtdbg.h to debug
|
||||
* versions. We need to include stdlib.h first or else we get
|
||||
* conflicting declarations. */
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* standard C-99 include files */
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
/* Windows include files */
|
||||
#include <process.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
/* indicate to sqltypes.h that windows.h has already been included and
|
||||
that it doesn't have to define Windows constants */
|
||||
#define ALREADY_HAVE_WINDOWS_TYPE 1
|
||||
|
||||
#define NATIVE_WIN32 1
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if !defined(WIN32) && defined(__CYGWIN__)
|
||||
#define WIN32 1
|
||||
#endif
|
||||
|
||||
// Section: monetdb configure defines
|
||||
/* #undef HAVE_DISPATCH_DISPATCH_H */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_IO_H 1
|
||||
/* #undef HAVE_KVM_H */
|
||||
/* #undef HAVE_LIBGEN_H */
|
||||
/* #undef HAVE_LIBINTL_H */
|
||||
/* #undef HAVE_MACH_MACH_INIT_H */
|
||||
/* #undef HAVE_MACH_TASK_H */
|
||||
/* #undef HAVE_MACH_O_DYLD_H */
|
||||
/* #undef HAVE_NETDB_H */
|
||||
/* #undef HAVE_NETINET_IN_H */
|
||||
/* #undef HAVE_POLL_H */
|
||||
/* #undef HAVE_PROCFS_H */
|
||||
/* #undef HAVE_PWD_H */
|
||||
/* #undef HAVE_STRINGS_H */
|
||||
/* #undef HAVE_STROPTS_H */
|
||||
/* #undef HAVE_SYS_FILE_H */
|
||||
/* #undef HAVE_SYS_IOCTL_H */
|
||||
/* #undef HAVE_SYS_SYSCTL_H */
|
||||
/* #undef HAVE_SYS_MMAN_H */
|
||||
/* #undef HAVE_SYS_PARAM_H */
|
||||
/* #undef HAVE_SYS_RANDOM_H */
|
||||
/* #undef HAVE_SYS_RESOURCE_H */
|
||||
/* #undef HAVE_SYS_TIME_H */
|
||||
/* #undef HAVE_SYS_TIMES_H */
|
||||
/* #undef HAVE_SYS_UIO_H */
|
||||
/* #undef HAVE_SYS_UN_H */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
/* #undef HAVE_TERMIOS_H */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
/* #undef HAVE_UUID_UUID_H */
|
||||
#define HAVE_WINSOCK_H 1
|
||||
/* #undef HAVE_SEMAPHORE_H */
|
||||
#define HAVE_GETOPT_H 1
|
||||
|
||||
/* #undef HAVE_STDATOMIC_H */
|
||||
|
||||
/* #undef HAVE_DIRENT_H */
|
||||
/* #undef HAVE_SYS_SOCKET_H */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
/* #undef HAVE_FDATASYNC */
|
||||
/* #undef HAVE_ACCEPT4 */
|
||||
/* #undef HAVE_ASCTIME_R */
|
||||
/* #undef HAVE_CLOCK_GETTIME */
|
||||
/* #undef HAVE_CTIME_R */
|
||||
/* #undef HAVE_DISPATCH_SEMAPHORE_CREATE */
|
||||
/* #undef HAVE_FALLOCATE */
|
||||
/* #undef HAVE_FCNTL */
|
||||
/* #undef HAVE_FORK */
|
||||
/* #undef HAVE_FSYNC */
|
||||
#define HAVE_FTIME 1
|
||||
/* #undef HAVE_GETENTROPY */
|
||||
/* #undef HAVE_GETEXECNAME */
|
||||
/* #undef HAVE_GETLOGIN */
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
/* #undef HAVE_GETRLIMIT */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
/* #undef HAVE_GETUID */
|
||||
/* #undef HAVE_GMTIME_R */
|
||||
/* #undef HAVE_LOCALTIME_R */
|
||||
/* #undef HAVE_STRERROR_R */
|
||||
/* #undef HAVE_LOCKF */
|
||||
/* #undef HAVE_MADVISE */
|
||||
/* #undef HAVE_MREMAP */
|
||||
/* #undef HAVE_NANOSLEEP */
|
||||
/* #undef HAVE_NL_LANGINFO */
|
||||
/* #undef HAVE__NSGETEXECUTABLEPATH */
|
||||
/* #undef HAVE_PIPE2 */
|
||||
/* #undef HAVE_POLL */
|
||||
/* #undef HAVE_POPEN */
|
||||
/* #undef HAVE_POSIX_FADVISE */
|
||||
/* #undef HAVE_POSIX_FALLOCATE */
|
||||
/* #undef HAVE_POSIX_MADVISE */
|
||||
#define HAVE_PUTENV 1
|
||||
/* #undef HAVE_SETSID */
|
||||
#define HAVE_SHUTDOWN 1
|
||||
/* #undef HAVE_SIGACTION */
|
||||
/* #undef HAVE_STPCPY */
|
||||
/* #undef HAVE_STRCASESTR */
|
||||
/* #undef HAVE_STRNCASECMP */
|
||||
/* #undef HAVE_STRPTIME */
|
||||
/* #undef HAVE_STRSIGNAL */
|
||||
/* #undef HAVE_SYSCONF */
|
||||
/* #undef HAVE_TASK_INFO */
|
||||
/* #undef HAVE_TIMES */
|
||||
/* #undef HAVE_UNAME */
|
||||
/* #undef HAVE_SEMTIMEDOP */
|
||||
/* #undef HAVE_PTHREAD_KILL */
|
||||
/* #undef HAVE_PTHREAD_SIGMASK */
|
||||
#define HAVE_GETOPT 1
|
||||
|
||||
#define ICONV_CONST
|
||||
#define FLEXIBLE_ARRAY_MEMBER
|
||||
#define ENABLE_MAPI 1
|
||||
#define HAVE_MAPI 1
|
||||
// End Section: monetdb configure defines
|
||||
|
||||
// Section: monetdb macro variables
|
||||
#define HAVE_ICONV 1
|
||||
/* #undef HAVE_PTHREAD_H */
|
||||
#define HAVE_LIBPCRE 1
|
||||
#define HAVE_LIBBZ2 1
|
||||
/* #undef HAVE_CURL */
|
||||
#define HAVE_LIBLZMA 1
|
||||
#define HAVE_LIBXML 1
|
||||
#define HAVE_LIBZ 1
|
||||
#define HAVE_LIBLZ4 1
|
||||
/* #undef HAVE_PROJ */
|
||||
/* #undef HAVE_SNAPPY */
|
||||
/* #undef HAVE_FITS */
|
||||
/* #undef HAVE_UUID */
|
||||
/* #undef HAVE_VALGRIND */
|
||||
/* #undef HAVE_NETCDF */
|
||||
/* #undef HAVE_READLINE */
|
||||
/* #undef HAVE_LIBR */
|
||||
#define RHOME "/registry"
|
||||
#define HAVE_GEOM 1
|
||||
/* #undef HAVE_SHP */
|
||||
#define HAVE_LIBPY3 1
|
||||
|
||||
// #define SOCKET_LIBRARIES
|
||||
#define HAVE_GETADDRINFO 1
|
||||
/* #undef HAVE_CUDF */
|
||||
|
||||
#define MAPI_PORT 50000
|
||||
#define MAPI_PORT_STR "50000"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define DIR_SEP '\\'
|
||||
#define PATH_SEP ';'
|
||||
#define DIR_SEP_STR "\\"
|
||||
#define SO_PREFIX ""
|
||||
#else
|
||||
#define DIR_SEP '/'
|
||||
#define PATH_SEP ':'
|
||||
#define DIR_SEP_STR "/"
|
||||
/* #undef SO_PREFIX */
|
||||
#endif
|
||||
#define SO_EXT ".dll"
|
||||
|
||||
#define BINDIR "C:/cygwin64/home/monet/x86_64/install/bin"
|
||||
#define LIBDIR "C:/cygwin64/home/monet/x86_64/install/lib"
|
||||
#define LOCALSTATEDIR "C:/cygwin64/home/monet/x86_64/install/var"
|
||||
|
||||
// End Section: monetdb macro variables
|
||||
|
||||
// Section: monetdb configure misc
|
||||
#define MONETDB_RELEASE "Jan2022-SP3"
|
||||
|
||||
#define MONETDB_VERSION "11.43.15"
|
||||
#define MONETDB_VERSION_MAJOR 11
|
||||
#define MONETDB_VERSION_MINOR 43
|
||||
#define MONETDB_VERSION_PATCH 15
|
||||
|
||||
#define GDK_VERSION "25.1.0"
|
||||
#define GDK_VERSION_MAJOR 25
|
||||
#define GDK_VERSION_MINOR 1
|
||||
#define GDK_VERSION_PATCH 0
|
||||
#define MAPI_VERSION "14.0.2"
|
||||
#define MAPI_VERSION_MAJOR 14
|
||||
#define MAPI_VERSION_MINOR 0
|
||||
#define MAPI_VERSION_PATCH 2
|
||||
#define MONETDB5_VERSION "32.0.6"
|
||||
#define MONETDB5_VERSION_MAJOR 32
|
||||
#define MONETDB5_VERSION_MINOR 0
|
||||
#define MONETDB5_VERSION_PATCH 6
|
||||
#define MONETDBE_VERSION "3.0.2"
|
||||
#define MONETDBE_VERSION_MAJOR 3
|
||||
#define MONETDBE_VERSION_MINOR 0
|
||||
#define MONETDBE_VERSION_PATCH 2
|
||||
#define STREAM_VERSION "16.0.1"
|
||||
#define STREAM_VERSION_MAJOR 16
|
||||
#define STREAM_VERSION_MINOR 0
|
||||
#define STREAM_VERSION_PATCH 1
|
||||
#define SQL_VERSION "12.0.5"
|
||||
#define SQL_VERSION_MAJOR 12
|
||||
#define SQL_VERSION_MINOR 0
|
||||
#define SQL_VERSION_PATCH 5
|
||||
|
||||
/* Host identifier */
|
||||
#define HOST "amd64-pc-windows-msvc"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH "SHA512"
|
||||
|
||||
/* The used password hash algorithm */
|
||||
#define MONETDB5_PASSWDHASH_TOKEN SHA512
|
||||
|
||||
#ifndef _Noreturn
|
||||
#define _Noreturn __declspec(noreturn)
|
||||
#endif
|
||||
#ifndef __cplusplus
|
||||
/* Does your compiler support `inline' keyword? (C99 feature) */
|
||||
#ifndef inline
|
||||
#define inline __inline
|
||||
#endif
|
||||
/* Does your compiler support `__restrict__' keyword? (C99 feature) */
|
||||
#ifndef __restrict__
|
||||
#define __restrict__ restrict
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef __restrict__
|
||||
#define __restrict__ __restrict
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure misc
|
||||
|
||||
// Section: monetdb configure sizes
|
||||
#define SIZEOF_SIZE_T 8
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#define SIZEOF_VOID_P 8
|
||||
|
||||
#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_WCHAR_T 2
|
||||
#define HAVE_LONG_LONG 1 /* for ODBC include files */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN64
|
||||
#define LENP_OR_POINTER_T SQLLEN *
|
||||
#else
|
||||
#define LENP_OR_POINTER_T SQLPOINTER
|
||||
#endif
|
||||
#else
|
||||
#define LENP_OR_POINTER_T SQLLEN *
|
||||
#endif
|
||||
#define SIZEOF_SQLWCHAR 2
|
||||
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Does your compiler support `ssize_t' type? (Posix type) */
|
||||
#ifndef ssize_t
|
||||
#define ssize_t int64_t
|
||||
#endif
|
||||
|
||||
/* The size of `__int128', as computed by sizeof. */
|
||||
/* #undef SIZEOF___INT128 */
|
||||
|
||||
/* The size of `__int128_t', as computed by sizeof. */
|
||||
/* #undef SIZEOF___INT128_T */
|
||||
|
||||
/* The size of `__uint128_t', as computed by sizeof. */
|
||||
/* #undef SIZEOF___UINT128_T */
|
||||
|
||||
#ifdef SIZEOF___INT128
|
||||
typedef __int128 hge;
|
||||
typedef unsigned __int128 uhge;
|
||||
#define HAVE_HGE 1
|
||||
#define SIZEOF_HGE SIZEOF___INT128
|
||||
#elif defined(SIZEOF___INT128_T) && defined(SIZEOF___UINT128_T)
|
||||
typedef __int128_t hge;
|
||||
typedef __uint128_t uhge;
|
||||
#define HAVE_HGE 1
|
||||
#define SIZEOF_HGE SIZEOF___INT128_T
|
||||
#endif
|
||||
|
||||
// End Section: monetdb configure sizes
|
||||
|
||||
/* Does your compiler support `__attribute__' extension? */
|
||||
#if !defined(__GNUC__) && !defined(__clang__) && !defined(__attribute__)
|
||||
#define __attribute__(a)
|
||||
#endif
|
||||
|
||||
#if !defined(__cplusplus) || __cplusplus < 201103L
|
||||
#ifndef static_assert
|
||||
/* static_assert is a C11/C++11 feature, defined in assert.h which also exists
|
||||
* in many other compilers we ignore it if the compiler doesn't support it
|
||||
* However in C11 static_assert is a macro, while on C++11 is a keyword */
|
||||
#define static_assert(expr, mesg) ((void) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h> /* strcasecmp */
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define strdup(s) _strdup(s)
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp(x,y) _stricmp(x,y)
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
#ifndef strncasecmp
|
||||
#define strncasecmp(x,y,z) _strnicmp(x,y,z)
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#ifdef lstat
|
||||
#undef lstat
|
||||
#endif
|
||||
#define lstat _stat64
|
||||
#ifdef stat
|
||||
#undef stat
|
||||
#endif
|
||||
#define stat _stat64
|
||||
#ifdef fstat
|
||||
#undef fstat
|
||||
#endif
|
||||
#define fstat _fstat64
|
||||
|
||||
static inline char *
|
||||
stpcpy(char *__restrict__ dst, const char *__restrict__ src)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; src[i]; i++)
|
||||
dst[i] = src[i];
|
||||
dst[i] = 0;
|
||||
return dst + i;
|
||||
}
|
||||
|
||||
/* Define to 1 if the system has the type `socklen_t'. */
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
/* type used by connect */
|
||||
#define socklen_t int
|
||||
#define strtok_r(t,d,c) strtok_s(t,d,c)
|
||||
|
||||
#define HAVE_GETOPT_LONG 1
|
||||
|
||||
/* there is something very similar to localtime_r on Windows: */
|
||||
#include <time.h>
|
||||
#define HAVE_LOCALTIME_R 1
|
||||
static inline struct tm *
|
||||
localtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
||||
{
|
||||
return localtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
#define HAVE_GMTIME_R 1
|
||||
static inline struct tm *
|
||||
gmtime_r(const time_t *__restrict__ timep, struct tm *__restrict__ result)
|
||||
{
|
||||
return gmtime_s(result, timep) == 0 ? result : NULL;
|
||||
}
|
||||
|
||||
/* Define if you have ctime_r(time_t*,char *buf,size_t s) */
|
||||
#define HAVE_CTIME_R 1
|
||||
#define HAVE_CTIME_R3 1
|
||||
/* there is something very similar to ctime_r on Windows: */
|
||||
#define ctime_r(t,b,s) (ctime_s(b,s,t) ? NULL : (b))
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#define HAVE_SOCKLEN_T 1
|
||||
#ifndef _MSC_VER
|
||||
#define SOCKET int
|
||||
#define closesocket close
|
||||
#endif
|
||||
|
||||
#ifndef _In_z_
|
||||
#define _In_z_
|
||||
#endif
|
||||
#ifndef _Printf_format_string_
|
||||
#define _Printf_format_string_
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _LIB_STARTUP_FUNC_(f,q) \
|
||||
static void f(void); \
|
||||
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||
__pragma(comment(linker,"/include:" q #f "_")) \
|
||||
static void f(void)
|
||||
#ifdef _WIN64
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"")
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) _LIB_STARTUP_FUNC_(f,"_")
|
||||
#endif
|
||||
#else
|
||||
#define LIB_STARTUP_FUNC(f) \
|
||||
static void f(void) __attribute__((__constructor__)); \
|
||||
static void f(void)
|
||||
#endif
|
||||
|
||||
#endif /* MT_SEEN_MONETDB_CONFIG_H */
|
||||
+56
-11
@@ -1,28 +1,63 @@
|
||||
#include "monetdb_conn.h"
|
||||
#include "libaquery.h"
|
||||
#include <cstdio>
|
||||
#include "monetdb_conn.h"
|
||||
|
||||
const char* monetdbe_type_str[] = {
|
||||
"monetdbe_bool", "monetdbe_int8_t", "monetdbe_int16_t", "monetdbe_int32_t", "monetdbe_int64_t",
|
||||
#ifdef HAVE_HGE
|
||||
"monetdbe_int128_t",
|
||||
#endif
|
||||
"monetdbe_size_t", "monetdbe_float", "monetdbe_double",
|
||||
"monetdbe_str", "monetdbe_blob",
|
||||
"monetdbe_date", "monetdbe_time", "monetdbe_timestamp",
|
||||
|
||||
// should be last:
|
||||
"monetdbe_type_unknown"
|
||||
} ;
|
||||
|
||||
Server::Server(Context* cxt){
|
||||
if (cxt){
|
||||
connect(cxt);
|
||||
}
|
||||
}
|
||||
|
||||
void Server::connect(Context *cxt){
|
||||
if (!cxt){
|
||||
if (cxt){
|
||||
cxt->alt_server = this;
|
||||
this->cxt = cxt;
|
||||
}
|
||||
else{
|
||||
puts("Error: Empty context.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (server != 0){
|
||||
monetdbe_close(*server);
|
||||
free(*server);
|
||||
server = (monetdbe_database*)malloc(sizeof(monetdbe_database));
|
||||
if (server){
|
||||
printf("Error: Server %llx already connected. Restart? (Y/n). \n", server);
|
||||
char c[50];
|
||||
std::cin.getline(c, 49);
|
||||
for(int i = 0; i < 50; ++i){
|
||||
if (!c[i] || c[i] == 'y' || c[i] == 'Y'){
|
||||
monetdbe_close(*server);
|
||||
free(*server);
|
||||
server = 0;
|
||||
break;
|
||||
}
|
||||
else if(c[i]&&!(c[i] == ' ' || c[i] == '\t'))
|
||||
break;
|
||||
}
|
||||
}
|
||||
monetdbe_open(server, nullptr, nullptr);
|
||||
|
||||
server = (monetdbe_database*)malloc(sizeof(monetdbe_database));
|
||||
auto ret = monetdbe_open(server, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void Server::exec(const char* q){
|
||||
auto qstatus = monetdbe_query(*server, const_cast<char*>(q), &res, &cnt);
|
||||
if (qstatus != nullptr){
|
||||
puts("Execution Failed.\n");
|
||||
auto qresult = monetdbe_query(*server, const_cast<char*>(q), &res, &cnt);
|
||||
if (res != 0)
|
||||
this->cnt = res->nrows;
|
||||
if (qresult != nullptr){
|
||||
printf("Execution Failed. %s\n", qresult);
|
||||
last_error = qresult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +71,21 @@ void Server::close(){
|
||||
|
||||
void* Server::getCol(int col_idx){
|
||||
if(res){
|
||||
if(monetdbe_result_fetch(res, &ret_col, col_idx) != nullptr)
|
||||
res->ncols;
|
||||
auto err_msg = monetdbe_result_fetch(res, &ret_col, col_idx);
|
||||
if(err_msg == nullptr)
|
||||
{
|
||||
cnt = ret_col->count;
|
||||
printf("Dbg: Getting col %s, type: %s\n",
|
||||
ret_col->name, monetdbe_type_str[ret_col->type]);
|
||||
return ret_col->data;
|
||||
}
|
||||
else{
|
||||
printf("Error fetching result: %s\n", err_msg);
|
||||
}
|
||||
}
|
||||
else{
|
||||
puts("Error: No result.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ struct Server{
|
||||
monetdbe_result* res = 0;
|
||||
monetdbe_column* ret_col = 0;
|
||||
monetdbe_cnt cnt = 0;
|
||||
|
||||
char* last_error = 0;
|
||||
|
||||
Server(Context* cxt = nullptr);
|
||||
void connect(Context* cxt);
|
||||
void exec(const char* q);
|
||||
void *getCol(int col_idx);
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* Copyright 1997 - July 2008 CWI, August 2008 - 2022 MonetDB B.V.
|
||||
*/
|
||||
|
||||
#ifndef _MONETDBE_LIB_
|
||||
#define _MONETDBE_LIB_
|
||||
|
||||
#include "monetdb_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef LIBMONETDBE
|
||||
#define monetdbe_export extern __declspec(dllimport)
|
||||
#else
|
||||
#define monetdbe_export extern __declspec(dllexport)
|
||||
#endif
|
||||
#else
|
||||
#define monetdbe_export extern
|
||||
#endif
|
||||
|
||||
typedef int64_t monetdbe_cnt;
|
||||
|
||||
typedef struct {
|
||||
unsigned char day;
|
||||
unsigned char month;
|
||||
short year;
|
||||
} monetdbe_data_date;
|
||||
|
||||
typedef struct {
|
||||
unsigned int ms;
|
||||
unsigned char seconds;
|
||||
unsigned char minutes;
|
||||
unsigned char hours;
|
||||
} monetdbe_data_time;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_data_date date;
|
||||
monetdbe_data_time time;
|
||||
} monetdbe_data_timestamp;
|
||||
|
||||
typedef struct {
|
||||
size_t size;
|
||||
char* data;
|
||||
} monetdbe_data_blob;
|
||||
|
||||
typedef enum {
|
||||
monetdbe_bool, monetdbe_int8_t, monetdbe_int16_t, monetdbe_int32_t, monetdbe_int64_t,
|
||||
#ifdef HAVE_HGE
|
||||
monetdbe_int128_t,
|
||||
#endif
|
||||
monetdbe_size_t, monetdbe_float, monetdbe_double,
|
||||
monetdbe_str, monetdbe_blob,
|
||||
monetdbe_date, monetdbe_time, monetdbe_timestamp,
|
||||
|
||||
// should be last:
|
||||
monetdbe_type_unknown
|
||||
} monetdbe_types;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
unsigned int scale;
|
||||
unsigned int digits;
|
||||
} monetdbe_sql_type;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_types type;
|
||||
monetdbe_sql_type sql_type;
|
||||
void *data;
|
||||
size_t count;
|
||||
char* name;
|
||||
} monetdbe_column;
|
||||
|
||||
typedef struct {
|
||||
size_t nparam;
|
||||
monetdbe_types *type;
|
||||
} monetdbe_statement;
|
||||
|
||||
typedef struct {
|
||||
monetdbe_cnt nrows;
|
||||
size_t ncols;
|
||||
char *name;
|
||||
monetdbe_cnt last_id; /* last auto incremented id */
|
||||
} monetdbe_result;
|
||||
|
||||
typedef void* monetdbe_database;
|
||||
|
||||
typedef struct {
|
||||
const char *host;
|
||||
int port;
|
||||
const char *database;
|
||||
const char *username;
|
||||
const char *password;
|
||||
const char *lang;
|
||||
} monetdbe_remote;
|
||||
|
||||
typedef struct {
|
||||
const char* port;
|
||||
const char* usock;
|
||||
} monetdbe_mapi_server;
|
||||
|
||||
typedef struct {
|
||||
int memorylimit; // top off the amount of RAM to be used, in MB
|
||||
int querytimeout; // graceful terminate query after a few seconds
|
||||
int sessiontimeout; // graceful terminate the session after a few seconds
|
||||
int nr_threads; // maximum number of worker treads, limits level of parallelism
|
||||
monetdbe_remote* remote;
|
||||
monetdbe_mapi_server* mapi_server;
|
||||
const char *trace_file; // file to which log output should be written
|
||||
} monetdbe_options;
|
||||
|
||||
#define DEFAULT_STRUCT_DEFINITION(ctype, typename) \
|
||||
typedef struct \
|
||||
{ \
|
||||
monetdbe_types type; \
|
||||
monetdbe_sql_type sql_type; \
|
||||
ctype *data; \
|
||||
size_t count; \
|
||||
char *name; \
|
||||
ctype null_value; \
|
||||
double scale; \
|
||||
int (*is_null)(ctype *value); \
|
||||
} monetdbe_column_##typename
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(int8_t, bool);
|
||||
DEFAULT_STRUCT_DEFINITION(int8_t, int8_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int16_t, int16_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int32_t, int32_t);
|
||||
DEFAULT_STRUCT_DEFINITION(int64_t, int64_t);
|
||||
#ifdef HAVE_HGE
|
||||
DEFAULT_STRUCT_DEFINITION(__int128, int128_t);
|
||||
#endif
|
||||
DEFAULT_STRUCT_DEFINITION(size_t, size_t);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(float, float);
|
||||
DEFAULT_STRUCT_DEFINITION(double, double);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(char *, str);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_blob, blob);
|
||||
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_date, date);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_time, time);
|
||||
DEFAULT_STRUCT_DEFINITION(monetdbe_data_timestamp, timestamp);
|
||||
// UUID, INET, XML ?
|
||||
|
||||
monetdbe_export const char *monetdbe_version(void);
|
||||
|
||||
monetdbe_export int monetdbe_open(monetdbe_database *db, char *url, monetdbe_options *opts);
|
||||
/* 0 ok, -1 (allocation failed), -2 error in db */
|
||||
monetdbe_export int monetdbe_close(monetdbe_database db);
|
||||
|
||||
monetdbe_export char* monetdbe_error(monetdbe_database db);
|
||||
|
||||
monetdbe_export char* monetdbe_get_autocommit(monetdbe_database dbhdl, int* result);
|
||||
monetdbe_export char* monetdbe_set_autocommit(monetdbe_database dbhdl, int value);
|
||||
monetdbe_export int monetdbe_in_transaction(monetdbe_database dbhdl);
|
||||
|
||||
monetdbe_export char* monetdbe_query(monetdbe_database dbhdl, char* query, monetdbe_result** result, monetdbe_cnt* affected_rows);
|
||||
monetdbe_export char* monetdbe_result_fetch(monetdbe_result *mres, monetdbe_column** res, size_t column_index);
|
||||
monetdbe_export char* monetdbe_cleanup_result(monetdbe_database dbhdl, monetdbe_result* result);
|
||||
|
||||
monetdbe_export char* monetdbe_prepare(monetdbe_database dbhdl, char *query, monetdbe_statement **stmt, monetdbe_result** result);
|
||||
monetdbe_export char* monetdbe_bind(monetdbe_statement *stmt, void *data, size_t parameter_nr);
|
||||
monetdbe_export char* monetdbe_execute(monetdbe_statement *stmt, monetdbe_result **result, monetdbe_cnt* affected_rows);
|
||||
monetdbe_export char* monetdbe_cleanup_statement(monetdbe_database dbhdl, monetdbe_statement *stmt);
|
||||
|
||||
monetdbe_export char* monetdbe_append(monetdbe_database dbhdl, const char* schema, const char* table, monetdbe_column **input, size_t column_count);
|
||||
monetdbe_export const void* monetdbe_null(monetdbe_database dbhdl, monetdbe_types t);
|
||||
|
||||
monetdbe_export char* monetdbe_get_columns(monetdbe_database dbhdl, const char* schema_name, const char *table_name, size_t *column_count, monetdbe_column **columns);
|
||||
|
||||
monetdbe_export char* monetdbe_dump_database(monetdbe_database dbhdl, const char *backupfile);
|
||||
monetdbe_export char* monetdbe_dump_table(monetdbe_database dbhdl, const char *schema_name, const char *table_name, const char *backupfile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
+71
-6
@@ -38,6 +38,27 @@ void daemon(thread_context* c) {
|
||||
typedef int (*code_snippet)(void*);
|
||||
int test_main();
|
||||
|
||||
int n_recv = 0;
|
||||
char** n_recvd = nullptr;
|
||||
|
||||
extern "C" void __DLLEXPORT__ receive_args(int argc, char**argv){
|
||||
n_recv = argc;
|
||||
n_recvd = argv;
|
||||
}
|
||||
enum BinaryInfo_t {
|
||||
MSVC, MSYS, GCC, CLANG, AppleClang
|
||||
};
|
||||
extern "C" int __DLLEXPORT__ binary_info() {
|
||||
#if defined(_MSC_VER) && !defined (__llvm__)
|
||||
return MSVC;
|
||||
#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||
return MSYS;
|
||||
#elif defined(__GNUC__)
|
||||
return GCC;
|
||||
#else
|
||||
return AppleClang;
|
||||
#endif
|
||||
}
|
||||
int dll_main(int argc, char** argv, Context* cxt){
|
||||
Config *cfg = reinterpret_cast<Config *>(argv[0]);
|
||||
|
||||
@@ -50,17 +71,39 @@ int dll_main(int argc, char** argv, Context* cxt){
|
||||
cxt->cfg = cfg;
|
||||
cxt->n_buffers = cfg->n_buffers;
|
||||
cxt->sz_bufs = buf_szs;
|
||||
|
||||
cxt->alt_server = NULL;
|
||||
|
||||
while(cfg->running){
|
||||
if (cfg->new_query) {
|
||||
if (cfg->backend_type == BACKEND_MonetDB){
|
||||
|
||||
if (cfg->backend_type == BACKEND_MonetDB){
|
||||
if (cxt->alt_server == 0)
|
||||
cxt->alt_server = new Server(cxt);
|
||||
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
||||
if(n_recv > 0){
|
||||
for(int i = 0; i < n_recv; ++i)
|
||||
{
|
||||
server->exec(n_recvd[i]);
|
||||
printf("Exec Q%d: %s\n", i, n_recvd[i]);
|
||||
}
|
||||
n_recv = 0;
|
||||
}
|
||||
if(server->last_error == nullptr){
|
||||
|
||||
}
|
||||
else{
|
||||
server->last_error = nullptr;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// puts(cfg->has_dll ? "true" : "false");
|
||||
if (cfg->backend_type == BACKEND_AQuery || cfg->has_dll) {
|
||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
||||
c(cxt);
|
||||
dlclose(handle);
|
||||
}
|
||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
code_snippet c = reinterpret_cast<code_snippet>(dlsym(handle, "dllmain"));
|
||||
c(cxt);
|
||||
dlclose(handle);
|
||||
cfg->new_query = 0;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
@@ -70,6 +113,7 @@ int dll_main(int argc, char** argv, Context* cxt){
|
||||
}
|
||||
|
||||
extern "C" int __DLLEXPORT__ main(int argc, char** argv) {
|
||||
puts("running");
|
||||
Context* cxt = new Context();
|
||||
cxt->log("%d %s\n", argc, argv[1]);
|
||||
|
||||
@@ -119,6 +163,27 @@ int test_main()
|
||||
//print(t);
|
||||
//return 0;
|
||||
Context* cxt = new Context();
|
||||
if (cxt->alt_server == 0)
|
||||
cxt->alt_server = new Server(cxt);
|
||||
Server* server = reinterpret_cast<Server*>(cxt->alt_server);
|
||||
const char* qs[]= {
|
||||
"CREATE TABLE tt(a INT, b INT, c INT, d INT);",
|
||||
"COPY OFFSET 2 INTO tt FROM 'D:/gg/AQuery++/test.csv' ON SERVER USING DELIMITERS ',';",
|
||||
"CREATE TABLE sale(Mont INT, sales INT);",
|
||||
"COPY OFFSET 2 INTO sale FROM 'D:/gg/AQuery++/moving_avg.csv' ON SERVER USING DELIMITERS ',';",
|
||||
"SELECT a FROM tt, sale WHERE a = Mont ;"
|
||||
};
|
||||
n_recv = sizeof(qs)/(sizeof (char*));
|
||||
n_recvd = const_cast<char**>(qs);
|
||||
if (n_recv > 0) {
|
||||
for (int i = 0; i < n_recv; ++i)
|
||||
{
|
||||
server->exec(n_recvd[i]);
|
||||
printf("Exec Q%d: %s\n", i, n_recvd[i]);
|
||||
}
|
||||
n_recv = 0;
|
||||
}
|
||||
|
||||
cxt->log_level = LOG_INFO;
|
||||
puts(cpp_17 ?"true":"false");
|
||||
void* handle = dlopen("./dll.so", RTLD_LAZY);
|
||||
|
||||
@@ -20,6 +20,12 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
shared|Any CPU = shared|Any CPU
|
||||
shared|x64 = shared|x64
|
||||
shared|x86 = shared|x86
|
||||
sharedlib|Any CPU = sharedlib|Any CPU
|
||||
sharedlib|x64 = sharedlib|x64
|
||||
sharedlib|x86 = sharedlib|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
@@ -34,6 +40,16 @@ 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}.shared|Any CPU.ActiveCfg = Release|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.shared|Any CPU.Build.0 = Release|x64
|
||||
{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|Any CPU.ActiveCfg = sharedlib|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.sharedlib|Any CPU.Build.0 = sharedlib|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.sharedlib|x64.ActiveCfg = sharedlib|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.sharedlib|x64.Build.0 = sharedlib|x64
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.sharedlib|x86.ActiveCfg = sharedlib|Win32
|
||||
{031352C2-AFBB-45AA-9518-DBC1F9EF2AF3}.sharedlib|x86.Build.0 = sharedlib|Win32
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@@ -46,12 +62,30 @@ 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}.shared|Any CPU.ActiveCfg = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.shared|Any CPU.Build.0 = Release|x64
|
||||
{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
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.shared|x86.Build.0 = Release|Win32
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.sharedlib|Any CPU.ActiveCfg = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.sharedlib|Any CPU.Build.0 = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.sharedlib|x64.ActiveCfg = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.sharedlib|x64.Build.0 = Release|x64
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.sharedlib|x86.ActiveCfg = Release|Win32
|
||||
{8081FDAA-4D13-4B7A-ADB2-8224AF7F1C81}.sharedlib|x86.Build.0 = Release|Win32
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.Release|Any CPU.ActiveCfg = Release|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}.shared|Any CPU.ActiveCfg = Release|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|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.sharedlib|x64.ActiveCfg = Release|Any CPU
|
||||
{CCC243F5-663E-45B7-A6DE-B2468C58B3A7}.sharedlib|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -17,6 +17,14 @@
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="sharedlib|Win32">
|
||||
<Configuration>sharedlib</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="sharedlib|x64">
|
||||
<Configuration>sharedlib</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
@@ -41,6 +49,14 @@
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>true</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='sharedlib|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>true</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
@@ -56,6 +72,14 @@
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>true</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='sharedlib|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
@@ -67,12 +91,18 @@
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='sharedlib|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='sharedlib|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
@@ -80,12 +110,18 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='sharedlib|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='sharedlib|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -96,10 +132,12 @@
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -114,14 +152,41 @@
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='sharedlib|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy $(OutDir)$(TargetName)$(TargetExt) $(ProjectDir)\..\server.so /y</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -132,10 +197,12 @@
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -150,16 +217,44 @@
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='sharedlib|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)\..\monetdb\msvc</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>$(ProjectDir)\..\monetdb\msvc\monetdbe.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy "$(OutDir)$(TargetName)$(TargetExt)" "$(ProjectDir)\..\server.so" /y</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Media Include="..\out.cpp" />
|
||||
<ClCompile Include="monetdb_conn.cpp" />
|
||||
<ClCompile Include="table.cpp" />
|
||||
<ClCompile Include="server.cpp" />
|
||||
<ClCompile Include="types.cpp" />
|
||||
|
||||
+71
-5
@@ -34,7 +34,31 @@ public:
|
||||
ColRef() : vector_type<_Ty>(0), name("") {}
|
||||
ColRef(const uint32_t& size, const char* name = "") : vector_type<_Ty>(size), name(name) {}
|
||||
ColRef(const char* name) : name(name) {}
|
||||
ColRef(const uint32_t size, void* data, const char* name = "") : vector_type<_Ty>(size, data), name(name) {}
|
||||
void init(const char* name = "") { ty = types::Types<_Ty>::getType(); this->size = this->capacity = 0; this->container = 0; this->name = name; }
|
||||
void initfrom(uint32_t sz, void*container, const char* name = "") {
|
||||
ty = types::Types<_Ty>::getType();
|
||||
this->size = sz;
|
||||
this->capacity = 0;
|
||||
this->container = (_Ty*)container;
|
||||
this->name = name;
|
||||
}
|
||||
template<template <typename ...> class VT, typename T>
|
||||
void initfrom(const VT<T>& v, const char* name = ""){
|
||||
ty = types::Types<_Ty>::getType();
|
||||
this->size = v.size;
|
||||
this->capacity = 0;
|
||||
this->container = (_Ty*)(v.container);
|
||||
this->name = name;
|
||||
}
|
||||
template <class T>
|
||||
ColRef<_Ty>& operator =(ColRef<T>&& vt) {
|
||||
this->container = (_Ty*)vt.container;
|
||||
this->size = vt.size;
|
||||
this->capacity = vt.capacity;
|
||||
vt.capacity = 0; // rvalue's
|
||||
return *this;
|
||||
}
|
||||
ColRef(const char* name, types::Type_t ty) : name(name), ty(ty) {}
|
||||
using vector_type<_Ty>::operator[];
|
||||
using vector_type<_Ty>::operator=;
|
||||
@@ -180,7 +204,10 @@ struct TableInfo {
|
||||
auto bind(TableInfo<Types2...>* table2) {
|
||||
return lineage_t(this, table2);
|
||||
}
|
||||
|
||||
template <size_t i = 0>
|
||||
auto& get_col() {
|
||||
return *reinterpret_cast<ColRef<std::tuple_element_t <i, tuple_type>>*>(colrefs + i);
|
||||
}
|
||||
template <size_t j = 0>
|
||||
typename std::enable_if<j == sizeof...(Types) - 1, void>::type print_impl(const uint32_t& i, const char* __restrict sep = " ") const;
|
||||
template <size_t j = 0>
|
||||
@@ -192,6 +219,7 @@ struct TableInfo {
|
||||
template <size_t ...Idxs>
|
||||
using getRecordType = typename GetTypes<Idxs...>::type;
|
||||
TableInfo(const char* name, uint32_t n_cols);
|
||||
TableInfo(const char* name = "");
|
||||
template <int prog = 0>
|
||||
inline void materialize(const vector_type<uint32_t>& idxs, TableInfo<Types...>* tbl = nullptr) { // inplace materialize
|
||||
if constexpr(prog == 0) tbl = (tbl == 0 ? this : tbl);
|
||||
@@ -331,6 +359,16 @@ constexpr static inline bool is_vector(const vector_type<T>&) {
|
||||
template<class ...Types>
|
||||
TableInfo<Types...>::TableInfo(const char* name, uint32_t n_cols) : name(name), n_cols(n_cols) {
|
||||
this->colrefs = (ColRef<void>*)malloc(sizeof(ColRef<void>) * n_cols);
|
||||
for (int i = 0; i < n_cols; ++i) {
|
||||
this->colrefs[i].init();
|
||||
}
|
||||
}
|
||||
template<class ...Types>
|
||||
TableInfo<Types...>::TableInfo(const char* name) : name(name), n_cols(sizeof...(Types)) {
|
||||
this->colrefs = (ColRef<void>*)malloc(sizeof(ColRef<void>) * this->n_cols);
|
||||
for (int i = 0; i < n_cols; ++i) {
|
||||
this->colrefs[i].init();
|
||||
}
|
||||
}
|
||||
template <class ...Types>
|
||||
template <size_t j>
|
||||
@@ -405,6 +443,13 @@ decayed_t<VT, typename types::Coercion<T1, T2>::type> operator -(const VT<T1>& l
|
||||
ret[i] = lhs[i] - rhs;
|
||||
return ret;
|
||||
}
|
||||
template <class T1, class T2, template<typename ...> class VT>
|
||||
decayed_t<VT, typename types::Coercion<T1, T2>::type> operator -(const T2& lhs, const VT<T1>& rhs) {
|
||||
auto ret = decayed_t<VT, typename types::Coercion<T1, T2>::type>(rhs.size, "");
|
||||
for (int i = 0; i < rhs.size; ++i)
|
||||
ret[i] = lhs - rhs[i];
|
||||
return ret;
|
||||
}
|
||||
template <class T1, class T2, template<typename ...> class VT, template<typename ...> class VT2>
|
||||
decayed_t<VT, typename types::Coercion<T1, T2>::type> operator +(const VT<T1>& lhs, const VT2<T2>& rhs) {
|
||||
auto ret = decayed_t<VT, typename types::Coercion<T1, T2>::type>(lhs.size, "");
|
||||
@@ -419,6 +464,13 @@ decayed_t<VT, typename types::Coercion<T1, T2>::type> operator +(const VT<T1>& l
|
||||
ret[i] = lhs[i] + rhs;
|
||||
return ret;
|
||||
}
|
||||
template <class T1, class T2, template<typename ...> class VT>
|
||||
decayed_t<VT, typename types::Coercion<T1, T2>::type> operator +(const T2& lhs, const VT<T1>& rhs) {
|
||||
auto ret = decayed_t<VT, typename types::Coercion<T1, T2>::type>(rhs.size, "");
|
||||
for (int i = 0; i < rhs.size; ++i)
|
||||
ret[i] = lhs + rhs[i];
|
||||
return ret;
|
||||
}
|
||||
template <class T1, class T2, template<typename ...> class VT, template<typename ...> class VT2>
|
||||
decayed_t<VT, typename types::Coercion<T1, T2>::type> operator *(const VT<T1>& lhs, const VT2<T2>& rhs) {
|
||||
auto ret = decayed_t<VT, typename types::Coercion<T1, T2>::type>(lhs.size, "");
|
||||
@@ -433,20 +485,34 @@ decayed_t<VT, typename types::Coercion<T1, T2>::type> operator *(const VT<T1>& l
|
||||
ret[i] = lhs[i] * rhs;
|
||||
return ret;
|
||||
}
|
||||
template <class T1, class T2, template<typename ...> class VT>
|
||||
decayed_t<VT, typename types::Coercion<T1, T2>::type> operator *(const T2& lhs, const VT<T1>& rhs) {
|
||||
auto ret = decayed_t<VT, typename types::Coercion<T1, T2>::type>(rhs.size, "");
|
||||
for (int i = 0; i < rhs.size; ++i)
|
||||
ret[i] = lhs * rhs[i];
|
||||
return ret;
|
||||
}
|
||||
template <class T1, class T2, template<typename ...> class VT, template<typename ...> class VT2>
|
||||
decayed_t<VT, typename types::Coercion<T1, T2>::type> operator /(const VT<T1>& lhs, const VT2<T2>& rhs) {
|
||||
auto ret = decayed_t<VT, typename types::Coercion<T1, T2>::type>(lhs.size, "");
|
||||
decayed_t<VT, types::GetFPType<typename types::Coercion<T1, T2>::type>> operator /(const VT<T1>& lhs, const VT2<T2>& rhs) {
|
||||
auto ret = decayed_t<VT, types::GetFPType<typename types::Coercion<T1, T2>::type>>(lhs.size, "");
|
||||
for (int i = 0; i < lhs.size; ++i)
|
||||
ret[i] = lhs[i] / rhs[i];
|
||||
return ret;
|
||||
}
|
||||
template <class T1, class T2, template<typename ...> class VT>
|
||||
decayed_t<VT, typename types::Coercion<T1, T2>::type> operator /(const VT<T1>& lhs, const T2& rhs) {
|
||||
auto ret = decayed_t<VT, typename types::Coercion<T1, T2>::type>(lhs.size, "");
|
||||
decayed_t<VT, types::GetFPType<typename types::Coercion<T1, T2>::type>> operator /(const VT<T1>& lhs, const T2& rhs) {
|
||||
auto ret = decayed_t<VT, types::GetFPType<typename types::Coercion<T1, T2>::type>>(lhs.size, "");
|
||||
for (int i = 0; i < lhs.size; ++i)
|
||||
ret[i] = lhs[i] / rhs;
|
||||
return ret;
|
||||
}
|
||||
template <class T1, class T2, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetFPType<typename types::Coercion<T1, T2>::type>> operator /(const T2& lhs, const VT<T1>& rhs) {
|
||||
auto ret = decayed_t<VT, types::GetFPType<typename types::Coercion<T1, T2>::type>>(rhs.size, "");
|
||||
for (int i = 0; i < rhs.size; ++i)
|
||||
ret[i] = lhs / rhs[i];
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class ...Types>
|
||||
void print(const TableInfo<Types...>& v, const char* delimiter = " ", const char* endline = "\n") {
|
||||
|
||||
+26
-13
@@ -21,8 +21,8 @@ constexpr static bool is_vector_type = is_vector_impl<T>::value;
|
||||
|
||||
namespace types {
|
||||
enum Type_t {
|
||||
AINT, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, ALONG, ASHORT, ADATE, ATIME, ACHAR,
|
||||
AUINT, AULONG, AUSHORT, AUCHAR, VECTOR, NONE, ERROR
|
||||
AINT32, AFLOAT, ASTR, ADOUBLE, ALDOUBLE, AINT64, AINT16, ADATE, ATIME, AINT8,
|
||||
AUINT32, AUINT64, AUINT16, AUINT8, VECTOR, NONE, ERROR
|
||||
};
|
||||
static constexpr const char* printf_str[] = { "%d", "%f", "%s", "%lf", "%llf", "%ld", "%hi", "%s", "%s", "%c",
|
||||
"%u", "%lu", "%hu", "%hhu", "Vector<%s>", "NULL", "ERROR" };
|
||||
@@ -44,20 +44,20 @@ namespace types {
|
||||
typedef T type;
|
||||
constexpr Types() noexcept = default;
|
||||
#define ConnectTypes(f) \
|
||||
f(int, AINT) \
|
||||
f(int, AINT32) \
|
||||
f(float, AFLOAT) \
|
||||
f(const char*, ASTR) \
|
||||
f(double, ADOUBLE) \
|
||||
f(long double, ALDOUBLE) \
|
||||
f(long, ALONG) \
|
||||
f(short, ASHORT) \
|
||||
f(long, AINT64) \
|
||||
f(short, AINT16) \
|
||||
f(date_t, ADATE) \
|
||||
f(time_t, ATIME) \
|
||||
f(unsigned char, ACHAR) \
|
||||
f(unsigned int, AUINT) \
|
||||
f(unsigned long, AULONG) \
|
||||
f(unsigned short, AUSHORT) \
|
||||
f(unsigned char, AUCHAR)
|
||||
f(unsigned char, AINT8) \
|
||||
f(unsigned int, AUINT32) \
|
||||
f(unsigned long, AUINT64) \
|
||||
f(unsigned short, AUINT16) \
|
||||
f(unsigned char, AUINT8)
|
||||
|
||||
inline constexpr static Type_t getType() {
|
||||
#define TypeConnect(x, y) if constexpr(std::is_same<x, T>::value) return y; else
|
||||
@@ -73,11 +73,11 @@ namespace types {
|
||||
#define Cond(c, x, y) typename std::conditional<c, x, y>::type
|
||||
#define Comp(o) (sizeof(T1) o sizeof(T2))
|
||||
#define Same(x, y) (std::is_same_v<x, y>)
|
||||
#define _U(x) std::is_unsigned<x>::value
|
||||
#define __U(x) std::is_unsigned<x>::value
|
||||
#define Fp(x) std::is_floating_point<x>::value
|
||||
template <class T1, class T2>
|
||||
struct Coercion {
|
||||
using t1 = Cond(Comp(<= ), Cond(Comp(== ), Cond(Fp(T1), T1, Cond(Fp(T2), T2, Cond(_U(T1), T2, T1))), T2), T1);
|
||||
using t1 = Cond(Comp(<= ), Cond(Comp(== ), Cond(Fp(T1), T1, Cond(Fp(T2), T2, Cond(__U(T1), T2, T1))), T2), T1);
|
||||
using t2 = Cond(Same(T1, T2), T1, Cond(Same(T1, const char*) || Same(T2, const char*), const char*, void));
|
||||
using type = Cond(Same(t2, void), Cond(Same(T1, date_t) && Same(T2, time_t) || Same(T1, time_t) && Same(T2, time_t), void, t1), t2);
|
||||
};
|
||||
@@ -90,7 +90,7 @@ namespace types {
|
||||
using GetFPType = typename GetFPTypeImpl<typename std::decay<T>::type>::type;
|
||||
template<class T>
|
||||
struct GetLongTypeImpl {
|
||||
using type = Cond(_U(T), unsigned long long, Cond(Fp(T), long double, long long));
|
||||
using type = Cond(__U(T), unsigned long long, Cond(Fp(T), long double, long long));
|
||||
};
|
||||
template<class T>
|
||||
using GetLongType = typename GetLongTypeImpl<typename std::decay<T>::type>::type;
|
||||
@@ -189,4 +189,17 @@ template <template <class...> class VT, class ...V>
|
||||
struct value_type_rec_impl<VT<V...>> { typedef typename value_type_rec_impl<get_first<int>>::type type; };
|
||||
template <class T>
|
||||
using value_type_r = typename value_type_rec_impl<T>::type;
|
||||
|
||||
template <class T>
|
||||
struct nullval_impl { constexpr static T value = 0; };
|
||||
template <class T>
|
||||
constexpr static T nullval = nullval_impl<T>::value;
|
||||
#include <limits>
|
||||
template <>
|
||||
struct nullval_impl<int> { constexpr static int value = std::numeric_limits<int>::min(); };
|
||||
template<>
|
||||
struct nullval_impl<float> { constexpr static float value = -std::numeric_limits<float>::quiet_NaN(); };
|
||||
template<>
|
||||
struct nullval_impl<double> { constexpr static double value = -std::numeric_limits<double>::quiet_NaN(); };
|
||||
|
||||
#endif // !_TYPES_H
|
||||
|
||||
+17
-5
@@ -64,7 +64,11 @@ public:
|
||||
constexpr vector_type(vector_type<_Ty>&& vt) noexcept : capacity(0) {
|
||||
_move(std::move(vt));
|
||||
}
|
||||
vector_type<_Ty> operator =(const _Ty& vt) {
|
||||
// size >= capacity ==> readonly vector
|
||||
constexpr vector_type(const uint32_t size, void* data) :
|
||||
size(size), capacity(0), container(static_cast<_Ty*>(data)) {}
|
||||
|
||||
vector_type<_Ty>& operator =(const _Ty& vt) {
|
||||
if (!container) {
|
||||
container = (_Ty*)malloc(sizeof(_Ty));
|
||||
capacity = 1;
|
||||
@@ -73,16 +77,24 @@ public:
|
||||
container[0] = vt;
|
||||
return *this;
|
||||
}
|
||||
vector_type<_Ty> operator =(const vector_type<_Ty>& vt) {
|
||||
// template<template <typename ...> class VT, class T>
|
||||
// vector_type<_Ty>& operator =(VT<T>&& vt) {
|
||||
// this->container = (_Ty*)vt.container;
|
||||
// this->size = vt.size;
|
||||
// this->capacity = vt.capacity;
|
||||
// vt.capacity = 0; // rvalue's
|
||||
// return *this;
|
||||
// }
|
||||
vector_type<_Ty>& operator =(const vector_type<_Ty>& vt) {
|
||||
_copy(vt);
|
||||
return *this;
|
||||
}
|
||||
vector_type<_Ty> operator =(vector_type<_Ty>&& vt) {
|
||||
vector_type<_Ty>& operator =(vector_type<_Ty>&& vt) {
|
||||
_move(std::move(vt));
|
||||
return *this;
|
||||
}
|
||||
template <template <class> class VT>
|
||||
vector_type<_Ty> operator =(const VT<_Ty>& vt) {
|
||||
vector_type<_Ty>& operator =(const VT<_Ty>& vt) {
|
||||
if (capacity > 0) free(container);
|
||||
container = static_cast<_Ty*>(malloc(vt.size * sizeof(_Ty)));
|
||||
|
||||
@@ -211,7 +223,7 @@ public:
|
||||
|
||||
#define Opeq(o, x) \
|
||||
template<typename T>\
|
||||
vector_type<typename types::Coercion<_Ty, T>::type> inline x##eq(const vector_type<T>& r) {\
|
||||
inline vector_type<typename types::Coercion<_Ty, T>::type>& x##eq(const vector_type<T>& r) {\
|
||||
for (int i = 0; i < size; ++i)\
|
||||
container[i] = container[i] o##= r[i];\
|
||||
return *this;\
|
||||
|
||||
Reference in New Issue
Block a user