OmniSciDB  85c2d10cdc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 ()
 
ExtArgumentType getRet ()
 
SqlTypeName getSqlRet ()
 
List< SqlTypeName > getSqlOuts ()
 
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)
 

Static Package Attributes

static final Logger MAPDLOGGER = 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 ExtArgumentType ret
 
final boolean isRowUdf
 

Detailed Description

Author
alex

Definition at line 32 of file ExtensionFunction.java.

Constructor & Destructor Documentation

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

Definition at line 84 of file ExtensionFunction.java.

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

84  {
85  this.args = args;
86  this.ret = ret;
87  this.outs = null;
88  this.isRowUdf = true;
89  }
com.mapd.parser.server.ExtensionFunction.ExtensionFunction ( final List< ExtArgumentType args,
final List< ExtArgumentType outs 
)
inlinepackage

Definition at line 91 of file ExtensionFunction.java.

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

91  {
92  this.args = args;
93  this.ret = null;
94  this.outs = outs;
95  this.isRowUdf = false;
96  }

Member Function Documentation

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

Definition at line 259 of file ExtensionFunction.java.

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

259  {
260  return "\"" + str + "\"";
261  }

+ Here is the caller graph for this function:

List<ExtArgumentType> com.mapd.parser.server.ExtensionFunction.getArgs ( )
inline

Definition at line 98 of file ExtensionFunction.java.

References run_benchmark_import.args.

98  {
99  return this.args;
100  }
List<ExtArgumentType> com.mapd.parser.server.ExtensionFunction.getOuts ( )
inline

Definition at line 102 of file ExtensionFunction.java.

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

102  {
103  return this.outs;
104  }

+ Here is the caller graph for this function:

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

Definition at line 106 of file ExtensionFunction.java.

106  {
107  return this.ret;
108  }
List<SqlTypeName> com.mapd.parser.server.ExtensionFunction.getSqlOuts ( )
inline

Definition at line 115 of file ExtensionFunction.java.

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

115  {
116  assert this.isTableUdf();
117  List<SqlTypeName> sql_outs = new ArrayList<SqlTypeName>();
118  for (final ExtArgumentType otype : this.getOuts()) {
119  sql_outs.add(toSqlTypeName(getValueType(otype)));
120  }
121  return sql_outs;
122  }
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 110 of file ExtensionFunction.java.

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

110  {
111  assert this.isRowUdf();
112  return toSqlTypeName(this.ret);
113  }
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 309 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, 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, and run_benchmark_import.type.

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

309  {
310  switch (type) {
311  case PInt8:
312  case ColumnInt8:
313  case ColumnListInt8:
314  case Int8:
315  return ExtArgumentType.Int8;
316  case PInt16:
317  case ColumnInt16:
318  case ColumnListInt16:
319  case Int16:
320  return ExtArgumentType.Int16;
321  case PInt32:
322  case ColumnInt32:
323  case ColumnListInt32:
324  case Int32:
325  return ExtArgumentType.Int32;
326  case PInt64:
327  case ColumnInt64:
328  case ColumnListInt64:
329  case Int64:
330  return ExtArgumentType.Int64;
331  case PFloat:
332  case ColumnFloat:
333  case ColumnListFloat:
334  case Float:
335  return ExtArgumentType.Float;
336  case PDouble:
337  case ColumnDouble:
338  case ColumnListDouble:
339  case Double:
340  return ExtArgumentType.Double;
341  case PBool:
342  case ColumnBool:
343  case ColumnListBool:
344  case Bool:
345  return ExtArgumentType.Bool;
346  }
347  MAPDLOGGER.error("getValueType: no value for type " + type);
348  assert false;
349  return null;
350  }

+ Here is the caller graph for this function:

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

Definition at line 299 of file ExtensionFunction.java.

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

299  {
300  return type == ExtArgumentType.ColumnListInt8
301  || type == ExtArgumentType.ColumnListInt16
302  || type == ExtArgumentType.ColumnListInt32
303  || type == ExtArgumentType.ColumnListInt64
304  || type == ExtArgumentType.ColumnListFloat
305  || type == ExtArgumentType.ColumnListDouble
307  }
static boolean com.mapd.parser.server.ExtensionFunction.isColumnType ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 292 of file ExtensionFunction.java.

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

292  {
293  return type == ExtArgumentType.ColumnInt8 || type == ExtArgumentType.ColumnInt16
294  || type == ExtArgumentType.ColumnInt32 || type == ExtArgumentType.ColumnInt64
295  || type == ExtArgumentType.ColumnFloat || type == ExtArgumentType.ColumnDouble
297  }
static boolean com.mapd.parser.server.ExtensionFunction.isPointerType ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 285 of file ExtensionFunction.java.

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

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

285  {
286  return type == ExtArgumentType.PInt8 || type == ExtArgumentType.PInt16
287  || type == ExtArgumentType.PInt32 || type == ExtArgumentType.PInt64
288  || type == ExtArgumentType.PFloat || type == ExtArgumentType.PDouble
290  }

+ Here is the caller graph for this function:

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

Definition at line 124 of file ExtensionFunction.java.

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

124  {
125  return this.isRowUdf;
126  }

+ Here is the caller graph for this function:

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

Definition at line 128 of file ExtensionFunction.java.

128  {
129  return !this.isRowUdf();
130  }
String com.mapd.parser.server.ExtensionFunction.toJson ( final String  name)
inline

Definition at line 132 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().

132  {
133  MAPDLOGGER.debug("Extensionfunction::toJson: " + name);
134  StringBuilder json_cons = new StringBuilder();
135  json_cons.append("{");
136  json_cons.append("\"name\":").append(dq(name)).append(",");
137  if (isRowUdf) {
138  json_cons.append("\"ret\":").append(dq(typeName(ret))).append(",");
139  } else {
140  json_cons.append("\"outs\":");
141  json_cons.append("[");
142  List<String> param_list = new ArrayList<String>();
143  for (final ExtArgumentType out : outs) {
144  param_list.add(dq(typeName(out)));
145  }
146  json_cons.append(ExtensionFunctionSignatureParser.join(param_list, ","));
147  json_cons.append("],");
148  }
149  json_cons.append("\"args\":");
150  json_cons.append("[");
151  List<String> param_list = new ArrayList<String>();
152  for (final ExtArgumentType arg : args) {
153  param_list.add(dq(typeName(arg)));
154  }
155  json_cons.append(ExtensionFunctionSignatureParser.join(param_list, ","));
156  json_cons.append("]");
157  json_cons.append("}");
158  return json_cons.toString();
159  }
string name
Definition: setup.in.py:62
size_t append(FILE *f, const size_t size, int8_t *buf)
Appends the specified number of bytes to the end of the file f from buf.
Definition: File.cpp:159
static String typeName(final ExtArgumentType type)
static String dq(final String str)

+ Here is the call graph for this function:

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

Definition at line 268 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.MapDSqlOperatorTable.ExtFunction.ExtFunction(), and com.mapd.calcite.parser.MapDSqlOperatorTable.ExtTableFunction.ExtTableFunction().

268  {
269  java.util.List<SqlTypeFamily> sql_sig = new java.util.ArrayList<SqlTypeFamily>();
270  boolean isRowUdf = this.isRowUdf();
271  for (int arg_idx = 0; arg_idx < this.getArgs().size(); ++arg_idx) {
272  final ExtArgumentType arg_type = this.getArgs().get(arg_idx);
273  if (isRowUdf) {
274  sql_sig.add(toSqlTypeName(arg_type).getFamily());
275  if (isPointerType(arg_type)) {
276  ++arg_idx;
277  }
278  } else {
279  sql_sig.add(toSqlTypeName(arg_type).getFamily());
280  }
281  }
282  return sql_sig;
283  }
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 352 of file ExtensionFunction.java.

References ARRAY, ArrayBool, ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, BIGINT, Bool, BOOLEAN, ColumnListBool, ColumnListDouble, ColumnListFloat, ColumnListInt16, ColumnListInt32, ColumnListInt64, ColumnListInt8, Cursor, CURSOR, Double, DOUBLE, Float, FLOAT, GEOMETRY, Int16, Int32, Int64, Int8, INTEGER, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, SMALLINT, TextEncodingDict16, TextEncodingDict32, TextEncodingDict8, TextEncodingNone, and TINYINT.

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

352  {
353  switch (type) {
354  case Bool:
355  return SqlTypeName.BOOLEAN;
356  case Int8:
357  return SqlTypeName.TINYINT;
358  case Int16:
359  return SqlTypeName.SMALLINT;
360  case Int32:
361  return SqlTypeName.INTEGER;
362  case Int64:
363  return SqlTypeName.BIGINT;
364  case Float:
365  return SqlTypeName.FLOAT;
366  case Double:
367  return SqlTypeName.DOUBLE;
368  case PInt8:
369  case PInt16:
370  case PInt32:
371  case PInt64:
372  case PFloat:
373  case PDouble:
374  case PBool:
375  case ArrayInt8:
376  case ArrayInt16:
377  case ArrayInt32:
378  case ArrayInt64:
379  case ArrayFloat:
380  case ArrayDouble:
381  case ArrayBool:
382  return SqlTypeName.ARRAY;
383  case GeoPoint:
384  case GeoLineString:
385  case GeoPolygon:
386  case GeoMultiPolygon:
387  return SqlTypeName.GEOMETRY;
388  case Cursor:
389  return SqlTypeName.CURSOR;
390  case TextEncodingNone:
391  return SqlTypeName.VARCHAR;
392  case TextEncodingDict8:
393  case TextEncodingDict16:
394  case TextEncodingDict32:
395  return SqlTypeName.VARCHAR; // ?
396  case ColumnListInt8:
397  case ColumnListInt16:
398  case ColumnListInt32:
399  case ColumnListInt64:
400  case ColumnListFloat:
401  case ColumnListDouble:
402  case ColumnListBool:
403  return SqlTypeName.COLUMN_LIST;
404  }
405  Set<SqlTypeName> allSqlTypeNames = EnumSet.allOf(SqlTypeName.class);
406  MAPDLOGGER.error("toSqlTypeName: unknown type " + type + " to be mapped to {"
407  + allSqlTypeNames + "}");
408  assert false;
409  return null;
410  }
#define GEOMETRY
#define CURSOR
#define SMALLINT
#define DOUBLE
#define BIGINT
#define TINYINT
#define ARRAY
#define FLOAT
#define BOOLEAN
#define INTEGER

+ Here is the caller graph for this function:

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

Definition at line 161 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, Cursor, Double, Float, Int16, Int32, Int64, Int8, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, TextEncodingDict16, TextEncodingDict32, TextEncodingDict8, TextEncodingNone, and Void.

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

161  {
162  switch (type) {
163  case Bool:
164  return "i1";
165  case Int8:
166  return "i8";
167  case Int16:
168  return "i16";
169  case Int32:
170  return "i32";
171  case Int64:
172  return "i64";
173  case Float:
174  return "float";
175  case Double:
176  return "double";
177  case Void:
178  return "void";
179  case PInt8:
180  return "i8*";
181  case PInt16:
182  return "i16*";
183  case PInt32:
184  return "i32*";
185  case PInt64:
186  return "i64*";
187  case PFloat:
188  return "float*";
189  case PDouble:
190  return "double*";
191  case PBool:
192  return "i1*";
193  case ArrayInt8:
194  return "{i8*, i64, i8}*";
195  case ArrayInt16:
196  return "{i16*, i64, i8}*";
197  case ArrayInt32:
198  return "{i32*, i64, i8}*";
199  case ArrayInt64:
200  return "{i64*, i64, i8}*";
201  case ArrayFloat:
202  return "{float*, i64, i8}*";
203  case ArrayDouble:
204  return "{double*, i64, i8}*";
205  case ArrayBool:
206  return "{i1*, i64, i8}*";
207  case ColumnInt8:
208  return "{i8*, i64}";
209  case ColumnInt16:
210  return "{i16*, i64}";
211  case ColumnInt32:
212  return "{i32*, i64}";
213  case ColumnInt64:
214  return "{i64*, i64}";
215  case ColumnFloat:
216  return "{float*, i64}";
217  case ColumnDouble:
218  return "{double*, i64}";
219  case ColumnBool:
220  return "{i1*, i64}";
221  case GeoPoint:
222  return "geo_point";
223  case Cursor:
224  return "cursor";
225  case GeoLineString:
226  return "geo_linestring";
227  case GeoPolygon:
228  return "geo_polygon";
229  case GeoMultiPolygon:
230  return "geo_multi_polygon";
231  case TextEncodingNone:
232  return "text_encoding_none";
233  case TextEncodingDict8:
234  return "text_encoding_dict8";
235  case TextEncodingDict16:
236  return "text_encoding_dict16";
237  case TextEncodingDict32:
238  return "text_encoding_dict32";
239  case ColumnListInt8:
240  return "column_list_int8";
241  case ColumnListInt16:
242  return "column_list_int16";
243  case ColumnListInt32:
244  return "column_list_int32";
245  case ColumnListInt64:
246  return "column_list_int64";
247  case ColumnListFloat:
248  return "column_list_float";
249  case ColumnListDouble:
250  return "column_list_double";
251  case ColumnListBool:
252  return "column_list_bool";
253  }
254  MAPDLOGGER.info("Extensionfunction::typeName: unknown type=`" + type + "`");
255  assert false;
256  return null;
257  }

+ Here is the caller graph for this function:

Member Data Documentation

final List<ExtArgumentType> com.mapd.parser.server.ExtensionFunction.args
private
final boolean com.mapd.parser.server.ExtensionFunction.isRowUdf
private

Definition at line 266 of file ExtensionFunction.java.

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

Definition at line 33 of file ExtensionFunction.java.

final List<ExtArgumentType> com.mapd.parser.server.ExtensionFunction.outs
private

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