OmniSciDB  c1a53651b2
 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 340 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.

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

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

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

+ 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 389 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.

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

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

+ Here is the caller graph for this function:

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

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

439  {
440  List<ExtensionFunction.ExtArgumentType> args =
441  new ArrayList<ExtensionFunction.ExtArgumentType>();
442  for (TExtArgumentType atype : udf.argTypes) {
443  final ExtensionFunction.ExtArgumentType arg_type = toExtArgumentType(atype);
444  if (arg_type != ExtensionFunction.ExtArgumentType.Void) {
445  args.add(arg_type);
446  }
447  }
448  return new ExtensionFunction(args, toExtArgumentType(udf.retType), udf.annotations);
449  }
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 451 of file CalciteServerHandler.java.

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

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

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

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

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: