OmniSciDB  8a228a1076
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 30 of file ExtensionFunction.java.

Constructor & Destructor Documentation

◆ ExtensionFunction() [1/2]

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

Definition at line 71 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.args, com.mapd.parser.server.ExtensionFunction.isRowUdf(), com.mapd.parser.server.ExtensionFunction.outs, and com.mapd.parser.server.ExtensionFunction.ret.

71  {
72  this.args = args;
73  this.ret = ret;
74  this.outs = null;
75  this.isRowUdf = true;
76  }
+ Here is the call graph for this function:

◆ ExtensionFunction() [2/2]

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

Definition at line 78 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.args, com.mapd.parser.server.ExtensionFunction.isRowUdf(), com.mapd.parser.server.ExtensionFunction.outs, and com.mapd.parser.server.ExtensionFunction.ret.

78  {
79  this.args = args;
80  this.ret = null;
81  this.outs = outs;
82  this.isRowUdf = false;
83  }
+ Here is the call graph for this function:

Member Function Documentation

◆ dq()

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

Definition at line 225 of file ExtensionFunction.java.

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

225  {
226  return "\"" + str + "\"";
227  }
+ Here is the caller graph for this function:

◆ getArgs()

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

Definition at line 85 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.args.

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

85  {
86  return this.args;
87  }
+ Here is the caller graph for this function:

◆ getOuts()

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

Definition at line 89 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.outs.

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

89  {
90  return this.outs;
91  }
+ Here is the caller graph for this function:

◆ getRet()

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

Definition at line 93 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.ret.

93  {
94  return this.ret;
95  }

◆ getSqlOuts()

List<SqlTypeName> com.mapd.parser.server.ExtensionFunction.getSqlOuts ( )
inline

Definition at line 102 of file ExtensionFunction.java.

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

Referenced by com.mapd.calcite.parser.MapDSqlOperatorTable.ExtFunction.ExtFunction().

102  {
103  assert this.isTableUdf();
104  List<SqlTypeName> sql_outs = new ArrayList<SqlTypeName>();
105  for (final ExtArgumentType otype : this.getOuts()) {
106  assert isColumnType(otype);
107  sql_outs.add(toSqlTypeName(getValueType(otype)));
108  }
109  return sql_outs;
110  }
static SqlTypeName toSqlTypeName(final ExtArgumentType type)
static boolean isColumnType(final ExtArgumentType type)
static ExtArgumentType getValueType(final ExtArgumentType type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSqlRet()

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

Definition at line 97 of file ExtensionFunction.java.

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

Referenced by com.mapd.calcite.parser.MapDSqlOperatorTable.ExtFunction.ExtFunction().

97  {
98  assert this.isRowUdf();
99  return toSqlTypeName(this.ret);
100  }
static SqlTypeName toSqlTypeName(final ExtArgumentType type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValueType()

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

Definition at line 266 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Bool, ColumnBool, ColumnDouble, ColumnFloat, ColumnInt16, ColumnInt32, ColumnInt64, ColumnInt8, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Double, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Float, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Int16, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Int32, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Int64, com.mapd.parser.server.ExtensionFunction.ExtArgumentType.Int8, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, and PInt8.

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

266  {
267  switch (type) {
268  case PInt8:
269  case ColumnInt8:
270  return ExtArgumentType.Int8;
271  case ColumnInt16:
272  case PInt16:
273  return ExtArgumentType.Int16;
274  case PInt32:
275  case ColumnInt32:
276  return ExtArgumentType.Int32;
277  case PInt64:
278  case ColumnInt64:
279  return ExtArgumentType.Int64;
280  case PFloat:
281  case ColumnFloat:
282  return ExtArgumentType.Float;
283  case PDouble:
284  case ColumnDouble:
285  return ExtArgumentType.Double;
286  case PBool:
287  case ColumnBool:
288  return ExtArgumentType.Bool;
289  }
290  MAPDLOGGER.error("getValueType: no value for type " + type);
291  assert false;
292  return null;
293  }
+ Here is the caller graph for this function:

◆ isColumnType()

◆ isPointerType()

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

◆ isRowUdf()

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

Definition at line 112 of file ExtensionFunction.java.

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

112  {
113  return this.isRowUdf;
114  }
+ Here is the caller graph for this function:

◆ isTableUdf()

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

Definition at line 116 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.isRowUdf().

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

116  {
117  return !this.isRowUdf();
118  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toJson()

String com.mapd.parser.server.ExtensionFunction.toJson ( final String  name)
inline

Definition at line 120 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.args, com.mapd.parser.server.ExtensionFunction.dq(), com.mapd.parser.server.ExtensionFunction.isRowUdf(), com.mapd.parser.server.ExtensionFunctionSignatureParser.join(), out, com.mapd.parser.server.ExtensionFunction.outs, com.mapd.parser.server.ExtensionFunction.ret, and com.mapd.parser.server.ExtensionFunction.typeName().

120  {
121  MAPDLOGGER.debug("Extensionfunction::toJson: " + name);
122  StringBuilder json_cons = new StringBuilder();
123  json_cons.append("{");
124  json_cons.append("\"name\":").append(dq(name)).append(",");
125  if (isRowUdf) {
126  json_cons.append("\"ret\":").append(dq(typeName(ret))).append(",");
127  } else {
128  json_cons.append("\"outs\":");
129  json_cons.append("[");
130  List<String> param_list = new ArrayList<String>();
131  for (final ExtArgumentType out : outs) {
132  param_list.add(dq(typeName(out)));
133  }
134  json_cons.append(ExtensionFunctionSignatureParser.join(param_list, ","));
135  json_cons.append("],");
136  }
137  json_cons.append("\"args\":");
138  json_cons.append("[");
139  List<String> param_list = new ArrayList<String>();
140  for (final ExtArgumentType arg : args) {
141  param_list.add(dq(typeName(arg)));
142  }
143  json_cons.append(ExtensionFunctionSignatureParser.join(param_list, ","));
144  json_cons.append("]");
145  json_cons.append("}");
146  return json_cons.toString();
147  }
static String typeName(final ExtArgumentType type)
static String dq(final String str)
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t ** out
+ Here is the call graph for this function:

◆ toSqlSignature()

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

Definition at line 234 of file ExtensionFunction.java.

References com.mapd.parser.server.ExtensionFunction.getArgs(), com.mapd.parser.server.ExtensionFunction.isColumnType(), 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().

234  {
235  java.util.List<SqlTypeFamily> sql_sig = new java.util.ArrayList<SqlTypeFamily>();
236  boolean isRowUdf = this.isRowUdf();
237  for (int arg_idx = 0; arg_idx < this.getArgs().size(); ++arg_idx) {
238  final ExtArgumentType arg_type = this.getArgs().get(arg_idx);
239  if (isRowUdf) {
240  sql_sig.add(toSqlTypeName(arg_type).getFamily());
241  if (isPointerType(arg_type)) {
242  ++arg_idx;
243  }
244  } else {
245  assert isColumnType(arg_type);
246  sql_sig.add(toSqlTypeName(arg_type).getFamily());
247  }
248  }
249  return sql_sig;
250  }
static SqlTypeName toSqlTypeName(final ExtArgumentType type)
static boolean isColumnType(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:

◆ toSqlTypeName()

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

Definition at line 295 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, and PInt8.

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

295  {
296  switch (type) {
297  case Bool:
298  return SqlTypeName.BOOLEAN;
299  case Int8:
300  return SqlTypeName.TINYINT;
301  case Int16:
302  return SqlTypeName.SMALLINT;
303  case Int32:
304  return SqlTypeName.INTEGER;
305  case Int64:
306  return SqlTypeName.BIGINT;
307  case Float:
308  return SqlTypeName.FLOAT;
309  case Double:
310  return SqlTypeName.DOUBLE;
311  case PInt8:
312  case PInt16:
313  case PInt32:
314  case PInt64:
315  case PFloat:
316  case PDouble:
317  case PBool:
318  case ArrayInt8:
319  case ArrayInt16:
320  case ArrayInt32:
321  case ArrayInt64:
322  case ArrayFloat:
323  case ArrayDouble:
324  case ArrayBool:
325  return SqlTypeName.ARRAY;
326  case GeoPoint:
327  case GeoLineString:
328  case GeoPolygon:
329  case GeoMultiPolygon:
330  return SqlTypeName.GEOMETRY;
331  case Cursor:
332  return SqlTypeName.CURSOR;
333  }
334  MAPDLOGGER.error("toSqlTypeName: unknown type " + type);
335  assert false;
336  return null;
337  }
+ Here is the caller graph for this function:

◆ typeName()

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

Definition at line 149 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, and Void.

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

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

Member Data Documentation

◆ args

◆ isRowUdf

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

◆ MAPDLOGGER

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

Definition at line 31 of file ExtensionFunction.java.

◆ outs

◆ ret


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