OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Array< T > Struct Template Reference

#include <heavydbTypes.h>

Public Member Functions

DEVICE Array (T *ptr, const int64_t size, const bool is_null=false)
 
DEVICE Array ()
 
template<typename M >
HOST Array (M &mgr, const int64_t size, const bool is_null=false)
 
DEVICE Array (const int64_t size, const bool is_null=false)
 
DEVICE Array (const flatbuffer::Array< T > &arr)
 
DEVICE ALWAYS_INLINE T * data () const
 
DEVICE ALWAYS_INLINE size_t size () const
 
DEVICEoperator() (const unsigned int index) const
 
DEVICE T & operator[] (const unsigned int index)
 
DEVICE const T & operator[] (const unsigned int index) const
 
DEVICE int64_t getSize () const
 
DEVICE bool isNull () const
 
DEVICE constexpr T null_value () const
 
DEVICE bool isNull (const unsigned int index) const
 
DEVICE bool operator== (const Array &other) const
 
std::string toString () const
 

Public Attributes

T * ptr_
 
int64_t size_
 
int8_t is_null_
 

Detailed Description

template<typename T>
struct Array< T >

Definition at line 470 of file heavydbTypes.h.

Constructor & Destructor Documentation

template<typename T>
DEVICE Array< T >::Array ( T *  ptr,
const int64_t  size,
const bool  is_null = false 
)
inline

Definition at line 475 of file heavydbTypes.h.

476  : ptr_(is_null ? nullptr : ptr), size_(size), is_null_(is_null) {}
int8_t is_null_
Definition: heavydbTypes.h:473
CONSTEXPR DEVICE bool is_null(const T &value)
T * ptr_
Definition: heavydbTypes.h:471
DEVICE ALWAYS_INLINE size_t size() const
Definition: heavydbTypes.h:520
int64_t size_
Definition: heavydbTypes.h:472
template<typename T>
DEVICE Array< T >::Array ( )
inline

Definition at line 477 of file heavydbTypes.h.

477 : ptr_(nullptr), size_(0), is_null_(true) {}
int8_t is_null_
Definition: heavydbTypes.h:473
T * ptr_
Definition: heavydbTypes.h:471
int64_t size_
Definition: heavydbTypes.h:472
template<typename T>
template<typename M >
HOST Array< T >::Array ( M &  mgr,
const int64_t  size,
const bool  is_null = false 
)
inline

Definition at line 481 of file heavydbTypes.h.

References Array< T >::is_null_, Array< T >::ptr_, and heavydb.dtypes::T.

482  : size_(size), is_null_(is_null) {
483  static_assert(
484 #ifndef UDF_COMPILED
485  (std::is_same<TableFunctionManager, M>::value) ||
486 #endif // #ifndef UDF_COMPILED
487  (std::is_same<RowFunctionManager, M>::value),
488  "M must be a TableFunctionManager or RowFunctionManager");
489  if (!is_null_) {
490  ptr_ = reinterpret_cast<T*>(mgr.makeBuffer(size, static_cast<int64_t>(sizeof(T))));
491  } else {
492  ptr_ = nullptr;
493  }
494  }
int8_t is_null_
Definition: heavydbTypes.h:473
CONSTEXPR DEVICE bool is_null(const T &value)
T * ptr_
Definition: heavydbTypes.h:471
DEVICE ALWAYS_INLINE size_t size() const
Definition: heavydbTypes.h:520
int64_t size_
Definition: heavydbTypes.h:472
template<typename T>
DEVICE Array< T >::Array ( const int64_t  size,
const bool  is_null = false 
)
inline

Definition at line 497 of file heavydbTypes.h.

References allocate_varlen_buffer(), is_null(), Array< T >::ptr_, and heavydb.dtypes::T.

498  : size_(size), is_null_(is_null) {
499  if (!is_null) {
500  // Memory must be manually released, otherwise leaks can happen.
501  // On UDFs, if it is the return argument, memory is released with
502  // register_buffer_with_executor_rsm
503  ptr_ = reinterpret_cast<T*>(
504  allocate_varlen_buffer(size, static_cast<int64_t>(sizeof(T))));
505  } else {
506  ptr_ = nullptr;
507  }
508  }
int8_t is_null_
Definition: heavydbTypes.h:473
EXTENSION_NOINLINE int8_t * allocate_varlen_buffer(int64_t element_count, int64_t element_size)
CONSTEXPR DEVICE bool is_null(const T &value)
T * ptr_
Definition: heavydbTypes.h:471
DEVICE ALWAYS_INLINE size_t size() const
Definition: heavydbTypes.h:520
int64_t size_
Definition: heavydbTypes.h:472

+ Here is the call graph for this function:

template<typename T>
DEVICE Array< T >::Array ( const flatbuffer::Array< T > &  arr)
inline

Definition at line 510 of file heavydbTypes.h.

References flatbuffer::NestedArray< T >::getValuesBuffer(), Array< T >::is_null_, Array< T >::ptr_, and Array< T >::size_.

510  {
511  bool _is_null;
512  arr.getValuesBuffer(ptr_, size_, _is_null);
513  is_null_ = _is_null;
514  }
int8_t is_null_
Definition: heavydbTypes.h:473
T * ptr_
Definition: heavydbTypes.h:471
int64_t size_
Definition: heavydbTypes.h:472
void getValuesBuffer(T *&values, int64_t &nof_values, bool &is_null, bool require_1d_item=true) const

+ Here is the call graph for this function:

Member Function Documentation

template<typename T>
DEVICE ALWAYS_INLINE T* Array< T >::data ( ) const
inline

Definition at line 516 of file heavydbTypes.h.

References Array< T >::ptr_.

Referenced by anonymous_namespace{ExtensionFunctionsArray.hpp}::barray_append_impl(), raw_array_as_array_diff_type(), and raw_array_as_array_same_type().

516  {
517  return ptr_;
518  }
T * ptr_
Definition: heavydbTypes.h:471

+ Here is the caller graph for this function:

template<typename T>
DEVICE int64_t Array< T >::getSize ( ) const
inline

Definition at line 552 of file heavydbTypes.h.

References Array< T >::size_.

552  {
553  return size_;
554  }
int64_t size_
Definition: heavydbTypes.h:472
template<typename T>
DEVICE bool Array< T >::isNull ( ) const
inline

Definition at line 556 of file heavydbTypes.h.

References Array< T >::is_null_.

Referenced by array_first_half__t32(), anonymous_namespace{ExtensionFunctionsArray.hpp}::array_first_half_impl(), array_second_half__t32(), anonymous_namespace{ExtensionFunctionsArray.hpp}::array_second_half_impl(), Array< T >::operator==(), sum_along_row__cpu_template(), and tarray_append().

556  {
557  return is_null_;
558  }
int8_t is_null_
Definition: heavydbTypes.h:473

+ Here is the caller graph for this function:

template<typename T>
DEVICE bool Array< T >::isNull ( const unsigned int  index) const
inline

Definition at line 568 of file heavydbTypes.h.

References Array< T >::is_null_, Array< T >::null_value(), and Array< T >::ptr_.

568  {
569  return (is_null_ ? false : ptr_[index] == null_value());
570  }
int8_t is_null_
Definition: heavydbTypes.h:473
DEVICE constexpr T null_value() const
Definition: heavydbTypes.h:560
T * ptr_
Definition: heavydbTypes.h:471

+ Here is the call graph for this function:

template<typename T>
DEVICE constexpr T Array< T >::null_value ( ) const
inline

Definition at line 560 of file heavydbTypes.h.

Referenced by Array< T >::isNull().

560  {
561  if constexpr (std::is_same<T, TextEncodingNone>::value) {
562  return {};
563  } else {
564  return inline_null_value<T>();
565  }
566  }

+ Here is the caller graph for this function:

template<typename T>
DEVICE T Array< T >::operator() ( const unsigned int  index) const
inline

Definition at line 524 of file heavydbTypes.h.

References Array< T >::ptr_, and Array< T >::size_.

524  {
525 #ifndef UDF_COMPILED
526  // TODO: implement Array<TextEncodingNone> indexing support
527  static_assert(!std::is_same<T, TextEncodingNone>::value);
528 #endif
529  if (index < static_cast<unsigned int>(size_)) {
530  return ptr_[index];
531  } else {
532  return 0; // see array_at
533  }
534  }
T * ptr_
Definition: heavydbTypes.h:471
int64_t size_
Definition: heavydbTypes.h:472
template<typename T>
DEVICE bool Array< T >::operator== ( const Array< T > &  other) const
inline

Definition at line 572 of file heavydbTypes.h.

References Array< T >::isNull(), Array< T >::size(), and Array< T >::size_.

572  {
573  if (isNull() || other.isNull() || size() != other.size()) {
574  return false;
575  }
576  for (int64_t i = 0; i < size_; i++) {
577  if ((*this)[i] != other[i]) {
578  return false;
579  }
580  }
581  return true;
582  }
DEVICE ALWAYS_INLINE size_t size() const
Definition: heavydbTypes.h:520
int64_t size_
Definition: heavydbTypes.h:472
DEVICE bool isNull() const
Definition: heavydbTypes.h:556

+ Here is the call graph for this function:

template<typename T>
DEVICE T& Array< T >::operator[] ( const unsigned int  index)
inline

Definition at line 536 of file heavydbTypes.h.

References Array< T >::ptr_.

536  {
537 #ifndef UDF_COMPILED
538  // TODO: implement Array<TextEncodingNone> indexing support
539  static_assert(!std::is_same<T, TextEncodingNone>::value);
540 #endif
541  return ptr_[index];
542  }
T * ptr_
Definition: heavydbTypes.h:471
template<typename T>
DEVICE const T& Array< T >::operator[] ( const unsigned int  index) const
inline

Definition at line 544 of file heavydbTypes.h.

References Array< T >::ptr_.

544  {
545 #ifndef UDF_COMPILED
546  // TODO: implement Array<TextEncodingNone> indexing support
547  static_assert(!std::is_same<T, TextEncodingNone>::value);
548 #endif
549  return ptr_[index];
550  }
T * ptr_
Definition: heavydbTypes.h:471
template<typename T>
std::string Array< T >::toString ( ) const
inline

Definition at line 585 of file heavydbTypes.h.

References Array< T >::is_null_, Array< T >::ptr_, run_benchmark_import::result, Array< T >::size_, to_string(), and typeName().

585  {
586  std::string result = ::typeName(this) +
587  "(ptr=" + ::toString(reinterpret_cast<void*>(ptr_)) +
588  ", size=" + std::to_string(size_) +
589  ", is_null=" + std::to_string(is_null_) + ")[";
590  for (int64_t i = 0; i < size_; i++) {
591  if (size_ > 10) {
592  // show the first 8 and the last 2 values in the array:
593  if (i == 8) {
594  result += "..., ";
595  } else if (i > 8 && i < size_ - 2) {
596  continue;
597  }
598  }
599  result += ::toString((*this)[i]) + ", ";
600  }
601  result += "]";
602  return result;
603  }
std::string toString() const
Definition: heavydbTypes.h:585
int8_t is_null_
Definition: heavydbTypes.h:473
std::string to_string(char const *&&v)
std::string typeName(const T *v)
Definition: toString.h:106
T * ptr_
Definition: heavydbTypes.h:471
int64_t size_
Definition: heavydbTypes.h:472

+ Here is the call graph for this function:

Member Data Documentation

template<typename T>
int8_t Array< T >::is_null_

Definition at line 473 of file heavydbTypes.h.

Referenced by Array< T >::Array(), Array< T >::isNull(), and Array< T >::toString().

template<typename T>
int64_t Array< T >::size_

The documentation for this struct was generated from the following file: