OmniSciDB  fe05a0c208
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
table_functions::TableFunctionsFactory Class Reference

#include <TableFunctionsFactory.h>

Static Public Member Functions

static void add (const std::string &name, const TableFunctionOutputRowSizer sizer, const std::vector< ExtArgumentType > &input_args, const std::vector< ExtArgumentType > &output_args, const std::vector< ExtArgumentType > &sql_args, bool is_runtime=false)
 
static std::vector< TableFunctionget_table_funcs (const std::string &name, const bool is_gpu)
 
static std::vector< TableFunctionget_table_funcs (const bool is_runtime=false)
 
static void init ()
 
static void reset ()
 

Static Private Attributes

static std::unordered_map
< std::string, TableFunction
functions_
 

Friends

class ::ExtensionFunctionsWhitelist
 

Detailed Description

Definition at line 251 of file TableFunctionsFactory.h.

Member Function Documentation

void table_functions::TableFunctionsFactory::add ( const std::string &  name,
const TableFunctionOutputRowSizer  sizer,
const std::vector< ExtArgumentType > &  input_args,
const std::vector< ExtArgumentType > &  output_args,
const std::vector< ExtArgumentType > &  sql_args,
bool  is_runtime = false 
)
static

Definition at line 196 of file TableFunctionsFactory.cpp.

References DEFAULT_ROW_MULTIPLIER_SUFFIX, functions_, table_functions::kUserSpecifiedRowMultiplier, LOG, setup::name, table_functions::TableFunctionOutputRowSizer::val, and logger::WARNING.

Referenced by DBHandler::register_runtime_extension_functions().

201  {
202  auto tf = TableFunction(name, sizer, input_args, output_args, sql_args, is_runtime);
203  auto sig = tf.getSignature();
204  for (auto it = functions_.begin(); it != functions_.end();) {
205  if (it->second.getName() == name) {
206  if (it->second.isRuntime()) {
207  LOG(WARNING)
208  << "Overriding existing run-time table function (reset not called?): "
209  << name;
210  it = functions_.erase(it);
211  } else {
212  throw std::runtime_error("Will not override existing load-time table function: " +
213  name);
214  }
215  } else {
216  if (sig == it->second.getSignature() &&
217  ((tf.isCPU() && it->second.isCPU()) || (tf.isGPU() && it->second.isGPU()))) {
218  LOG(WARNING)
219  << "The existing (1) and added (2) table functions have the same signature `"
220  << sig << "`:\n"
221  << " 1: " << it->second.toString() << "\n 2: " << tf.toString() << "\n";
222  }
223  ++it;
224  }
225  }
226 
227  functions_.emplace(name, tf);
229  auto input_args2 = input_args;
230  input_args2.erase(input_args2.begin() + sizer.val - 1);
231 
232  auto sql_args2 = sql_args;
233  auto sql_sizer_pos = tf.getSqlOutputRowSizeParameter();
234  sql_args2.erase(sql_args2.begin() + sql_sizer_pos);
235 
236  auto tf2 = TableFunction(name + DEFAULT_ROW_MULTIPLIER_SUFFIX,
237  sizer,
238  input_args2,
239  output_args,
240  sql_args2,
241  is_runtime);
242  auto sig = tf2.getSignature();
243  for (auto it = functions_.begin(); it != functions_.end();) {
244  if (sig == it->second.getSignature() &&
245  ((tf2.isCPU() && it->second.isCPU()) || (tf2.isGPU() && it->second.isGPU()))) {
246  LOG(WARNING)
247  << "The existing (1) and added (2) table functions have the same signature `"
248  << sig << "`:\n"
249  << " 1: " << it->second.toString() << "\n 2: " << tf2.toString() << "\n";
250  }
251  ++it;
252  }
254  }
255 }
#define LOG(tag)
Definition: Logger.h:194
string name
Definition: setup.in.py:72
#define DEFAULT_ROW_MULTIPLIER_SUFFIX
static std::unordered_map< std::string, TableFunction > functions_

+ Here is the caller graph for this function:

std::vector< TableFunction > table_functions::TableFunctionsFactory::get_table_funcs ( const std::string &  name,
const bool  is_gpu 
)
static

Definition at line 300 of file TableFunctionsFactory.cpp.

References table_functions::anonymous_namespace{TableFunctionsFactory.cpp}::drop_suffix_impl(), functions_, setup::name, and to_lower().

Referenced by bind_table_function(), DBHandler::initialize(), and QueryRunner::QueryRunner::QueryRunner().

301  {
302  std::vector<TableFunction> table_funcs;
303  auto table_func_name = name;
304  boost::algorithm::to_lower(table_func_name);
305  for (const auto& pair : functions_) {
306  auto fname = drop_suffix_impl(pair.first);
307  if (fname == table_func_name &&
308  (is_gpu ? pair.second.isGPU() : pair.second.isCPU())) {
309  table_funcs.push_back(pair.second);
310  }
311  }
312  return table_funcs;
313 }
std::string to_lower(const std::string &str)
string name
Definition: setup.in.py:72
static std::unordered_map< std::string, TableFunction > functions_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< TableFunction > table_functions::TableFunctionsFactory::get_table_funcs ( const bool  is_runtime = false)
static

Definition at line 315 of file TableFunctionsFactory.cpp.

References functions_.

315  {
316  std::vector<TableFunction> table_funcs;
317  for (const auto& pair : functions_) {
318  if (pair.second.isRuntime() == is_runtime) {
319  table_funcs.push_back(pair.second);
320  }
321  }
322  return table_funcs;
323 }
static std::unordered_map< std::string, TableFunction > functions_
static void table_functions::TableFunctionsFactory::init ( )
static

Referenced by DBHandler::initialize(), and QueryRunner::QueryRunner::QueryRunner().

+ Here is the caller graph for this function:

void table_functions::TableFunctionsFactory::reset ( )
static

Definition at line 263 of file TableFunctionsFactory.cpp.

References functions_, and g_enable_table_functions.

Referenced by DBHandler::register_runtime_extension_functions().

263  {
265  return;
266  }
267  for (auto it = functions_.begin(); it != functions_.end();) {
268  if (it->second.isRuntime()) {
269  it = functions_.erase(it);
270  } else {
271  ++it;
272  }
273  }
274 }
static std::unordered_map< std::string, TableFunction > functions_
bool g_enable_table_functions
Definition: Execute.cpp:104

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class ::ExtensionFunctionsWhitelist
friend

Definition at line 269 of file TableFunctionsFactory.h.

Member Data Documentation

std::unordered_map< std::string, TableFunction > table_functions::TableFunctionsFactory::functions_
staticprivate

The documentation for this class was generated from the following files: