OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtensionFunctionsArrayTesting.hpp
Go to the documentation of this file.
1 #include "heavydbTypes.h"
2 
3 #ifdef __clang__
4 #pragma clang diagnostic push
5 #pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
6 #endif
7 
8 EXTENSION_NOINLINE int64_t raw_array_as_scalar_same_type(const int64_t* in_arr,
9  const int64_t val) {
10  // return sum of array and val as array
11  int64_t scalar{};
12  for (int64_t i = 0; i < val; i++) {
13  scalar += in_arr[i];
14  }
15  scalar += val;
16  return scalar;
17 }
18 
19 EXTENSION_NOINLINE int32_t raw_array_as_scalar_diff_type(const int64_t* in_arr,
20  const int64_t val) {
21  // return sum of array and val as array
22  int32_t scalar{};
23  for (int64_t i = 0; i < val; i++) {
24  scalar += static_cast<int32_t>(in_arr[i]);
25  }
26  scalar += static_cast<int32_t>(val);
27  return scalar;
28 }
29 
31  const int64_t val) {
32  // return array with val appended as array
33  auto array = Array<int64_t>(val + 1, false);
34  auto* data = array.data();
35  for (int64_t i = 0; i < val; i++) {
36  data[i] = in_arr[i];
37  }
38  data[val] = val;
39  return array;
40 }
41 
43  const int64_t val) {
44  // return array with val appended as array
45  auto array = Array<int32_t>(val + 1, false);
46  auto* data = array.data();
47  for (int64_t i = 0; i < val; i++) {
48  data[i] = static_cast<int32_t>(in_arr[i]);
49  }
50  data[val] = static_cast<int32_t>(val);
51  return array;
52 }
53 
54 #ifdef __clang__
55 #pragma clang diagnostic pop
56 #endif
#define EXTENSION_NOINLINE
Definition: heavydbTypes.h:58
EXTENSION_NOINLINE Array< int32_t > raw_array_as_array_diff_type(const int64_t *in_arr, const int64_t val)
EXTENSION_NOINLINE int32_t raw_array_as_scalar_diff_type(const int64_t *in_arr, const int64_t val)
EXTENSION_NOINLINE int64_t raw_array_as_scalar_same_type(const int64_t *in_arr, const int64_t val)
DEVICE ALWAYS_INLINE T * data() const
Definition: heavydbTypes.h:516
EXTENSION_NOINLINE Array< int64_t > raw_array_as_array_same_type(const int64_t *in_arr, const int64_t val)