OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.parser.server.ExtensionFunction Class Reference
+ Collaboration diagram for com.mapd.parser.server.ExtensionFunction:

Classes

enum  ExtArgumentType
 

Public Member Functions

List< ExtArgumentTypegetArgs ()
 
List< ExtArgumentTypegetOuts ()
 
List< String > getArgNames ()
 
List< String > getPrettyArgNames ()
 
List< String > getOutNames ()
 
ExtArgumentType getRet ()
 
SqlTypeName getSqlRet ()
 
List< SqlTypeName > getSqlOuts ()
 
Map< String, String > getOptions ()
 
boolean isRowUdf ()
 
boolean isTableUdf ()
 
String toJson (final String name)
 
final java.util.List
< SqlTypeFamily > 
toSqlSignature ()
 

Package Functions

 ExtensionFunction (final List< ExtArgumentType > args, final ExtArgumentType ret)
 
 ExtensionFunction (final List< ExtArgumentType > args, final List< ExtArgumentType > outs, final List< String > names, final Map< String, String > options)
 

Static Package Attributes

static final Logger HEAVYDBLOGGER = LoggerFactory.getLogger(ExtensionFunction.class)
 

Static Private Member Functions

static String typeName (final ExtArgumentType type)
 
static String dq (final String str)
 
static boolean isPointerType (final ExtArgumentType type)
 
static boolean isColumnType (final ExtArgumentType type)
 
static boolean isColumnListType (final ExtArgumentType type)
 
static ExtArgumentType getValueType (final ExtArgumentType type)
 
static SqlTypeName toSqlTypeName (final ExtArgumentType type)
 

Private Attributes

final List< ExtArgumentTypeargs
 
final List< ExtArgumentTypeouts
 
final List< String > names
 
final ExtArgumentType ret
 
final boolean isRowUdf
 
final Map< String, String > options
 

Detailed Description

Author
alex

Definition at line 34 of file ExtensionFunction.java.

Constructor & Destructor Documentation

com.mapd.parser.server.ExtensionFunction.ExtensionFunction ( final List< ExtArgumentType args,
final ExtArgumentType  ret 
)
inlinepackage

Definition at line 88 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.args, and com.mapd.parser.server.ExtensionFunction.ret.

88  {
89  this.args = args;
90  this.ret = ret;
91  this.outs = null;
92  this.names = null;
93  this.isRowUdf = true;
94  this.options = null;
95  }
com.mapd.parser.server.ExtensionFunction.ExtensionFunction ( final List< ExtArgumentType args,
final List< ExtArgumentType outs,
final List< String >  names,
final Map< String, String >  options 
)
inlinepackage

Definition at line 97 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.args, com.mapd.parser.server.ExtensionFunction.names, com.mapd.parser.server.ExtensionFunction.options, and com.mapd.parser.server.ExtensionFunction.outs.

100  {
101  this.args = args;
102  this.ret = null;
103  this.outs = outs;
104  this.names = names;
105  this.isRowUdf = false;
106  this.options = options;
107  }

Member Function Documentation

static String com.mapd.parser.server.ExtensionFunction.dq ( final String  str)
inlinestaticprivate

Definition at line 308 of file ExtensionFunction.java.

Referenced by com.mapd.parser.server.ExtensionFunction.toJson().

308  {
309  return "\"" + str + "\"";
310  }

+ Here is the caller graph for this function:

List<String> com.mapd.parser.server.ExtensionFunction.getArgNames ( )
inline

Definition at line 117 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.names.

117  {
118  if (this.names != null) {
119  return this.names.subList(0, this.args.size());
120  }
121  return null;
122  }
List<ExtArgumentType> com.mapd.parser.server.ExtensionFunction.getArgs ( )
inline

Definition at line 109 of file ExtensionFunction.java.

References run_benchmark_import.args.

109  {
110  return this.args;
111  }
Map<String, String> com.mapd.parser.server.ExtensionFunction.getOptions ( )
inline

Definition at line 162 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.options.

162  {
163  if (this.options != null) {
164  return new HashMap<String, String>(this.options);
165  }
166  return null;
167  }
List<String> com.mapd.parser.server.ExtensionFunction.getOutNames ( )
inline

Definition at line 137 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.names.

137  {
138  if (this.names != null) {
139  return this.names.subList(this.args.size(), this.names.size());
140  }
141  return null;
142  }
List<ExtArgumentType> com.mapd.parser.server.ExtensionFunction.getOuts ( )
inline

Definition at line 113 of file ExtensionFunction.java.

Referenced by com.mapd.parser.server.ExtensionFunction.getSqlOuts().

113  {
114  return this.outs;
115  }

+ Here is the caller graph for this function:

List<String> com.mapd.parser.server.ExtensionFunction.getPrettyArgNames ( )
inline

Definition at line 124 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.names, and split().

124  {
125  if (this.names != null) {
126  List<String> pretty_names = new ArrayList<String>();
127  for (int arg_idx = 0; arg_idx < this.args.size(); ++arg_idx) {
128  // Split on first array opening bracket and take everything preceding
129  // For names without array brackets this will just be the name
130  pretty_names.add(this.names.get(arg_idx).split("\\[", 2)[0]);
131  }
132  return pretty_names;
133  }
134  return null;
135  }
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

+ Here is the call graph for this function:

ExtArgumentType com.mapd.parser.server.ExtensionFunction.getRet ( )
inline

Definition at line 144 of file ExtensionFunction.java.

144  {
145  return this.ret;
146  }
List<SqlTypeName> com.mapd.parser.server.ExtensionFunction.getSqlOuts ( )
inline

Definition at line 153 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.getOuts(), com.mapd.parser.server.ExtensionFunction.getValueType(), and com.mapd.parser.server.ExtensionFunction.toSqlTypeName().

153  {
154  assert this.isTableUdf();
155  List<SqlTypeName> sql_outs = new ArrayList<SqlTypeName>();
156  for (final ExtArgumentType otype : this.getOuts()) {
157  sql_outs.add(toSqlTypeName(getValueType(otype)));
158  }
159  return sql_outs;
160  }
static SqlTypeName toSqlTypeName(final ExtArgumentType type)
static ExtArgumentType getValueType(final ExtArgumentType type)

+ Here is the call graph for this function:

SqlTypeName com.mapd.parser.server.ExtensionFunction.getSqlRet ( )
inline

Definition at line 148 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.ret, and com.mapd.parser.server.ExtensionFunction.toSqlTypeName().

148  {
149  assert this.isRowUdf();
150  return toSqlTypeName(this.ret);
151  }
static SqlTypeName toSqlTypeName(final ExtArgumentType type)

+ Here is the call graph for this function:

static ExtArgumentType com.mapd.parser.server.ExtensionFunction.getValueType ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 363 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Bool, Bool, ColumnBool, ColumnDouble, ColumnFloat, ColumnInt16, ColumnInt32, ColumnInt64, ColumnInt8, ColumnListBool, ColumnListDouble, ColumnListFloat, ColumnListInt16, ColumnListInt32, ColumnListInt64, ColumnListInt8, ColumnListTextEncodingDict, ColumnTextEncodingDict, ColumnTimestamp, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Double, Double, Float, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Float, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Int16, Int16, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Int32, Int32, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Int64, Int64, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Int8, Int8, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.TextEncodingDict, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Timestamp, and run_benchmark_import.type.

Referenced by com.mapd.parser.server.ExtensionFunction.getSqlOuts().

363  {
364  switch (type) {
365  case PInt8:
366  case ColumnInt8:
367  case ColumnListInt8:
368  case Int8:
369  return ExtArgumentType.Int8;
370  case PInt16:
371  case ColumnInt16:
372  case ColumnListInt16:
373  case Int16:
374  return ExtArgumentType.Int16;
375  case PInt32:
376  case ColumnInt32:
377  case ColumnListInt32:
378  case Int32:
379  return ExtArgumentType.Int32;
380  case PInt64:
381  case ColumnInt64:
382  case ColumnListInt64:
383  case Int64:
384  return ExtArgumentType.Int64;
385  case PFloat:
386  case ColumnFloat:
387  case ColumnListFloat:
388  case Float:
389  return ExtArgumentType.Float;
390  case PDouble:
391  case ColumnDouble:
392  case ColumnListDouble:
393  case Double:
394  return ExtArgumentType.Double;
395  case PBool:
396  case ColumnBool:
397  case ColumnListBool:
398  case Bool:
399  return ExtArgumentType.Bool;
400  case TextEncodingDict:
404  case ColumnTimestamp:
406  }
407  HEAVYDBLOGGER.error("getValueType: no value for type " + type);
408  assert false;
409  return null;
410  }

+ Here is the caller graph for this function:

static boolean com.mapd.parser.server.ExtensionFunction.isColumnListType ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 352 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.ExtArgumentType.ColumnListTextEncodingDict.

352  {
353  return type == ExtArgumentType.ColumnListInt8
354  || type == ExtArgumentType.ColumnListInt16
355  || type == ExtArgumentType.ColumnListInt32
356  || type == ExtArgumentType.ColumnListInt64
357  || type == ExtArgumentType.ColumnListFloat
358  || type == ExtArgumentType.ColumnListDouble
359  || type == ExtArgumentType.ColumnListBool
361  }
static boolean com.mapd.parser.server.ExtensionFunction.isColumnType ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 343 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.ExtArgumentType.ColumnTimestamp.

343  {
344  return type == ExtArgumentType.ColumnInt8 || type == ExtArgumentType.ColumnInt16
345  || type == ExtArgumentType.ColumnInt32 || type == ExtArgumentType.ColumnInt64
346  || type == ExtArgumentType.ColumnFloat || type == ExtArgumentType.ColumnDouble
347  || type == ExtArgumentType.ColumnBool
348  || type == ExtArgumentType.ColumnTextEncodingDict
350  }
static boolean com.mapd.parser.server.ExtensionFunction.isPointerType ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 336 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.ExtArgumentType.PBool.

Referenced by com.mapd.parser.server.ExtensionFunction.toSqlSignature().

336  {
337  return type == ExtArgumentType.PInt8 || type == ExtArgumentType.PInt16
338  || type == ExtArgumentType.PInt32 || type == ExtArgumentType.PInt64
339  || type == ExtArgumentType.PFloat || type == ExtArgumentType.PDouble
341  }

+ Here is the caller graph for this function:

boolean com.mapd.parser.server.ExtensionFunction.isRowUdf ( )
inline

Definition at line 169 of file ExtensionFunction.java.

Referenced by com.mapd.parser.server.ExtensionFunction.toJson(), and com.mapd.parser.server.ExtensionFunction.toSqlSignature().

169  {
170  return this.isRowUdf;
171  }

+ Here is the caller graph for this function:

boolean com.mapd.parser.server.ExtensionFunction.isTableUdf ( )
inline

Definition at line 173 of file ExtensionFunction.java.

173  {
174  return !this.isRowUdf();
175  }
String com.mapd.parser.server.ExtensionFunction.toJson ( final String  name)
inline

Definition at line 177 of file ExtensionFunction.java.

References File_Namespace.append(), com.mapd.parser.server.ExtensionFunction.args, com.mapd.parser.server.ExtensionFunction.dq(), com.mapd.parser.server.ExtensionFunction.isRowUdf(), setup.name, com.mapd.parser.server.ExtensionFunction.outs, com.mapd.parser.server.ExtensionFunction.ret, and com.mapd.parser.server.ExtensionFunction.typeName().

177  {
178  HEAVYDBLOGGER.debug("Extensionfunction::toJson: " + name);
179  StringBuilder json_cons = new StringBuilder();
180  json_cons.append("{");
181  json_cons.append("\"name\":").append(dq(name)).append(",");
182  if (isRowUdf) {
183  json_cons.append("\"ret\":").append(dq(typeName(ret))).append(",");
184  } else {
185  json_cons.append("\"outs\":");
186  json_cons.append("[");
187  List<String> param_list = new ArrayList<String>();
188  for (final ExtArgumentType out : outs) {
189  param_list.add(dq(typeName(out)));
190  }
191  json_cons.append(ExtensionFunctionSignatureParser.join(param_list, ","));
192  json_cons.append("],");
193  }
194  json_cons.append("\"args\":");
195  json_cons.append("[");
196  List<String> param_list = new ArrayList<String>();
197  for (final ExtArgumentType arg : args) {
198  param_list.add(dq(typeName(arg)));
199  }
200  json_cons.append(ExtensionFunctionSignatureParser.join(param_list, ","));
201  json_cons.append("]");
202  json_cons.append("}");
203  return json_cons.toString();
204  }
size_t append(FILE *f, const size_t size, const int8_t *buf)
Appends the specified number of bytes to the end of the file f from buf.
Definition: File.cpp:168
static String typeName(final ExtArgumentType type)
static String dq(final String str)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

final java.util.List<SqlTypeFamily> com.mapd.parser.server.ExtensionFunction.toSqlSignature ( )
inline

Definition at line 319 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.isPointerType(), com.mapd.parser.server.ExtensionFunction.isRowUdf(), and com.mapd.parser.server.ExtensionFunction.toSqlTypeName().

Referenced by com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtFunction.ExtFunction(), and com.mapd.calcite.parser.HeavyDBSqlOperatorTable.ExtTableFunction.ExtTableFunction().

319  {
320  java.util.List<SqlTypeFamily> sql_sig = new java.util.ArrayList<SqlTypeFamily>();
321  boolean isRowUdf = this.isRowUdf();
322  for (int arg_idx = 0; arg_idx < this.getArgs().size(); ++arg_idx) {
323  final ExtArgumentType arg_type = this.getArgs().get(arg_idx);
324  if (isRowUdf) {
325  sql_sig.add(toSqlTypeName(arg_type).getFamily());
326  if (isPointerType(arg_type)) {
327  ++arg_idx;
328  }
329  } else {
330  sql_sig.add(toSqlTypeName(arg_type).getFamily());
331  }
332  }
333  return sql_sig;
334  }
static SqlTypeName toSqlTypeName(final ExtArgumentType type)
static boolean isPointerType(final ExtArgumentType type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static SqlTypeName com.mapd.parser.server.ExtensionFunction.toSqlTypeName ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 412 of file ExtensionFunction.java.

References ArrayBool, ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, Bool, ColumnListBool, ColumnListDouble, ColumnListFloat, ColumnListInt16, ColumnListInt32, ColumnListInt64, ColumnListInt8, ColumnListTextEncodingDict, Cursor, Double, Float, Int16, Int32, Int64, Int8, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, and Void.

Referenced by com.mapd.parser.server.ExtensionFunction.getSqlOuts(), com.mapd.parser.server.ExtensionFunction.getSqlRet(), and com.mapd.parser.server.ExtensionFunction.toSqlSignature().

412  {
413  switch (type) {
414  case Bool:
415  return SqlTypeName.BOOLEAN;
416  case Int8:
417  return SqlTypeName.TINYINT;
418  case Int16:
419  return SqlTypeName.SMALLINT;
420  case Int32:
421  return SqlTypeName.INTEGER;
422  case Int64:
423  return SqlTypeName.BIGINT;
424  case Float:
425  return SqlTypeName.FLOAT;
426  case Double:
427  return SqlTypeName.DOUBLE;
428  case PInt8:
429  case PInt16:
430  case PInt32:
431  case PInt64:
432  case PFloat:
433  case PDouble:
434  case PBool:
435  case ArrayInt8:
436  case ArrayInt16:
437  case ArrayInt32:
438  case ArrayInt64:
439  case ArrayFloat:
440  case ArrayDouble:
441  case ArrayBool:
442  return SqlTypeName.ARRAY;
443  case GeoPoint:
444  case GeoLineString:
445  case GeoPolygon:
446  case GeoMultiPolygon:
447  return SqlTypeName.GEOMETRY;
448  case Cursor:
449  return SqlTypeName.CURSOR;
450  case TextEncodingNone:
451  case TextEncodingDict:
452  return SqlTypeName.VARCHAR;
453  case Timestamp:
454  return SqlTypeName.TIMESTAMP;
455  case ColumnListInt8:
456  case ColumnListInt16:
457  case ColumnListInt32:
458  case ColumnListInt64:
459  case ColumnListFloat:
460  case ColumnListDouble:
461  case ColumnListBool:
463  return SqlTypeName.COLUMN_LIST;
464  case Void:
465  // some extension functions return void. these functions should be defined in
466  // HeavyDBSqlOperatorTable and never have their definition set from the AST file
467  return null;
468  }
469  Set<SqlTypeName> allSqlTypeNames = EnumSet.allOf(SqlTypeName.class);
470  HEAVYDBLOGGER.error("toSqlTypeName: unknown type " + type + " to be mapped to {"
471  + allSqlTypeNames + "}");
472  assert false;
473  return null;
474  }
Simplified core of GeoJSON Polygon coordinates definition.
Definition: heavydbTypes.h:366
Simplified core of GeoJSON MultiPolygon coordinates definition.
Definition: heavydbTypes.h:387

+ Here is the caller graph for this function:

static String com.mapd.parser.server.ExtensionFunction.typeName ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 206 of file ExtensionFunction.java.

References ArrayBool, ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, Bool, ColumnBool, ColumnDouble, ColumnFloat, ColumnInt16, ColumnInt32, ColumnInt64, ColumnInt8, ColumnListBool, ColumnListDouble, ColumnListFloat, ColumnListInt16, ColumnListInt32, ColumnListInt64, ColumnListInt8, ColumnListTextEncodingDict, ColumnTextEncodingDict, ColumnTimestamp, Cursor, Double, Float, Int16, Int32, Int64, Int8, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, and Void.

Referenced by com.mapd.parser.server.ExtensionFunction.toJson().

206  {
207  switch (type) {
208  case Bool:
209  return "i1";
210  case Int8:
211  return "i8";
212  case Int16:
213  return "i16";
214  case Int32:
215  return "i32";
216  case Int64:
217  return "i64";
218  case Float:
219  return "float";
220  case Double:
221  return "double";
222  case Void:
223  return "void";
224  case PInt8:
225  return "i8*";
226  case PInt16:
227  return "i16*";
228  case PInt32:
229  return "i32*";
230  case PInt64:
231  return "i64*";
232  case PFloat:
233  return "float*";
234  case PDouble:
235  return "double*";
236  case PBool:
237  return "i1*";
238  case ArrayInt8:
239  return "Array<i8>";
240  case ArrayInt16:
241  return "Array<i16>";
242  case ArrayInt32:
243  return "Array<i32>";
244  case ArrayInt64:
245  return "Array<i64>";
246  case ArrayFloat:
247  return "Array<float>";
248  case ArrayDouble:
249  return "Array<double>";
250  case ArrayBool:
251  return "Array<bool>";
252  case ColumnInt8:
253  return "Column<i8>";
254  case ColumnInt16:
255  return "Column<i16>";
256  case ColumnInt32:
257  return "Column<i32>";
258  case ColumnInt64:
259  return "Column<i64>";
260  case ColumnFloat:
261  return "Column<float>";
262  case ColumnDouble:
263  return "Column<double>";
264  case ColumnBool:
265  return "Column<bool>";
267  return "Column<TextEncodingDict>";
268  case ColumnTimestamp:
269  return "Column<timestamp>";
270  case GeoPoint:
271  return "geo_point";
272  case Cursor:
273  return "cursor";
274  case GeoLineString:
275  return "geo_linestring";
276  case GeoPolygon:
277  return "geo_polygon";
278  case GeoMultiPolygon:
279  return "geo_multi_polygon";
280  case Timestamp:
281  return "timestamp";
282  case TextEncodingNone:
283  return "TextEncodingNone";
284  case TextEncodingDict:
285  return "TextEncodingDict";
286  case ColumnListInt8:
287  return "ColumnList<i8>";
288  case ColumnListInt16:
289  return "ColumnList<i16>";
290  case ColumnListInt32:
291  return "ColumnList<i32>";
292  case ColumnListInt64:
293  return "ColumnList<i64>";
294  case ColumnListFloat:
295  return "ColumnList<float>";
296  case ColumnListDouble:
297  return "ColumnList<double>";
298  case ColumnListBool:
299  return "ColumnList<bool>";
301  return "ColumnList<TextEncodingDict>";
302  }
303  HEAVYDBLOGGER.info("Extensionfunction::typeName: unknown type=`" + type + "`");
304  assert false;
305  return null;
306  }
Simplified core of GeoJSON Polygon coordinates definition.
Definition: heavydbTypes.h:366
Simplified core of GeoJSON MultiPolygon coordinates definition.
Definition: heavydbTypes.h:387

+ Here is the caller graph for this function:

Member Data Documentation

final Logger com.mapd.parser.server.ExtensionFunction.HEAVYDBLOGGER = LoggerFactory.getLogger(ExtensionFunction.class)
staticpackage

Definition at line 35 of file ExtensionFunction.java.

final boolean com.mapd.parser.server.ExtensionFunction.isRowUdf
private

Definition at line 316 of file ExtensionFunction.java.

final Map<String, String> com.mapd.parser.server.ExtensionFunction.options
private
final List<ExtArgumentType> com.mapd.parser.server.ExtensionFunction.outs
private

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