OmniSciDB  a5dc49c757
 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 Comparable<?> getDefaultValueForAnnot (String annot, TExtArgumentType input_type)
 
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 341 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.

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

+ Here is the call graph for this function:

static Comparable<?> com.mapd.parser.server.CalciteServerHandler.getDefaultValueForAnnot ( String  annot,
TExtArgumentType  input_type 
)
inlinestaticprivate

Definition at line 515 of file CalciteServerHandler.java.

References Bool, Double, Float, Int16, Int32, Int64, Int8, and Integer.

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

516  {
517  switch (input_type) {
518  case Int8:
519  return new Byte(annot);
520  case Int16:
521  return new Short(annot);
522  case Int32:
523  return new Integer(annot);
524  case Int64:
525  return new Long(annot);
526  case Float:
527  return new Float(annot);
528  case Double:
529  return new Double(annot);
530  case Bool:
531  return new Boolean(annot);
532  case TextEncodingNone:
533  return annot;
534  default:
535  HEAVYDBLOGGER.error("Unsupported type in UDTF 'default' annotation: "
536  + input_type.toString());
537  return null;
538  }
539  }

+ Here is the caller graph for this function:

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

Definition at line 291 of file CalciteServerHandler.java.

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

Definition at line 301 of file CalciteServerHandler.java.

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

Definition at line 296 of file CalciteServerHandler.java.

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

Definition at line 720 of file CalciteServerHandler.java.

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

720  {
721  switch (type) {
722  case COLUMN:
723  return TCompletionHintType.COLUMN;
724  case TABLE:
725  return TCompletionHintType.TABLE;
726  case VIEW:
727  return TCompletionHintType.VIEW;
728  case SCHEMA:
729  return TCompletionHintType.SCHEMA;
730  case CATALOG:
731  return TCompletionHintType.CATALOG;
732  case REPOSITORY:
733  return TCompletionHintType.REPOSITORY;
734  case FUNCTION:
735  return TCompletionHintType.FUNCTION;
736  case KEYWORD:
737  return TCompletionHintType.KEYWORD;
738  default:
739  return null;
740  }
741  }

+ 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  queryParsingOption.is_explain_detail,
206  optimizationOption.is_view_optimize,
207  optimizationOption.enable_watchdog,
208  optimizationOption.distributed_mode);
209 
210  if (!buildRATreeFromRAString) {
211  Pair<String, SqlIdentifierCapturer> res;
212  SqlNode node;
213 
214  res = parser.process(queryText, parserOptions);
215  jsonResult = res.left;
216  capturer = res.right;
217 
218  primaryAccessedObjects.tables_selected_from = new ArrayList<>(capturer.selects);
219  primaryAccessedObjects.tables_inserted_into = new ArrayList<>(capturer.inserts);
220  primaryAccessedObjects.tables_updated_in = new ArrayList<>(capturer.updates);
221  primaryAccessedObjects.tables_deleted_from = new ArrayList<>(capturer.deletes);
222 
223  // also resolve all the views in the select part
224  // resolution of the other parts is not
225  // necessary as these cannot be views
226  resolvedAccessedObjects.tables_selected_from =
227  new ArrayList<>(parser.resolveSelectIdentifiers(capturer));
228  resolvedAccessedObjects.tables_inserted_into = new ArrayList<>(capturer.inserts);
229  resolvedAccessedObjects.tables_updated_in = new ArrayList<>(capturer.updates);
230  resolvedAccessedObjects.tables_deleted_from = new ArrayList<>(capturer.deletes);
231 
232  } else {
233  // exploit Calcite's query optimization rules for RA string
234  jsonResult =
235  parser.buildRATreeAndPerformQueryOptimization(queryText, parserOptions);
236  }
237  } catch (SqlParseException ex) {
238  String msg = "SQL Error: " + ex.getMessage();
239  HEAVYDBLOGGER.error(msg);
240  throw new InvalidParseRequest(-2, msg);
241  } catch (org.apache.calcite.tools.ValidationException ex) {
242  String msg = "SQL Error: " + ex.getMessage();
243  if (ex.getCause() != null
244  && (ex.getCause().getClass() == CalciteContextException.class)) {
245  msg = "SQL Error: " + ex.getCause().getMessage();
246  }
247  HEAVYDBLOGGER.error(msg);
248  throw new InvalidParseRequest(-3, msg);
249  } catch (CalciteContextException ex) {
250  String msg = ex.getMessage();
251  HEAVYDBLOGGER.error(msg);
252  throw new InvalidParseRequest(-6, msg);
253  } catch (RelConversionException ex) {
254  String msg = "Failed to generate relational algebra for query " + ex.getMessage();
255  HEAVYDBLOGGER.error(msg, ex);
256  throw new InvalidParseRequest(-5, msg);
257  } catch (Throwable ex) {
258  HEAVYDBLOGGER.error(ex.getClass().toString());
259  String msg = ex.getMessage();
260  HEAVYDBLOGGER.error(msg, ex);
261  throw new InvalidParseRequest(-4, msg);
262  } finally {
263  CURRENT_PARSER.set(null);
264  try {
265  // put parser object back in pool for others to use
266  parserPool.returnObject(parser);
267  } catch (Exception ex) {
268  String msg = "Could not return parse object: " + ex.getMessage();
269  HEAVYDBLOGGER.error(msg, ex);
270  throw new InvalidParseRequest(-7, msg);
271  }
272  }
273 
274  TPlanResult result = new TPlanResult();
275  result.primary_accessed_objects = primaryAccessedObjects;
276  result.resolved_accessed_objects = resolvedAccessedObjects;
277  result.plan_result = jsonResult;
278  result.execution_time_ms = System.currentTimeMillis() - timer;
279 
280  return result;
281  }
std::string toString(const Executor::ExtModuleKinds &kind)
Definition: Execute.h:1703

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

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

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

Definition at line 541 of file CalciteServerHandler.java.

References ArrayBool, ArrayDouble, ArrayFloat, ArrayInt16, ArrayInt32, ArrayInt64, ArrayInt8, ArrayTextEncodingDict, ArrayTextEncodingNone, Bool, ColumnArrayBool, ColumnArrayDouble, ColumnArrayFloat, ColumnArrayInt16, ColumnArrayInt32, ColumnArrayInt64, ColumnArrayInt8, ColumnArrayTextEncodingDict, ColumnArrayTextEncodingNone, ColumnBool, ColumnDouble, ColumnFloat, ColumnGeoLineString, ColumnGeoMultiLineString, ColumnGeoMultiPoint, ColumnGeoMultiPolygon, ColumnGeoPoint, ColumnGeoPolygon, ColumnInt16, ColumnInt32, ColumnInt64, ColumnInt8, ColumnListArrayBool, ColumnListArrayDouble, ColumnListArrayFloat, ColumnListArrayInt16, ColumnListArrayInt32, ColumnListArrayInt64, ColumnListArrayInt8, ColumnListArrayTextEncodingDict, ColumnListArrayTextEncodingNone, ColumnListBool, ColumnListDouble, ColumnListFloat, ColumnListGeoLineString, ColumnListGeoMultiLineString, ColumnListGeoMultiPoint, ColumnListGeoMultiPolygon, ColumnListGeoPoint, ColumnListGeoPolygon, ColumnListInt16, ColumnListInt32, ColumnListInt64, ColumnListInt8, ColumnListTextEncodingDict, ColumnListTextEncodingNone, ColumnTextEncodingDict, ColumnTextEncodingNone, 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().

542  {
543  switch (type) {
544  case Int8:
545  return ExtensionFunction.ExtArgumentType.Int8;
546  case Int16:
547  return ExtensionFunction.ExtArgumentType.Int16;
548  case Int32:
549  return ExtensionFunction.ExtArgumentType.Int32;
550  case Int64:
551  return ExtensionFunction.ExtArgumentType.Int64;
552  case Float:
553  return ExtensionFunction.ExtArgumentType.Float;
554  case Double:
556  case Void:
557  return ExtensionFunction.ExtArgumentType.Void;
558  case PInt8:
559  return ExtensionFunction.ExtArgumentType.PInt8;
560  case PInt16:
561  return ExtensionFunction.ExtArgumentType.PInt16;
562  case PInt32:
563  return ExtensionFunction.ExtArgumentType.PInt32;
564  case PInt64:
565  return ExtensionFunction.ExtArgumentType.PInt64;
566  case PFloat:
567  return ExtensionFunction.ExtArgumentType.PFloat;
568  case PDouble:
569  return ExtensionFunction.ExtArgumentType.PDouble;
570  case PBool:
571  return ExtensionFunction.ExtArgumentType.PBool;
572  case Bool:
573  return ExtensionFunction.ExtArgumentType.Bool;
574  case ArrayInt8:
575  return ExtensionFunction.ExtArgumentType.ArrayInt8;
576  case ArrayInt16:
577  return ExtensionFunction.ExtArgumentType.ArrayInt16;
578  case ArrayInt32:
579  return ExtensionFunction.ExtArgumentType.ArrayInt32;
580  case ArrayInt64:
581  return ExtensionFunction.ExtArgumentType.ArrayInt64;
582  case ArrayFloat:
583  return ExtensionFunction.ExtArgumentType.ArrayFloat;
584  case ArrayDouble:
585  return ExtensionFunction.ExtArgumentType.ArrayDouble;
586  case ArrayBool:
587  return ExtensionFunction.ExtArgumentType.ArrayBool;
589  return ExtensionFunction.ExtArgumentType.ArrayTextEncodingDict;
590  case ColumnInt8:
591  return ExtensionFunction.ExtArgumentType.ColumnInt8;
592  case ColumnInt16:
593  return ExtensionFunction.ExtArgumentType.ColumnInt16;
594  case ColumnInt32:
595  return ExtensionFunction.ExtArgumentType.ColumnInt32;
596  case ColumnInt64:
597  return ExtensionFunction.ExtArgumentType.ColumnInt64;
598  case ColumnFloat:
599  return ExtensionFunction.ExtArgumentType.ColumnFloat;
600  case ColumnDouble:
601  return ExtensionFunction.ExtArgumentType.ColumnDouble;
602  case ColumnBool:
603  return ExtensionFunction.ExtArgumentType.ColumnBool;
605  return ExtensionFunction.ExtArgumentType.ColumnTextEncodingDict;
606  case ColumnTimestamp:
607  return ExtensionFunction.ExtArgumentType.ColumnTimestamp;
608  case GeoPoint:
610  case GeoMultiPoint:
612  case GeoLineString:
614  case GeoMultiLineString:
616  case Cursor:
617  return ExtensionFunction.ExtArgumentType.Cursor;
618  case GeoPolygon:
620  case GeoMultiPolygon:
622  case TextEncodingNone:
623  return ExtensionFunction.ExtArgumentType.TextEncodingNone;
624  case TextEncodingDict:
625  return ExtensionFunction.ExtArgumentType.TextEncodingDict;
626  case Timestamp:
627  return ExtensionFunction.ExtArgumentType.Timestamp;
628  case ColumnListInt8:
629  return ExtensionFunction.ExtArgumentType.ColumnListInt8;
630  case ColumnListInt16:
631  return ExtensionFunction.ExtArgumentType.ColumnListInt16;
632  case ColumnListInt32:
633  return ExtensionFunction.ExtArgumentType.ColumnListInt32;
634  case ColumnListInt64:
635  return ExtensionFunction.ExtArgumentType.ColumnListInt64;
636  case ColumnListFloat:
637  return ExtensionFunction.ExtArgumentType.ColumnListFloat;
638  case ColumnListDouble:
639  return ExtensionFunction.ExtArgumentType.ColumnListDouble;
640  case ColumnListBool:
641  return ExtensionFunction.ExtArgumentType.ColumnListBool;
643  return ExtensionFunction.ExtArgumentType.ColumnListTextEncodingDict;
644  case ColumnArrayInt8:
645  return ExtensionFunction.ExtArgumentType.ColumnArrayInt8;
646  case ColumnArrayInt16:
647  return ExtensionFunction.ExtArgumentType.ColumnArrayInt16;
648  case ColumnArrayInt32:
649  return ExtensionFunction.ExtArgumentType.ColumnArrayInt32;
650  case ColumnArrayInt64:
651  return ExtensionFunction.ExtArgumentType.ColumnArrayInt64;
652  case ColumnArrayFloat:
653  return ExtensionFunction.ExtArgumentType.ColumnArrayFloat;
654  case ColumnArrayDouble:
655  return ExtensionFunction.ExtArgumentType.ColumnArrayDouble;
656  case ColumnArrayBool:
657  return ExtensionFunction.ExtArgumentType.ColumnArrayBool;
659  return ExtensionFunction.ExtArgumentType.ColumnArrayTextEncodingDict;
660  case ColumnListArrayInt8:
661  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt8;
663  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt16;
665  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt32;
667  return ExtensionFunction.ExtArgumentType.ColumnListArrayInt64;
669  return ExtensionFunction.ExtArgumentType.ColumnListArrayFloat;
671  return ExtensionFunction.ExtArgumentType.ColumnListArrayDouble;
672  case ColumnListArrayBool:
673  return ExtensionFunction.ExtArgumentType.ColumnListArrayBool;
675  return ExtensionFunction.ExtArgumentType.ColumnListArrayTextEncodingDict;
676  case DayTimeInterval:
677  return ExtensionFunction.ExtArgumentType.DayTimeInterval;
679  return ExtensionFunction.ExtArgumentType.YearMonthTimeInterval;
680  case ColumnGeoPoint:
681  return ExtensionFunction.ExtArgumentType.ColumnGeoPoint;
682  case ColumnGeoLineString:
683  return ExtensionFunction.ExtArgumentType.ColumnGeoLineString;
684  case ColumnGeoPolygon:
685  return ExtensionFunction.ExtArgumentType.ColumnGeoPolygon;
686  case ColumnGeoMultiPoint:
687  return ExtensionFunction.ExtArgumentType.ColumnGeoMultiPoint;
689  return ExtensionFunction.ExtArgumentType.ColumnGeoMultiLineString;
691  return ExtensionFunction.ExtArgumentType.ColumnGeoMultiPolygon;
692  case ColumnListGeoPoint:
693  return ExtensionFunction.ExtArgumentType.ColumnListGeoPoint;
695  return ExtensionFunction.ExtArgumentType.ColumnListGeoLineString;
697  return ExtensionFunction.ExtArgumentType.ColumnListGeoPolygon;
699  return ExtensionFunction.ExtArgumentType.ColumnListGeoMultiPoint;
701  return ExtensionFunction.ExtArgumentType.ColumnListGeoMultiLineString;
703  return ExtensionFunction.ExtArgumentType.ColumnListGeoMultiPolygon;
705  return ExtensionFunction.ExtArgumentType.ArrayTextEncodingNone;
707  return ExtensionFunction.ExtArgumentType.ColumnTextEncodingNone;
709  return ExtensionFunction.ExtArgumentType.ColumnListTextEncodingNone;
711  return ExtensionFunction.ExtArgumentType.ColumnArrayTextEncodingNone;
713  return ExtensionFunction.ExtArgumentType.ColumnListArrayTextEncodingNone;
714  default:
715  HEAVYDBLOGGER.error("toExtArgumentType: unknown type " + type);
716  return null;
717  }
718  }
struct GeoLineStringStruct GeoLineString
Definition: heavydbTypes.h:999
struct GeoPointStruct GeoPoint
Definition: heavydbTypes.h:963
Simplified core of GeoJSON Polygon coordinates definition.
Simplified core of GeoJSON MultiPolygon coordinates definition.
struct GeoMultiPointStruct GeoMultiPoint
Definition: heavydbTypes.h:981
struct GeoMultiLineStringStruct GeoMultiLineString
struct GeoMultiPolygonStruct GeoMultiPolygon
struct GeoPolygonStruct GeoPolygon

+ Here is the caller graph for this function:

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

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

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

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

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

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

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

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: