22 #include <type_traits>
27 #if !(defined(__CUDACC__) || defined(NO_BOOST))
28 #include "../Shared/DateTimeParser.h"
32 #include "../Shared/InlineNullValues.h"
33 #include "../Shared/funcannotations.h"
37 #include "../StringDictionary/StringDictionaryProxy.h"
38 #endif // #ifndef UDF_COMPILED
39 #endif // #ifndef __CUDACC__
43 #define EXTENSION_INLINE_HOST extern "C" RUNTIME_EXPORT ALWAYS_INLINE HOST
44 #define EXTENSION_NOINLINE_HOST extern "C" RUNTIME_EXPORT NEVER_INLINE HOST
46 #define EXTENSION_INLINE extern "C" RUNTIME_EXPORT ALWAYS_INLINE DEVICE
47 #define EXTENSION_NOINLINE extern "C" RUNTIME_EXPORT NEVER_INLINE DEVICE
48 #define TEMPLATE_INLINE ALWAYS_INLINE DEVICE
49 #define TEMPLATE_NOINLINE NEVER_INLINE DEVICE
52 int64_t element_size);
57 #define FUNC_NAME (std::string(__func__).substr(0, std::string(__func__).find("__")))
59 #define ERROR_STRING(MSG) \
60 (std::string(__FILE__).substr(std::string(__FILE__).rfind("/") + 1) + ":" + \
61 std::to_string(__LINE__) + " " + FUNC_NAME + ": " + MSG) \
63 #define TABLE_FUNCTION_ERROR(MSG) table_function_error(ERROR_STRING(MSG))
64 #define ERROR_MESSAGE(MSG) error_message(ERROR_STRING(MSG))
83 operator int32_t()
const {
return value; }
95 return value == other;
99 return value == other;
118 return value < other;
122 return value < other;
132 null_val.
value = inline_int_null_value<int32_t>();
137 template <
typename T>
146 ptr =
reinterpret_cast<T*
>(
154 if (index < static_cast<unsigned int>(
size)) {
168 return std::is_signed<T>::value ? std::numeric_limits<T>::min()
169 : std::numeric_limits<T>::max();
182 ptr_ =
const_cast<char*
>(str.data());
183 size_ = str.length();
185 operator std::string()
const {
return std::string(
ptr_,
size_); }
194 for (
int i = 0; i <
size_; i++) {
195 if (rhs[i] ==
'\0' ||
ptr_[i] != rhs[i]) {
199 return rhs[
size_] ==
'\0';
201 return strcmp(
ptr_, rhs) == 0;
219 #if !(defined(__CUDACC__) || defined(NO_BOOST))
221 time = dateTimeParse<kTIMESTAMP>(str, 9);
227 if (other.
time > 0) {
228 if (
time > (std::numeric_limits<int64_t>::max() - other.
time)) {
229 throw std::underflow_error(
"Underflow in Timestamp addition!");
232 if (
time < (std::numeric_limits<int64_t>::min() - other.
time)) {
233 throw std::overflow_error(
"Overflow in Timestamp addition!");
242 if (other.
time > 0) {
243 if (
time < (std::numeric_limits<int64_t>::min() + other.
time)) {
244 throw std::underflow_error(
"Underflow in Timestamp substraction!");
247 if (
time > (std::numeric_limits<int64_t>::max() + other.
time)) {
248 throw std::overflow_error(
"Overflow in Timestamp substraction!");
257 if (other.
time == 0) {
258 throw std::runtime_error(
"Timestamp division by zero!");
266 uint64_t overflow_test =
267 static_cast<uint64_t
>(
time) * static_cast<uint64_t>(multiplier);
268 if (
time != 0 && overflow_test /
time != static_cast<uint64_t>(multiplier)) {
269 throw std::runtime_error(
"Overflow in Timestamp multiplication!");
355 return Timestamp(inline_int_null_value<int64_t>());
448 template <
typename T>
449 static DEVICE __constant__
T Column_null_value;
452 template <
typename T>
458 if (index >=
size_) {
460 throw std::runtime_error(
"column buffer index is out of range");
462 auto& null_value = Column_null_value<T>;
476 memcpy(
ptr_, &other[0], other.
size() *
sizeof(
T));
478 throw std::runtime_error(
"cannot copy assign columns with different sizes");
482 for (
unsigned int i = 0; i <
size(); i++) {
507 #endif // #ifndef UDF_COMPILED
508 #endif // #ifndef __CUDACC__
511 if (index >=
size_) {
513 throw std::runtime_error(
"column buffer index is out of range");
531 return isNull(index) ?
"" : string_dict_proxy_->getString(
ptr_[index].value);
534 return string_dict_proxy_->getOrAddTransient(str);
536 #endif // #ifndef UDF_COMPILED
537 #endif // #ifndef __CUDACC__
544 throw std::runtime_error(
"cannot copy assign columns with different sizes");
548 for (
unsigned int i = 0; i <
size(); i++) {
568 return is_null(ptr_[index].time);
584 template <
typename T>
594 return {
reinterpret_cast<T*
>(
ptrs_[index]),
size_};
596 return {
nullptr, -1};
603 for (int64_t index = 0; index <
num_cols_; index++) {
605 (index < num_cols_ - 1 ?
", " :
"");
623 #endif // #ifndef UDF_COMPILED
624 #endif // #ifndef __CUDACC__
634 string_dict_proxies_[index]
645 #endif // #ifndef UDF_COMPILED
646 #endif // #ifndef__CUDACC__
655 for (int64_t index = 0; index <
num_cols_; index++) {
657 (index < num_cols_ - 1 ?
", " :
"");
680 if (!output_allocations_disabled) {
697 result +=
"UNINITIALIZED";
702 #endif // HAVE_TOSTRING
703 bool output_allocations_disabled{
false};
705 #endif // #ifndef __CUDACC__
707 #endif // #ifndef UDF_COMPILED
DEVICE const std::string getString(int64_t index) const
void set_output_row_size(int64_t num_rows)
DEVICE ALWAYS_INLINE Timestamp truncateToSeconds() const
DEVICE ALWAYS_INLINE Timestamp truncateToDay() const
DEVICE int32_t getCompression() const
DEVICE ALWAYS_INLINE bool operator!=(const int64_t &other) const
DEVICE int32_t getInputSrid() const
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
EXTENSION_NOINLINE_HOST void set_output_row_size(int64_t num_rows)
#define EXTENSION_NOINLINE
DEVICE ALWAYS_INLINE const Timestamp operator+(const Timestamp &other) const
EXTENSION_NOINLINE_HOST int8_t * TableFunctionManager_get_singleton()
std::string getString() const
DEVICE ALWAYS_INLINE bool operator<(const TextEncodingDict &other) const
Simplified core of GeoJSON Polygon coordinates definition.
DEVICE ALWAYS_INLINE int64_t getMicroseconds() const
TextEncodingDict operator=(const int32_t other)
DEVICE int64_t size() const
CONSTEXPR DEVICE void set_null< Timestamp >(Timestamp &t)
DEVICE Timestamp(std::string_view const str)
DEVICE int64_t numCols() const
DEVICE int8_t * getPolygonSizes()
DEVICE ALWAYS_INLINE int64_t getYear() const
DEVICE Column< T > & operator=(const Column< T > &other)
DEVICE Column< T > operator[](const int index) const
DEVICE int8_t * getRingSizes()
DEVICE int64_t size() const
DEVICE void setNull(int64_t index)
DEVICE ALWAYS_INLINE Timestamp truncateToHours() const
DEVICE ALWAYS_INLINE int64_t getDay() const
DEVICE ALWAYS_INLINE bool operator==(const Timestamp &other) const
DEVICE ALWAYS_INLINE int64_t size() const
Simplified core of GeoJSON MultiPolygon coordinates definition.
DEVICE int32_t getNumRings() const
DEVICE ALWAYS_INLINE Timestamp truncateToYear() const
EXTENSION_NOINLINE_HOST int32_t TableFunctionManager_error_message(int8_t *mgr_ptr, const char *message)
DEVICE ALWAYS_INLINE bool operator==(const TextEncodingDict &other) const
DEVICE int32_t getInputSrid() const
DEVICE int32_t getInputSrid() const
int32_t error_message(const char *message)
EXTENSION_NOINLINE int8_t * allocate_varlen_buffer(int64_t element_count, int64_t element_size)
DEVICE T & operator[](const unsigned int index) const
CONSTEXPR DEVICE bool is_null(const T &value)
StringDictionaryProxy ** string_dict_proxies_
DEVICE Array(const int64_t size, const bool is_null=false)
DEVICE TextEncodingDict inline_null_value()
DEVICE ALWAYS_INLINE bool operator<(const int32_t &other) const
DEVICE ALWAYS_INLINE bool operator!=(const int32_t &other) const
DEVICE T operator()(const unsigned int index) const
DEVICE int32_t getCoordsSize() const
StringDictionaryProxy * string_dict_proxy_
CONSTEXPR DEVICE void set_null(T &value)
DEVICE int32_t getNumPolygons() const
TextEncodingNone(const std::string &str)
DEVICE int64_t getSize() const
#define EXTENSION_NOINLINE_HOST
DEVICE int32_t getCompression() const
DEVICE ALWAYS_INLINE bool operator==(const char *rhs) const
DEVICE const TextEncodingDict getStringId(const std::string &str)
DEVICE ALWAYS_INLINE int64_t operator/(const Timestamp &other) const
DEVICE int32_t getCoordsSize() const
DEVICE int32_t getInputSrid() const
DEVICE TextEncodingDict & operator[](const unsigned int index) const
DEVICE ALWAYS_INLINE int64_t getMinutes() const
DEVICE ALWAYS_INLINE int64_t getSeconds() const
std::string toString(const Executor::ExtModuleKinds &kind)
DEVICE ALWAYS_INLINE bool operator!=(const TextEncodingDict &other) const
void disable_output_allocations()
DEVICE ALWAYS_INLINE const Timestamp operator-(const Timestamp &other) const
EXTENSION_NOINLINE_HOST int32_t table_function_error(const char *message)
DEVICE int64_t numCols() const
DEVICE int32_t getNumRings() const
DEVICE ALWAYS_INLINE Timestamp truncateToMilliseconds() const
TextEncodingDict(const int32_t other)
DEVICE ALWAYS_INLINE bool operator!=(const Timestamp &other) const
DEVICE int32_t getSize() const
DEVICE int32_t getCompression() const
DEVICE constexpr T null_value() const
DEVICE int32_t getOutputSrid() const
DEVICE Timestamp(int64_t timeval)
DEVICE ALWAYS_INLINE char & operator[](const unsigned int index)
DEVICE bool isNull(int64_t index) const
DEVICE ALWAYS_INLINE Timestamp truncateToMicroseconds() const
DEVICE void setNull(int64_t index)
DEVICE int32_t getOutputSrid() const
DEVICE Column< TextEncodingDict > operator[](const int index) const
DEVICE ALWAYS_INLINE int64_t getMonth() const
DEVICE bool isNull(int64_t index) const
DEVICE int8_t * getRingSizes()
std::string typeName(const T *v)
DEVICE int64_t getSize() const
DEVICE Column< TextEncodingDict > & operator=(const Column< TextEncodingDict > &other)
DEVICE ALWAYS_INLINE int64_t getHours() const
DEVICE ALWAYS_INLINE bool isNull() const
DEVICE int32_t getCompression() const
EXTENSION_NOINLINE_HOST void TableFunctionManager_set_output_row_size(int8_t *mgr_ptr, int64_t num_rows)
TextEncodingNone()=default
DEVICE ALWAYS_INLINE Timestamp truncateToMonth() const
DEVICE ALWAYS_INLINE bool operator<(const Timestamp &other) const
DEVICE ALWAYS_INLINE int64_t getMilliseconds() const
DEVICE T & operator[](const unsigned int index)
DEVICE int64_t size() const
DEVICE int64_t size() const
DEVICE ALWAYS_INLINE const Timestamp operator*(const int64_t multiplier) const
DEVICE int32_t getOutputSrid() const
DEVICE ALWAYS_INLINE int64_t getNanoseconds() const
DEVICE ALWAYS_INLINE Timestamp truncateToMinutes() const
void enable_output_allocations()
DEVICE ALWAYS_INLINE bool operator==(const int32_t &other) const
static TableFunctionManager * get_singleton()
DEVICE bool isNull() const
DEVICE ALWAYS_INLINE bool operator<(const int64_t &other) const
DEVICE ALWAYS_INLINE bool operator!=(const char *rhs) const
DEVICE ALWAYS_INLINE bool operator==(const int64_t &other) const
DEVICE int32_t getOutputSrid() const