OmniSciDB  a987f07e93
 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 ()
 
DEVICE Array (const int64_t size, const bool is_null=false)
 
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
 
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 198 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 203 of file heavydbTypes.h.

204  : ptr(is_null ? nullptr : ptr), size(size), is_null(is_null) {}
int64_t size
Definition: heavydbTypes.h:200
int8_t is_null
Definition: heavydbTypes.h:201
T * ptr
Definition: heavydbTypes.h:199
template<typename T>
DEVICE Array< T >::Array ( )
inline

Definition at line 205 of file heavydbTypes.h.

205 : ptr(nullptr), size(0), is_null(true) {}
int64_t size
Definition: heavydbTypes.h:200
int8_t is_null
Definition: heavydbTypes.h:201
T * ptr
Definition: heavydbTypes.h:199
template<typename T>
DEVICE Array< T >::Array ( const int64_t  size,
const bool  is_null = false 
)
inline

Definition at line 207 of file heavydbTypes.h.

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

208  : size(size), is_null(is_null) {
209  if (!is_null) {
210  // Memory must be manually released, otherwise leaks can happen.
211  // On UDFs, if it is the return argument, memory is released with
212  // register_buffer_with_executor_rsm
213  ptr = reinterpret_cast<T*>(
214  allocate_varlen_buffer(size, static_cast<int64_t>(sizeof(T))));
215  } else {
216  ptr = nullptr;
217  }
218  }
int64_t size
Definition: heavydbTypes.h:200
EXTENSION_NOINLINE int8_t * allocate_varlen_buffer(int64_t element_count, int64_t element_size)
int8_t is_null
Definition: heavydbTypes.h:201
T * ptr
Definition: heavydbTypes.h:199

+ Here is the call graph for this function:

Member Function Documentation

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

Definition at line 233 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(), Column< Array< T > >::concatItem(), Column< Array< T > >::setItem(), sum_along_row__cpu_template(), and tarray_append().

233 { return is_null; }
int8_t is_null
Definition: heavydbTypes.h:201

+ 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 237 of file heavydbTypes.h.

References Array< T >::is_null, Array< T >::null_value(), and Array< T >::ptr.

237  {
238  return (is_null ? false : ptr[index] == null_value());
239  }
int8_t is_null
Definition: heavydbTypes.h:201
DEVICE constexpr T null_value() const
Definition: heavydbTypes.h:235
T * ptr
Definition: heavydbTypes.h:199

+ Here is the call graph for this function:

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

Definition at line 235 of file heavydbTypes.h.

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

235 { return inline_null_value<T>(); }

+ 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 220 of file heavydbTypes.h.

References Array< T >::ptr, and Array< T >::size.

220  {
221  if (index < static_cast<unsigned int>(size)) {
222  return ptr[index];
223  } else {
224  return 0; // see array_at
225  }
226  }
int64_t size
Definition: heavydbTypes.h:200
T * ptr
Definition: heavydbTypes.h:199
template<typename T>
DEVICE T& Array< T >::operator[] ( const unsigned int  index)
inline

Definition at line 228 of file heavydbTypes.h.

References Array< T >::ptr.

228 { return ptr[index]; }
T * ptr
Definition: heavydbTypes.h:199
template<typename T>
DEVICE const T& Array< T >::operator[] ( const unsigned int  index) const
inline

Definition at line 229 of file heavydbTypes.h.

References Array< T >::ptr.

229 { return ptr[index]; }
T * ptr
Definition: heavydbTypes.h:199
template<typename T>
std::string Array< T >::toString ( ) const
inline

Definition at line 242 of file heavydbTypes.h.

References Array< T >::is_null, Array< T >::ptr, run_benchmark_import::result, Array< T >::size, to_string(), and typeName().

242  {
243  std::string result =
244  ::typeName(this) + "(ptr=" + ::toString(reinterpret_cast<void*>(ptr)) +
245  ", size=" + std::to_string(size) + ", is_null=" + std::to_string(is_null) + ")[";
246  for (int64_t i = 0; i < size; i++) {
247  if (size > 10) {
248  // show the first 8 and the last 2 values in the array:
249  if (i == 8) {
250  result += "..., ";
251  } else if (i > 8 && i < size - 2) {
252  continue;
253  }
254  }
255  result += ::toString((*this)[i]) + ", ";
256  }
257  result += "]";
258  return result;
259  }
int64_t size
Definition: heavydbTypes.h:200
std::string toString() const
Definition: heavydbTypes.h:242
std::string to_string(char const *&&v)
int8_t is_null
Definition: heavydbTypes.h:201
std::string typeName(const T *v)
Definition: toString.h:103
T * ptr
Definition: heavydbTypes.h:199

+ Here is the call graph for this function:

Member Data Documentation

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

Definition at line 201 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: