OmniSciDB  c0231cc57d
 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 177 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 182 of file heavydbTypes.h.

183  : ptr(is_null ? nullptr : ptr), size(size), is_null(is_null) {}
int64_t size
Definition: heavydbTypes.h:179
int8_t is_null
Definition: heavydbTypes.h:180
T * ptr
Definition: heavydbTypes.h:178
template<typename T>
DEVICE Array< T >::Array ( )
inline

Definition at line 184 of file heavydbTypes.h.

184 : ptr(nullptr), size(0), is_null(true) {}
int64_t size
Definition: heavydbTypes.h:179
int8_t is_null
Definition: heavydbTypes.h:180
T * ptr
Definition: heavydbTypes.h:178
template<typename T>
DEVICE Array< T >::Array ( const int64_t  size,
const bool  is_null = false 
)
inline

Definition at line 186 of file heavydbTypes.h.

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

187  : size(size), is_null(is_null) {
188  if (!is_null) {
189  ptr = reinterpret_cast<T*>(
190  allocate_varlen_buffer(size, static_cast<int64_t>(sizeof(T))));
191  } else {
192  ptr = nullptr;
193  }
194  }
int64_t size
Definition: heavydbTypes.h:179
EXTENSION_NOINLINE int8_t * allocate_varlen_buffer(int64_t element_count, int64_t element_size)
int8_t is_null
Definition: heavydbTypes.h:180
T * ptr
Definition: heavydbTypes.h:178

+ Here is the call graph for this function:

Member Function Documentation

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

Definition at line 207 of file heavydbTypes.h.

References Array< T >::size.

Referenced by anonymous_namespace{ExtensionFunctionsArray.hpp}::array_append_impl(), anonymous_namespace{ExtensionFunctionsArray.hpp}::barray_append_impl(), Column< Array< T > >::concatItem(), Column< Array< T > >::setItem(), and sum_along_row__cpu_template().

207 { return size; }
int64_t size
Definition: heavydbTypes.h:179

+ Here is the caller graph for this function:

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

Definition at line 209 of file heavydbTypes.h.

References Array< T >::is_null.

Referenced by Column< Array< T > >::concatItem(), Column< Array< T > >::setItem(), and sum_along_row__cpu_template().

209 { return is_null; }
int8_t is_null
Definition: heavydbTypes.h:180

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

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

213  {
214  return (is_null ? false : ptr[index] == null_value());
215  }
int8_t is_null
Definition: heavydbTypes.h:180
DEVICE constexpr T null_value() const
Definition: heavydbTypes.h:211
T * ptr
Definition: heavydbTypes.h:178

+ Here is the call graph for this function:

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

Definition at line 211 of file heavydbTypes.h.

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

211 { 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 196 of file heavydbTypes.h.

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

196  {
197  if (index < static_cast<unsigned int>(size)) {
198  return ptr[index];
199  } else {
200  return 0; // see array_at
201  }
202  }
int64_t size
Definition: heavydbTypes.h:179
T * ptr
Definition: heavydbTypes.h:178
template<typename T>
DEVICE T& Array< T >::operator[] ( const unsigned int  index)
inline

Definition at line 204 of file heavydbTypes.h.

References Array< T >::ptr.

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

Definition at line 205 of file heavydbTypes.h.

References Array< T >::ptr.

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

Definition at line 218 of file heavydbTypes.h.

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

218  {
219  std::string result =
220  ::typeName(this) + "(ptr=" + ::toString(reinterpret_cast<void*>(ptr)) +
221  ", size=" + std::to_string(size) + ", is_null=" + std::to_string(is_null) + ")[";
222  for (int64_t i = 0; i < size; i++) {
223  if (size > 10) {
224  // show the first 8 and the last 2 values in the array:
225  if (i == 8) {
226  result += "..., ";
227  } else if (i > 8 && i < size - 2) {
228  continue;
229  }
230  }
231  result += ::toString((*this)[i]) + ", ";
232  }
233  result += "]";
234  return result;
235  }
int64_t size
Definition: heavydbTypes.h:179
std::string toString() const
Definition: heavydbTypes.h:218
std::string to_string(char const *&&v)
int8_t is_null
Definition: heavydbTypes.h:180
std::string typeName(const T *v)
Definition: toString.h:103
T * ptr
Definition: heavydbTypes.h:178

+ Here is the call graph for this function:

Member Data Documentation

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

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