OmniSciDB  471d68cefb
 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 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 int32_t get_max_with_row_offset (const Column< int > &input_col, Column< int > &output_max_col, Column< int > &output_max_row_col)
 
EXTENSION_NOINLINE 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 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 262 of file TableFunctions.hpp.

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

265  {
266  col1 = col_list[0];
267  col2 = col_list[col_list.numCols() - 1];
268  return col1.size();
269 }
DEVICE int64_t size() const
Definition: OmniSciTypes.h:218
DEVICE int64_t numCols() const
Definition: OmniSciTypes.h:269

+ Here is the call graph for this function:

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

Definition at line 248 of file TableFunctions.hpp.

References Column< T >::size().

251  {
252  col = col_list[index]; // copy the data of col_list item to output column
253  return col.size();
254 }
DEVICE int64_t size() const
Definition: OmniSciTypes.h:218

+ Here is the call graph for this function:

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

Definition at line 277 of file TableFunctions.hpp.

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

278  {
279  int32_t output_num_rows = input.numCols();
280  set_output_row_size(output_num_rows);
281  for (int i = 0; i < output_num_rows; i++) {
282  auto col = input[i];
283  int32_t s = 0;
284  for (int j = 0; j < col.size(); j++) {
285  s += col[j];
286  }
287  out[i] = s;
288  }
289  return output_num_rows;
290 }
DEVICE int64_t numCols() const
Definition: OmniSciTypes.h:269
EXTENSION_NOINLINE void set_output_row_size(int64_t num_rows)

+ Here is the call graph for this function:

EXTENSION_NOINLINE int32_t get_max_with_row_offset ( const Column< int > &  input_col,
Column< int > &  output_max_col,
Column< int > &  output_max_row_col 
)

Definition at line 214 of file TableFunctions.hpp.

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

216  {
217  if ((output_max_col.size() != 1) || output_max_row_col.size() != 1) {
218  return -1;
219  }
220 #ifdef __CUDACC__
221  int32_t start = threadIdx.x + blockDim.x * blockIdx.x;
222  int32_t stop = static_cast<int32_t>(input_col.size());
223  int32_t step = blockDim.x * gridDim.x;
224 #else
225  auto start = 0;
226  auto stop = input_col.size();
227  auto step = 1;
228 #endif
229 
230  int curr_max = -2147483648;
231  int curr_max_row = -1;
232  for (auto i = start; i < stop; i += step) {
233  if (input_col[i] > curr_max) {
234  curr_max = input_col[i];
235  curr_max_row = i;
236  }
237  }
238  output_max_col[0] = curr_max;
239  output_max_row_col[0] = curr_max_row;
240  return 1;
241 }
DEVICE int64_t size() const
Definition: OmniSciTypes.h:218

+ 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 134 of file TableFunctions.hpp.

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

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

+ 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 175 of file TableFunctions.hpp.

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

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

+ 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 i, and 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: OmniSciTypes.h:218

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 59 of file TableFunctions.hpp.

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

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

+ 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 100 of file TableFunctions.hpp.

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

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

+ Here is the call graph for this function: