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

Public Member Functions

 CalciteServerHandler (int dbPort, String dataDir, String extensionFunctionsAstFile, SockTransportProperties skT, String udfAstFile)
 
void ping () throws TException
 
TPlanResult process (String user, String session, String catalog, String queryText, TQueryParsingOption queryParsingOption, TOptimizationOption optimizationOption, List< TRestriction > trestrictions) throws InvalidParseRequest, TException
 
void shutdown () throws TException
 
String getExtensionFunctionWhitelist ()
 
String getUserDefinedFunctionWhitelist ()
 
String getRuntimeExtensionFunctionWhitelist ()
 
void updateMetadata (String catalog, String table) throws TException
 
List< TCompletionHint > getCompletionHints (String user, String session, String catalog, List< String > visible_tables, String sql, int cursor) throws TException
 
void setRuntimeExtensionFunctions (List< TUserDefinedFunction > udfs, List< TUserDefinedTableFunction > udtfs, boolean isruntime)
 

Package Functions

void setServer (TServer s)
 

Package Attributes

Map< String, ExtensionFunctionudfRTSigs = null
 
Map< String, ExtensionFunctionudtfSigs = null
 

Static Package Attributes

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

Static Private Member Functions

static ExtensionFunction toExtensionFunction (TUserDefinedFunction udf, boolean isruntime)
 
static ExtensionFunction toExtensionFunction (TUserDefinedTableFunction udtf, boolean isruntime)
 
static
ExtensionFunction.ExtArgumentType 
toExtArgumentType (TExtArgumentType type)
 
static TCompletionHintType hintTypeToThrift (final SqlMonikerType type)
 

Private Attributes

TServer server
 
final int dbPort
 
volatile long callCount
 
final GenericObjectPool parserPool
 
final CalciteParserFactory calciteParserFactory
 
final String extSigsJson
 
final String udfSigsJson
 
String udfRTSigsJson = ""
 
SockTransportProperties skT
 
Map< String, ExtensionFunctionextSigs = null
 
String dataDir
 

Detailed Description

Definition at line 67 of file CalciteServerHandler.java.

Constructor & Destructor Documentation

com.mapd.parser.server.CalciteServerHandler.CalciteServerHandler ( int  dbPort,
String  dataDir,
String  extensionFunctionsAstFile,
SockTransportProperties  skT,
String  udfAstFile 
)
inline

Definition at line 94 of file CalciteServerHandler.java.

References com.mapd.parser.server.CalciteServerHandler.calciteParserFactory, com.mapd.parser.server.CalciteServerHandler.dataDir, com.mapd.parser.server.CalciteServerHandler.dbPort, com.mapd.parser.server.CalciteServerHandler.extSigs, com.mapd.parser.server.CalciteServerHandler.extSigsJson, and com.mapd.parser.server.CalciteServerHandler.udfSigsJson.

98  {
99  this.dbPort = dbPort;
100  this.dataDir = dataDir;
101 
102  Map<String, ExtensionFunction> udfSigs = null;
103 
104  try {
105  extSigs = ExtensionFunctionSignatureParser.parse(extensionFunctionsAstFile);
106  } catch (IOException ex) {
107  HEAVYDBLOGGER.error(
108  "Could not load extension function signatures: " + ex.getMessage(), ex);
109  }
110  extSigsJson = ExtensionFunctionSignatureParser.signaturesToJson(extSigs);
111 
112  try {
113  if (!udfAstFile.isEmpty()) {
114  udfSigs = ExtensionFunctionSignatureParser.parseUdfAst(udfAstFile);
115  }
116  } catch (IOException ex) {
117  HEAVYDBLOGGER.error(
118  "Could not load udf function signatures: " + ex.getMessage(), ex);
119  }
120  udfSigsJson = ExtensionFunctionSignatureParser.signaturesToJson(udfSigs);
121 
122  // Put all the udf functions signatures in extSigs so Calcite has a view of
123  // extension functions and udf functions
124  if (!udfAstFile.isEmpty()) {
125  extSigs.putAll(udfSigs);
126  }
127 
128  calciteParserFactory = new CalciteParserFactory(dataDir, extSigs, dbPort, skT);
129 
130  // GenericObjectPool::setFactory is deprecated
131  this.parserPool = new GenericObjectPool(calciteParserFactory);
132  }

Member Function Documentation

List<TCompletionHint> com.mapd.parser.server.CalciteServerHandler.getCompletionHints ( String  user,
String  session,
String  catalog,
List< String >  visible_tables,
String  sql,
int  cursor 
) throws TException
inline

Definition at line 339 of file CalciteServerHandler.java.

References com.mapd.parser.server.CalciteServerHandler.callCount, com.mapd.parser.server.CalciteServerHandler.dbPort, com.mapd.parser.server.CalciteServerHandler.hintTypeToThrift(), run_benchmark_import.parser, com.mapd.parser.server.CalciteServerHandler.parserPool, and run_benchmark_import.result.

344  {
345  callCount++;
346  HeavyDBParser parser;
347  try {
348  parser = (HeavyDBParser) parserPool.borrowObject();
349  } catch (Exception ex) {
350  String msg = "Could not get Parse Item from pool: " + ex.getMessage();
351  HEAVYDBLOGGER.error(msg, ex);
352  throw new TException(msg);
353  }
354  HeavyDBUser dbUser = new HeavyDBUser(user, session, catalog, dbPort, null);
355  HEAVYDBLOGGER.debug("getCompletionHints was called User: " + user
356  + " Catalog: " + catalog + " sql: " + sql);
357  parser.setUser(dbUser);
358  CURRENT_PARSER.set(parser);
359 
360  HeavyDBPlanner.CompletionResult completion_result;
361  try {
362  completion_result = parser.getCompletionHints(sql, cursor, visible_tables);
363  } catch (Exception ex) {
364  String msg = "Could not retrieve completion hints: " + ex.getMessage();
365  HEAVYDBLOGGER.error(msg, ex);
366  return new ArrayList<>();
367  } finally {
368  CURRENT_PARSER.set(null);
369  try {
370  // put parser object back in pool for others to use
371  parserPool.returnObject(parser);
372  } catch (Exception ex) {
373  String msg = "Could not return parse object: " + ex.getMessage();
374  HEAVYDBLOGGER.error(msg, ex);
375  throw new InvalidParseRequest(-4, msg);
376  }
377  }
378  List<TCompletionHint> result = new ArrayList<>();
379  for (final SqlMoniker hint : completion_result.hints) {
380  result.add(new TCompletionHint(hintTypeToThrift(hint.getType()),
381  hint.getFullyQualifiedNames(),
382  completion_result.replaced));
383  }
384  return result;
385  }
static TCompletionHintType hintTypeToThrift(final SqlMonikerType type)

+ Here is the call graph for this function:

String com.mapd.parser.server.CalciteServerHandler.getExtensionFunctionWhitelist ( )
inline

Definition at line 290 of file CalciteServerHandler.java.

290  {
291  return this.extSigsJson;
292  }
String com.mapd.parser.server.CalciteServerHandler.getRuntimeExtensionFunctionWhitelist ( )
inline

Definition at line 300 of file CalciteServerHandler.java.

300  {
301  return this.udfRTSigsJson;
302  }
String com.mapd.parser.server.CalciteServerHandler.getUserDefinedFunctionWhitelist ( )
inline

Definition at line 295 of file CalciteServerHandler.java.

295  {
296  return this.udfSigsJson;
297  }
static TCompletionHintType com.mapd.parser.server.CalciteServerHandler.hintTypeToThrift ( final SqlMonikerType  type)
inlinestaticprivate

Definition at line 649 of file CalciteServerHandler.java.

Referenced by com.mapd.parser.server.CalciteServerHandler.getCompletionHints().

649  {
650  switch (type) {
651  case COLUMN:
652  return TCompletionHintType.COLUMN;
653  case TABLE:
654  return TCompletionHintType.TABLE;
655  case VIEW:
656  return TCompletionHintType.VIEW;
657  case SCHEMA:
658  return TCompletionHintType.SCHEMA;
659  case CATALOG:
660  return TCompletionHintType.CATALOG;
661  case REPOSITORY:
662  return TCompletionHintType.REPOSITORY;
663  case FUNCTION:
664  return TCompletionHintType.FUNCTION;
665  case KEYWORD:
666  return TCompletionHintType.KEYWORD;
667  default:
668  return null;
669  }
670  }

+ Here is the caller graph for this function:

void com.mapd.parser.server.CalciteServerHandler.ping ( ) throws TException
inline

Definition at line 135 of file CalciteServerHandler.java.

135  {
136  HEAVYDBLOGGER.debug("Ping hit");
137  }
TPlanResult com.mapd.parser.server.CalciteServerHandler.process ( String  user,
String  session,
String  catalog,
String  queryText,
TQueryParsingOption  queryParsingOption,
TOptimizationOption  optimizationOption,
List< TRestriction >  trestrictions 
) throws InvalidParseRequest, TException
inline

Definition at line 140 of file CalciteServerHandler.java.

References com.mapd.parser.server.CalciteServerHandler.callCount, com.mapd.parser.server.CalciteServerHandler.dbPort, run_benchmark_import.parser, com.mapd.parser.server.CalciteServerHandler.parserPool, run_benchmark_import.res, run_benchmark_import.result, and toString().

146  {
147  long timer = System.currentTimeMillis();
148  callCount++;
149 
150  HeavyDBParser parser;
151  try {
152  parser = (HeavyDBParser) parserPool.borrowObject();
153  parser.clearMemo();
154  } catch (Exception ex) {
155  String msg = "Could not get Parse Item from pool: " + ex.getMessage();
156  HEAVYDBLOGGER.error(msg, ex);
157  throw new InvalidParseRequest(-1, msg);
158  }
159  List<Restriction> rests = null;
160  if (trestrictions != null && !trestrictions.isEmpty()) {
161  rests = new ArrayList<>();
162  for (TRestriction trestriction : trestrictions) {
163  Restriction rest = null;
164  rest = new Restriction(trestriction.database,
165  trestriction.table,
166  trestriction.column,
167  trestriction.values);
168  rests.add(rest);
169  }
170  }
171  HeavyDBUser dbUser = new HeavyDBUser(user, session, catalog, dbPort, rests);
172  HEAVYDBLOGGER.debug("process was called User: " + user + " Catalog: " + catalog
173  + " sql: " + queryText);
174  parser.setUser(dbUser);
175  CURRENT_PARSER.set(parser);
176 
177  // this code path is introduced to execute a query for intel-modin project
178  // they appended a special prefix "execute calcite" to distinguish their usage
179  boolean buildRATreeFromRAString = false;
180  if (queryText.startsWith("execute calcite")) {
181  queryText = queryText.replaceFirst("execute calcite", "");
182  buildRATreeFromRAString = true;
183  }
184 
185  // need to trim the sql string as it seems it is not trimed prior to here
186  queryText = queryText.trim();
187  // remove last charcter if it is a ;
188  if (queryText.length() > 0 && queryText.charAt(queryText.length() - 1) == ';') {
189  queryText = queryText.substring(0, queryText.length() - 1);
190  }
191  String jsonResult;
192  SqlIdentifierCapturer capturer;
193  TAccessedQueryObjects primaryAccessedObjects = new TAccessedQueryObjects();
194  TAccessedQueryObjects resolvedAccessedObjects = new TAccessedQueryObjects();
195  try {
196  final List<HeavyDBParserOptions.FilterPushDownInfo> filterPushDownInfo =
197  new ArrayList<>();
198  for (final TFilterPushDownInfo req : optimizationOption.filter_push_down_info) {
199  filterPushDownInfo.add(new HeavyDBParserOptions.FilterPushDownInfo(
200  req.input_prev, req.input_start, req.input_next));
201  }
202  HeavyDBParserOptions parserOptions = new HeavyDBParserOptions(filterPushDownInfo,
203  queryParsingOption.legacy_syntax,
204  queryParsingOption.is_explain,
205  optimizationOption.is_view_optimize,
206  optimizationOption.enable_watchdog,
207  optimizationOption.distributed_mode);
208 
209  if (!buildRATreeFromRAString) {
210  Pair<String, SqlIdentifierCapturer> res;
211  SqlNode node;
212 
213  res = parser.process(queryText, parserOptions);
214  jsonResult = res.left;
215  capturer = res.right;
216 
217  primaryAccessedObjects.tables_selected_from = new ArrayList<>(capturer.selects);
218  primaryAccessedObjects.tables_inserted_into = new ArrayList<>(capturer.inserts);
219  primaryAccessedObjects.tables_updated_in = new ArrayList<>(capturer.updates);
220  primaryAccessedObjects.tables_deleted_from = new ArrayList<>(capturer.deletes);
221 
222  // also resolve all the views in the select part
223  // resolution of the other parts is not
224  // necessary as these cannot be views
225  resolvedAccessedObjects.tables_selected_from =
226  new ArrayList<>(parser.resolveSelectIdentifiers(capturer));
227  resolvedAccessedObjects.tables_inserted_into = new ArrayList<>(capturer.inserts);
228  resolvedAccessedObjects.tables_updated_in = new ArrayList<>(capturer.updates);
229  resolvedAccessedObjects.tables_deleted_from = new ArrayList<>(capturer.deletes);
230 
231  } else {
232  // exploit Calcite's query optimization rules for RA string
233  jsonResult =
234  parser.buildRATreeAndPerformQueryOptimization(queryText, parserOptions);
235  }
236  } catch (SqlParseException ex) {
237  String msg = "SQL Error: " + ex.getMessage();
238  HEAVYDBLOGGER.error(msg);
239  throw new InvalidParseRequest(-2, msg);
240  } catch (org.apache.calcite.tools.ValidationException ex) {
241  String msg = "SQL Error: " + ex.getMessage();
242  if (ex.getCause() != null
243  && (ex.getCause().getClass() == CalciteContextException.class)) {
244  msg = "SQL Error: " + ex.getCause().getMessage();
245  }
246  HEAVYDBLOGGER.error(msg);
247  throw new InvalidParseRequest(-3, msg);
248  } catch (CalciteContextException ex) {
249  String msg = ex.getMessage();
250  HEAVYDBLOGGER.error(msg);
251  throw new InvalidParseRequest(-6, msg);
252  } catch (RelConversionException ex) {
253  String msg = "Failed to generate relational algebra for query " + ex.getMessage();
254  HEAVYDBLOGGER.error(msg, ex);
255  throw new InvalidParseRequest(-5, msg);
256  } catch (Throwable ex) {
257  HEAVYDBLOGGER.error(ex.getClass().toString());
258  String msg = ex.getMessage();
259  HEAVYDBLOGGER.error(msg, ex);
260  throw new InvalidParseRequest(-4, msg);
261  } finally {
262  CURRENT_PARSER.set(null);
263  try {
264  // put parser object back in pool for others to use
265  parserPool.returnObject(parser);
266  } catch (Exception ex) {
267  String msg = "Could not return parse object: " + ex.getMessage();
268  HEAVYDBLOGGER.error(msg, ex);
269  throw new InvalidParseRequest(-7, msg);
270  }
271  }
272 
273  TPlanResult result = new TPlanResult();
274  result.primary_accessed_objects = primaryAccessedObjects;
275  result.resolved_accessed_objects = resolvedAccessedObjects;
276  result.plan_result = jsonResult;
277  result.execution_time_ms = System.currentTimeMillis() - timer;
278 
279  return result;
280  }
std::string toString(const ExecutorDeviceType &device_type)

+ Here is the call graph for this function:

void com.mapd.parser.server.CalciteServerHandler.setRuntimeExtensionFunctions ( List< TUserDefinedFunction >  udfs,
List< TUserDefinedTableFunction >  udtfs,
boolean  isruntime 
)
inline

Definition at line 388 of file CalciteServerHandler.java.

References com.mapd.parser.server.CalciteServerHandler.extSigs, setup.name, com.mapd.parser.server.CalciteServerHandler.toExtensionFunction(), com.mapd.parser.server.CalciteServerHandler.udfRTSigs, com.mapd.parser.server.CalciteServerHandler.udfRTSigsJson, and com.mapd.parser.server.CalciteServerHandler.udtfSigs.

390  {
391  if (isruntime) {
392  // Clean up previously defined Runtime UDFs
393  if (udfRTSigs != null) {
394  for (String name : udfRTSigs.keySet()) extSigs.remove(name);
395  udfRTSigsJson = "";
396  udfRTSigs.clear();
397  } else {
398  udfRTSigs = new HashMap<String, ExtensionFunction>();
399  }
400 
401  for (TUserDefinedFunction udf : udfs) {
402  udfRTSigs.put(udf.name, toExtensionFunction(udf, isruntime));
403  }
404 
405  for (TUserDefinedTableFunction udtf : udtfs) {
406  udfRTSigs.put(udtf.name, toExtensionFunction(udtf, isruntime));
407  }
408 
409  // Avoid overwritting compiled and Loadtime UDFs:
410  for (String name : udfRTSigs.keySet()) {
411  if (extSigs.containsKey(name)) {
412  HEAVYDBLOGGER.error("Extension function `" + name
413  + "` exists. Skipping runtime extenension function with the same name.");
414  udfRTSigs.remove(name);
415  }
416  }
417  // udfRTSigsJson will contain only the signatures of UDFs:
418  udfRTSigsJson = ExtensionFunctionSignatureParser.signaturesToJson(udfRTSigs);
419  // Expose RT UDFs to Calcite server:
420  extSigs.putAll(udfRTSigs);
421  } else {
422  // currently only LoadTime UDTFs can be registered via calcite thrift interface
423  if (udtfSigs == null) {
424  udtfSigs = new HashMap<String, ExtensionFunction>();
425  }
426 
427  for (TUserDefinedTableFunction udtf : udtfs) {
428  udtfSigs.put(udtf.name, toExtensionFunction(udtf, isruntime));
429  }
430 
431  extSigs.putAll(udtfSigs);
432  }
433 
434  calciteParserFactory.updateOperatorTable();
435  }
Map< String, ExtensionFunction > udfRTSigs
static ExtensionFunction toExtensionFunction(TUserDefinedFunction udf, boolean isruntime)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

void com.mapd.parser.server.CalciteServerHandler.setServer ( TServer  s)
inlinepackage
void com.mapd.parser.server.CalciteServerHandler.shutdown ( ) throws TException
inline

Definition at line 283 of file CalciteServerHandler.java.

283  {
284  // received request to shutdown
285  HEAVYDBLOGGER.debug("Shutdown calcite java server");
286  server.stop();
287  }
static ExtensionFunction.ExtArgumentType com.mapd.parser.server.CalciteServerHandler.toExtArgumentType ( TExtArgumentType  type)
inlinestaticprivate

Definition at line 504 of file CalciteServerHandler.java.

References ArrayBool, ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, ArrayTextEncodingDict, Bool, ColumnArrayBool, ColumnArrayDouble, ColumnArrayFloat, ColumnArrayInt16, ColumnArrayInt32, ColumnArrayInt64, ColumnArrayInt8, ColumnArrayTextEncodingDict, ColumnBool, ColumnDouble, ColumnFloat, ColumnInt16, ColumnInt32, ColumnInt64, ColumnInt8, ColumnListArrayBool, ColumnListArrayDouble, ColumnListArrayFloat, ColumnListArrayInt16, ColumnListArrayInt32, ColumnListArrayInt64, ColumnListArrayInt8, ColumnListArrayTextEncodingDict, ColumnListBool, ColumnListDouble, ColumnListFloat, ColumnListInt16, ColumnListInt32, ColumnListInt64, ColumnListInt8, ColumnListTextEncodingDict, ColumnTextEncodingDict, ColumnTimestamp, Cursor, Double, Float, Int16, Int32, Int64, Int8, PBool, PDouble, PFloat, PInt16, PInt32, PInt64, PInt8, run_benchmark_import.type, and Void.

Referenced by com.mapd.parser.server.CalciteServerHandler.toExtensionFunction().

505  {
506  switch (type) {
507  case Int8:
508  return ExtensionFunction.ExtArgumentType.Int8;
509  case Int16:
510  return ExtensionFunction.ExtArgumentType.Int16;
511  case Int32:
512  return ExtensionFunction.ExtArgumentType.Int32;
513  case Int64:
514  return ExtensionFunction.ExtArgumentType.Int64;
515  case Float:
516  return ExtensionFunction.ExtArgumentType.Float;
517  case Double:
519  case Void:
520  return ExtensionFunction.ExtArgumentType.Void;
521  case PInt8:
522  return ExtensionFunction.ExtArgumentType.PInt8;
523  case PInt16:
524  return ExtensionFunction.ExtArgumentType.PInt16;
525  case PInt32:
526  return ExtensionFunction.ExtArgumentType.PInt32;
527  case PInt64:
528  return ExtensionFunction.ExtArgumentType.PInt64;
529  case PFloat:
530  return ExtensionFunction.ExtArgumentType.PFloat;
531  case PDouble:
532  return ExtensionFunction.ExtArgumentType.PDouble;
533  case PBool:
534  return ExtensionFunction.ExtArgumentType.PBool;
535  case Bool:
536  return ExtensionFunction.ExtArgumentType.Bool;
537  case ArrayInt8:
538  return ExtensionFunction.ExtArgumentType.ArrayInt8;
539  case ArrayInt16:
540  return ExtensionFunction.ExtArgumentType.ArrayInt16;
541  case ArrayInt32:
542  return ExtensionFunction.ExtArgumentType.ArrayInt32;
543  case ArrayInt64:
544  return ExtensionFunction.ExtArgumentType.ArrayInt64;
545  case ArrayFloat:
546  return ExtensionFunction.ExtArgumentType.ArrayFloat;
547  case ArrayDouble:
548  return ExtensionFunction.ExtArgumentType.ArrayDouble;
549  case ArrayBool:
550  return ExtensionFunction.ExtArgumentType.ArrayBool;
552  return ExtensionFunction.ExtArgumentType.ArrayTextEncodingDict;
553  case ColumnInt8:
554  return ExtensionFunction.ExtArgumentType.ColumnInt8;
555  case ColumnInt16:
556  return ExtensionFunction.ExtArgumentType.ColumnInt16;
557  case ColumnInt32:
558  return ExtensionFunction.ExtArgumentType.ColumnInt32;
559  case ColumnInt64:
560  return ExtensionFunction.ExtArgumentType.ColumnInt64;
561  case ColumnFloat:
562  return ExtensionFunction.ExtArgumentType.ColumnFloat;
563  case ColumnDouble:
564  return ExtensionFunction.ExtArgumentType.ColumnDouble;
565  case ColumnBool:
566  return ExtensionFunction.ExtArgumentType.ColumnBool;
568  return ExtensionFunction.ExtArgumentType.ColumnTextEncodingDict;
569  case ColumnTimestamp:
570  return ExtensionFunction.ExtArgumentType.ColumnTimestamp;
571  case GeoPoint:
572  return ExtensionFunction.ExtArgumentType.GeoPoint;
573  case GeoMultiPoint:
574  return ExtensionFunction.ExtArgumentType.GeoMultiPoint;
575  case GeoLineString:
576  return ExtensionFunction.ExtArgumentType.GeoLineString;
577  case GeoMultiLineString:
578  return ExtensionFunction.ExtArgumentType.GeoMultiLineString;
579  case Cursor:
580  return ExtensionFunction.ExtArgumentType.Cursor;
581  case GeoPolygon:
582  return ExtensionFunction.ExtArgumentType.GeoPolygon;
583  case GeoMultiPolygon:
584  return ExtensionFunction.ExtArgumentType.GeoMultiPolygon;
585  case TextEncodingNone:
586  return ExtensionFunction.ExtArgumentType.TextEncodingNone;
587  case TextEncodingDict:
588  return ExtensionFunction.ExtArgumentType.TextEncodingDict;
589  case Timestamp:
590  return ExtensionFunction.ExtArgumentType.Timestamp;
591  case ColumnListInt8:
592  return ExtensionFunction.ExtArgumentType.ColumnListInt8;
593  case ColumnListInt16:
594  return ExtensionFunction.ExtArgumentType.ColumnListInt16;
595  case ColumnListInt32:
596  return ExtensionFunction.ExtArgumentType.ColumnListInt32;
597  case ColumnListInt64:
598  return ExtensionFunction.ExtArgumentType.ColumnListInt64;
599  case ColumnListFloat:
600  return ExtensionFunction.ExtArgumentType.ColumnListFloat;
601  case ColumnListDouble:
602  return ExtensionFunction.ExtArgumentType.ColumnListDouble;
603  case ColumnListBool:
604  return ExtensionFunction.ExtArgumentType.ColumnListBool;
606  return ExtensionFunction.ExtArgumentType.ColumnListTextEncodingDict;
607  case ColumnArrayInt8:
608  return ExtensionFunction.ExtArgumentType.ColumnArrayInt8;
609  case ColumnArrayInt16:
610  return ExtensionFunction.ExtArgumentType.ColumnArrayInt16;
611  case ColumnArrayInt32:
612  return ExtensionFunction.ExtArgumentType.ColumnArrayInt32;
613  case ColumnArrayInt64:
614  return ExtensionFunction.ExtArgumentType.ColumnArrayInt64;
615  case ColumnArrayFloat:
616  return ExtensionFunction.ExtArgumentType.ColumnArrayFloat;
617  case ColumnArrayDouble:
618  return ExtensionFunction.ExtArgumentType.ColumnArrayDouble;
619  case ColumnArrayBool:
620  return ExtensionFunction.ExtArgumentType.ColumnArrayBool;
622  return ExtensionFunction.ExtArgumentType.ColumnArrayTextEncodingDict;
623  case ColumnListArrayInt8:
624  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt8;
626  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt16;
628  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt32;
630  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt64;
632  return ExtensionFunction.ExtArgumentType.ColumnListArrayFloat;
634  return ExtensionFunction.ExtArgumentType.ColumnListArrayDouble;
635  case ColumnListArrayBool:
636  return ExtensionFunction.ExtArgumentType.ColumnListArrayBool;
638  return ExtensionFunction.ExtArgumentType.ColumnListArrayTextEncodingDict;
639  case DayTimeInterval:
640  return ExtensionFunction.ExtArgumentType.DayTimeInterval;
642  return ExtensionFunction.ExtArgumentType.YearMonthTimeInterval;
643  default:
644  HEAVYDBLOGGER.error("toExtArgumentType: unknown type " + type);
645  return null;
646  }
647  }
Simplified core of GeoJSON Polygon coordinates definition.
Definition: heavydbTypes.h:636
Simplified core of GeoJSON MultiPolygon coordinates definition.
Definition: heavydbTypes.h:657

+ Here is the caller graph for this function:

static ExtensionFunction com.mapd.parser.server.CalciteServerHandler.toExtensionFunction ( TUserDefinedFunction  udf,
boolean  isruntime 
)
inlinestaticprivate

Definition at line 437 of file CalciteServerHandler.java.

References com.mapd.parser.server.ExtensionFunction.annotations, run_benchmark_import.args, and com.mapd.parser.server.CalciteServerHandler.toExtArgumentType().

Referenced by com.mapd.parser.server.CalciteServerHandler.setRuntimeExtensionFunctions().

438  {
439  List<ExtensionFunction.ExtArgumentType> args =
440  new ArrayList<ExtensionFunction.ExtArgumentType>();
441  for (TExtArgumentType atype : udf.argTypes) {
442  final ExtensionFunction.ExtArgumentType arg_type = toExtArgumentType(atype);
443  if (arg_type != ExtensionFunction.ExtArgumentType.Void) {
444  args.add(arg_type);
445  }
446  }
447  return new ExtensionFunction(args, toExtArgumentType(udf.retType), udf.annotations);
448  }
static ExtensionFunction.ExtArgumentType toExtArgumentType(TExtArgumentType type)
final List< Map< String, String > > annotations

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ExtensionFunction com.mapd.parser.server.CalciteServerHandler.toExtensionFunction ( TUserDefinedTableFunction  udtf,
boolean  isruntime 
)
inlinestaticprivate

Definition at line 450 of file CalciteServerHandler.java.

References run_benchmark_import.args, setup.name, and com.mapd.parser.server.CalciteServerHandler.toExtArgumentType().

451  {
452  int sqlInputArgIdx = 0;
453  int inputArgIdx = 0;
454  int outputArgIdx = 0;
455  List<String> names = new ArrayList<String>();
456  List<ExtensionFunction.ExtArgumentType> args = new ArrayList<>();
457  Map<String, List<ExtensionFunction.ExtArgumentType>> cursor_field_types =
458  new HashMap<>();
459  for (TExtArgumentType atype : udtf.sqlArgTypes) {
460  args.add(toExtArgumentType(atype));
461  Map<String, String> annot = udtf.annotations.get(sqlInputArgIdx);
462  String name = annot.getOrDefault("name", "inp" + sqlInputArgIdx);
463  if (atype == TExtArgumentType.Cursor) {
464  String field_names_annot = annot.getOrDefault("fields", "");
465  List<ExtensionFunction.ExtArgumentType> field_types = new ArrayList<>();
466  if (field_names_annot.length() > 0) {
467  String[] field_names =
468  field_names_annot.substring(1, field_names_annot.length() - 1)
469  .split(",");
470  for (int i = 0; i < field_names.length; i++) {
471  field_types.add(
472  toExtArgumentType(udtf.getInputArgTypes().get(inputArgIdx++)));
473  }
474  } else {
475  if (!isruntime) {
476  field_types.add(
477  toExtArgumentType(udtf.getInputArgTypes().get(inputArgIdx++)));
478  }
479  }
480  name = name + field_names_annot;
481  cursor_field_types.put(name, field_types);
482  } else {
483  inputArgIdx++;
484  }
485  names.add(name);
486  sqlInputArgIdx++;
487  }
488 
489  List<ExtensionFunction.ExtArgumentType> outs = new ArrayList<>();
490  for (TExtArgumentType otype : udtf.outputArgTypes) {
491  outs.add(toExtArgumentType(otype));
492  Map<String, String> annot = udtf.annotations.get(sqlInputArgIdx);
493  names.add(annot.getOrDefault("name", "out" + outputArgIdx));
494  sqlInputArgIdx++;
495  outputArgIdx++;
496  }
497  return new ExtensionFunction(args,
498  outs,
499  names,
500  udtf.annotations.get(udtf.annotations.size() - 1),
501  cursor_field_types);
502  }
static ExtensionFunction.ExtArgumentType toExtArgumentType(TExtArgumentType type)
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

void com.mapd.parser.server.CalciteServerHandler.updateMetadata ( String  catalog,
String  table 
) throws TException
inline

Definition at line 309 of file CalciteServerHandler.java.

References com.mapd.parser.server.CalciteServerHandler.callCount, run_benchmark_import.parser, and com.mapd.parser.server.CalciteServerHandler.parserPool.

309  {
310  HEAVYDBLOGGER.debug(
311  "Received invalidation from server for " + catalog + " : " + table);
312  long timer = System.currentTimeMillis();
313  callCount++;
314  HeavyDBParser parser;
315  try {
316  parser = (HeavyDBParser) parserPool.borrowObject();
317  } catch (Exception ex) {
318  String msg = "Could not get Parse Item from pool: " + ex.getMessage();
319  HEAVYDBLOGGER.error(msg, ex);
320  return;
321  }
322  CURRENT_PARSER.set(parser);
323  try {
324  parser.updateMetaData(catalog, table);
325  } finally {
326  CURRENT_PARSER.set(null);
327  try {
328  // put parser object back in pool for others to use
329  HEAVYDBLOGGER.debug("Returning object to pool");
330  parserPool.returnObject(parser);
331  } catch (Exception ex) {
332  String msg = "Could not return parse object: " + ex.getMessage();
333  HEAVYDBLOGGER.error(msg, ex);
334  }
335  }
336  }

Member Data Documentation

final CalciteParserFactory com.mapd.parser.server.CalciteServerHandler.calciteParserFactory
private
String com.mapd.parser.server.CalciteServerHandler.dataDir
private
Map<String, ExtensionFunction> com.mapd.parser.server.CalciteServerHandler.extSigs = null
private
final String com.mapd.parser.server.CalciteServerHandler.extSigsJson
private
final Logger com.mapd.parser.server.CalciteServerHandler.HEAVYDBLOGGER = LoggerFactory.getLogger(CalciteServerHandler.class)
staticpackage

Definition at line 68 of file CalciteServerHandler.java.

final GenericObjectPool com.mapd.parser.server.CalciteServerHandler.parserPool
private
TServer com.mapd.parser.server.CalciteServerHandler.server
private
SockTransportProperties com.mapd.parser.server.CalciteServerHandler.skT
private

Definition at line 88 of file CalciteServerHandler.java.

Map<String, ExtensionFunction> com.mapd.parser.server.CalciteServerHandler.udfRTSigs = null
package
String com.mapd.parser.server.CalciteServerHandler.udfRTSigsJson = ""
private
final String com.mapd.parser.server.CalciteServerHandler.udfSigsJson
private
Map<String, ExtensionFunction> com.mapd.parser.server.CalciteServerHandler.udtfSigs = null
package

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