OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlatBufferTableFunctions.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "TableFunctionsTesting.h"
18 
19 /*
20  This file contains testing compile-time UDTFs that arguments use
21  FlatBuffer storage and that implementations use the NestedArray API
22  only.
23  */
24 
25 #ifndef __CUDACC__
26 
27 template <typename T>
29  const Column<T>& inputs,
30  Column<T>& outputs) {
31  auto size = inputs.size();
32  mgr.set_output_item_values_total_number(0, inputs.getNofValues());
33  mgr.set_output_row_size(size);
34  for (int64_t i = 0; i < size; i++) {
35  if (inputs.isNull(i)) {
36  outputs.setNull(i);
37  } else {
38  outputs[i] = inputs[i];
39  }
40  }
41  return size;
42 }
43 
44 #define INSTANTIATE_CT_COPY(T) \
45  template NEVER_INLINE HOST int32_t ct_copy__generic_cpu_template( \
46  TableFunctionManager& mgr, const Column<T>& inputs, Column<T>& outputs);
47 
54 
55 template <typename T>
57  const Column<T>& input1,
58  const Column<T>& input2,
59  Column<T>& outputs) {
60  auto size = input1.size();
61  mgr.set_output_item_values_total_number(0,
62  input1.getNofValues() + input2.getNofValues());
63  mgr.set_output_row_size(size);
64  for (int64_t i = 0; i < size; i++) {
65  if (input1.isNull(i)) {
66  if (input2.isNull(i)) {
67  outputs.setNull(i);
68  } else {
69  outputs[i] = input2[i];
70  }
71  } else if (input2.isNull(i)) {
72  outputs[i] = input1[i];
73  } else {
74  outputs[i] = input1[i];
75  outputs.concatItem(i, input2[i]);
76  }
77  }
78  return size;
79 }
80 
81 #define INSTANTIATE_CT_CONCAT(T) \
82  template NEVER_INLINE HOST int32_t ct_concat__generic_cpu_template( \
83  TableFunctionManager& mgr, \
84  const Column<T>& input1, \
85  const Column<T>& input2, \
86  Column<T>& outputs);
87 
89 
90 template <typename T>
92  const Column<T>& input1,
93  const T& input2,
94  Column<T>& output) {
95  auto size = input1.size();
96  mgr.set_output_item_values_total_number(0,
97  input1.getNofValues() + size * input2.size());
98  mgr.set_output_row_size(size);
99  for (int64_t i = 0; i < size; i++) {
100  if (input1.isNull(i) || input2.isNull()) {
101  output.setNull(i);
102  } else {
103  output[i] = input1[i];
104  output[i] += input2;
105  }
106  }
107  return size;
108 }
109 
110 #define INSTANTIATE_CT_CONCAT2(T) \
111  template NEVER_INLINE HOST int32_t ct_concat__generic2_cpu_template( \
112  TableFunctionManager& mgr, \
113  const Column<T>& input1, \
114  const T& input2, \
115  Column<T>& outputs);
116 
119 
120 template <typename T>
122  const T& input1,
123  const Column<T>& input2,
124  Column<T>& output) {
125  auto size = input2.size();
126  mgr.set_output_item_values_total_number(0,
127  input2.getNofValues() + size * input1.size());
128  mgr.set_output_row_size(size);
129  for (int64_t i = 0; i < size; i++) {
130  if (input2.isNull(i) || input1.isNull()) {
131  output.setNull(i);
132  } else {
133  output[i] = input1;
134  output[i] += input2[i];
135  }
136  }
137  return size;
138 }
139 
140 #define INSTANTIATE_CT_CONCAT3(T) \
141  template NEVER_INLINE HOST int32_t ct_concat__generic3_cpu_template( \
142  TableFunctionManager& mgr, \
143  const T& input1, \
144  const Column<T>& input2, \
145  Column<T>& outputs);
146 
148 
149 #endif
#define INSTANTIATE_CT_CONCAT2(T)
void set_output_row_size(int64_t num_rows)
Definition: heavydbTypes.h:373
NEVER_INLINE HOST int32_t ct_concat__generic3_cpu_template(TableFunctionManager &mgr, const T &input1, const Column< T > &input2, Column< T > &output)
#define INSTANTIATE_CT_CONCAT3(T)
NEVER_INLINE HOST int32_t ct_copy__generic_cpu_template(TableFunctionManager &mgr, const Column< T > &inputs, Column< T > &outputs)
Simplified core of GeoJSON Polygon coordinates definition.
DEVICE int64_t size() const
Simplified core of GeoJSON MultiPolygon coordinates definition.
#define HOST
#define INSTANTIATE_CT_COPY(T)
DEVICE bool isNull(int64_t index) const
DEVICE void setNull(int64_t index)
void set_output_item_values_total_number(int32_t index, int64_t output_item_values_total_number)
Definition: heavydbTypes.h:367
NEVER_INLINE HOST int32_t ct_concat__generic2_cpu_template(TableFunctionManager &mgr, const Column< T > &input1, const T &input2, Column< T > &output)
#define NEVER_INLINE
#define INSTANTIATE_CT_CONCAT(T)
NEVER_INLINE HOST int32_t ct_concat__generic_cpu_template(TableFunctionManager &mgr, const Column< T > &input1, const Column< T > &input2, Column< T > &outputs)