OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TableFunctionsFactory.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <string>
20 #include <vector>
21 
23 
24 namespace table_functions {
25 
29  kConstant
30 };
31 
34  const size_t val{0};
35 };
36 
38  public:
39  TableFunction(const std::string& name,
40  const TableFunctionOutputRowSizer output_sizer,
41  const std::vector<ExtArgumentType>& input_args,
42  const std::vector<ExtArgumentType>& output_args,
43  bool is_runtime)
44  : name_(name)
45  , output_sizer_(output_sizer)
46  , input_args_(input_args)
47  , output_args_(output_args)
48  , is_runtime_(is_runtime) {}
49 
50  std::vector<ExtArgumentType> getArgs() const {
51  std::vector<ExtArgumentType> args;
52  args.insert(args.end(), input_args_.begin(), input_args_.end());
53  args.insert(args.end(), output_args_.begin(), output_args_.end());
54  return args;
55  }
56 
57  SQLTypeInfo getOutputSQLType(const size_t idx) const;
58 
59  auto getOutputsSize() const { return output_args_.size(); }
60 
61  auto getName() const { return name_; }
62 
65  }
66 
67  size_t getOutputRowParameter() const { return output_sizer_.val; }
68 
69  bool isRuntime() const { return is_runtime_; }
70 
71  private:
72  const std::string name_;
74  const std::vector<ExtArgumentType> input_args_;
75  const std::vector<ExtArgumentType> output_args_;
76  const bool is_runtime_;
77 };
78 
80  public:
81  static void add(const std::string& name,
82  const TableFunctionOutputRowSizer sizer,
83  const std::vector<ExtArgumentType>& input_args,
84  const std::vector<ExtArgumentType>& output_args,
85  bool is_runtime = false);
86 
87  static const TableFunction& get(const std::string& name);
88 
89  static void init();
90 
91  private:
92  static std::unordered_map<std::string, TableFunction> functions_;
93 
94  friend class ::ExtensionFunctionsWhitelist;
95 };
96 
97 } // namespace table_functions
SQLTypeInfo getOutputSQLType(const size_t idx) const
TableFunction(const std::string &name, const TableFunctionOutputRowSizer output_sizer, const std::vector< ExtArgumentType > &input_args, const std::vector< ExtArgumentType > &output_args, bool is_runtime)
const TableFunctionOutputRowSizer output_sizer_
const std::vector< ExtArgumentType > output_args_
std::vector< ExtArgumentType > getArgs() const
static std::unordered_map< std::string, TableFunction > functions_
static void add(const std::string &name, const TableFunctionOutputRowSizer sizer, const std::vector< ExtArgumentType > &input_args, const std::vector< ExtArgumentType > &output_args, bool is_runtime=false)
const std::vector< ExtArgumentType > input_args_