OmniSciDB  85c2d10cdc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExtensionFunctionsArray.hpp
Go to the documentation of this file.
1 #include <cassert>
2 
3 #if defined(__clang__)
4 #pragma clang diagnostic push
5 #pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
6 #endif
7 
8 #ifndef __CUDACC__
9 
10 namespace {
11 
12 template <typename T>
14  Array<T> out_arr(in_arr.getSize() + 1);
15  for (int64_t i = 0; i < in_arr.getSize(); i++) {
16  out_arr[i] = in_arr(i);
17  }
18  out_arr[in_arr.getSize()] = val;
19  return out_arr;
20 }
21 
22 } // namespace
23 
24 #endif
25 
26 #ifdef _WIN32
27 // MSVC doesn't allow extern "C" function using template type
28 // without explicit instantiation
29 template struct Array<bool>;
30 template struct Array<int8_t>;
31 template struct Array<int16_t>;
32 template struct Array<int32_t>;
33 template struct Array<int64_t>;
34 template struct Array<float>;
35 template struct Array<double>;
36 #endif
37 
39  const int64_t val) {
40 #ifndef __CUDACC__
41  return array_append_impl(in_arr, val);
42 #else
43  assert(false);
44  return Array<int64_t>(0, true);
45 #endif
46 }
47 
49  const int32_t val) {
50 #ifndef __CUDACC__
51  return array_append_impl(in_arr, val);
52 #else
53  assert(false);
54  return Array<int32_t>(0, true);
55 #endif
56 }
57 
59  const int16_t val) {
60 #ifndef __CUDACC__
61  return array_append_impl(in_arr, val);
62 #else
63  assert(false);
64  return Array<int16_t>(0, true);
65 #endif
66 }
67 
69  const int8_t val) {
70 #ifndef __CUDACC__
71  return array_append_impl(in_arr, val);
72 #else
73  assert(false);
74  return Array<int8_t>(0, true);
75 #endif
76 }
77 
79  const double val) {
80 #ifndef __CUDACC__
81  return array_append_impl(in_arr, val);
82 #else
83  assert(false);
84  return Array<double>(0, true);
85 #endif
86 }
87 
89  const float val) {
90 #ifndef __CUDACC__
91  return array_append_impl(in_arr, val);
92 #else
93  assert(false);
94  return Array<float>(0, true);
95 #endif
96 }
97 
98 /*
99  Overloading UDFs works for types in the same SQL family. BOOLEAN
100  does not belong to NUMERIC family, hence we need to use different
101  name for boolean UDF.
102  */
104 #ifndef __CUDACC__
105  return array_append_impl(in_arr, val);
106 #else
107  assert(false);
108  return Array<bool>(0, true);
109 #endif
110 }
111 
112 #if defined(__clang__)
113 #pragma clang diagnostic pop
114 #endif
EXTENSION_NOINLINE Array< bool > barray_append(const Array< bool > in_arr, const bool val)
EXTENSION_NOINLINE Array< int16_t > array_append__1(const Array< int16_t > in_arr, const int16_t val)
#define DEVICE
#define EXTENSION_NOINLINE
Definition: OmniSciTypes.h:27
EXTENSION_NOINLINE Array< float > array_append__4(const Array< float > in_arr, const float val)
EXTENSION_NOINLINE Array< int32_t > array_append__(const Array< int32_t > in_arr, const int32_t val)
DEVICE int64_t getSize() const
Definition: OmniSciTypes.h:58
EXTENSION_NOINLINE Array< double > array_append__3(const Array< double > in_arr, const double val)
EXTENSION_NOINLINE Array< int64_t > array_append(const Array< int64_t > in_arr, const int64_t val)
EXTENSION_NOINLINE Array< int8_t > array_append__2(const Array< int8_t > in_arr, const int8_t val)
DEVICE ALWAYS_INLINE Array< T > array_append_impl(const Array< T > in_arr, T val)
#define ALWAYS_INLINE