OmniSciDB  bf83d84833
 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 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 77 of file ExtensionFunction.java.

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

77  {
78  this.args = args;
79  this.ret = ret;
80  this.outs = null;
81  this.isRowUdf = true;
82  }
com.mapd.parser.server.ExtensionFunction.ExtensionFunction ( final List< ExtArgumentType args,
final List< ExtArgumentType outs 
)
inlinepackage

Definition at line 84 of file ExtensionFunction.java.

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

84  {
85  this.args = args;
86  this.ret = null;
87  this.outs = outs;
88  this.isRowUdf = false;
89  }

Member Function Documentation

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

Definition at line 238 of file ExtensionFunction.java.

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

238  {
239  return "\"" + str + "\"";
240  }

+ Here is the caller graph for this function:

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

Definition at line 91 of file ExtensionFunction.java.

References run_benchmark_import.args.

91  {
92  return this.args;
93  }
List<ExtArgumentType> com.mapd.parser.server.ExtensionFunction.getOuts ( )
inline

Definition at line 95 of file ExtensionFunction.java.

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

95  {
96  return this.outs;
97  }

+ Here is the caller graph for this function:

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

Definition at line 99 of file ExtensionFunction.java.

99  {
100  return this.ret;
101  }
List<SqlTypeName> com.mapd.parser.server.ExtensionFunction.getSqlOuts ( )
inline

Definition at line 108 of file ExtensionFunction.java.

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

108  {
109  assert this.isTableUdf();
110  List<SqlTypeName> sql_outs = new ArrayList<SqlTypeName>();
111  for (final ExtArgumentType otype : this.getOuts()) {
112  sql_outs.add(toSqlTypeName(getValueType(otype)));
113  }
114  return sql_outs;
115  }
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 103 of file ExtensionFunction.java.

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

103  {
104  assert this.isRowUdf();
105  return toSqlTypeName(this.ret);
106  }
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 278 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Bool, Bool, ColumnBool, ColumnDouble, ColumnFloat, ColumnInt16, ColumnInt32, ColumnInt64, ColumnInt8, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Double, Double, 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().

278  {
279  switch (type) {
280  case PInt8:
281  case ColumnInt8:
282  case Int8:
283  return ExtArgumentType.Int8;
284  case ColumnInt16:
285  case PInt16:
286  case Int16:
287  return ExtArgumentType.Int16;
288  case PInt32:
289  case ColumnInt32:
290  case Int32:
291  return ExtArgumentType.Int32;
292  case PInt64:
293  case ColumnInt64:
294  case Int64:
295  return ExtArgumentType.Int64;
296  case PFloat:
297  case ColumnFloat:
298  case Float:
299  return ExtArgumentType.Float;
300  case PDouble:
301  case ColumnDouble:
302  case Double:
303  return ExtArgumentType.Double;
304  case PBool:
305  case ColumnBool:
306  case Bool:
307  return ExtArgumentType.Bool;
308  }
309  MAPDLOGGER.error("getValueType: no value for type " + type);
310  assert false;
311  return null;
312  }

+ Here is the caller graph for this function:

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

Definition at line 271 of file ExtensionFunction.java.

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

271  {
272  return type == ExtArgumentType.ColumnInt8 || type == ExtArgumentType.ColumnInt16
273  || type == ExtArgumentType.ColumnInt32 || type == ExtArgumentType.ColumnInt64
274  || type == ExtArgumentType.ColumnFloat || type == ExtArgumentType.ColumnDouble
276  }
static boolean com.mapd.parser.server.ExtensionFunction.isPointerType ( final ExtArgumentType  type)
inlinestaticprivate

Definition at line 264 of file ExtensionFunction.java.

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

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

264  {
265  return type == ExtArgumentType.PInt8 || type == ExtArgumentType.PInt16
266  || type == ExtArgumentType.PInt32 || type == ExtArgumentType.PInt64
267  || type == ExtArgumentType.PFloat || type == ExtArgumentType.PDouble
269  }

+ Here is the caller graph for this function:

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

Definition at line 117 of file ExtensionFunction.java.

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

117  {
118  return this.isRowUdf;
119  }

+ Here is the caller graph for this function:

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

Definition at line 121 of file ExtensionFunction.java.

121  {
122  return !this.isRowUdf();
123  }
String com.mapd.parser.server.ExtensionFunction.toJson ( final String  name)
inline

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

125  {
126  MAPDLOGGER.debug("Extensionfunction::toJson: " + name);
127  StringBuilder json_cons = new StringBuilder();
128  json_cons.append("{");
129  json_cons.append("\"name\":").append(dq(name)).append(",");
130  if (isRowUdf) {
131  json_cons.append("\"ret\":").append(dq(typeName(ret))).append(",");
132  } else {
133  json_cons.append("\"outs\":");
134  json_cons.append("[");
135  List<String> param_list = new ArrayList<String>();
136  for (final ExtArgumentType out : outs) {
137  param_list.add(dq(typeName(out)));
138  }
139  json_cons.append(ExtensionFunctionSignatureParser.join(param_list, ","));
140  json_cons.append("],");
141  }
142  json_cons.append("\"args\":");
143  json_cons.append("[");
144  List<String> param_list = new ArrayList<String>();
145  for (final ExtArgumentType arg : args) {
146  param_list.add(dq(typeName(arg)));
147  }
148  json_cons.append(ExtensionFunctionSignatureParser.join(param_list, ","));
149  json_cons.append("]");
150  json_cons.append("}");
151  return json_cons.toString();
152  }
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:141
static String typeName(final ExtArgumentType type)
static String dq(final String str)
string name
Definition: setup.py:35

+ Here is the call graph for this function:

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

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

247  {
248  java.util.List<SqlTypeFamily> sql_sig = new java.util.ArrayList<SqlTypeFamily>();
249  boolean isRowUdf = this.isRowUdf();
250  for (int arg_idx = 0; arg_idx < this.getArgs().size(); ++arg_idx) {
251  final ExtArgumentType arg_type = this.getArgs().get(arg_idx);
252  if (isRowUdf) {
253  sql_sig.add(toSqlTypeName(arg_type).getFamily());
254  if (isPointerType(arg_type)) {
255  ++arg_idx;
256  }
257  } else {
258  sql_sig.add(toSqlTypeName(arg_type).getFamily());
259  }
260  }
261  return sql_sig;
262  }
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 314 of file ExtensionFunction.java.

References ArrayBool, ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, Bool, Cursor, Double, Int16, Int32, Int64, Int8, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, TextEncodingDict16, TextEncodingDict32, TextEncodingDict8, and TextEncodingNone.

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

314  {
315  switch (type) {
316  case Bool:
317  return SqlTypeName.BOOLEAN;
318  case Int8:
319  return SqlTypeName.TINYINT;
320  case Int16:
321  return SqlTypeName.SMALLINT;
322  case Int32:
323  return SqlTypeName.INTEGER;
324  case Int64:
325  return SqlTypeName.BIGINT;
326  case Float:
327  return SqlTypeName.FLOAT;
328  case Double:
329  return SqlTypeName.DOUBLE;
330  case PInt8:
331  case PInt16:
332  case PInt32:
333  case PInt64:
334  case PFloat:
335  case PDouble:
336  case PBool:
337  case ArrayInt8:
338  case ArrayInt16:
339  case ArrayInt32:
340  case ArrayInt64:
341  case ArrayFloat:
342  case ArrayDouble:
343  case ArrayBool:
344  return SqlTypeName.ARRAY;
345  case GeoPoint:
346  case GeoLineString:
347  case GeoPolygon:
348  case GeoMultiPolygon:
349  return SqlTypeName.GEOMETRY;
350  case Cursor:
351  return SqlTypeName.CURSOR;
352  case TextEncodingNone:
353  return SqlTypeName.VARCHAR;
354  case TextEncodingDict8:
355  case TextEncodingDict16:
356  case TextEncodingDict32:
357  return SqlTypeName.VARCHAR; // ?
358  }
359  Set<SqlTypeName> allSqlTypeNames = EnumSet.allOf(SqlTypeName.class);
360  MAPDLOGGER.error("toSqlTypeName: unknown type " + type + " to be mapped to {"
361  + allSqlTypeNames + "}");
362  assert false;
363  return null;
364  }

+ Here is the caller graph for this function:

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

Definition at line 154 of file ExtensionFunction.java.

References ArrayBool, ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, Bool, ColumnBool, ColumnDouble, ColumnFloat, ColumnInt16, ColumnInt32, ColumnInt64, ColumnInt8, Cursor, Double, 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().

154  {
155  switch (type) {
156  case Bool:
157  return "i1";
158  case Int8:
159  return "i8";
160  case Int16:
161  return "i16";
162  case Int32:
163  return "i32";
164  case Int64:
165  return "i64";
166  case Float:
167  return "float";
168  case Double:
169  return "double";
170  case Void:
171  return "void";
172  case PInt8:
173  return "i8*";
174  case PInt16:
175  return "i16*";
176  case PInt32:
177  return "i32*";
178  case PInt64:
179  return "i64*";
180  case PFloat:
181  return "float*";
182  case PDouble:
183  return "double*";
184  case PBool:
185  return "i1*";
186  case ArrayInt8:
187  return "{i8*, i64, i8}*";
188  case ArrayInt16:
189  return "{i16*, i64, i8}*";
190  case ArrayInt32:
191  return "{i32*, i64, i8}*";
192  case ArrayInt64:
193  return "{i64*, i64, i8}*";
194  case ArrayFloat:
195  return "{float*, i64, i8}*";
196  case ArrayDouble:
197  return "{double*, i64, i8}*";
198  case ArrayBool:
199  return "{i1*, i64, i8}*";
200  case ColumnInt8:
201  return "{i8*, i64}";
202  case ColumnInt16:
203  return "{i16*, i64}";
204  case ColumnInt32:
205  return "{i32*, i64}";
206  case ColumnInt64:
207  return "{i64*, i64}";
208  case ColumnFloat:
209  return "{float*, i64}";
210  case ColumnDouble:
211  return "{double*, i64}";
212  case ColumnBool:
213  return "{i1*, i64}";
214  case GeoPoint:
215  return "geo_point";
216  case Cursor:
217  return "cursor";
218  case GeoLineString:
219  return "geo_linestring";
220  case GeoPolygon:
221  return "geo_polygon";
222  case GeoMultiPolygon:
223  return "geo_multi_polygon";
224  case TextEncodingNone:
225  return "text_encoding_none";
226  case TextEncodingDict8:
227  return "text_encoding_dict8";
228  case TextEncodingDict16:
229  return "text_encoding_dict16";
230  case TextEncodingDict32:
231  return "text_encoding_dict32";
232  }
233  MAPDLOGGER.info("Extensionfunction::typeName: unknown type=`" + type + "`");
234  assert false;
235  return null;
236  }

+ 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
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: