OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableFunctionsTesting.hpp
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 #pragma once
18 
19 #include "../../QueryEngine/OmniSciTypes.h"
20 
21 /*
22  This file contains tesing compile-time UDTFs. The unit-tests are
23  implemented within the RBC package.
24  */
25 
26 #define CPU_DEVICE_CODE 0x637075; // 'cpu' in hex
27 #define GPU_DEVICE_CODE 0x677075; // 'gpu' in hex
28 
29 // clang-format off
30 /*
31  UDTF: ct_device_selection_udtf_any(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
32  UDTF: ct_device_selection_udtf_cpu__cpu_(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
33  UDTF: ct_device_selection_udtf_gpu__gpu_(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
34  UDTF: ct_device_selection_udtf_both__cpu_(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
35  UDTF: ct_device_selection_udtf_both__gpu_(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
36 */
37 // clang-format on
38 
41 #ifdef __CUDACC__
42  out[0] = GPU_DEVICE_CODE;
43 #else
44  out[0] = CPU_DEVICE_CODE;
45 #endif
46  return 1;
47 }
48 
51  Column<int64_t>& out) {
52  out[0] = CPU_DEVICE_CODE;
53  return 1;
54 }
55 
58  Column<int64_t>& out) {
59  out[0] = GPU_DEVICE_CODE;
60  return 1;
61 }
62 
65  Column<int64_t>& out) {
66  out[0] = CPU_DEVICE_CODE;
67  return 1;
68 }
69 
72  Column<int64_t>& out) {
73  out[0] = GPU_DEVICE_CODE;
74  return 1;
75 }
76 
77 #undef CPU_DEVICE_CODE
78 #undef GPU_DEVICE_CODE
79 
80 // clang-format off
81 /*
82  Test functions for constant sizer parameter:
83 
84  UDTF: ct_binding_udtf_constant__cpu_1(Cursor<int32_t>, Constant<1>) -> Column<int32_t>
85  UDTF: ct_binding_udtf_constant__cpu_2(Cursor<int32_t, int32_t>, Constant<1>) -> Column<int32_t>
86  UDTF: ct_binding_udtf_constant__cpu_3(Cursor<int32_t, int32_t, int32_t>, Constant<1>) -> Column<int32_t>
87  UDTF: ct_binding_udtf_constant__cpu_4(Cursor<int64_t, int32_t, int32_t>, Constant<1>) -> Column<int32_t>
88  UDTF: ct_binding_udtf_constant__cpu_5(Cursor<int64_t, int64_t, int32_t>, Constant<1>) -> Column<int32_t>
89  UDTF: ct_binding_udtf_constant__cpu_6(Cursor<int64_t, int32_t, int64_t>, Constant<1>) -> Column<int32_t>
90  UDTF: ct_binding_udtf_constant__cpu_7(Cursor<int32_t, ColumnList<int32_t>>, Constant<1>) -> Column<int32_t>
91  UDTF: ct_binding_udtf_constant__cpu_8(Cursor<ColumnList<int32_t>, int64_t>, Constant<1>) -> Column<int32_t>
92  UDTF: ct_binding_udtf_constant__cpu_9(Cursor<ColumnList<int32_t>, ColumnList<int64_t>>, Constant<1>) -> Column<int32_t>
93  UDTF: ct_binding_udtf_constant__cpu_10(Cursor<int64_t, ColumnList<int64_t>, int64_t>, Constant<1>) -> Column<int32_t>
94 
95 
96  Test functions for row multiplier sizer parameter:
97 
98  UDTF: ct_binding_udtf__cpu_11(Cursor<int32_t>, RowMultiplier) -> Column<int32_t>
99  UDTF: ct_binding_udtf__cpu_12(Cursor<int32_t, int32_t>, RowMultiplier) -> Column<int32_t>
100  UDTF: ct_binding_udtf__cpu_13(Cursor<int32_t, int32_t, int32_t>, RowMultiplier) -> Column<int32_t>
101  UDTF: ct_binding_udtf__cpu_14(Cursor<int64_t, int32_t, int32_t>, RowMultiplier) -> Column<int32_t>
102  UDTF: ct_binding_udtf__cpu_15(Cursor<int64_t, int64_t, int32_t>, RowMultiplier) -> Column<int32_t>
103  UDTF: ct_binding_udtf__cpu_16(Cursor<int64_t, int32_t, int64_t>, RowMultiplier) -> Column<int32_t>
104  UDTF: ct_binding_udtf__cpu_17(Cursor<int32_t, ColumnList<int32_t>>, RowMultiplier) -> Column<int32_t>
105  UDTF: ct_binding_udtf__cpu_18(Cursor<ColumnList<int32_t>, int64_t>, RowMultiplier) -> Column<int32_t>
106  UDTF: ct_binding_udtf__cpu_19(Cursor<ColumnList<int32_t>, ColumnList<int64_t>>, RowMultiplier) -> Column<int32_t>
107  UDTF: ct_binding_udtf__cpu_20(Cursor<int64_t, ColumnList<int64_t>, int64_t>, RowMultiplier) -> Column<int32_t>
108 
109  UDTF: ct_binding_udtf2__cpu_21(RowMultiplier, Cursor<int32_t>) -> Column<int32_t>
110  UDTF: ct_binding_udtf6__cpu_22(Cursor<int32_t>, RowMultiplier, int32_t) -> Column<int32_t>
111  UDTF: ct_binding_udtf4__cpu_23(Cursor<ColumnList<int32_t>>, RowMultiplier, int32_t) -> Column<int32_t>
112  UDTF: ct_binding_udtf5__cpu_24(Cursor<ColumnList<int32_t>>, int32_t, RowMultiplier) -> Column<int32_t>
113  UDTF: ct_binding_udtf3__cpu_25(Cursor<Column<int32_t>>, int32_t, RowMultiplier) -> Column<int32_t>
114 */
115 // clang-format on
116 
118  Column<int32_t>& out) {
119  out[0] = 1;
120  return 1;
121 }
123  const Column<int32_t>& input2,
124  Column<int32_t>& out) {
125  out[0] = 11;
126  return 1;
127 }
129  const Column<int32_t>& input2,
130  const Column<int32_t>& input3,
131  Column<int32_t>& out) {
132  out[0] = 111;
133  return 1;
134 }
136  const Column<int32_t>& input2,
137  const Column<int32_t>& input3,
138  Column<int32_t>& out) {
139  out[0] = 211;
140  return 1;
141 }
143  const Column<int64_t>& input2,
144  const Column<int32_t>& input3,
145  Column<int32_t>& out) {
146  out[0] = 221;
147  return 1;
148 }
150  const Column<int32_t>& input2,
151  const Column<int64_t>& input3,
152  Column<int32_t>& out) {
153  out[0] = 212;
154  return 1;
155 }
156 EXTENSION_NOINLINE int32_t
158  const ColumnList<int32_t>& input2,
159  Column<int32_t>& out) {
160  out[0] = 13;
161  return 1;
162 }
163 EXTENSION_NOINLINE int32_t
165  const Column<int64_t>& input2,
166  Column<int32_t>& out) {
167  out[0] = 32;
168  return 1;
169 }
170 EXTENSION_NOINLINE int32_t
172  const ColumnList<int64_t>& input2,
173  Column<int32_t>& out) {
174  out[0] = 34;
175  return 1;
176 }
177 EXTENSION_NOINLINE int32_t
179  const ColumnList<int64_t>& input2,
180  const Column<int64_t>& input3,
181  Column<int64_t>& out) {
182  out[0] = 242;
183  return 1;
184 }
185 
187  const int32_t multiplier,
188  Column<int32_t>& out) {
189  out[0] = 1000 + 19 + multiplier;
190  return 1;
191 }
193  const Column<int32_t>& input2,
194  const int32_t multiplier,
195  Column<int32_t>& out) {
196  out[0] = 1000 + 119 + multiplier;
197  return 1;
198 }
200  const Column<int32_t>& input2,
201  const Column<int32_t>& input3,
202  const int32_t multiplier,
203  Column<int32_t>& out) {
204  out[0] = 1000 + 1119 + multiplier;
205  return 1;
206 }
208  const Column<int32_t>& input2,
209  const Column<int32_t>& input3,
210  const int32_t multiplier,
211  Column<int32_t>& out) {
212  out[0] = 1000 + 2119 + multiplier;
213  return 1;
214 }
216  const Column<int64_t>& input2,
217  const Column<int32_t>& input3,
218  const int32_t multiplier,
219  Column<int32_t>& out) {
220  out[0] = 1000 + 2219 + multiplier;
221  return 1;
222 }
224  const Column<int32_t>& input2,
225  const Column<int64_t>& input3,
226  const int32_t multiplier,
227  Column<int32_t>& out) {
228  out[0] = 1000 + 2129 + multiplier;
229  return 1;
230 }
232  const ColumnList<int32_t>& input2,
233  const int32_t multiplier,
234  Column<int32_t>& out) {
235  out[0] = 1000 + 139 + multiplier;
236  return 1;
237 }
239  const Column<int64_t>& input2,
240  const int32_t multiplier,
241  Column<int32_t>& out) {
242  out[0] = 1000 + 329 + multiplier;
243  return 1;
244 }
246  const ColumnList<int64_t>& input2,
247  const int32_t multiplier,
248  Column<int32_t>& out) {
249  out[0] = 1000 + 349 + multiplier;
250  return 1;
251 }
253  const ColumnList<int64_t>& input2,
254  const Column<int64_t>& input3,
255  const int32_t multiplier,
256  Column<int64_t>& out) {
257  out[0] = 1000 + 2429 + multiplier;
258  return 1;
259 }
260 
261 EXTENSION_NOINLINE int32_t ct_binding_udtf2__cpu_21(const int32_t multiplier,
262  const Column<int32_t>& input1,
263  Column<int32_t>& out) {
264  out[0] = 1000 + 91 + multiplier;
265  return 1;
266 }
268  const int32_t multiplier,
269  const int32_t input2,
270  Column<int32_t>& out) {
271  out[0] = 1000 + 196 + multiplier + 10 * input2;
272  return 1;
273 }
275  const int32_t multiplier,
276  const int32_t input2,
277  Column<int32_t>& out) {
278  out[0] = 1000 + 396 + multiplier + 10 * input2;
279  return 1;
280 }
282  const int32_t input2,
283  const int32_t multiplier,
284  Column<int32_t>& out) {
285  out[0] = 1000 + 369 + multiplier + 10 * input2;
286  return 1;
287 }
289  const int32_t input2,
290  const int32_t multiplier,
291  Column<int32_t>& out) {
292  out[0] = 1000 + 169 + multiplier + 10 * input2;
293  return 1;
294 }
295 
296 /*
297  Test functions for default sizer parameter:
298 */
299 
300 // clang-format off
301 /*
302  UDTF: ct_udtf_default_sizer1a__cpu_1(Cursor<int32_t>, RowMultiplier) -> Column<int32_t>
303  UDTF: ct_udtf_default_sizer1b__cpu_2(Cursor<int32_t>, Cursor<int32_t>, RowMultiplier) -> Column<int32_t>
304  UDTF: ct_udtf_default_sizer1c__cpu_3(Cursor<int32_t, int32_t, int32_t>, RowMultiplier, Cursor<int32_t>, int32_t) -> Column<int32_t>
305  UDTF: ct_udtf_default_sizer1d__cpu_4(RowMultiplier, int32_t, Cursor<int32_t>) -> Column<int32_t>
306  UDTF: ct_udtf_default_sizer2a__cpu_1(Cursor<int32_t>, int32_t, RowMultiplier) -> Column<int32_t>
307  UDTF: ct_udtf_default_sizer2b__cpu_2(Cursor<int32_t>, RowMultiplier, Cursor<int32_t>) -> Column<int32_t>
308  UDTF: ct_udtf_default_sizer2c__cpu_3(int32_t, RowMultiplier, Cursor<int32_t>) -> Column<int32_t>
309  UDTF: ct_udtf_default_sizer3a__cpu_1(Cursor<int32_t>, RowMultiplier, int32_t) -> Column<int32_t>
310  UDTF: ct_udtf_default_sizer3b__cpu_2(Cursor<int32_t>, int32_t, Cursor<int32_t>, RowMultiplier) -> Column<int32_t>
311  UDTF: ct_udtf_default_sizer4a__cpu_1(Cursor<int32_t>, RowMultiplier, Cursor<int32_t>, int32_t) -> Column<int32_t>
312  UDTF: ct_udtf_default_sizer4b__cpu_2(RowMultiplier, Cursor<int32_t>, int32_t) -> Column<int32_t>
313 */
314 // clang-format on
316  const int32_t multiplier,
317  Column<int32_t>& out) {
318  out[0] = 1000 + 1 + 10 * multiplier;
319  return 1;
320 }
322  const Column<int32_t>& input2,
323  const int32_t multiplier,
324  Column<int32_t>& out) {
325  out[0] = 1000 + 2 + 11 * multiplier;
326  return 1;
327 }
329  const Column<int32_t>& input2,
330  const Column<int32_t>& input3,
331  const int32_t multiplier,
332  const Column<int32_t>& input4,
333  const int32_t x,
334  Column<int32_t>& out) {
335  out[0] = 1000 + 101 + 10 * multiplier + x;
336  return 1;
337 }
338 EXTENSION_NOINLINE int32_t ct_udtf_default_sizer1d__cpu_4(const int32_t multiplier,
339  const int32_t x,
340  const Column<int32_t>& input1,
341  Column<int32_t>& out) {
342  out[0] = 1000 + 99 + 10 * multiplier + x;
343  return 1;
344 }
346  const int32_t x,
347  const int32_t multiplier,
348  Column<int32_t>& out) {
349  out[0] = 1000 + 98 + multiplier + 10 * x;
350  return 1;
351 }
353  const int32_t multiplier,
354  const Column<int32_t>& input2,
355  Column<int32_t>& out) {
356  out[0] = 1000 + 2 + multiplier;
357  return 1;
358 }
360  const int32_t multiplier,
361  const Column<int32_t>& input1,
362  Column<int32_t>& out) {
363  out[0] = 1000 + 99 + multiplier + 11 * x;
364  return 1;
365 }
367  const int32_t multiplier,
368  const int32_t x,
369  Column<int32_t>& out) {
370  out[0] = 1000 + 98 + 100 * multiplier + x;
371  return 1;
372 }
374  const int32_t x,
375  const Column<int32_t>& input2,
376  const int32_t multiplier,
377  Column<int32_t>& out) {
378  out[0] = 1000 + 99 + 100 * multiplier + x;
379  return 1;
380 }
382  const int32_t multiplier,
383  const Column<int32_t>& input2,
384  const int32_t x,
385  Column<int32_t>& out) {
386  out[0] = 1000 + 99 + 10 * multiplier + x;
387  return 1;
388 }
389 EXTENSION_NOINLINE int32_t ct_udtf_default_sizer4b__cpu_2(const int32_t multiplier,
390  const Column<int32_t>& input,
391  const int32_t x,
392  Column<int32_t>& out) {
393  out[0] = 1000 + 99 + 9 * multiplier + x;
394  return 1;
395 }
396 
397 // clang-format off
398 /*
399  UDTF: ct_binding_dict_encoded1__cpu_1(Cursor<TextEncodingDict>, RowMultiplier) -> Column<TextEncodingDict> | input_id=args<0>
400  UDTF: ct_binding_dict_encoded2__cpu_1(Cursor<TextEncodingDict, TextEncodingDict>) -> Column<TextEncodingDict> | input_id=args<0, 0>, Column<TextEncodingDict> | input_id=args<0, 1>
401  UDTF: ct_binding_dict_encoded3__cpu_1(Cursor<TextEncodingDict, TextEncodingDict>) -> Column<TextEncodingDict> | input_id=args<0, 1>, Column<TextEncodingDict> | input_id=args<0, 0>
402  UDTF: ct_binding_dict_encoded4__cpu_1(Cursor<ColumnList<TextEncodingDict>>) -> Column<TextEncodingDict> | input_id=args<0,0>
403  UDTF: ct_binding_dict_encoded5__cpu_1(Cursor<ColumnList<TextEncodingDict>>) -> Column<TextEncodingDict> | input_id=args<0,1>
404  UDTF: ct_binding_dict_encoded6__cpu_1(Cursor<ColumnList<TextEncodingDict>>) -> Column<TextEncodingDict> | input_id=args<0,0>, Column<TextEncodingDict> | input_id=args<0,1>
405 */
406 // clang-format on
407 EXTENSION_NOINLINE int32_t
409  const int32_t multiplier,
411  for (int64_t i = 0; i < input.size(); i++) {
412  out[i] = input[i]; // assign string id
413  }
414  return multiplier * input.size();
415 }
416 
417 EXTENSION_NOINLINE int32_t
419  const Column<TextEncodingDict>& input2,
421  Column<TextEncodingDict>& out2) {
422  set_output_row_size(input1.size());
423  for (int64_t i = 0; i < input1.size(); i++) {
424  out1[i] = input1[i];
425  out2[i] = input2[i];
426  }
427  return input1.size();
428 }
429 
430 EXTENSION_NOINLINE int32_t
432  const Column<TextEncodingDict>& input2,
434  Column<TextEncodingDict>& out2) {
435  set_output_row_size(input1.size());
436  for (int64_t i = 0; i < input1.size(); i++) {
437  out1[i] = input2[i];
438  out2[i] = input1[i];
439  }
440  return input1.size();
441 }
442 
443 EXTENSION_NOINLINE int32_t
446  int64_t sz = input[0].size();
448  for (int64_t i = 0; i < sz; i++) {
449  out[i] = input[0][i];
450  }
451  return sz;
452 }
453 
454 EXTENSION_NOINLINE int32_t
457  int64_t sz = input[1].size();
459  for (int64_t i = 0; i < sz; i++) {
460  out[i] = input[1][i];
461  }
462  return sz;
463 }
464 
465 EXTENSION_NOINLINE int32_t
468  Column<TextEncodingDict>& out1) {
469  int64_t sz = input[0].size();
471  for (int64_t i = 0; i < sz; i++) {
472  out0[i] = input[0][i];
473  out1[i] = input[1][i];
474  }
475  return sz;
476 }
477 
478 // clang-format off
479 /*
480  UDTF: ct_binding_template__cpu_template(Cursor<TextEncodingDict>) -> Column<TextEncodingDict> | input_id=args<0>
481  UDTF: ct_binding_template__cpu_template(Cursor<int>) -> Column<int>
482  UDTF: ct_binding_template__cpu_template(Cursor<float>) -> Column<float>
483 */
484 // clang-format on
485 template <typename T>
487  Column<T>& out) {
488  set_output_row_size(input.size());
489  for (int64_t i = 0; i < input.size(); i++) {
490  out[i] = input[i];
491  }
492  return input.size();
493 }
494 
495 // clang-format off
496 /*
497  UDTF: ct_binding_columnlist__cpu_template(Cursor<int32_t, ColumnList<int32_t>>) -> Column<int32_t>
498  UDTF: ct_binding_columnlist__cpu_template(Cursor<float, ColumnList<float>>) -> Column<int32_t>
499  UDTF: ct_binding_columnlist__cpu_template(Cursor<TextEncodingDict, ColumnList<TextEncodingDict>>) -> Column<int32_t>
500  UDTF: ct_binding_columnlist__cpu_template(Cursor<int16_t, ColumnList<int16_t>>) -> Column<int32_t>
501 */
502 // clang-format on
503 template <typename T>
505  const ColumnList<T>& input2,
506  Column<int32_t>& out) {
508  if constexpr (std::is_same<T, int32_t>::value) {
509  out[0] = 1;
510  } else if constexpr (std::is_same<T, float>::value) {
511  out[0] = 2;
512  } else if constexpr (std::is_same<T, TextEncodingDict>::value) {
513  out[0] = 3;
514  } else {
515  out[0] = 4;
516  }
517  return 1;
518 }
519 
520 // clang-format off
521 /*
522  UDTF: ct_binding_column__cpu_template(Column<int32_t>) -> Column<int32_t>
523  UDTF: ct_binding_column__cpu_template(Column<float>) -> Column<int32_t>
524 */
525 // clang-format on
526 template <typename T>
528  Column<int32_t>& out) {
530  if constexpr (std::is_same<T, int32_t>::value) {
531  out[0] = 10;
532  } else {
533  out[0] = 20;
534  }
535  return 1;
536 }
537 
538 // clang-format off
539 /*
540  UDTF: ct_binding_scalar_multiply__cpu_template(Cursor<Column<float>>, float) -> Column<float>
541  UDTF: ct_binding_scalar_multiply__cpu_template(Cursor<Column<double>>, double) -> Column<double>
542  UDTF: ct_binding_scalar_multiply__cpu_template(Cursor<Column<int32_t>>, int32_t) -> Column<int32_t>
543  UDTF: ct_binding_scalar_multiply__cpu_template(Cursor<Column<int64_t>>, int64_t) -> Column<int64_t>
544 */
545 // clang-format on
546 template <typename T>
548  const T multiplier,
549  Column<T>& out) {
550  const int64_t num_rows = input.size();
551  set_output_row_size(num_rows);
552  for (int64_t r = 0; r < num_rows; ++r) {
553  if (!input.isNull(r)) {
554  out[r] = input[r] * multiplier;
555  } else {
556  out.setNull(r);
557  }
558  }
559  return num_rows;
560 }
561 
562 #ifndef __CUDACC__
563 
564 #include <algorithm>
565 
566 template <typename T>
567 struct SortAsc {
568  SortAsc(const bool nulls_last)
569  : null_value_(std::numeric_limits<T>::lowest())
570  , null_value_mapped_(map_null_value(nulls_last)) {}
571  static T map_null_value(const bool nulls_last) {
572  return nulls_last ? std::numeric_limits<T>::max() : std::numeric_limits<T>::lowest();
573  }
574  inline T mapValue(const T& val) {
575  return val == null_value_ ? null_value_mapped_ : val;
576  }
577  bool operator()(const T& a, const T& b) { return mapValue(a) < mapValue(b); }
578  const T null_value_;
580 };
581 
582 template <typename T>
583 struct SortDesc {
584  SortDesc(const bool nulls_last)
585  : null_value_(std::numeric_limits<T>::lowest())
586  , null_value_mapped_(map_null_value(nulls_last)) {}
587  static T map_null_value(const bool nulls_last) {
588  return nulls_last ? std::numeric_limits<T>::lowest() : std::numeric_limits<T>::max();
589  }
590 
591  inline T mapValue(const T& val) {
592  return val == null_value_ ? null_value_mapped_ : val;
593  }
594 
595  bool operator()(const T& a, const T& b) { return mapValue(a) > mapValue(b); }
596  const T null_value_;
598 };
599 
600 // clang-format off
601 /*
602  UDTF: sort_column_limit__cpu_template(Cursor<Column<int8_t>>, int32_t, bool, bool) -> Column<int8_t>
603  UDTF: sort_column_limit__cpu_template(Cursor<Column<int16_t>>, int32_t, bool, bool) -> Column<int16_t>
604  UDTF: sort_column_limit__cpu_template(Cursor<Column<int32_t>>, int32_t, bool, bool) -> Column<int32_t>
605  UDTF: sort_column_limit__cpu_template(Cursor<Column<int64_t>>, int32_t, bool, bool) -> Column<int64_t>
606  UDTF: sort_column_limit__cpu_template(Cursor<Column<float>>, int32_t, bool, bool) -> Column<float>
607  UDTF: sort_column_limit__cpu_template(Cursor<Column<double>>, int32_t, bool, bool) -> Column<double>
608 */
609 // clang-format on
610 
611 template <typename T>
613  const int32_t limit,
614  const bool sort_ascending,
615  const bool nulls_last,
616  Column<T>& output) {
617  const int64_t num_rows = input.size();
618  set_output_row_size(num_rows);
619  output = input;
620  if (sort_ascending) {
621  std::sort(output.ptr_, output.ptr_ + num_rows, SortAsc<T>(nulls_last));
622  } else {
623  std::sort(output.ptr_, output.ptr_ + num_rows, SortDesc<T>(nulls_last));
624  }
625  if (limit < 0 || limit > num_rows) {
626  return num_rows;
627  }
628  return limit;
629 }
630 
631 #endif
632 
633 // clang-format off
634 /*
635  UDTF: ct_binding_column2__cpu_template(Column<T>, Column<U>) -> Column<K>, T=[int32_t, double], U=[int32_t, double], K=[int32_t]
636  UDTF: ct_binding_column2__cpu_template(Column<T>, Column<T>) -> Column<T> | input_id=args<0>, T=[TextEncodingDict]
637 */
638 // clang-format on
639 template <typename T, typename U, typename K>
641  const Column<U>& input2,
642  Column<K>& out) {
643  if constexpr (std::is_same<T, TextEncodingDict>::value &&
644  std::is_same<U, TextEncodingDict>::value) {
645  set_output_row_size(input1.size());
646  for (int64_t i = 0; i < input1.size(); i++) {
647  out[i] = input1[i];
648  }
649  return input1.size();
650  }
651 
653  if constexpr (std::is_same<T, int32_t>::value && std::is_same<U, double>::value) {
654  out[0] = 10;
655  } else if constexpr (std::is_same<T, double>::value && std::is_same<U, double>::value) {
656  out[0] = 20;
657  } else if constexpr (std::is_same<T, int32_t>::value &&
658  std::is_same<U, int32_t>::value) {
659  out[0] = 30;
660  } else if constexpr (std::is_same<T, double>::value &&
661  std::is_same<U, int32_t>::value) {
662  out[0] = 40;
663  }
664  return 1;
665 }
666 
667 // clang-format off
668 /*
669  UDTF: ct_named_output__cpu_template(Column<T> input) -> Column<T> total, T=[int32_t, double]
670  UDTF: ct_named_const_output__template(Column<T> input, Constant<2>) -> Column<T> total, T=[int32_t, double]
671  UDTF: ct_named_user_const_output__template(Column<T> input, ConstantParameter c) -> Column<T> total, T=[int32_t, double]
672  UDTF: ct_named_rowmul_output__template(Column<T> input, RowMultiplier m) -> Column<T> total, T=[int32_t, double]
673 */
674 // clang-format on
675 
676 template <typename T>
678  Column<T>& out) {
680  T acc = 0;
681  for (int64_t i = 0; i < input.size(); i++) {
682  acc += input[i];
683  }
684  out[0] = acc;
685  return 1;
686 }
687 
688 template <typename T>
690  Column<T>& out) {
691  T acc1 = 0, acc2 = 0;
692  for (int64_t i = 0; i < input.size(); i++) {
693  if (i % 2 == 0) {
694  acc1 += input[i];
695  } else {
696  acc2 += input[i];
697  }
698  }
699  out[0] = acc1;
700  out[1] = acc2;
701  return 2;
702 }
703 
704 template <typename T>
706  int32_t c,
707  Column<T>& out) {
708  for (int64_t i = 0; i < c; i++) {
709  out[i] = 0;
710  }
711  for (int64_t i = 0; i < input.size(); i++) {
712  out[i % c] += input[i];
713  }
714  return c;
715 }
716 
717 template <typename T>
719  int32_t m,
720  Column<T>& out) {
721  for (int64_t j = 0; j < m; j++) {
722  for (int64_t i = 0; i < input.size(); i++) {
723  out[j * input.size() + i] += input[i];
724  }
725  }
726  return m * input.size();
727 }
728 
729 // clang-format off
730 /*
731  UDTF: ct_no_arg_runtime_sizing__cpu_template() -> Column<T> answer, T=[int32_t]
732 */
733 // clang-format on
734 
735 template <typename T>
738  answer[0] = 42;
739  return 1;
740 }
741 
742 // clang-format off
743 /*
744  UDTF: ct_no_arg_constant_sizing__cpu_(Constant<42>) -> Column<int32_t> answer
745 */
746 // clang-format on
747 
749 #ifdef __CUDACC__
750  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
751  int32_t stop = static_cast<int32_t>(42);
752  int32_t step = blockDim.x * gridDim.x;
753 #else
754  auto start = 0;
755  auto stop = 42;
756  auto step = 1;
757 #endif
758  for (auto i = start; i < stop; i += step) {
759  answer[i] = 42 * i;
760  }
761  return 42;
762 }
763 
764 // clang-format off
765 /*
766  UDTF: ct_scalar_1_arg_runtime_sizing__cpu_template(T) -> Column<T> answer, T=[float, double, int32_t, int64_t]
767 */
768 // clang-format on
769 
770 template <typename T>
771 TEMPLATE_NOINLINE int32_t
773  T quotient = num;
775  int32_t counter{0};
776  while (quotient >= 1) {
777  answer[counter++] = quotient;
778  quotient /= 10;
779  }
780  return counter;
781 }
782 
783 // clang-format off
784 /*
785  UDTF: ct_scalar_2_args_constant_sizing(int64_t, int64_t, Constant<5>) -> Column<int64_t> answer1, Column<int64_t> answer2
786 */
787 // clang-format on
788 
790  const int64_t num2,
791  Column<int64_t>& answer1,
792  Column<int64_t>& answer2) {
793 #ifdef __CUDACC__
794  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
795  int32_t stop = static_cast<int32_t>(5);
796  int32_t step = blockDim.x * gridDim.x;
797 #else
798  auto start = 0;
799  auto stop = 5;
800  auto step = 1;
801 #endif
802  for (auto i = start; i < stop; i += step) {
803  answer1[i] = num1 + i * num2;
804  answer2[i] = num1 - i * num2;
805  }
806  return 5;
807 }
808 
809 // clang-format off
810 /*
811  UDTF: ct_no_cursor_user_constant_sizer__cpu_(int32_t, ConstantParameter c) -> Column<int32_t> output
812 */
813 // clang-format on
814 
815 EXTENSION_NOINLINE int32_t
817  int32_t c,
818  Column<int32_t>& output) {
819  for (int32_t i = 0; i < c; i++) {
820  output[i] = input_num;
821  }
822  return c;
823 }
824 
825 // clang-format off
826 /*
827  UDTF: ct_templated_no_cursor_user_constant_sizer__cpu_template(T, ConstantParameter c) -> Column<T> output, T=[int32_t, float]
828 */
829 // clang-format on
830 
831 template <typename T>
832 TEMPLATE_NOINLINE int32_t
834  int32_t c,
835  Column<T>& output) {
836  for (int32_t i = 0; i < c; i++) {
837  output[i] = input_num;
838  }
839  return c;
840 }
841 
842 #ifdef __CUDACC__
843 
844 // clang-format off
845 /*
846  UDTF: ct_user_constant_sizer__gpu_(int32_t, ConstantParameter c) -> Column<int32_t> output
847 */
848 // clang-format on
849 
850 EXTENSION_NOINLINE int32_t
851 ct_no_cursor_user_constant_sizer__gpu_(const int32_t input_num,
852  int32_t c,
853  Column<int32_t>& output) {
854  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
855  int32_t step = blockDim.x * gridDim.x;
856 
857  for (int32_t i = start; i < c; i += step) {
858  output[i] = input_num;
859  }
860  return c;
861 }
862 
863 // clang-format off
864 /*
865  UDTF: ct_templated_no_cursor_user_constant_sizer__gpu_template(T, ConstantParameter c) -> Column<T> output, T=[int32_t, float]
866 */
867 // clang-format on
868 
869 template <typename T>
870 TEMPLATE_NOINLINE int32_t
871 ct_templated_no_cursor_user_constant_sizer__gpu_template(const T input_num,
872  int32_t c,
873  Column<T>& output) {
874  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
875  int32_t step = blockDim.x * gridDim.x;
876 
877  for (int32_t i = start; i < c; i += step) {
878  output[i] = input_num;
879  }
880  return c;
881 }
882 
883 #endif //__CUDACC__
884 
885 template <typename T>
887  if (x >= 0) {
888  if (y > (std::numeric_limits<T>::max() - x)) {
889  throw std::overflow_error("Addition overflow detected");
890  }
891  } else {
892  if (y < (std::numeric_limits<T>::min() - x)) {
893  throw std::underflow_error("Addition underflow detected");
894  }
895  }
896  return x + y;
897 }
898 
899 // clang-format off
900 /*
901  UDTF: column_list_safe_row_sum__cpu_template(Cursor<ColumnList<T>>) -> Column<T>, T=[int32_t, int64_t, float, double]
902 */
903 // clang-format on
904 
905 template <typename T>
907  Column<T>& out) {
908  int32_t output_num_rows = input.numCols();
909  set_output_row_size(output_num_rows);
910  for (int i = 0; i < output_num_rows; i++) {
911  auto col = input[i];
912  T s = 0;
913  for (int j = 0; j < col.size(); j++) {
914  try {
915  s = safe_addition(s, col[j]);
916  } catch (const std::exception& e) {
917  return TABLE_FUNCTION_ERROR(e.what());
918  } catch (...) {
919  return TABLE_FUNCTION_ERROR("Unknown error");
920  }
921  }
922  out[i] = s;
923  }
924  return output_num_rows;
925 }
926 
927 // clang-format off
928 /*
929  UDTF: ct_hamming_distance(TextEncodingNone, TextEncodingNone, Constant<1>) -> Column<int32_t> hamming_distance
930 */
931 // clang-format on
932 
934  const TextEncodingNone& str2,
935  Column<int32_t>& hamming_distance) {
936  const int32_t str_len = str1.size() <= str2.size() ? str1.size() : str2.size();
937 
938 #ifdef __CUDACC__
939  const int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
940  const int32_t step = blockDim.x * gridDim.x;
941  if (start == 0) {
942  hamming_distance[0] = 0;
943  }
944  int32_t* output_ptr = hamming_distance.ptr_;
945  __syncthreads();
946 #else
947  const int32_t start = 0;
948  const int32_t step = 1;
949 #endif
950 
951  int32_t num_chars_unequal = 0;
952  for (int32_t i = start; i < str_len; i += step) {
953  num_chars_unequal += (str1[i] != str2[i]) ? 1 : 0;
954  }
955 #ifdef __CUDACC__
956  atomicAdd(output_ptr, num_chars_unequal);
957 #else
958  hamming_distance[0] = num_chars_unequal;
959 #endif
960  return 1;
961 }
962 
963 // clang-format off
964 /*
965  UDTF: ct_get_string_chars__template(Column<T>, TextEncodingNone, RowMultiplier) -> Column<int32_t> idx, Column<int8_t> char_bytes, T=[int16_t, int32_t]
966 */
967 // clang-format on
968 template <typename T>
970  const TextEncodingNone& str,
971  const int32_t multiplier,
972  Column<int32_t>& idx,
973  Column<int8_t>& char_bytes) {
974  const int32_t str_len = str.size();
975  // Note: we assume RowMultiplier is 1 for this test, was to make running on GPU easy
976  // Todo: Provide Constant RowMultiplier interface
977  if (multiplier != 1) {
978  return 0;
979  }
980  const int32_t num_input_rows = indices.size();
981  const int32_t num_output_rows = num_input_rows * multiplier;
982 
983 #ifdef __CUDACC__
984  const int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
985  const int32_t step = blockDim.x * gridDim.x;
986 #else
987  const int32_t start = 0;
988  const int32_t step = 1;
989 #endif
990 
991  for (int32_t i = start; i < num_output_rows; i += step) {
992  idx[i] = indices[i % num_output_rows];
993  char_bytes[i] = str[i % str_len]; // index < str_len ? str[i] : 0;
994  }
995  return num_output_rows;
996 }
997 
998 #ifndef __CUDACC__
999 
1000 #include <iostream>
1001 #include <string>
1002 
1003 // clang-format off
1004 /*
1005  UDTF: ct_string_to_chars__cpu_(TextEncodingNone) -> Column<int32_t> char_idx, Column<int8_t> char_bytes
1006 */
1007 // clang-format on
1008 
1010  Column<int32_t>& char_idx,
1011  Column<int8_t>& char_bytes) {
1012  const std::string str{input.getString()};
1013  const int64_t str_size(str.size());
1014  set_output_row_size(str_size);
1015  for (int32_t i = 0; i < str_size; ++i) {
1016  char_idx[i] = i;
1017  char_bytes[i] = str[i];
1018  }
1019  return str_size;
1020 }
1021 
1022 // clang-format off
1023 /*
1024  The purpose of ct_sleep1 and ct_sleep2 is to test parallel execution
1025  of UDTFs (use --num-executors=..). For instance, ct_sleep1 output
1026  column buffers are managed by a global manager, hence, ct_sleep1 can
1027  be run only sequentially. However, ct_sleep2 output column buffers
1028  are managed with a thread-safe manager instance, hence, ct_sleep2
1029  can be run in parallel.
1030 
1031  UDTF: ct_sleep1(int32_t seconds, int32_t mode) -> Column<int32_t> output
1032  UDTF: ct_sleep2(TableFunctionManager, int32_t seconds, int32_t mode) -> Column<int32_t> output
1033 
1034  Here mode argument is used to test various approaches of accessing
1035  the table function manager:
1036 
1037  - mode == 0
1038  ct_sleep1 uses global set_output_row_size function
1039  ct_sleep2 uses thread-safe set_output_row_size method
1040 
1041  - mode == 1
1042  ct_sleep1 retrieves global singleton manager and uses its set_output_row_size method
1043  ct_sleep2 same as in mode == 1
1044 
1045  - mode == 2
1046  ct_sleep1 does not call set_output_row_size function, expect error return
1047  ct_sleep2 does not call set_output_row_size method, expect error return
1048 
1049  - mode == 3
1050  ct_sleep1 same as mode == 2
1051  ct_sleep2 calls global set_output_row_size function, expect error return
1052 */
1053 // clang-format on
1054 EXTENSION_NOINLINE int32_t ct_sleep_worker(int32_t seconds, Column<int32_t>& output) {
1055  // save entering time
1056  output[0] = std::chrono::duration_cast<std::chrono::milliseconds>(
1057  std::chrono::system_clock::now().time_since_epoch())
1058  .count() &
1059  0xffffff;
1060  // store thread id info
1061  output[2] = std::hash<std::thread::id>()(std::this_thread::get_id()) & 0xffff;
1062  // do "computations" for given seconds
1063  std::this_thread::sleep_for(std::chrono::seconds(seconds));
1064  // save leaving time
1065  output[1] = std::chrono::duration_cast<std::chrono::milliseconds>(
1066  std::chrono::system_clock::now().time_since_epoch())
1067  .count() &
1068  0xffffff;
1069  return 3;
1070 }
1071 
1072 EXTENSION_NOINLINE int32_t ct_sleep1(int32_t seconds,
1073  int32_t mode,
1074  Column<int32_t>& output) {
1075  switch (mode) {
1076  case 0: {
1077  set_output_row_size(3); // uses global singleton of TableFunctionManager
1078  break;
1079  }
1080  case 1: {
1082  mgr->set_output_row_size(3);
1083  break;
1084  }
1085  case 2:
1086  case 3: {
1087  break;
1088  }
1089  default:
1090  return TABLE_FUNCTION_ERROR("unexpected mode");
1091  }
1092  if (output.size() == 0) {
1093  return TABLE_FUNCTION_ERROR("unspecified output columns row size");
1094  }
1095  return ct_sleep_worker(seconds, output);
1096 }
1097 
1099  int32_t seconds,
1100  int32_t mode,
1101  Column<int32_t>& output) {
1102  switch (mode) {
1103  case 0:
1104  case 1: {
1105  mgr.set_output_row_size(3); // uses thread-safe TableFunctionManager instance
1106  break;
1107  }
1108  case 2: {
1109  break;
1110  }
1111  case 3: {
1112  try {
1113  auto* mgr0 = TableFunctionManager::get_singleton(); // it may throw "singleton is
1114  // not initialized"
1115  mgr0->set_output_row_size(3);
1116  } catch (std::exception& e) {
1117  return mgr.ERROR_MESSAGE(e.what());
1118  }
1119  break;
1120  }
1121  default:
1122  return mgr.ERROR_MESSAGE("unexpected mode");
1123  }
1124  if (output.size() == 0) {
1125  return mgr.ERROR_MESSAGE("unspecified output columns row size");
1126  }
1127  return ct_sleep_worker(seconds, output);
1128 }
1129 
1130 // clang-format off
1131 /*
1132  UDTF: ct_throw_if_gt_100__cpu_template(TableFunctionManager, Column<T>) -> Column<T> val, T=[float, double]
1133 */
1134 // clang-format on
1135 
1136 template <typename T>
1138  const Column<T>& input,
1139  Column<T>& output) {
1140  int64_t num_rows = input.size();
1141  mgr.set_output_row_size(num_rows);
1142  for (int64_t r = 0; r < num_rows; ++r) {
1143  if (input[r] > 100) {
1144  return mgr.ERROR_MESSAGE("Values greater than 100 not allowed");
1145  }
1146  output[r] = input[r];
1147  }
1148  return num_rows;
1149 }
1150 
1151 // clang-format off
1152 /*
1153  The following UDTFs are used to test an optimization rule that moves
1154  filters on UDTF outputs to the inputs when the names of outputs and
1155  input arguments match in the UDTF signatures. This optimization
1156  makes sense only if filters and table functions are commutative with
1157  respect to the corresponding input and output arguments:
1158 
1159  filter(udtf(..., input[j], ...)[i]) == udtf(..., filter(input[j]), ...)[i]
1160 
1161  The UDTFs below invalidate this requirement for the purpose of
1162  testing the feature: the result will depend on whether the
1163  optimization is enabled or not.
1164 
1165  UDTF: ct_copy_and_add_size(TableFunctionManager, Column<int32_t> x) | filter_table_function_transpose=on -> Column<int32_t> x
1166  UDTF: ct_add_size_and_mul_alpha(TableFunctionManager, Cursor<Column<int32_t>, Column<int32_t>> | fields=[x, x2], int32_t alpha) | filter_table_function_transpose=on -> Column<int32_t> x, Column<int32_t> x2
1167 */
1168 // clang-format on
1170  const Column<int32_t>& input,
1171  Column<int32_t>& output) {
1172  mgr.set_output_row_size(input.size());
1173  for (int32_t i = 0; i < input.size(); i++) {
1174  output[i] = input[i] + input.size();
1175  }
1176  return output.size();
1177 }
1178 
1180  const Column<int32_t>& input1,
1181  const Column<int32_t>& input2,
1182  int32_t alpha,
1183  Column<int32_t>& output1,
1184  Column<int32_t>& output2) {
1185  auto size = input1.size();
1186  mgr.set_output_row_size(size);
1187  for (int32_t i = 0; i < size; i++) {
1188  output1[i] = input1[i] + size;
1189  output2[i] = input2[i] * alpha;
1190  }
1191  return size;
1192 }
1193 #endif
1194 
1195 // clang-format off
1196 /*
1197  UDTF: ct_require(Column<int32_t>, int | name=i | require="i > 0") -> Column<int32_t>
1198  UDTF: ct_require_mgr(TableFunctionManager, Column<int32_t>, int i | require="i > 1" | require="i < 5") -> Column<int32_t>
1199  UDTF: ct_require_str(Column<int32>t, TextEncodingNone s | require="s == \"hello\"") -> Column<int32_t>
1200 */
1201 // clang-format on
1203  const int32_t i,
1204  Column<int32_t>& out) {
1206  out[0] = 3;
1207  return 1;
1208 }
1209 
1211  const TextEncodingNone& s,
1212  Column<int32_t>& out) {
1214  out[0] = 3;
1215  return 1;
1216 }
1217 
1219  const Column<int32_t>& input1,
1220  const int32_t i,
1221  Column<int32_t>& out) {
1223  out[0] = 4;
1224  return 1;
1225 }
EXTENSION_NOINLINE 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)
void set_output_row_size(int64_t num_rows)
Definition: OmniSciTypes.h:304
EXTENSION_NOINLINE 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 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)
const T null_value_mapped_
EXTENSION_NOINLINE int32_t ct_require(const Column< int32_t > &input1, const int32_t i, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_binding_udtf2__cpu_21(const int32_t multiplier, const Column< int32_t > &input1, Column< int32_t > &out)
EXTENSION_NOINLINE 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)
EXTENSION_NOINLINE int32_t ct_string_to_chars__cpu_(const TextEncodingNone &input, Column< int32_t > &char_idx, Column< int8_t > &char_bytes)
EXTENSION_NOINLINE 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 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 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)
static T map_null_value(const bool nulls_last)
T mapValue(const T &val)
EXTENSION_NOINLINE int32_t ct_require_str(const Column< int32_t > &input1, const TextEncodingNone &s, Column< int32_t > &out)
TEMPLATE_NOINLINE int32_t ct_binding_template__cpu_template(const Column< T > &input, Column< T > &out)
TEMPLATE_NOINLINE int32_t ct_templated_no_cursor_user_constant_sizer__cpu_template(const T input_num, int32_t c, Column< T > &output)
TEMPLATE_NOINLINE int32_t ct_binding_column__cpu_template(const Column< T > &input, Column< int32_t > &out)
std::string getString() const
Definition: OmniSciTypes.h:106
DEVICE int64_t size() const
Definition: OmniSciTypes.h:218
#define TEMPLATE_NOINLINE
Definition: OmniSciTypes.h:30
EXTENSION_NOINLINE int32_t ct_copy_and_add_size(TableFunctionManager &mgr, const Column< int32_t > &input, Column< int32_t > &output)
EXTENSION_NOINLINE int32_t ct_binding_udtf_constant__cpu_9(const ColumnList< int32_t > &input1, const ColumnList< int64_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE 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)
DEVICE int64_t numCols() const
Definition: OmniSciTypes.h:269
DEVICE void sort(ARGS &&...args)
Definition: gpu_enabled.h:105
T * ptr_
Definition: OmniSciTypes.h:199
EXTENSION_NOINLINE 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 int32_t ct_binding_udtf__cpu_11(const Column< int32_t > &input1, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_binding_udtf_constant__cpu_7(const Column< int32_t > &input1, const ColumnList< int32_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_sleep2(TableFunctionManager &mgr, int32_t seconds, int32_t mode, Column< int32_t > &output)
SortAsc(const bool nulls_last)
EXTENSION_NOINLINE 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 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 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)
SortDesc(const bool nulls_last)
TEMPLATE_NOINLINE int32_t ct_get_string_chars__template(const Column< T > &indices, const TextEncodingNone &str, const int32_t multiplier, Column< int32_t > &idx, Column< int8_t > &char_bytes)
DEVICE ALWAYS_INLINE int64_t size() const
Definition: OmniSciTypes.h:113
EXTENSION_NOINLINE 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)
constexpr double a
Definition: Utm.h:38
#define CPU_DEVICE_CODE
#define EXTENSION_NOINLINE
Definition: OmniSciTypes.h:28
EXTENSION_NOINLINE 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)
TEMPLATE_NOINLINE int32_t ct_scalar_1_arg_runtime_sizing__cpu_template(const T num, Column< T > &answer)
EXTENSION_NOINLINE 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)
EXTENSION_NOINLINE int32_t ct_binding_dict_encoded6__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out0, Column< TextEncodingDict > &out1)
TEMPLATE_NOINLINE int32_t ct_binding_column2__cpu_template(const Column< T > &input1, const Column< U > &input2, Column< K > &out)
EXTENSION_NOINLINE int32_t ct_sleep1(int32_t seconds, int32_t mode, Column< int32_t > &output)
T safe_addition(T x, T y)
EXTENSION_NOINLINE int32_t ct_binding_dict_encoded1__cpu_1(const Column< TextEncodingDict > &input, const int32_t multiplier, Column< TextEncodingDict > &out)
EXTENSION_NOINLINE 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_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)
int count
#define GPU_DEVICE_CODE
EXTENSION_NOINLINE 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 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 int32_t ct_binding_dict_encoded4__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out)
EXTENSION_NOINLINE int32_t ct_scalar_2_args_constant_sizing(const int64_t num1, const int64_t num2, Column< int64_t > &answer1, Column< int64_t > &answer2)
EXTENSION_NOINLINE 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 int32_t ct_device_selection_udtf_cpu__cpu_(const Column< int32_t > &input, Column< int64_t > &out)
TEMPLATE_NOINLINE int32_t ct_no_arg_runtime_sizing__cpu_template(Column< T > &answer)
TEMPLATE_NOINLINE int32_t ct_named_rowmul_output__template(const Column< T > &input, int32_t m, Column< T > &out)
EXTENSION_NOINLINE int32_t ct_udtf_default_sizer1a__cpu_1(const Column< int32_t > &input1, const int32_t multiplier, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_no_cursor_user_constant_sizer__cpu_(const int32_t input_num, int32_t c, Column< int32_t > &output)
EXTENSION_NOINLINE void set_output_row_size(int64_t num_rows)
T mapValue(const T &val)
TEMPLATE_NOINLINE int32_t ct_binding_scalar_multiply__cpu_template(const Column< T > &input, const T multiplier, Column< T > &out)
EXTENSION_NOINLINE 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)
EXTENSION_NOINLINE int32_t ct_add_size_and_mul_alpha(TableFunctionManager &mgr, const Column< int32_t > &input1, const Column< int32_t > &input2, int32_t alpha, Column< int32_t > &output1, Column< int32_t > &output2)
bool operator()(const T &a, const T &b)
TEMPLATE_NOINLINE int32_t sort_column_limit__cpu_template(const Column< T > &input, const int32_t limit, const bool sort_ascending, const bool nulls_last, Column< T > &output)
DEVICE bool isNull(int64_t index) const
Definition: OmniSciTypes.h:220
TEMPLATE_NOINLINE int32_t ct_throw_if_gt_100__cpu_template(TableFunctionManager &mgr, const Column< T > &input, Column< T > &output)
EXTENSION_NOINLINE int32_t ct_binding_udtf_constant__cpu_1(const Column< int32_t > &input1, Column< int32_t > &out)
DEVICE void setNull(int64_t index)
Definition: OmniSciTypes.h:221
EXTENSION_NOINLINE 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)
TEMPLATE_NOINLINE int32_t ct_named_output__cpu_template(const Column< T > &input, Column< T > &out)
const T null_value_mapped_
EXTENSION_NOINLINE 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 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 int32_t ct_hamming_distance(const TextEncodingNone &str1, const TextEncodingNone &str2, Column< int32_t > &hamming_distance)
EXTENSION_NOINLINE int32_t ct_binding_udtf_constant__cpu_2(const Column< int32_t > &input1, const Column< int32_t > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_binding_dict_encoded5__cpu_1(const ColumnList< TextEncodingDict > &input, Column< TextEncodingDict > &out)
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_both__cpu_(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE int32_t ct_sleep_worker(int32_t seconds, Column< int32_t > &output)
static T map_null_value(const bool nulls_last)
bool operator()(const T &a, const T &b)
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_any(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE 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_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 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)
TEMPLATE_NOINLINE int32_t ct_binding_columnlist__cpu_template(const Column< T > &input1, const ColumnList< T > &input2, Column< int32_t > &out)
EXTENSION_NOINLINE 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 int32_t ct_device_selection_udtf_both__gpu_(const Column< int32_t > &input, Column< int64_t > &out)
EXTENSION_NOINLINE int32_t ct_require_mgr(TableFunctionManager &mgr, const Column< int32_t > &input1, const int32_t i, Column< int32_t > &out)
EXTENSION_NOINLINE int32_t ct_binding_dict_encoded3__cpu_1(const Column< TextEncodingDict > &input1, const Column< TextEncodingDict > &input2, Column< TextEncodingDict > &out1, Column< TextEncodingDict > &out2)
EXTENSION_NOINLINE int32_t ct_binding_udtf_constant__cpu_8(const ColumnList< int32_t > &input1, const Column< int64_t > &input2, Column< int32_t > &out)
DEVICE int64_t size() const
Definition: OmniSciTypes.h:268
EXTENSION_NOINLINE int32_t ct_device_selection_udtf_gpu__gpu_(const Column< int32_t > &input, Column< int64_t > &out)
static TableFunctionManager * get_singleton()
Definition: OmniSciTypes.h:300
EXTENSION_NOINLINE 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)
TEMPLATE_NOINLINE int32_t ct_named_const_output__template(const Column< T > &input, Column< T > &out)
#define TABLE_FUNCTION_ERROR(MSG)
Definition: OmniSciTypes.h:44
EXTENSION_NOINLINE int32_t ct_no_arg_constant_sizing__cpu_(Column< int32_t > &answer)
int32_t column_list_safe_row_sum__cpu_template(const ColumnList< T > &input, Column< T > &out)
TEMPLATE_NOINLINE int32_t ct_named_user_const_output__template(const Column< T > &input, int32_t c, Column< T > &out)