OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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, const std::vector< std::map< std::string, std::string >> &annotations, bool is_runtime, bool uses_manager)
 
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 std::vector< std::map
< std::string, std::string > > & 
getAnnotations () const
 
const ExtArgumentType getRet () const
 
SQLTypeInfo getInputSQLType (const size_t idx) const
 
SQLTypeInfo getOutputSQLType (const size_t idx) const
 
int32_t countScalarArgs () const
 
size_t getInputsSize () const
 
size_t getOutputsSize () const
 
std::string getName (const bool drop_suffix=false, const bool lower=false) const
 
std::string getSignature (const bool include_name, const bool include_output) const
 
bool hasCompileTimeOutputSizeConstant () const
 
bool hasPreFlightOutputSizer () const
 
bool hasUserSpecifiedOutputSizeConstant () const
 
bool hasConstantOutputSize () const
 
bool hasTableFunctionSpecifiedParameter () const
 
bool hasUserSpecifiedOutputSizeParameter () const
 
bool hasNonUserSpecifiedOutputSize () const
 
bool hasOutputSizeIndependentOfInputSize () const
 
bool hasOutputSizeKnownPreLaunch () const
 
bool hasUserSpecifiedOutputSizeMultiplier () const
 
OutputBufferSizeType getOutputRowSizeType () const
 
size_t getOutputRowSizeParameter () const
 
bool containsPreFlightFn () const
 
std::string getPreFlightFnName () const
 
const std::map< std::string,
std::string > 
getAnnotations (const size_t idx) const
 
const std::map< std::string,
std::string > 
getInputAnnotations (const size_t input_arg_idx) const
 
const std::string getInputAnnotation (const size_t input_arg_idx, const std::string &key, const std::string &default_) const
 
const std::map< std::string,
std::string > 
getOutputAnnotations (const size_t output_arg_idx) const
 
const std::string getOutputAnnotation (const size_t output_arg_idx, const std::string &key, const std::string &default_) const
 
const std::string getFunctionAnnotation (const std::string &key, const std::string &default_) const
 
const std::map< std::string,
std::string > 
getFunctionAnnotations () const
 
const std::vector< std::string > getCursorFields (const size_t sql_idx) const
 
const std::string getArgTypes (const bool use_input_args) const
 
const std::string getArgNames (const bool use_input_args) const
 
const std::string getInputArgsDefaultValues () const
 
std::pair< int32_t, int32_t > getInputID (const size_t idx) const
 
size_t getSqlOutputRowSizeParameter () const
 
size_t getOutputRowSizeParameter (const std::vector< SQLTypeInfo > &variant) const
 
bool isRuntime () const
 
bool usesManager () 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 std::vector< std::map
< std::string, std::string > > 
annotations_
 
const bool is_runtime_
 
const bool uses_manager_
 

Detailed Description

Definition at line 126 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,
const std::vector< std::map< std::string, std::string >> &  annotations,
bool  is_runtime,
bool  uses_manager 
)
inline

Definition at line 128 of file TableFunctionsFactory.h.

136  : name_(name)
137  , output_sizer_(output_sizer)
138  , input_args_(input_args)
139  , output_args_(output_args)
140  , sql_args_(sql_args)
141  , annotations_(annotations)
142  , is_runtime_(is_runtime)
const TableFunctionOutputRowSizer output_sizer_
const std::vector< std::map< std::string, std::string > > annotations_
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
const std::vector< ExtArgumentType > input_args_
string name
Definition: setup.in.py:72

Member Function Documentation

bool table_functions::TableFunction::containsPreFlightFn ( ) const

Definition at line 106 of file TableFunctionsFactory.cpp.

References annotations_, getInputAnnotations(), hasPreFlightOutputSizer(), and input_args_.

Referenced by TableFunctionExecutionContext::execute(), and Executor::executeTableFunction().

106  {
107  if (hasPreFlightOutputSizer()) {
108  return true;
109  }
110  // workaround for default args
111  for (size_t idx = 0; idx < std::min(input_args_.size(), annotations_.size()); idx++) {
112  const auto& ann = getInputAnnotations(idx);
113  if (ann.find("require") != ann.end()) {
114  return true;
115  }
116  }
117  return false;
118 }
const std::vector< std::map< std::string, std::string > > annotations_
const std::map< std::string, std::string > getInputAnnotations(const size_t input_arg_idx) const
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t table_functions::TableFunction::countScalarArgs ( ) const

Definition at line 96 of file TableFunctionsFactory.cpp.

References input_args_, and is_ext_arg_type_scalar().

96  {
97  int32_t scalar_args = 0;
98  for (const auto& ext_arg : input_args_) {
99  if (is_ext_arg_type_scalar(ext_arg)) {
100  scalar_args += 1;
101  }
102  }
103  return scalar_args;
104 }
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:

const std::vector<std::map<std::string, std::string> >& table_functions::TableFunction::getAnnotations ( ) const
inline

Definition at line 161 of file TableFunctionsFactory.h.

References annotations_.

Referenced by getFunctionAnnotations(), getInputAnnotations(), getOutputAnnotations(), and ThriftSerializers::to_thrift().

161  {
162  return annotations_;
163  }
const std::vector< std::map< std::string, std::string > > annotations_

+ Here is the caller graph for this function:

const std::map< std::string, std::string > table_functions::TableFunction::getAnnotations ( const size_t  idx) const

Definition at line 120 of file TableFunctionsFactory.cpp.

References annotations_, CHECK_LE, output_args_, and sql_args_.

121  {
122  CHECK_LE(idx, sql_args_.size() + output_args_.size());
123  if (annotations_.empty() || idx >= annotations_.size()) {
124  static const std::map<std::string, std::string> empty = {};
125  return empty;
126  }
127  return annotations_[idx];
128 }
const std::vector< std::map< std::string, std::string > > annotations_
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
#define CHECK_LE(x, y)
Definition: Logger.h:304
const std::string table_functions::TableFunction::getArgNames ( const bool  use_input_args) const

Definition at line 216 of file TableFunctionsFactory.cpp.

References getCursorFields(), getInputAnnotation(), getOutputAnnotation(), join(), setup::name, output_args_, and sql_args_.

216  {
217  std::vector<std::string> names;
218  if (use_input_args) {
219  for (size_t idx = 0; idx < sql_args_.size(); idx++) {
220  const std::vector<std::string> cursor_fields = getCursorFields(idx);
221  if (cursor_fields.empty()) {
222  const std::string& name = getInputAnnotation(idx, "name", "''");
223  names.emplace_back(name);
224  } else {
225  names.emplace_back("Cursor<" + boost::algorithm::join(cursor_fields, ", ") + ">");
226  }
227  }
228  } else {
229  for (size_t idx = 0; idx < output_args_.size(); idx++) {
230  const std::string& name = getOutputAnnotation(idx, "name", "''");
231  names.emplace_back(name);
232  }
233  }
234 
235  return "[" + boost::algorithm::join(names, ", ") + "]";
236 }
const std::string getOutputAnnotation(const size_t output_arg_idx, const std::string &key, const std::string &default_) const
std::string join(T const &container, std::string const &delim)
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
const std::string getInputAnnotation(const size_t input_arg_idx, const std::string &key, const std::string &default_) const
const std::vector< std::string > getCursorFields(const size_t sql_idx) const
string name
Definition: setup.in.py:72

+ 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 145 of file TableFunctionsFactory.h.

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

145  {
146  std::vector<ExtArgumentType> args;
147  args.insert(args.end(), input_args_.begin(), input_args_.end());
148  if (ensure_column) {
149  // map row dtype to column type
150  std::for_each(output_args_.begin(), output_args_.end(), [&args](auto t) {
151  args.push_back(ext_arg_type_ensure_column(t));
152  });
153  } else {
154  args.insert(args.end(), output_args_.begin(), output_args_.end());
155  }
156  return args;
157  }
const std::vector< ExtArgumentType > output_args_
ExtArgumentType ext_arg_type_ensure_column(const ExtArgumentType ext_arg_type)
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

const std::string table_functions::TableFunction::getArgTypes ( const bool  use_input_args) const

Definition at line 192 of file TableFunctionsFactory.cpp.

References getCursorFields(), input_args_, join(), output_args_, sql_args_, and ExtensionFunctionsWhitelist::toString().

192  {
193  if (use_input_args) {
194  std::vector<std::string> arg_types;
195  size_t arg_idx = 0;
196  for (size_t sql_idx = 0; sql_idx < sql_args_.size(); sql_idx++) {
197  const std::vector<std::string> cursor_fields = getCursorFields(sql_idx);
198  if (cursor_fields.empty()) {
199  // fields => {}
200  arg_types.emplace_back(
202  } else {
203  std::vector<std::string> vec;
204  for (size_t i = 0; i < cursor_fields.size(); i++) {
205  vec.emplace_back(ExtensionFunctionsWhitelist::toString(input_args_[arg_idx++]));
206  }
207  arg_types.emplace_back("Cursor<" + boost::algorithm::join(vec, ", ") + ">");
208  }
209  }
210  return "[" + boost::algorithm::join(arg_types, ", ") + "]";
211  } else {
213  }
214 }
std::string join(T const &container, std::string const &delim)
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
const std::vector< std::string > getCursorFields(const size_t sql_idx) 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< std::string > table_functions::TableFunction::getCursorFields ( const size_t  sql_idx) const

Definition at line 179 of file TableFunctionsFactory.cpp.

References getInputAnnotation(), parse_ast::line, and split().

Referenced by getArgNames(), getArgTypes(), and getSignature().

180  {
181  std::vector<std::string> fields;
182  const std::string& line = getInputAnnotation(sql_idx, "fields", "");
183  if (line.empty()) {
184  static const std::vector<std::string> empty = {};
185  return empty;
186  }
187  std::string substr = line.substr(1, line.size() - 2);
188  boost::split(fields, substr, boost::is_any_of(", "), boost::token_compress_on);
189  return fields;
190 }
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings
const std::string getInputAnnotation(const size_t input_arg_idx, const std::string &key, const std::string &default_) const
tuple line
Definition: parse_ast.py:10

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::string table_functions::TableFunction::getFunctionAnnotation ( const std::string &  key,
const std::string &  default_ 
) const

Definition at line 168 of file TableFunctionsFactory.cpp.

References getFunctionAnnotations().

170  {
171  const std::map<std::string, std::string> ann = getFunctionAnnotations();
172  const auto& it = ann.find(key);
173  if (it != ann.end()) {
174  return it->second;
175  }
176  return default_;
177 }
const std::map< std::string, std::string > getFunctionAnnotations() const

+ Here is the call graph for this function:

const std::map< std::string, std::string > table_functions::TableFunction::getFunctionAnnotations ( ) const

Definition at line 164 of file TableFunctionsFactory.cpp.

References getAnnotations(), output_args_, and sql_args_.

Referenced by getFunctionAnnotation().

164  {
165  return getAnnotations(sql_args_.size() + output_args_.size());
166 }
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
const std::vector< std::map< std::string, std::string > > & getAnnotations() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::string table_functions::TableFunction::getInputAnnotation ( const size_t  input_arg_idx,
const std::string &  key,
const std::string &  default_ 
) const

Definition at line 136 of file TableFunctionsFactory.cpp.

References getInputAnnotations().

Referenced by getArgNames(), getCursorFields(), getInputArgsDefaultValues(), and getSignature().

138  {
139  const std::map<std::string, std::string> ann = getInputAnnotations(input_arg_idx);
140  const auto& it = ann.find(key);
141  if (it != ann.end()) {
142  return it->second;
143  }
144  return default_;
145 }
const std::map< std::string, std::string > getInputAnnotations(const size_t input_arg_idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::map< std::string, std::string > table_functions::TableFunction::getInputAnnotations ( const size_t  input_arg_idx) const

Definition at line 130 of file TableFunctionsFactory.cpp.

References CHECK_LT, getAnnotations(), and input_args_.

Referenced by containsPreFlightFn(), and getInputAnnotation().

131  {
132  CHECK_LT(input_arg_idx, input_args_.size());
133  return getAnnotations(input_arg_idx);
134 }
#define CHECK_LT(x, y)
Definition: Logger.h:303
const std::vector< ExtArgumentType > input_args_
const std::vector< std::map< std::string, std::string > > & getAnnotations() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 158 of file TableFunctionsFactory.h.

References input_args_.

Referenced by ThriftSerializers::to_thrift().

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

+ Here is the caller graph for this function:

const std::string table_functions::TableFunction::getInputArgsDefaultValues ( ) const

Definition at line 238 of file TableFunctionsFactory.cpp.

References getInputAnnotation(), join(), setup::name, and sql_args_.

238  {
239  std::vector<std::string> default_values;
240  default_values.reserve(sql_args_.size());
241  for (size_t idx = 0; idx < sql_args_.size(); idx++) {
242  const std::string& name = getInputAnnotation(idx, "default", "UNSPECIFIED");
243  default_values.emplace_back(name);
244  }
245 
246  return "[" + boost::algorithm::join(default_values, ",") + "]";
247 }
std::string join(T const &container, std::string const &delim)
const std::vector< ExtArgumentType > sql_args_
const std::string getInputAnnotation(const size_t input_arg_idx, const std::string &key, const std::string &default_) const
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

std::pair< int32_t, int32_t > table_functions::TableFunction::getInputID ( const size_t  idx) const

Definition at line 249 of file TableFunctionsFactory.cpp.

References ColumnGeoLineString, ColumnGeoMultiLineString, ColumnGeoMultiPoint, ColumnGeoMultiPolygon, ColumnGeoPoint, ColumnGeoPolygon, ColumnListGeoLineString, ColumnListGeoMultiLineString, ColumnListGeoMultiPoint, ColumnListGeoMultiPolygon, ColumnListGeoPoint, ColumnListGeoPolygon, ColumnListTextEncodingDict, ColumnTextEncodingDict, GeoLineString, GeoMultiLineString, GeoMultiPoint, GeoMultiPolygon, GeoPoint, GeoPolygon, getOutputAnnotations(), input_args_, PREFIX_LENGTH, and TextEncodingDict.

249  {
250  // if the annotation is of the form args<INT,INT>, it is refering to a column list
251 #define PREFIX_LENGTH 5
252  const auto& annotation = getOutputAnnotations(idx);
253  auto annot = annotation.find("input_id");
254  if (annot == annotation.end()) {
255  size_t lo = 0;
256  for (const auto& ext_arg : input_args_) {
257  switch (ext_arg) {
279  return std::make_pair(lo, 0);
280  default:
281  lo++;
282  }
283  }
284  return {-1, -1}; // indicates unspecified
285  }
286 
287  const std::string& input_id = annot->second;
288 
289  if (input_id == "args<-1>") {
290  // empty input id! -1 seems to be the magic number used in RelAlgExecutor.cpp
291  return {-1, -1};
292  }
293 
294  size_t comma = input_id.find(",");
295  int32_t gt = input_id.size() - 1;
296  int32_t lo = std::stoi(input_id.substr(PREFIX_LENGTH, comma - 1));
297 
298  if (comma == std::string::npos) {
299  return std::make_pair(lo, 0);
300  }
301  int32_t hi = std::stoi(input_id.substr(comma + 1, gt - comma - 1));
302  return std::make_pair(lo, hi);
303 }
#define PREFIX_LENGTH
const std::map< std::string, std::string > getOutputAnnotations(const size_t output_arg_idx) const
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

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

Definition at line 82 of file TableFunctionsFactory.cpp.

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

82  {
83  CHECK_LT(idx, input_args_.size());
85 }
SQLTypeInfo ext_arg_pointer_type_to_type_info(const ExtArgumentType ext_arg_type)
#define CHECK_LT(x, y)
Definition: Logger.h:303
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

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

Definition at line 171 of file TableFunctionsFactory.h.

References input_args_.

171 { 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 563 of file TableFunctionsFactory.cpp.

References anonymous_namespace{RowFunctionManager.h}::drop_suffix_impl(), name_, run_benchmark_import::result, and to_lower().

Referenced by TableFunctionManager::allocate_output_buffers(), TableFunctionCompilationContext::compile(), TableFunctionCompilationContext::generateTableFunctionCall(), getPreFlightFnName(), getSignature(), and ThriftSerializers::to_thrift().

563  {
564  std::string result = name_;
565  if (drop_suffix) {
566  result = drop_suffix_impl(result);
567  }
568  if (lower) {
570  }
571  return result;
572 }
std::string to_lower(const std::string &str)
std::string drop_suffix_impl(const std::string &str)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::string table_functions::TableFunction::getOutputAnnotation ( const size_t  output_arg_idx,
const std::string &  key,
const std::string &  default_ 
) const

Definition at line 153 of file TableFunctionsFactory.cpp.

References getOutputAnnotations().

Referenced by getArgNames().

155  {
156  const std::map<std::string, std::string> ann = getOutputAnnotations(output_arg_idx);
157  const auto& it = ann.find(key);
158  if (it != ann.end()) {
159  return it->second;
160  }
161  return default_;
162 }
const std::map< std::string, std::string > getOutputAnnotations(const size_t output_arg_idx) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::map< std::string, std::string > table_functions::TableFunction::getOutputAnnotations ( const size_t  output_arg_idx) const

Definition at line 147 of file TableFunctionsFactory.cpp.

References CHECK_LT, getAnnotations(), output_args_, and sql_args_.

Referenced by getInputID(), and getOutputAnnotation().

148  {
149  CHECK_LT(output_arg_idx, output_args_.size());
150  return getAnnotations(output_arg_idx + sql_args_.size());
151 }
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
#define CHECK_LT(x, y)
Definition: Logger.h:303
const std::vector< std::map< std::string, std::string > > & getAnnotations() const

+ 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 159 of file TableFunctionsFactory.h.

References output_args_.

Referenced by ThriftSerializers::to_thrift().

159 { 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 229 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 257 of file TableFunctionsFactory.h.

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

257  {
258  auto val = output_sizer_.val;
260  size_t col_index = 0;
261  size_t func_arg_index = 0;
262  for (const auto& ti : variant) {
263  func_arg_index++;
264  if (ti.is_column_list()) {
265  col_index += ti.get_dimension();
266  } else {
267  col_index++;
268  }
269  if (func_arg_index == val) {
270  val = col_index;
271  break;
272  }
273  }
274  }
275  return val;
276  }
const TableFunctionOutputRowSizer output_sizer_

+ Here is the call graph for this function:

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

Definition at line 227 of file TableFunctionsFactory.h.

References output_sizer_.

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

227 { 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 87 of file TableFunctionsFactory.cpp.

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

87  {
88  CHECK_LT(idx, output_args_.size());
89  // TODO(adb): conditionally handle nulls
91 }
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:303

+ Here is the call graph for this function:

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

Definition at line 172 of file TableFunctionsFactory.h.

References output_args_.

172 { return output_args_.size(); }
const std::vector< ExtArgumentType > output_args_
std::string table_functions::TableFunction::getPreFlightFnName ( ) const

Definition at line 606 of file TableFunctionsFactory.cpp.

References getName(), and PREFLIGHT_SUFFIX.

Referenced by TableFunctionCompilationContext::generateTableFunctionCall().

606  {
607  // gets the name of the pre flight function associated with this table function
608  return getName(false, true) + PREFLIGHT_SUFFIX;
609 }
#define PREFLIGHT_SUFFIX
std::string getName(const bool drop_suffix=false, const bool lower=false) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const ExtArgumentType table_functions::TableFunction::getRet ( ) const
inline

Definition at line 164 of file TableFunctionsFactory.h.

References Int32.

std::string table_functions::TableFunction::getSignature ( const bool  include_name,
const bool  include_output 
) const

Definition at line 574 of file TableFunctionsFactory.cpp.

References run_benchmark_import::args, getCursorFields(), getInputAnnotation(), getName(), input_args_, join(), setup::name, output_args_, sql_args_, ExtensionFunctionsWhitelist::toString(), and run_benchmark_import::type.

575  {
576  std::string sig;
577  if (include_name) {
578  sig += getName(/*drop_suffix=*/true, /*lower=*/true);
579  }
580 
581  size_t arg_idx = 0;
582  std::vector<std::string> args;
583  for (size_t sql_idx = 0; sql_idx < sql_args_.size(); sql_idx++) {
584  const std::vector<std::string> cursor_fields = getCursorFields(sql_idx);
585  if (cursor_fields.empty()) {
586  const auto& type = ExtensionFunctionsWhitelist::toString(input_args_[arg_idx++]);
587  const auto& name = getInputAnnotation(sql_idx, "name", "");
588  args.emplace_back(name.empty() ? type : (type + " " + name));
589  } else {
590  std::vector<std::string> vec;
591  for (size_t i = 0; i < cursor_fields.size(); i++) {
592  const auto& type = ExtensionFunctionsWhitelist::toString(input_args_[arg_idx++]);
593  const auto& name = cursor_fields[i];
594  vec.emplace_back((name.empty() ? type : type + " " + name));
595  }
596  args.emplace_back("Cursor<" + boost::algorithm::join(vec, ", ") + ">");
597  }
598  }
599  sig += "(" + boost::algorithm::join(args, ", ") + ")";
600  if (include_output) {
602  }
603  return sig;
604 }
std::string join(T const &container, std::string const &delim)
const std::vector< ExtArgumentType > output_args_
const std::vector< ExtArgumentType > sql_args_
const std::string getInputAnnotation(const size_t input_arg_idx, const std::string &key, const std::string &default_) const
std::string getName(const bool drop_suffix=false, const bool lower=false) const
const std::vector< std::string > getCursorFields(const size_t sql_idx) const
static std::string toString(const std::vector< ExtensionFunction > &ext_funcs, std::string tab="")
const std::vector< ExtArgumentType > input_args_
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

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

Definition at line 160 of file TableFunctionsFactory.h.

References sql_args_.

Referenced by ThriftSerializers::to_thrift().

160 { 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 305 of file TableFunctionsFactory.cpp.

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

305  {
306  /*
307  This function differs from getOutputRowSizeParameter() since it returns the correct
308  index for the sizer in the sql_args list. For instance, consider the example below:
309 
310  RowMultiplier=4
311  input_args=[{i32*, i64}, {i32*, i64}, {i32*, i64}, i32, {i32*, i64}, {i32*, i64},
312  i32] sql_args=[cursor, i32, cursor, i32]
313 
314  Non-scalar args are aggregated in a cursor inside the sql_args list and the new
315  sizer index is 2 rather than 4 originally specified.
316  */
317 
319  size_t sizer = getOutputRowSizeParameter(); // lookup until reach the sizer arg
320  int32_t ext_arg_index = 0, sql_arg_index = 0;
321 
322  auto same_kind = [&](const ExtArgumentType& ext_arg, const ExtArgumentType& sql_arg) {
323  return ((is_ext_arg_type_scalar(ext_arg) && is_ext_arg_type_scalar(sql_arg)) ||
325  };
326 
327  while ((size_t)ext_arg_index < sizer) {
328  if ((size_t)ext_arg_index == sizer - 1) {
329  return sql_arg_index;
330  }
331 
332  const auto& ext_arg = input_args_[ext_arg_index];
333  const auto& sql_arg = sql_args_[sql_arg_index];
334 
335  if (same_kind(ext_arg, sql_arg)) {
336  ++ext_arg_index;
337  ++sql_arg_index;
338  } else {
339  CHECK(same_kind(ext_arg, sql_args_[sql_arg_index - 1]));
340  ext_arg_index += 1;
341  }
342  }
343 
344  CHECK(false);
345  }
346 
347  return getOutputRowSizeParameter();
348 }
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:291
const std::vector< ExtArgumentType > input_args_

+ Here is the call graph for this function:

bool table_functions::TableFunction::hasCompileTimeOutputSizeConstant ( ) const
inline
bool table_functions::TableFunction::hasOutputSizeKnownPreLaunch ( ) const
inline
bool table_functions::TableFunction::hasPreFlightOutputSizer ( ) const
inline

Definition at line 182 of file TableFunctionsFactory.h.

References table_functions::kPreFlightParameter, and output_sizer_.

Referenced by containsPreFlightFn(), and TableFunctionCompilationContext::generateEntryPoint().

+ Here is the caller graph for this function:

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

Definition at line 195 of file TableFunctionsFactory.h.

References table_functions::kTableFunctionSpecifiedParameter, and output_sizer_.

Referenced by Executor::executeTableFunction(), and TableFunctionExecutionContext::launchGpuCode().

+ Here is the caller graph for this function:

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

Definition at line 223 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 286 of file TableFunctionsFactory.h.

References name_, and usesManager().

286  {
287  return usesManager() || (name_.find("_gpu_", name_.find("__")) == std::string::npos);
288  }

+ Here is the call graph for this function:

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

Definition at line 282 of file TableFunctionsFactory.h.

References name_, and usesManager().

282  {
283  return !usesManager() && (name_.find("_cpu_", name_.find("__")) == std::string::npos);
284  }

+ Here is the call graph for this function:

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

Definition at line 278 of file TableFunctionsFactory.h.

References is_runtime_.

Referenced by TableFunctionCompilationContext::passColumnsByValue().

278 { return is_runtime_; }

+ Here is the caller graph for this function:

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

Definition at line 295 of file TableFunctionsFactory.h.

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

295  {
296  auto result = "TableFunction(" + name_ + ", input_args=[";
298  result += "], output_args=[";
300  result += "], sql_args=[";
302  result += "], is_runtime=" + std::string((is_runtime_ ? "true" : "false"));
303  result += ", uses_manager=" + std::string((uses_manager_ ? "true" : "false"));
304  result += ", sizer=" + ::toString(output_sizer_);
305  result += ", annotations=[";
306  for (auto annotation : annotations_) {
307  if (annotation.empty()) {
308  result += "{}, ";
309  } else {
310  result += "{";
311  for (auto it : annotation) {
312  result += ::toString(it.first) + ": " + ::toString(it.second);
313  }
314  result += "}, ";
315  }
316  }
317  result += "])";
318  return result;
319  }
const TableFunctionOutputRowSizer output_sizer_
const std::vector< std::map< std::string, std::string > > annotations_
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 321 of file TableFunctionsFactory.h.

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

321  {
322  auto result = name_ + "(";
324  result += ") -> (";
326  result += ")";
327  return result;
328  }
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 290 of file TableFunctionsFactory.h.

References name_.

290  {
291  // Functions that use a default sizer value have one less argument
292  return (name_.find("_default_", name_.find("__")) != std::string::npos);
293  }
bool table_functions::TableFunction::usesManager ( ) const
inline

Definition at line 280 of file TableFunctionsFactory.h.

References uses_manager_.

Referenced by TableFunctionCompilationContext::generateEntryPoint(), isCPU(), and isGPU().

+ Here is the caller graph for this function:

Member Data Documentation

const std::vector<std::map<std::string, std::string> > table_functions::TableFunction::annotations_
private

Definition at line 336 of file TableFunctionsFactory.h.

Referenced by containsPreFlightFn(), getAnnotations(), and toString().

const bool table_functions::TableFunction::is_runtime_
private

Definition at line 337 of file TableFunctionsFactory.h.

Referenced by isRuntime(), and toString().

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

Definition at line 331 of file TableFunctionsFactory.h.

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

const bool table_functions::TableFunction::uses_manager_
private

Definition at line 338 of file TableFunctionsFactory.h.

Referenced by toString(), and usesManager().


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