OmniSciDB  91042dcc5b
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UtilityTableFunctions.cpp File Reference
#include <string>
#include "UtilityTableFunctions.h"
+ Include dependency graph for UtilityTableFunctions.cpp:

Go to the source code of this file.

Functions

EXTENSION_NOINLINE int32_t generate_series_parallel (const int64_t start, const int64_t stop, const int64_t step, Column< int64_t > &series_output)
 
EXTENSION_NOINLINE int32_t generate_series__cpu_1 (TableFunctionManager &mgr, const int64_t start, const int64_t stop, const int64_t step, Column< int64_t > &series_output)
 
EXTENSION_NOINLINE int32_t generate_series__cpu_2 (TableFunctionManager &mgr, const int64_t start, const int64_t stop, Column< int64_t > &series_output)
 

Function Documentation

EXTENSION_NOINLINE int32_t generate_series__cpu_1 ( TableFunctionManager mgr,
const int64_t  start,
const int64_t  stop,
const int64_t  step,
Column< int64_t > &  series_output 
)

Definition at line 57 of file UtilityTableFunctions.cpp.

References generate_series_parallel(), TableFunctionManager::set_output_row_size(), and to_string().

Referenced by generate_series__cpu_2().

61  {
62  const int64_t MAX_ROWS{1L << 30};
63  const int64_t PARALLEL_THRESHOLD{10000L};
64  const int64_t num_rows = ((stop - start) / step) + 1;
65  if (num_rows <= 0) {
66  mgr.set_output_row_size(0);
67  return 0;
68  }
69  mgr.set_output_row_size(num_rows);
70 
71  if (num_rows > MAX_ROWS) {
72  return mgr.ERROR_MESSAGE(
73  "Invocation of generate_series would result in " + std::to_string(num_rows) +
74  " rows, which exceeds the max limit of " + std::to_string(MAX_ROWS) + " rows.");
75  }
76 
77 #ifdef HAVE_TBB
78  if (num_rows > PARALLEL_THRESHOLD) {
79  return generate_series_parallel(start, stop, step, series_output);
80  }
81 #endif
82 
83  for (int64_t out_idx = 0; out_idx != num_rows; ++out_idx) {
84  series_output[out_idx] = start + out_idx * step;
85  }
86  return num_rows;
87 }
void set_output_row_size(int64_t num_rows)
Definition: OmniSciTypes.h:334
EXTENSION_NOINLINE int32_t generate_series_parallel(const int64_t start, const int64_t stop, const int64_t step, Column< int64_t > &series_output)
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE int32_t generate_series__cpu_2 ( TableFunctionManager mgr,
const int64_t  start,
const int64_t  stop,
Column< int64_t > &  series_output 
)

Definition at line 95 of file UtilityTableFunctions.cpp.

References generate_series__cpu_1().

98  {
99  return generate_series__cpu_1(mgr, start, stop, 1, series_output);
100 }
EXTENSION_NOINLINE int32_t generate_series__cpu_1(TableFunctionManager &mgr, const int64_t start, const int64_t stop, const int64_t step, Column< int64_t > &series_output)

+ Here is the call graph for this function:

EXTENSION_NOINLINE int32_t generate_series_parallel ( const int64_t  start,
const int64_t  stop,
const int64_t  step,
Column< int64_t > &  series_output 
)

Definition at line 33 of file UtilityTableFunctions.cpp.

References threading_serial::parallel_for().

Referenced by generate_series__cpu_1().

36  {
37  const int64_t num_rows = ((stop - start) / step) + 1;
38 
39  tbb::parallel_for(tbb::blocked_range<int64_t>(0, num_rows),
40  [&](const tbb::blocked_range<int64_t>& r) {
41  const int64_t start_out_idx = r.begin();
42  const int64_t end_out_idx = r.end();
43  for (int64_t out_idx = start_out_idx; out_idx != end_out_idx;
44  ++out_idx) {
45  series_output[out_idx] = start + out_idx * step;
46  }
47  });
48  return num_rows;
49 }
void parallel_for(const blocked_range< Int > &range, const Body &body, const Partitioner &p=Partitioner())

+ Here is the call graph for this function:

+ Here is the caller graph for this function: