fixed wildcard compound cols, ratios, etc.
This commit is contained in:
@@ -106,6 +106,27 @@ 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>> ratiow(uint32_t w, const VT<T>& arr) {
|
||||
typedef std::decay_t<types::GetFPType<T>> FPType;
|
||||
uint32_t len = arr.size;
|
||||
if (arr.size <= w)
|
||||
len = 1;
|
||||
w = w > len ? len : w;
|
||||
decayed_t<VT, FPType> ret(arr.size);
|
||||
ret[0] = 0;
|
||||
for (uint32_t i = 0; i < w; ++i)
|
||||
ret[i] = arr[i] / (FPType)arr[0];
|
||||
for (uint32_t i = w; i < arr.size; ++i)
|
||||
ret[i] = arr[i] / (FPType) arr[i - w];
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T, template<typename ...> class VT>
|
||||
decayed_t<VT, types::GetFPType<T>> ratios(const VT<T>& arr) {
|
||||
return ratiow(1, arr);
|
||||
}
|
||||
|
||||
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 +192,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; }
|
||||
@@ -185,9 +217,11 @@ template <class T> constexpr inline T maxw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T minw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T avgw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T sumw(uint32_t, const T& v) { return v; }
|
||||
template <class T> constexpr inline T ratiow(uint32_t, const T& v) { return 1; }
|
||||
template <class T> constexpr inline T maxs(const T& v) { return v; }
|
||||
template <class T> constexpr inline T mins(const T& v) { return v; }
|
||||
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; }
|
||||
|
||||
@@ -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 // padding for msvc not allowing empty arrays
|
||||
];
|
||||
setgbuf(cbuf);
|
||||
if(view)
|
||||
|
||||
@@ -44,8 +44,8 @@ void TableInfo<Ts ...>::monetdb_append_table(void* srv, const char* alt_name) {
|
||||
puts("getcols done");
|
||||
for(int i = 0; i < sizeof...(Ts); ++i)
|
||||
{
|
||||
printf("no:%d name: %s count:%d data: %p \n",
|
||||
i, monetdbe_cols[i]->name, monetdbe_cols[i]->count, monetdbe_cols[i]->data);
|
||||
printf("no:%d name: %s count:%d data: %p type:%d \n",
|
||||
i, monetdbe_cols[i]->name, monetdbe_cols[i]->count, monetdbe_cols[i]->data, monetdbe_cols[i]->type);
|
||||
}
|
||||
std::string create_table_str = "CREATE TABLE ";
|
||||
create_table_str += alt_name;
|
||||
|
||||
+27
-2
@@ -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", "BIGINT", "TIMESTAMP", "NULL", "ERROR"};
|
||||
|
||||
|
||||
// TODO: deal with data/time <=> str/uint conversion
|
||||
@@ -167,8 +167,33 @@ 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) :
|
||||
@@ -200,7 +225,7 @@ struct astring_view {
|
||||
return reinterpret_cast<const unsigned char*>(str);
|
||||
}
|
||||
operator const signed char* () const {
|
||||
return reinterpret_cast<const signed char*>(str);
|
||||
return reinterpret_cast<const signed char*>(str);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user