OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RbcTestTableFunctions.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. The unit-tests are
21  implemented within the RBC package.
22  */
23 
24 #define CPU_DEVICE_CODE 0x637075; // 'cpu' in hex
25 #define GPU_DEVICE_CODE 0x677075; // 'gpu' in hex
26 
29 #ifdef __CUDACC__
30  out[0] = GPU_DEVICE_CODE;
31 #else
32  out[0] = CPU_DEVICE_CODE;
33 #endif
34  return 1;
35 }
36 
37 #ifndef __CUDACC__
38 
41  Column<int64_t>& out) {
42  out[0] = CPU_DEVICE_CODE;
43  return 1;
44 }
45 
46 #endif // #ifndef __CUDACC__
47 
50  Column<int64_t>& out) {
51  out[0] = GPU_DEVICE_CODE;
52  return 1;
53 }
54 
55 #ifndef __CUDACC__
56 
59  Column<int64_t>& out) {
60  out[0] = CPU_DEVICE_CODE;
61  return 1;
62 }
63 
64 #endif // #ifndef __CUDACC__
65 
68  Column<int64_t>& out) {
69  out[0] = GPU_DEVICE_CODE;
70  return 1;
71 }
72 
73 #undef CPU_DEVICE_CODE
74 #undef GPU_DEVICE_CODE
75 
76 #ifndef __CUDACC__
77 
80  out[0] = 1;
81  return 1;
82 }
85  const Column<int32_t>& input2,
86  Column<int32_t>& out) {
87  out[0] = 11;
88  return 1;
89 }
92  const Column<int32_t>& input2,
93  const Column<int32_t>& input3,
94  Column<int32_t>& out) {
95  out[0] = 111;
96  return 1;
97 }
100  const Column<int32_t>& input2,
101  const Column<int32_t>& input3,
102  Column<int32_t>& out) {
103  out[0] = 211;
104  return 1;
105 }
108  const Column<int64_t>& input2,
109  const Column<int32_t>& input3,
110  Column<int32_t>& out) {
111  out[0] = 221;
112  return 1;
113 }
116  const Column<int32_t>& input2,
117  const Column<int64_t>& input3,
118  Column<int32_t>& out) {
119  out[0] = 212;
120  return 1;
121 }
124  const ColumnList<int32_t>& input2,
125  Column<int32_t>& out) {
126  out[0] = 13;
127  return 1;
128 }
131  const Column<int64_t>& input2,
132  Column<int32_t>& out) {
133  out[0] = 32;
134  return 1;
135 }
138  const ColumnList<int64_t>& input2,
139  Column<int32_t>& out) {
140  out[0] = 34;
141  return 1;
142 }
145  const ColumnList<int64_t>& input2,
146  const Column<int64_t>& input3,
147  Column<int64_t>& out) {
148  out[0] = 242;
149  return 1;
150 }
151 
153  const int32_t multiplier,
154  Column<int32_t>& out) {
155  out[0] = 1000 + 19 + multiplier;
156  return 1;
157 }
159  const Column<int32_t>& input2,
160  const int32_t multiplier,
161  Column<int32_t>& out) {
162  out[0] = 1000 + 119 + multiplier;
163  return 1;
164 }
166  const Column<int32_t>& input2,
167  const Column<int32_t>& input3,
168  const int32_t multiplier,
169  Column<int32_t>& out) {
170  out[0] = 1000 + 1119 + multiplier;
171  return 1;
172 }
174  const Column<int32_t>& input2,
175  const Column<int32_t>& input3,
176  const int32_t multiplier,
177  Column<int32_t>& out) {
178  out[0] = 1000 + 2119 + multiplier;
179  return 1;
180 }
182  const Column<int64_t>& input2,
183  const Column<int32_t>& input3,
184  const int32_t multiplier,
185  Column<int32_t>& out) {
186  out[0] = 1000 + 2219 + multiplier;
187  return 1;
188 }
190  const Column<int32_t>& input2,
191  const Column<int64_t>& input3,
192  const int32_t multiplier,
193  Column<int32_t>& out) {
194  out[0] = 1000 + 2129 + multiplier;
195  return 1;
196 }
198  const ColumnList<int32_t>& input2,
199  const int32_t multiplier,
200  Column<int32_t>& out) {
201  out[0] = 1000 + 139 + multiplier;
202  return 1;
203 }
205  const Column<int64_t>& input2,
206  const int32_t multiplier,
207  Column<int32_t>& out) {
208  out[0] = 1000 + 329 + multiplier;
209  return 1;
210 }
212  const ColumnList<int64_t>& input2,
213  const int32_t multiplier,
214  Column<int32_t>& out) {
215  out[0] = 1000 + 349 + multiplier;
216  return 1;
217 }
219  const ColumnList<int64_t>& input2,
220  const Column<int64_t>& input3,
221  const int32_t multiplier,
222  Column<int64_t>& out) {
223  out[0] = 1000 + 2429 + multiplier;
224  return 1;
225 }
226 
227 EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf2__cpu_21(const int32_t multiplier,
228  const Column<int32_t>& input1,
229  Column<int32_t>& out) {
230  out[0] = 1000 + 91 + multiplier;
231  return 1;
232 }
234  const int32_t multiplier,
235  const int32_t input2,
236  Column<int32_t>& out) {
237  out[0] = 1000 + 196 + multiplier + 10 * input2;
238  return 1;
239 }
242  const int32_t multiplier,
243  const int32_t input2,
244  Column<int32_t>& out) {
245  out[0] = 1000 + 396 + multiplier + 10 * input2;
246  return 1;
247 }
250  const int32_t input2,
251  const int32_t multiplier,
252  Column<int32_t>& out) {
253  out[0] = 1000 + 369 + multiplier + 10 * input2;
254  return 1;
255 }
257  const int32_t input2,
258  const int32_t multiplier,
259  Column<int32_t>& out) {
260  out[0] = 1000 + 169 + multiplier + 10 * input2;
261  return 1;
262 }
263 
264 #endif // #ifndef __CUDACC__
265 
266 /*
267  Test functions for default sizer parameter:
268 */
269 
270 #ifndef __CUDACC__
271 
274  const int32_t multiplier,
275  Column<int32_t>& out) {
276  out[0] = 1000 + 1 + 10 * multiplier;
277  return 1;
278 }
281  const Column<int32_t>& input2,
282  const int32_t multiplier,
283  Column<int32_t>& out) {
284  out[0] = 1000 + 2 + 11 * multiplier;
285  return 1;
286 }
289  const Column<int32_t>& input2,
290  const Column<int32_t>& input3,
291  const int32_t multiplier,
292  const Column<int32_t>& input4,
293  const int32_t x,
294  Column<int32_t>& out) {
295  out[0] = 1000 + 101 + 10 * multiplier + x;
296  return 1;
297 }
299 ct_udtf_default_sizer1d__cpu_4(const int32_t multiplier,
300  const int32_t x,
301  const Column<int32_t>& input1,
302  Column<int32_t>& out) {
303  out[0] = 1000 + 99 + 10 * multiplier + x;
304  return 1;
305 }
308  const int32_t x,
309  const int32_t multiplier,
310  Column<int32_t>& out) {
311  out[0] = 1000 + 98 + multiplier + 10 * x;
312  return 1;
313 }
316  const int32_t multiplier,
317  const Column<int32_t>& input2,
318  Column<int32_t>& out) {
319  out[0] = 1000 + 2 + multiplier;
320  return 1;
321 }
324  const int32_t multiplier,
325  const Column<int32_t>& input1,
326  Column<int32_t>& out) {
327  out[0] = 1000 + 99 + multiplier + 11 * x;
328  return 1;
329 }
332  const int32_t multiplier,
333  const int32_t x,
334  Column<int32_t>& out) {
335  out[0] = 1000 + 98 + 100 * multiplier + x;
336  return 1;
337 }
340  const int32_t x,
341  const Column<int32_t>& input2,
342  const int32_t multiplier,
343  Column<int32_t>& out) {
344  out[0] = 1000 + 99 + 100 * multiplier + x;
345  return 1;
346 }
349  const int32_t multiplier,
350  const Column<int32_t>& input2,
351  const int32_t x,
352  Column<int32_t>& out) {
353  out[0] = 1000 + 99 + 10 * multiplier + x;
354  return 1;
355 }
357 ct_udtf_default_sizer4b__cpu_2(const int32_t multiplier,
358  const Column<int32_t>& input,
359  const int32_t x,
360  Column<int32_t>& out) {
361  out[0] = 1000 + 99 + 9 * multiplier + x;
362  return 1;
363 }
364 
365 #endif // #ifndef __CUDACC__
366 
367 #ifndef __CUDACC__
368 
371  const int32_t multiplier,
373  for (int64_t i = 0; i < input.size(); i++) {
374  out[i] = input[i]; // assign string id
375  }
376  return multiplier * input.size();
377 }
378 
381  const Column<TextEncodingDict>& input2,
383  Column<TextEncodingDict>& out2) {
384  set_output_row_size(input1.size());
385  for (int64_t i = 0; i < input1.size(); i++) {
386  out1[i] = input1[i];
387  out2[i] = input2[i];
388  }
389  return input1.size();
390 }
391 
394  const Column<TextEncodingDict>& input2,
396  Column<TextEncodingDict>& out2) {
397  set_output_row_size(input1.size());
398  for (int64_t i = 0; i < input1.size(); i++) {
399  out1[i] = input2[i];
400  out2[i] = input1[i];
401  }
402  return input1.size();
403 }
404 
408  int64_t sz = input[0].size();
410  for (int64_t i = 0; i < sz; i++) {
411  out[i] = input[0][i];
412  }
413  return sz;
414 }
415 
419  int64_t sz = input[1].size();
421  for (int64_t i = 0; i < sz; i++) {
422  out[i] = input[1][i];
423  }
424  return sz;
425 }
426 
430  Column<TextEncodingDict>& out1) {
431  int64_t sz = input[0].size();
433  for (int64_t i = 0; i < sz; i++) {
434  out0[i] = input[0][i];
435  out1[i] = input[1][i];
436  }
437  return sz;
438 }
439 
440 #endif // #ifndef __CUDACC__
441 
442 #ifndef __CUDACC__
443 
444 template <typename T>
446  Column<T>& out) {
447  set_output_row_size(input.size());
448  for (int64_t i = 0; i < input.size(); i++) {
449  out[i] = input[i];
450  }
451  return input.size();
452 }
453 
454 // explicit instantiations
455 template NEVER_INLINE HOST int32_t
457 template NEVER_INLINE HOST int32_t
460 template NEVER_INLINE HOST int32_t
462 
463 #endif // #ifndef __CUDACC__
464 
465 #ifndef __CUDACC__
466 
467 template <typename T>
469  const ColumnList<T>& input2,
470  Column<int32_t>& out) {
472  if constexpr (std::is_same<T, int32_t>::value) {
473  out[0] = 1;
474  } else if constexpr (std::is_same<T, float>::value) {
475  out[0] = 2;
476  } else if constexpr (std::is_same<T, TextEncodingDict>::value) {
477  out[0] = 3;
478  } else {
479  out[0] = 4;
480  }
481  return 1;
482 }
483 
484 // explicit instantiations
485 template NEVER_INLINE HOST int32_t
487  const ColumnList<int32_t>& input2,
488  Column<int32_t>& out);
489 template NEVER_INLINE HOST int32_t
491  const ColumnList<float>& input2,
492  Column<int32_t>& out);
493 template NEVER_INLINE HOST int32_t
495  const ColumnList<TextEncodingDict>& input2,
496  Column<int32_t>& out);
497 template NEVER_INLINE HOST int32_t
499  const ColumnList<int16_t>& input2,
500  Column<int32_t>& out);
501 
502 #endif // #ifndef __CUDACC__
503 
504 #ifndef __CUDACC__
505 
506 template <typename T>
508  Column<int32_t>& out) {
510  if constexpr (std::is_same<T, int32_t>::value) {
511  out[0] = 10;
512  } else {
513  out[0] = 20;
514  }
515  return 1;
516 }
517 
518 // explicit instantiations
519 template NEVER_INLINE HOST int32_t
521 template NEVER_INLINE HOST int32_t
523 
524 #endif // #ifndef __CUDACC__
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer2b__cpu_2(const Column< int32_t > &input1, const int32_t multiplier, const Column< int32_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_1(const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer3b__cpu_2(const Column< int32_t > &input1, const int32_t x, const Column< int32_t > &input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded6__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out0, Column< TextEncodingDict > &out1)
#define GPU_DEVICE_CODE
EXTENSION_NOINLINE_HOST void set_output_row_size(int64_t num_rows)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_4(const Column< int64_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, Column< int32_t > &out)
#define EXTENSION_NOINLINE
Definition: heavydbTypes.h:58
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_19(const ColumnList< int32_t > &input1, const ColumnList< int64_t > &input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_11(const Column< int32_t > &input1, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf5__cpu_24(const ColumnList< int32_t > &input1, const int32_t input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_16(const Column< int64_t > &input1, const Column< int32_t > &input2, const Column< int64_t > &input3, const int32_t multiplier, Column< int32_t > &out)
DEVICE int64_t size() const
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf6__cpu_22(const Column< int32_t > &input1, const int32_t multiplier, const int32_t input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_5(const Column< int64_t > &input1, const Column< int64_t > &input2, const Column< int32_t > &input3, Column< int32_t > &out)
DEVICE int64_t size() const
NEVER_INLINE HOST int32_t ct_binding_column__cpu_template(const Column< T > &input, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer4a__cpu_1(const Column< int32_t > &input1, const int32_t multiplier, const Column< int32_t > &input2, const int32_t x, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_device_selection_udtf_cpu__cpu_(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer2a__cpu_1(const Column< int32_t > &input1, const int32_t x, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer1c__cpu_3(const Column< int32_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, const int32_t multiplier, const Column< int32_t > &input4, const int32_t x, Column< int32_t > &out)
#define HOST
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer1a__cpu_1(const Column< int32_t > &input1, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_9(const ColumnList< int32_t > &input1, const ColumnList< int64_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_20(const Column< int64_t > &input1, const ColumnList< int64_t > &input2, const Column< int64_t > &input3, const int32_t multiplier, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_3(const Column< int32_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer1d__cpu_4(const int32_t multiplier, const int32_t x, const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_any(const Column< int32_t > &input, Column< int64_t > &out)
NEVER_INLINE HOST int32_t ct_binding_columnlist__cpu_template(const Column< T > &input1, const ColumnList< T > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer2c__cpu_3(const int32_t x, const int32_t multiplier, const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_2(const Column< int32_t > &input1, const Column< int32_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded4__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded1__cpu_1(const Column< TextEncodingDict > &input, const int32_t multiplier, Column< TextEncodingDict > &out)
#define EXTENSION_NOINLINE_HOST
Definition: heavydbTypes.h:55
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_8(const ColumnList< int32_t > &input1, const Column< int64_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer3a__cpu_1(const Column< int32_t > &input1, const int32_t multiplier, const int32_t x, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_10(const Column< int64_t > &input1, const ColumnList< int64_t > &input2, const Column< int64_t > &input3, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_15(const Column< int64_t > &input1, const Column< int64_t > &input2, const Column< int32_t > &input3, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_17(const Column< int32_t > &input1, const ColumnList< int32_t > &input2, const int32_t multiplier, Column< int32_t > &out)
NEVER_INLINE HOST int32_t ct_binding_template__cpu_template(const Column< T > &input, Column< T > &out)
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_gpu__gpu_(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf2__cpu_21(const int32_t multiplier, const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_6(const Column< int64_t > &input1, const Column< int32_t > &input2, const Column< int64_t > &input3, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded3__cpu_1(const Column< TextEncodingDict > &input1, const Column< TextEncodingDict > &input2, Column< TextEncodingDict > &out1, Column< TextEncodingDict > &out2)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf4__cpu_23(const ColumnList< int32_t > &input1, const int32_t multiplier, const int32_t input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded5__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out)
#define NEVER_INLINE
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_12(const Column< int32_t > &input1, const Column< int32_t > &input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_13(const Column< int32_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer4b__cpu_2(const int32_t multiplier, const Column< int32_t > &input, const int32_t x, Column< int32_t > &out)
DEVICE int64_t size() const
EXTENSION_NOINLINE_HOST int32_t ct_udtf_default_sizer1b__cpu_2(const Column< int32_t > &input1, const Column< int32_t > &input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf_constant__cpu_7(const Column< int32_t > &input1, const ColumnList< int32_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf3__cpu_25(const Column< int32_t > &input1, const int32_t input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_device_selection_udtf_both__cpu_(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_14(const Column< int64_t > &input1, const Column< int32_t > &input2, const Column< int32_t > &input3, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_udtf__cpu_18(const ColumnList< int32_t > &input1, const Column< int64_t > &input2, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE_HOST int32_t ct_binding_dict_encoded2__cpu_1(const Column< TextEncodingDict > &input1, const Column< TextEncodingDict > &input2, Column< TextEncodingDict > &out1, Column< TextEncodingDict > &out2)
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_both__gpu_(const Column< int32_t > &input, Column< int64_t > &out)
#define CPU_DEVICE_CODE