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

#include <TableFunctionsFactory.h>

+ Collaboration diagram for table_functions::TableFunction:

Public Member Functions

 TableFunction (const std::string &name, const TableFunctionOutputRowSizer output_sizer, const std::vector< ExtArgumentType > &input_args, const std::vector< ExtArgumentType > &output_args, const std::vector< ExtArgumentType > &sql_args, bool is_runtime)
 
std::vector< ExtArgumentTypegetArgs (const bool ensure_column=false) const
 
const std::vector
< ExtArgumentType > & 
getInputArgs () const
 
const std::vector
< ExtArgumentType > & 
getOutputArgs () const
 
const std::vector
< ExtArgumentType > & 
getSqlArgs () const
 
const ExtArgumentType getRet () const
 
SQLTypeInfo getInputSQLType (const size_t idx) const
 
SQLTypeInfo getOutputSQLType (const size_t idx) const
 
int32_t countScalarArgs () const
 
auto getInputsSize () const
 
auto getOutputsSize () const
 
std::string getName (const bool drop_suffix=false, const bool lower=false) const
 
auto getSignature () const
 
bool hasNonUserSpecifiedOutputSizeConstant () const
 
bool hasUserSpecifiedOutputSizeConstant () const
 
bool hasUserSpecifiedOutputSizeMultiplier () const
 
OutputBufferSizeType getOutputRowSizeType () const
 
size_t getOutputRowSizeParameter () const
 
size_t getSqlOutputRowSizeParameter () const
 
size_t getOutputRowSizeParameter (const std::vector< SQLTypeInfo > &variant) const
 
bool isRuntime () const
 
bool isGPU () const
 
bool isCPU () const
 
bool useDefaultSizer () const
 
std::string toString () const
 
std::string toStringSQL () const
 

Private Attributes

const std::string name_
 
const TableFunctionOutputRowSizer output_sizer_
 
const std::vector
< ExtArgumentType
input_args_
 
const std::vector
< ExtArgumentType
output_args_
 
const std::vector
< ExtArgumentType
sql_args_
 
const bool is_runtime_
 

Detailed Description

Definition at line 118 of file TableFunctionsFactory.h.

Constructor & Destructor Documentation

table_functions::TableFunction::TableFunction ( const std::string &  name,
const TableFunctionOutputRowSizer  output_sizer,
const std::vector< ExtArgumentType > &  input_args,
const std::vector< ExtArgumentType > &  output_args,
const std::vector< ExtArgumentType > &  sql_args,
bool  is_runtime 
)
inline

Definition at line 120 of file TableFunctionsFactory.h.

126  : name_(name)
127  , output_sizer_(output_sizer)
128  , input_args_(input_args)
129  , output_args_(output_args)
130  , sql_args_(sql_args)
131  , is_runtime_(is_runtime) {}
const TableFunctionOutputRowSizer output_sizer_
string name
Definition: setup.in.py:72
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
const std::vector< ExtArgumentType > input_args_

Member Function Documentation

int32_t table_functions::TableFunction::countScalarArgs ( ) const

Definition at line 142 of file TableFunctionsFactory.cpp.

References input_args_, and is_ext_arg_type_scalar().

142  {
143  int32_t scalar_args = 0;
144  for (const auto& ext_arg : input_args_) {
145  if (is_ext_arg_type_scalar(ext_arg)) {
146  scalar_args += 1;
147  }
148  }
149  return scalar_args;
150 }
bool is_ext_arg_type_scalar(const ExtArgumentType ext_arg_type)
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

std::vector<ExtArgumentType> table_functions::TableFunction::getArgs ( const bool  ensure_column = false) const
inline

Definition at line 133 of file TableFunctionsFactory.h.

References run_benchmark_import::args, ext_arg_type_ensure_column(), input_args_, output_args_, and t.

133  {
134  std::vector<ExtArgumentType> args;
135  args.insert(args.end(), input_args_.begin(), input_args_.end());
136  if (ensure_column) {
137  // map row dtype to column type
138  std::for_each(output_args_.begin(), output_args_.end(), [&args](auto t) {
139  args.push_back(ext_arg_type_ensure_column(t));
140  });
141  } else {
142  args.insert(args.end(), output_args_.begin(), output_args_.end());
143  }
144  return args;
145  }
const std::vector< ExtArgumentType > output_args_
ExtArgumentType ext_arg_type_ensure_column(const ExtArgumentType ext_arg_type)
char * t
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

const std::vector<ExtArgumentType>& table_functions::TableFunction::getInputArgs ( ) const
inline

Definition at line 146 of file TableFunctionsFactory.h.

References input_args_.

Referenced by ThriftSerializers::to_thrift().

146 { return input_args_; }
const std::vector< ExtArgumentType > input_args_

+ Here is the caller graph for this function:

SQLTypeInfo table_functions::TableFunction::getInputSQLType ( const size_t  idx) const

Definition at line 131 of file TableFunctionsFactory.cpp.

References CHECK_LT, table_functions::anonymous_namespace{TableFunctionsFactory.cpp}::ext_arg_pointer_type_to_type_info(), and input_args_.

131  {
132  CHECK_LT(idx, input_args_.size());
134 }
SQLTypeInfo ext_arg_pointer_type_to_type_info(const ExtArgumentType ext_arg_type)
#define CHECK_LT(x, y)
Definition: Logger.h:213
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

auto table_functions::TableFunction::getInputsSize ( ) const
inline

Definition at line 156 of file TableFunctionsFactory.h.

References input_args_.

156 { return input_args_.size(); }
const std::vector< ExtArgumentType > input_args_
std::string table_functions::TableFunction::getName ( const bool  drop_suffix = false,
const bool  lower = false 
) const

Definition at line 289 of file TableFunctionsFactory.cpp.

References table_functions::anonymous_namespace{TableFunctionsFactory.cpp}::drop_suffix_impl(), name_, run_benchmark_import::result, and to_lower().

Referenced by TableFunctionCompilationContext::generateEntryPoint(), getSignature(), and ThriftSerializers::to_thrift().

289  {
290  std::string result = name_;
291  if (drop_suffix) {
292  result = drop_suffix_impl(result);
293  }
294  if (lower) {
296  }
297  return result;
298 }
std::string to_lower(const std::string &str)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::vector<ExtArgumentType>& table_functions::TableFunction::getOutputArgs ( ) const
inline

Definition at line 147 of file TableFunctionsFactory.h.

References output_args_.

Referenced by ThriftSerializers::to_thrift().

147 { return output_args_; }
const std::vector< ExtArgumentType > output_args_

+ Here is the caller graph for this function:

size_t table_functions::TableFunction::getOutputRowSizeParameter ( ) const
inline

Definition at line 180 of file TableFunctionsFactory.h.

References output_sizer_, and table_functions::TableFunctionOutputRowSizer::val.

Referenced by getSqlOutputRowSizeParameter(), and ThriftSerializers::to_thrift().

+ Here is the caller graph for this function:

size_t table_functions::TableFunction::getOutputRowSizeParameter ( const std::vector< SQLTypeInfo > &  variant) const
inline

Definition at line 184 of file TableFunctionsFactory.h.

References hasUserSpecifiedOutputSizeMultiplier(), output_sizer_, and table_functions::TableFunctionOutputRowSizer::val.

184  {
185  auto val = output_sizer_.val;
187  size_t col_index = 0;
188  size_t func_arg_index = 0;
189  for (const auto& ti : variant) {
190  func_arg_index++;
191  if (ti.is_column_list()) {
192  col_index += ti.get_dimension();
193  } else {
194  col_index++;
195  }
196  if (func_arg_index == val) {
197  val = col_index;
198  break;
199  }
200  }
201  }
202  return val;
203  }
const TableFunctionOutputRowSizer output_sizer_

+ Here is the call graph for this function:

OutputBufferSizeType table_functions::TableFunction::getOutputRowSizeType ( ) const
inline

Definition at line 178 of file TableFunctionsFactory.h.

References output_sizer_.

Referenced by anonymous_namespace{TableFunctionExecutionContext.cpp}::get_output_row_count(), and ThriftSerializers::to_thrift().

178 { return output_sizer_.type; }
const TableFunctionOutputRowSizer output_sizer_

+ Here is the caller graph for this function:

SQLTypeInfo table_functions::TableFunction::getOutputSQLType ( const size_t  idx) const

Definition at line 136 of file TableFunctionsFactory.cpp.

References CHECK_LT, table_functions::anonymous_namespace{TableFunctionsFactory.cpp}::ext_arg_type_to_type_info_output(), and output_args_.

136  {
137  CHECK_LT(idx, output_args_.size());
138  // TODO(adb): conditionally handle nulls
140 }
SQLTypeInfo ext_arg_type_to_type_info_output(const ExtArgumentType ext_arg_type)
const std::vector< ExtArgumentType > output_args_
#define CHECK_LT(x, y)
Definition: Logger.h:213

+ Here is the call graph for this function:

auto table_functions::TableFunction::getOutputsSize ( ) const
inline

Definition at line 157 of file TableFunctionsFactory.h.

References output_args_.

157 { return output_args_.size(); }
const std::vector< ExtArgumentType > output_args_
const ExtArgumentType table_functions::TableFunction::getRet ( ) const
inline

Definition at line 149 of file TableFunctionsFactory.h.

References Int32.

auto table_functions::TableFunction::getSignature ( ) const
inline

Definition at line 161 of file TableFunctionsFactory.h.

References getName(), input_args_, and ExtensionFunctionsWhitelist::toString().

161  {
162  return getName(/*drop_suffix=*/true, /*lower=*/true) + "(" +
164  }
std::string getName(const bool drop_suffix=false, const bool lower=false) const
static std::string toString(const std::vector< ExtensionFunction > &ext_funcs, std::string tab="")
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

const std::vector<ExtArgumentType>& table_functions::TableFunction::getSqlArgs ( ) const
inline

Definition at line 148 of file TableFunctionsFactory.h.

References sql_args_.

Referenced by ThriftSerializers::to_thrift().

148 { return sql_args_; }
const std::vector< ExtArgumentType > sql_args_

+ Here is the caller graph for this function:

size_t table_functions::TableFunction::getSqlOutputRowSizeParameter ( ) const

Definition at line 152 of file TableFunctionsFactory.cpp.

References CHECK, getOutputRowSizeParameter(), hasUserSpecifiedOutputSizeMultiplier(), input_args_, is_ext_arg_type_nonscalar(), is_ext_arg_type_scalar(), generate_TableFunctionsFactory_init::sizer, and sql_args_.

152  {
153  /*
154  This function differs from getOutputRowSizeParameter() since it returns the correct
155  index for the sizer in the sql_args list. For instance, consider the example below:
156 
157  RowMultiplier=4
158  input_args=[{i32*, i64}, {i32*, i64}, {i32*, i64}, i32, {i32*, i64}, {i32*, i64},
159  i32] sql_args=[cursor, i32, cursor, i32]
160 
161  Non-scalar args are aggregated in a cursor inside the sql_args list and the new
162  sizer index is 2 rather than 4 originally specified.
163  */
164 
166  size_t sizer = getOutputRowSizeParameter(); // lookup until reach the sizer arg
167  int32_t ext_arg_index = 0, sql_arg_index = 0;
168 
169  auto same_kind = [&](const ExtArgumentType& ext_arg, const ExtArgumentType& sql_arg) {
170  return ((is_ext_arg_type_scalar(ext_arg) && is_ext_arg_type_scalar(sql_arg)) ||
172  };
173 
174  while ((size_t)ext_arg_index < sizer) {
175  if ((size_t)ext_arg_index == sizer - 1)
176  return sql_arg_index;
177 
178  const auto& ext_arg = input_args_[ext_arg_index];
179  const auto& sql_arg = sql_args_[sql_arg_index];
180 
181  if (same_kind(ext_arg, sql_arg)) {
182  ++ext_arg_index;
183  ++sql_arg_index;
184  } else {
185  CHECK(same_kind(ext_arg, sql_args_[sql_arg_index - 1]));
186  ext_arg_index += 1;
187  }
188  }
189 
190  CHECK(false);
191  }
192 
193  return getOutputRowSizeParameter();
194 }
bool is_ext_arg_type_scalar(const ExtArgumentType ext_arg_type)
bool is_ext_arg_type_nonscalar(const ExtArgumentType ext_arg_type)
const std::vector< ExtArgumentType > sql_args_
#define CHECK(condition)
Definition: Logger.h:203
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

bool table_functions::TableFunction::hasNonUserSpecifiedOutputSizeConstant ( ) const
inline
bool table_functions::TableFunction::hasUserSpecifiedOutputSizeConstant ( ) const
inline
bool table_functions::TableFunction::hasUserSpecifiedOutputSizeMultiplier ( ) const
inline

Definition at line 174 of file TableFunctionsFactory.h.

References table_functions::kUserSpecifiedRowMultiplier, and output_sizer_.

Referenced by getOutputRowSizeParameter(), and getSqlOutputRowSizeParameter().

+ Here is the caller graph for this function:

bool table_functions::TableFunction::isCPU ( ) const
inline

Definition at line 211 of file TableFunctionsFactory.h.

References name_.

211  {
212  return (name_.find("_gpu_", name_.find("__")) == std::string::npos);
213  }
bool table_functions::TableFunction::isGPU ( ) const
inline

Definition at line 207 of file TableFunctionsFactory.h.

References name_.

207  {
208  return (name_.find("_cpu_", name_.find("__")) == std::string::npos);
209  }
bool table_functions::TableFunction::isRuntime ( ) const
inline

Definition at line 205 of file TableFunctionsFactory.h.

References is_runtime_.

Referenced by TableFunctionCompilationContext::generateEntryPoint().

205 { return is_runtime_; }

+ Here is the caller graph for this function:

std::string table_functions::TableFunction::toString ( ) const
inline

Definition at line 220 of file TableFunctionsFactory.h.

References input_args_, is_runtime_, name_, output_args_, output_sizer_, run_benchmark_import::result, sql_args_, and ExtensionFunctionsWhitelist::toString().

220  {
221  auto result = "TableFunction(" + name_ + ", input_args=[";
223  result += "], output_args=[";
225  result += "], sql_args=[";
227  result += "], is_runtime=" + std::string((is_runtime_ ? "true" : "false"));
228  result += ", sizer=" + ::toString(output_sizer_);
229  result += ")";
230  return result;
231  }
const TableFunctionOutputRowSizer output_sizer_
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
static std::string toString(const std::vector< ExtensionFunction > &ext_funcs, std::string tab="")
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

std::string table_functions::TableFunction::toStringSQL ( ) const
inline

Definition at line 233 of file TableFunctionsFactory.h.

References input_args_, name_, output_args_, run_benchmark_import::result, and ExtensionFunctionsWhitelist::toStringSQL().

233  {
234  auto result = name_ + "(";
236  result += ") -> (";
238  result += ")";
239  return result;
240  }
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > input_args_
static std::string toStringSQL(const std::vector< ExtArgumentType > &sig_types)

+ Here is the call graph for this function:

bool table_functions::TableFunction::useDefaultSizer ( ) const
inline

Definition at line 215 of file TableFunctionsFactory.h.

References name_.

215  {
216  // Functions that use a default sizer value have one less argument
217  return (name_.find("_default_", name_.find("__")) != std::string::npos);
218  }

Member Data Documentation

const std::vector<ExtArgumentType> table_functions::TableFunction::input_args_
private
const bool table_functions::TableFunction::is_runtime_
private

Definition at line 248 of file TableFunctionsFactory.h.

Referenced by isRuntime(), and toString().

const std::string table_functions::TableFunction::name_
private

Definition at line 243 of file TableFunctionsFactory.h.

Referenced by getName(), isCPU(), isGPU(), toString(), toStringSQL(), and useDefaultSizer().

const std::vector<ExtArgumentType> table_functions::TableFunction::output_args_
private
const std::vector<ExtArgumentType> table_functions::TableFunction::sql_args_
private

Definition at line 247 of file TableFunctionsFactory.h.

Referenced by getSqlArgs(), getSqlOutputRowSizeParameter(), and toString().


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