OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TableFunctions.hpp File Reference
+ Include dependency graph for TableFunctions.hpp:

Go to the source code of this file.

Functions

EXTENSION_NOINLINE int32_t row_copier (const Column< double > &input_col, int copy_multiplier, Column< double > &output_col)
 
EXTENSION_NOINLINE_HOST int32_t row_copier2__cpu__ (const Column< double > &input_col, int copy_multiplier, Column< double > &output_col, Column< double > &output_col2)
 
EXTENSION_NOINLINE int32_t row_copier_text (const Column< TextEncodingDict > &input_col, int copy_multiplier, Column< TextEncodingDict > &output_col)
 
EXTENSION_NOINLINE int32_t row_adder (const int copy_multiplier, const Column< double > &input_col1, const Column< double > &input_col2, Column< double > &output_col)
 
EXTENSION_NOINLINE int32_t row_addsub (const int copy_multiplier, const Column< double > &input_col1, const Column< double > &input_col2, Column< double > &output_col1, Column< double > &output_col2)
 
EXTENSION_NOINLINE_HOST int32_t get_max_with_row_offset__cpu_ (const Column< int > &input_col, Column< int > &output_max_col, Column< int > &output_max_row_col)
 
EXTENSION_NOINLINE_HOST int32_t column_list_get__cpu_ (const ColumnList< double > &col_list, const int index, const int m, Column< double > &col)
 
EXTENSION_NOINLINE int32_t column_list_first_last (const ColumnList< double > &col_list, const int m, Column< double > &col1, Column< double > &col2)
 
EXTENSION_NOINLINE_HOST int32_t column_list_row_sum__cpu_ (const ColumnList< int32_t > &input, Column< int32_t > &out)
 

Function Documentation

EXTENSION_NOINLINE int32_t column_list_first_last ( const ColumnList< double > &  col_list,
const int  m,
Column< double > &  col1,
Column< double > &  col2 
)

Definition at line 271 of file TableFunctions.hpp.

References ColumnList< T >::numCols(), and Column< T >::size().

274  {
275  col1 = col_list[0];
276  col2 = col_list[col_list.numCols() - 1];
277  return col1.size();
278 }
DEVICE int64_t size() const
Definition: heavydbTypes.h:445
DEVICE int64_t numCols() const
Definition: heavydbTypes.h:567

+ Here is the call graph for this function:

EXTENSION_NOINLINE_HOST int32_t column_list_get__cpu_ ( const ColumnList< double > &  col_list,
const int  index,
const int  m,
Column< double > &  col 
)

Definition at line 255 of file TableFunctions.hpp.

References Column< T >::size().

258  {
259  col = col_list[index]; // copy the data of col_list item to output column
260  return col.size();
261 }
DEVICE int64_t size() const
Definition: heavydbTypes.h:445

+ Here is the call graph for this function:

EXTENSION_NOINLINE_HOST int32_t column_list_row_sum__cpu_ ( const ColumnList< int32_t > &  input,
Column< int32_t > &  out 
)

Definition at line 289 of file TableFunctions.hpp.

References ColumnList< T >::numCols(), and set_output_row_size().

289  {
290  int32_t output_num_rows = input.numCols();
291  set_output_row_size(output_num_rows);
292  for (int i = 0; i < output_num_rows; i++) {
293  auto col = input[i];
294  int32_t s = 0;
295  for (int j = 0; j < col.size(); j++) {
296  s += col[j];
297  }
298  out[i] = s;
299  }
300  return output_num_rows;
301 }
EXTENSION_NOINLINE_HOST void set_output_row_size(int64_t num_rows)
DEVICE int64_t numCols() const
Definition: heavydbTypes.h:567

+ Here is the call graph for this function:

EXTENSION_NOINLINE_HOST int32_t get_max_with_row_offset__cpu_ ( const Column< int > &  input_col,
Column< int > &  output_max_col,
Column< int > &  output_max_row_col 
)

Definition at line 222 of file TableFunctions.hpp.

References Column< T >::size().

224  {
225  if ((output_max_col.size() != 1) || output_max_row_col.size() != 1) {
226  return -1;
227  }
228  auto start = 0;
229  auto stop = input_col.size();
230  auto step = 1;
231 
232  int curr_max = -2147483648;
233  int curr_max_row = -1;
234  for (auto i = start; i < stop; i += step) {
235  if (input_col[i] > curr_max) {
236  curr_max = input_col[i];
237  curr_max_row = i;
238  }
239  }
240  output_max_col[0] = curr_max;
241  output_max_row_col[0] = curr_max_row;
242  return 1;
243 }
DEVICE int64_t size() const
Definition: heavydbTypes.h:445

+ Here is the call graph for this function:

EXTENSION_NOINLINE int32_t row_adder ( const int  copy_multiplier,
const Column< double > &  input_col1,
const Column< double > &  input_col2,
Column< double > &  output_col 
)

Definition at line 138 of file TableFunctions.hpp.

References Column< T >::isNull(), Column< T >::setNull(), and Column< T >::size().

141  {
142  int32_t output_row_count = copy_multiplier * input_col1.size();
143  if (output_row_count > 100) {
144  // Test failure propagation.
145  return -1;
146  }
147  if (output_col.size() != output_row_count) {
148  return -1;
149  }
150 
151 #ifdef __CUDACC__
152  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
153  int32_t stop = static_cast<int32_t>(input_col1.size());
154  int32_t step = blockDim.x * gridDim.x;
155 #else
156  auto start = 0;
157  auto stop = input_col1.size();
158  auto step = 1;
159 #endif
160  auto stride = input_col1.size();
161  for (auto i = start; i < stop; i += step) {
162  for (int c = 0; c < copy_multiplier; c++) {
163  if (input_col1.isNull(i) || input_col2.isNull(i)) {
164  output_col.setNull(i + (c * stride));
165  } else {
166  output_col[i + (c * stride)] = input_col1[i] + input_col2[i];
167  }
168  }
169  }
170 
171  return output_row_count;
172 }
DEVICE int64_t size() const
Definition: heavydbTypes.h:445
DEVICE bool isNull(int64_t index) const
Definition: heavydbTypes.h:447
DEVICE void setNull(int64_t index)
Definition: heavydbTypes.h:448

+ Here is the call graph for this function:

EXTENSION_NOINLINE int32_t row_addsub ( const int  copy_multiplier,
const Column< double > &  input_col1,
const Column< double > &  input_col2,
Column< double > &  output_col1,
Column< double > &  output_col2 
)

Definition at line 179 of file TableFunctions.hpp.

References Column< T >::size().

183  {
184  int32_t output_row_count = copy_multiplier * input_col1.size();
185  if (output_row_count > 100) {
186  // Test failure propagation.
187  return -1;
188  }
189  if ((output_col1.size() != output_row_count) ||
190  (output_col2.size() != output_row_count)) {
191  return -1;
192  }
193 
194 #ifdef __CUDACC__
195  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
196  int32_t stop = static_cast<int32_t>(input_col1.size());
197  int32_t step = blockDim.x * gridDim.x;
198 #else
199  auto start = 0;
200  auto stop = input_col1.size();
201  auto step = 1;
202 #endif
203  auto stride = input_col1.size();
204  for (auto i = start; i < stop; i += step) {
205  for (int c = 0; c < copy_multiplier; c++) {
206  output_col1[i + (c * stride)] = input_col1[i] + input_col2[i];
207  output_col2[i + (c * stride)] = input_col1[i] - input_col2[i];
208  }
209  }
210  return output_row_count;
211 }
DEVICE int64_t size() const
Definition: heavydbTypes.h:445

+ Here is the call graph for this function:

EXTENSION_NOINLINE int32_t row_copier ( const Column< double > &  input_col,
int  copy_multiplier,
Column< double > &  output_col 
)

Definition at line 28 of file TableFunctions.hpp.

References Column< T >::size().

Referenced by row_copier2__cpu__().

30  {
31  int32_t output_row_count = copy_multiplier * input_col.size();
32  if (output_row_count > 100) {
33  // Test failure propagation.
34  return -1;
35  }
36  if (output_col.size() != output_row_count) {
37  return -1;
38  }
39 
40 #ifdef __CUDACC__
41  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
42  int32_t stop = static_cast<int32_t>(input_col.size());
43  int32_t step = blockDim.x * gridDim.x;
44 #else
45  auto start = 0;
46  auto stop = input_col.size();
47  auto step = 1;
48 #endif
49 
50  for (auto i = start; i < stop; i += step) {
51  for (int c = 0; c < copy_multiplier; c++) {
52  output_col[i + (c * input_col.size())] = input_col[i];
53  }
54  }
55 
56  return output_row_count;
57 }
DEVICE int64_t size() const
Definition: heavydbTypes.h:445

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE_HOST int32_t row_copier2__cpu__ ( const Column< double > &  input_col,
int  copy_multiplier,
Column< double > &  output_col,
Column< double > &  output_col2 
)

Definition at line 61 of file TableFunctions.hpp.

References run_benchmark_import::result, row_copier(), set_output_row_size(), and Column< T >::size().

64  {
65  if (copy_multiplier == -1) {
66  // Test UDTF return without allocating output columns, expect
67  // empty output columns.
68  return 0;
69  }
70  if (copy_multiplier == -2) {
71  // Test UDTF return without allocating output columns but
72  // returning positive row size, expect runtime error.
73  return 1;
74  }
75 #ifndef __CUDACC__
76  if (copy_multiplier == -3) {
77  // Test UDTF throw before allocating output columns, expect
78  // runtime error.
79  throw std::runtime_error("row_copier2: throw before calling set_output_row_size");
80  }
81  if (copy_multiplier == -4) {
82  // Test UDTF throw after allocating output columns, expect
83  // runtime error.
85  throw std::runtime_error("row_copier2: throw after calling set_output_row_size");
86  }
87 #endif
88  if (copy_multiplier == -5) {
89  // Test UDTF setting negative row size, expect runtime error.
91  }
92  int32_t output_row_count = copy_multiplier * input_col.size();
93  /* set_output_row_size can be used only when an UDTF is executed on CPU */
94  set_output_row_size(output_row_count);
95  auto result = row_copier(input_col, copy_multiplier, output_col);
96  if (result >= 0) {
97  result = row_copier(input_col, copy_multiplier, output_col2);
98  }
99  return result;
100 }
EXTENSION_NOINLINE_HOST void set_output_row_size(int64_t num_rows)
DEVICE int64_t size() const
Definition: heavydbTypes.h:445
EXTENSION_NOINLINE int32_t row_copier(const Column< double > &input_col, int copy_multiplier, Column< double > &output_col)

+ Here is the call graph for this function:

EXTENSION_NOINLINE int32_t row_copier_text ( const Column< TextEncodingDict > &  input_col,
int  copy_multiplier,
Column< TextEncodingDict > &  output_col 
)

Definition at line 104 of file TableFunctions.hpp.

References Column< TextEncodingDict >::size().

106  {
107  int32_t output_row_count = copy_multiplier * input_col.size();
108  if (output_row_count > 100) {
109  // Test failure propagation.
110  return -1;
111  }
112  if (output_col.size() != output_row_count) {
113  return -2;
114  }
115 
116 #ifdef __CUDACC__
117  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
118  int32_t stop = static_cast<int32_t>(input_col.size());
119  int32_t step = blockDim.x * gridDim.x;
120 #else
121  auto start = 0;
122  auto stop = input_col.size();
123  auto step = 1;
124 #endif
125 
126  for (auto i = start; i < stop; i += step) {
127  for (int c = 0; c < copy_multiplier; c++) {
128  output_col[i + (c * input_col.size())] = input_col[i];
129  }
130  }
131 
132  return output_row_count;
133 }
DEVICE int64_t size() const
Definition: heavydbTypes.h:498

+ Here is the call graph for this function: