fixed select into/create table as
This commit is contained in:
+4
-1
@@ -596,11 +596,14 @@ class groupby_c(ast_node):
|
|||||||
col_names : List[str], col_types : List[Types], col_tovec : List[bool]):
|
col_names : List[str], col_types : List[Types], col_tovec : List[bool]):
|
||||||
tovec_columns = set()
|
tovec_columns = set()
|
||||||
for i, c in enumerate(col_names):
|
for i, c in enumerate(col_names):
|
||||||
self.context.emitc(f'{c}.reserve({self.group}.size());')
|
|
||||||
if col_tovec[i]: # and type(col_types[i]) is VectorT:
|
if col_tovec[i]: # and type(col_types[i]) is VectorT:
|
||||||
|
self.context.emitc(f'{c}.resize({self.group}.size());')
|
||||||
typename : Types = col_types[i] # .inner_type
|
typename : Types = col_types[i] # .inner_type
|
||||||
self.context.emitc(f'auto buf_{c} = static_cast<{typename.cname} *>(calloc({self.total_sz}, sizeof({typename.cname})));')
|
self.context.emitc(f'auto buf_{c} = static_cast<{typename.cname} *>(calloc({self.total_sz}, sizeof({typename.cname})));')
|
||||||
tovec_columns.add(c)
|
tovec_columns.add(c)
|
||||||
|
else:
|
||||||
|
self.context.emitc(f'{c}.reserve({self.group}.size());')
|
||||||
|
|
||||||
self.arr_len = 'arrlen_' + base62uuid(3)
|
self.arr_len = 'arrlen_' + base62uuid(3)
|
||||||
self.arr_values = 'arrvals_' + base62uuid(3)
|
self.arr_values = 'arrvals_' + base62uuid(3)
|
||||||
|
|
||||||
|
|||||||
@@ -615,3 +615,26 @@ aq_to_chars<std::string_view>(void* value, char* buffer){
|
|||||||
return buffer + src.size();
|
return buffer + src.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Defined in vector_type.h
|
||||||
|
template <>
|
||||||
|
vector_type<std::string_view>::vector_type(const char** container, uint32_t len,
|
||||||
|
typename std::enable_if_t<true>*) noexcept
|
||||||
|
{
|
||||||
|
size = capacity = len;
|
||||||
|
this->container = static_cast<std::string_view*>(
|
||||||
|
malloc(sizeof(std::string_view) * len));
|
||||||
|
for(uint32_t i = 0; i < len; ++i){
|
||||||
|
this->container[i] = container[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
vector_type<std::string_view>::vector_type(const uint32_t size, void* data) :
|
||||||
|
size(size), capacity(0) {
|
||||||
|
this->container = static_cast<std::string_view*>(
|
||||||
|
malloc(sizeof(std::string_view) * size));
|
||||||
|
for(uint32_t i = 0; i < size; ++i){
|
||||||
|
this->container[i] = ((const char**)data)[i];
|
||||||
|
}
|
||||||
|
//std::cout<<size << container[1];
|
||||||
|
}
|
||||||
|
|||||||
+3
-3
@@ -913,8 +913,8 @@ VT<bool> operator >(const T2& lhs, const VT<T1>& rhs) {
|
|||||||
#define _AQ_OP_(x) __AQ_OP__##x
|
#define _AQ_OP_(x) __AQ_OP__##x
|
||||||
#define __AQ_OP__add +
|
#define __AQ_OP__add +
|
||||||
#define __AQ_OP__minus -
|
#define __AQ_OP__minus -
|
||||||
#define __AQ_OP__div *
|
#define __AQ_OP__mul *
|
||||||
#define __AQ_OP__mul /
|
#define __AQ_OP__div /
|
||||||
#define __AQ_OP__and &
|
#define __AQ_OP__and &
|
||||||
#define __AQ_OP__or |
|
#define __AQ_OP__or |
|
||||||
#define __AQ_OP__xor ^
|
#define __AQ_OP__xor ^
|
||||||
@@ -934,8 +934,8 @@ void aqop_##x (const VT<T1>& lhs, const VT<T2>& rhs, Ret& ret){\
|
|||||||
|
|
||||||
__D_AQOP(add)
|
__D_AQOP(add)
|
||||||
__D_AQOP(minus)
|
__D_AQOP(minus)
|
||||||
__D_AQOP(div)
|
|
||||||
__D_AQOP(mul)
|
__D_AQOP(mul)
|
||||||
|
__D_AQOP(div)
|
||||||
__D_AQOP(and)
|
__D_AQOP(and)
|
||||||
__D_AQOP(or)
|
__D_AQOP(or)
|
||||||
__D_AQOP(xor)
|
__D_AQOP(xor)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ inline constexpr monetdbe_types AQType_2_monetdbe[] = {
|
|||||||
#else
|
#else
|
||||||
monetdbe_int64_t,
|
monetdbe_int64_t,
|
||||||
#endif
|
#endif
|
||||||
monetdbe_timestamp, monetdbe_int64_t, monetdbe_int64_t
|
monetdbe_timestamp, monetdbe_int8_t, monetdbe_str, monetdbe_int64_t, monetdbe_int64_t
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class ...Ts>
|
template<class ...Ts>
|
||||||
@@ -75,12 +75,14 @@ void TableInfo<Ts ...>::monetdb_append_table(void* srv, const char* alt_name) {
|
|||||||
auto err = monetdbe_append(*((monetdbe_database*)server->server), "sys", alt_name, monetdbe_cols, sizeof...(Ts));
|
auto err = monetdbe_append(*((monetdbe_database*)server->server), "sys", alt_name, monetdbe_cols, sizeof...(Ts));
|
||||||
if (err)
|
if (err)
|
||||||
puts(err);
|
puts(err);
|
||||||
return;
|
goto finialize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// for(uint32_t i = 0; i < n_vecs; ++i)
|
|
||||||
// free(gc_vecs[i]);
|
|
||||||
puts("Error! Empty table.");
|
puts("Error! Empty table.");
|
||||||
|
|
||||||
|
finialize:
|
||||||
|
for(uint32_t i = 0; i < cnt; ++i)
|
||||||
|
GC::gc_handle->reg(gc_vecs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -92,6 +94,16 @@ void* ColRef<Type>::monetdb_get_col(void** gc_vecs, uint32_t& cnt) {
|
|||||||
col->type = aq_type;
|
col->type = aq_type;
|
||||||
col->count = this->size;
|
col->count = this->size;
|
||||||
col->data = this->container;
|
col->data = this->container;
|
||||||
|
|
||||||
|
if constexpr(std::is_same_v<Type, std::string_view>) {
|
||||||
|
auto _data = static_cast<const char **>(
|
||||||
|
malloc(sizeof(const char *) * this->size));
|
||||||
|
for(uint32_t i = 0; i < this->size; ++i){
|
||||||
|
_data[i] = this->container[i].data();
|
||||||
|
}
|
||||||
|
col->data = _data;
|
||||||
|
gc_vecs[cnt++] = _data;
|
||||||
|
}
|
||||||
col->name = const_cast<char*>(this->name);
|
col->name = const_cast<char*>(this->name);
|
||||||
// auto arr = (types::timestamp_t*) malloc (sizeof(types::timestamp_t)* this->size);
|
// auto arr = (types::timestamp_t*) malloc (sizeof(types::timestamp_t)* this->size);
|
||||||
// if constexpr (is_vector_type<Type>){
|
// if constexpr (is_vector_type<Type>){
|
||||||
@@ -102,5 +114,4 @@ void* ColRef<Type>::monetdb_get_col(void** gc_vecs, uint32_t& cnt) {
|
|||||||
// }
|
// }
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-2
@@ -393,9 +393,9 @@ template <class ...T1s, class ...T2s, template <class...> class T1>
|
|||||||
struct same_class_impl<T1<T1s...>, T1<T2s...>> : std::true_type {};
|
struct same_class_impl<T1<T1s...>, T1<T2s...>> : std::true_type {};
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
bool same_class = same_class_impl<T1, T2>::value;
|
constexpr bool same_class = same_class_impl<T1, T2>::value;
|
||||||
template <class T1, template <class...> class T2>
|
template <class T1, template <class...> class T2>
|
||||||
bool instance_of = instance_of_impl<T1, T2>::value;
|
constexpr bool instance_of = instance_of_impl<T1, T2>::value;
|
||||||
|
|
||||||
template <class lT, template <typename ...> class rT>
|
template <class lT, template <typename ...> class rT>
|
||||||
using transTypes = typename transTypes_s<lT, rT>::type;
|
using transTypes = typename transTypes_s<lT, rT>::type;
|
||||||
|
|||||||
+13
-26
@@ -61,7 +61,9 @@ public:
|
|||||||
[[likely]]
|
[[likely]]
|
||||||
container = (_Ty*)GC::scratch_space->alloc(size * sizeof(_Ty));
|
container = (_Ty*)GC::scratch_space->alloc(size * sizeof(_Ty));
|
||||||
}
|
}
|
||||||
container = (_Ty*)malloc(size * sizeof(_Ty));
|
else{
|
||||||
|
container = (_Ty*)malloc(size * sizeof(_Ty));
|
||||||
|
}
|
||||||
// TODO: calloc for objects.
|
// TODO: calloc for objects.
|
||||||
}
|
}
|
||||||
explicit constexpr vector_type(std::initializer_list<_Ty> _l) {
|
explicit constexpr vector_type(std::initializer_list<_Ty> _l) {
|
||||||
@@ -74,7 +76,7 @@ public:
|
|||||||
}
|
}
|
||||||
constexpr vector_type() noexcept : size(0), capacity(0), container(0) {};
|
constexpr vector_type() noexcept : size(0), capacity(0), container(0) {};
|
||||||
constexpr vector_type(_Ty* container, uint32_t len) noexcept : size(len), capacity(0), container(container) {};
|
constexpr vector_type(_Ty* container, uint32_t len) noexcept : size(len), capacity(0), container(container) {};
|
||||||
constexpr vector_type(const char** container, uint32_t len,
|
vector_type(const char** container, uint32_t len,
|
||||||
typename std::enable_if_t<!std::is_same_v<_Ty, const char*>>* = nullptr) noexcept = delete;
|
typename std::enable_if_t<!std::is_same_v<_Ty, const char*>>* = nullptr) noexcept = delete;
|
||||||
constexpr explicit vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) {
|
constexpr explicit vector_type(const vector_type<_Ty>& vt) noexcept : capacity(0) {
|
||||||
_copy(vt);
|
_copy(vt);
|
||||||
@@ -90,7 +92,7 @@ public:
|
|||||||
// out(10);
|
// out(10);
|
||||||
};
|
};
|
||||||
// size >= capacity ==> readonly vector
|
// size >= capacity ==> readonly vector
|
||||||
constexpr vector_type(const uint32_t size, void* data) :
|
vector_type(const uint32_t size, void* data) :
|
||||||
size(size), capacity(0), container(static_cast<_Ty*>(data)) {}
|
size(size), capacity(0), container(static_cast<_Ty*>(data)) {}
|
||||||
|
|
||||||
void init_from(const uint32_t size, void* data) {
|
void init_from(const uint32_t size, void* data) {
|
||||||
@@ -341,7 +343,8 @@ public:
|
|||||||
vector_type<_Ty> getRef() { return vector_type<_Ty>(container, size); }
|
vector_type<_Ty> getRef() { return vector_type<_Ty>(container, size); }
|
||||||
~vector_type() {
|
~vector_type() {
|
||||||
if (capacity > 0) GC::gc_handle->reg(container, sizeof(_Ty) * capacity);//free(container);
|
if (capacity > 0) GC::gc_handle->reg(container, sizeof(_Ty) * capacity);//free(container);
|
||||||
container = 0; size = capacity = 0;
|
container = nullptr;
|
||||||
|
size = capacity = 0;
|
||||||
}
|
}
|
||||||
#define Compare(_op) \
|
#define Compare(_op) \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
@@ -404,28 +407,6 @@ public:
|
|||||||
_Make_Ops(Opseq)
|
_Make_Ops(Opseq)
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
constexpr vector_type<std::string_view>::vector_type(const char** container, uint32_t len,
|
|
||||||
typename std::enable_if_t<true>*) noexcept
|
|
||||||
{
|
|
||||||
size = capacity = len;
|
|
||||||
this->container = static_cast<std::string_view*>(
|
|
||||||
malloc(sizeof(std::string_view) * len));
|
|
||||||
for(uint32_t i = 0; i < len; ++i){
|
|
||||||
this->container[i] = container[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
constexpr vector_type<std::string_view>::vector_type(const uint32_t size, void* data) :
|
|
||||||
size(size), capacity(0) {
|
|
||||||
this->container = static_cast<std::string_view*>(
|
|
||||||
malloc(sizeof(std::string_view) * size));
|
|
||||||
for(uint32_t i = 0; i < size; ++i){
|
|
||||||
this->container[i] = ((const char**)data)[i];
|
|
||||||
}
|
|
||||||
//std::cout<<size << container[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// template<>
|
// template<>
|
||||||
// void vector_type<std::string_view>::init_from(const uint32_t size, void* data) {
|
// void vector_type<std::string_view>::init_from(const uint32_t size, void* data) {
|
||||||
@@ -527,4 +508,10 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
vector_type<std::string_view>::vector_type(const uint32_t size, void* data);
|
||||||
|
template <>
|
||||||
|
vector_type<std::string_view>::vector_type(const char** container, uint32_t len,
|
||||||
|
typename std::enable_if_t<true>*) noexcept;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user