OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
org.apache.calcite.rel.externalize.MapDRelJson Class Reference
+ Collaboration diagram for org.apache.calcite.rel.externalize.MapDRelJson:

Public Member Functions

 MapDRelJson (JsonBuilder jsonBuilder)
 
RelNode create (Map< String, Object > map)
 
Constructor getConstructor (String type)
 
Class typeNameToClass (String type)
 
String classToTypeName (Class<?extends RelNode > class_)
 
Object toJson (RelCollationImpl node)
 
Object toJson (RexFieldCollation node)
 
RelCollation toCollation (List< Map< String, Object >> jsonFieldCollations)
 
RelFieldCollation toFieldCollation (Map< String, Object > map)
 
RelDistribution toDistribution (Object o)
 
RelDataType toType (RelDataTypeFactory typeFactory, Object o)
 
Object toJson (AggregateCall node)
 

Static Public Attributes

static final List< String > PACKAGES
 

Package Functions

Object toJson (Object value)
 
RexNode toRex (RelInput relInput, Object o)
 
SqlAggFunction toAggregation (String agg, Map< String, Object > map)
 

Private Member Functions

Object toJson (RelDataType node)
 
Object toJson (RelDataTypeField node)
 
Object toJson (CorrelationId node)
 
Object toJson (final RexWindowBound window_bound)
 
Object toJson (RexNode node)
 
List< RexNode > toRexList (RelInput relInput, List operands)
 
SqlOperator toOp (String op, Map< String, Object > map)
 
String toJson (SqlOperator operator)
 

Private Attributes

final Map< String, Constructor > constructorMap
 
final JsonBuilder jsonBuilder
 

Detailed Description

Utilities for converting org.apache.calcite.rel.RelNode into JSON format.

Definition at line 73 of file MapDRelJson.java.

Constructor & Destructor Documentation

org.apache.calcite.rel.externalize.MapDRelJson.MapDRelJson ( JsonBuilder  jsonBuilder)
inline

Definition at line 85 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.jsonBuilder.

85  {
86  this.jsonBuilder = jsonBuilder;
87  }

Member Function Documentation

String org.apache.calcite.rel.externalize.MapDRelJson.classToTypeName ( Class<?extends RelNode >  class_)
inline

Inverse of typeNameToClass.

Definition at line 145 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.PACKAGES.

145  {
146  final String canonicalName = class_.getName();
147  for (String package_ : PACKAGES) {
148  if (canonicalName.startsWith(package_)) {
149  String remaining = canonicalName.substring(package_.length());
150  if (remaining.indexOf('.') < 0 && remaining.indexOf('$') < 0) {
151  return remaining;
152  }
153  }
154  }
155  return canonicalName;
156  }
RelNode org.apache.calcite.rel.externalize.MapDRelJson.create ( Map< String, Object >  map)
inline

Definition at line 89 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.getConstructor(), and run_benchmark_import.type.

89  {
90  String type = (String) map.get("type");
91  Constructor constructor = getConstructor(type);
92  try {
93  return (RelNode) constructor.newInstance(map);
94  } catch (InstantiationException e) {
95  throw new RuntimeException("while invoking constructor for type '" + type + "'", e);
96  } catch (IllegalAccessException e) {
97  throw new RuntimeException("while invoking constructor for type '" + type + "'", e);
98  } catch (InvocationTargetException e) {
99  throw new RuntimeException("while invoking constructor for type '" + type + "'", e);
100  } catch (ClassCastException e) {
101  throw new RuntimeException("while invoking constructor for type '" + type + "'", e);
102  }
103  }

+ Here is the call graph for this function:

Constructor org.apache.calcite.rel.externalize.MapDRelJson.getConstructor ( String  type)
inline

Definition at line 105 of file MapDRelJson.java.

References run_benchmark_import.type, and org.apache.calcite.rel.externalize.MapDRelJson.typeNameToClass().

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.create().

105  {
106  Constructor constructor = constructorMap.get(type);
107  if (constructor == null) {
108  Class clazz = typeNameToClass(type);
109  try {
110  // noinspection unchecked
111  constructor = clazz.getConstructor(RelInput.class);
112  } catch (NoSuchMethodException e) {
113  throw new RuntimeException(
114  "class does not have required constructor, " + clazz + "(RelInput)");
115  }
116  constructorMap.put(type, constructor);
117  }
118  return constructor;
119  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SqlAggFunction org.apache.calcite.rel.externalize.MapDRelJson.toAggregation ( String  agg,
Map< String, Object >  map 
)
inlinepackage

Definition at line 518 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toOp().

518  {
519  return (SqlAggFunction) toOp(agg, map);
520  }
SqlOperator toOp(String op, Map< String, Object > map)

+ Here is the call graph for this function:

RelCollation org.apache.calcite.rel.externalize.MapDRelJson.toCollation ( List< Map< String, Object >>  jsonFieldCollations)
inline

Definition at line 178 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toFieldCollation().

178  {
179  final List<RelFieldCollation> fieldCollations = new ArrayList<RelFieldCollation>();
180  for (Map<String, Object> map : jsonFieldCollations) {
181  fieldCollations.add(toFieldCollation(map));
182  }
183  return RelCollations.of(fieldCollations);
184  }
RelFieldCollation toFieldCollation(Map< String, Object > map)

+ Here is the call graph for this function:

RelDistribution org.apache.calcite.rel.externalize.MapDRelJson.toDistribution ( Object  o)
inline

Definition at line 195 of file MapDRelJson.java.

195  {
196  return RelDistributions.ANY; // TODO:
197  }
RelFieldCollation org.apache.calcite.rel.externalize.MapDRelJson.toFieldCollation ( Map< String, Object >  map)
inline

Definition at line 186 of file MapDRelJson.java.

References field(), and Integer.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toCollation().

186  {
187  final Integer field = (Integer) map.get("field");
188  final RelFieldCollation.Direction direction = Util.enumVal(
189  RelFieldCollation.Direction.class, (String) map.get("direction"));
190  final RelFieldCollation.NullDirection nullDirection = Util.enumVal(
191  RelFieldCollation.NullDirection.class, (String) map.get("nulls"));
192  return new RelFieldCollation(field, direction, nullDirection);
193  }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RelCollationImpl  node)
inline

Definition at line 158 of file MapDRelJson.java.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toJson().

158  {
159  final List<Object> list = new ArrayList<Object>();
160  for (RelFieldCollation fieldCollation : node.getFieldCollations()) {
161  final Map<String, Object> map = jsonBuilder.map();
162  map.put("field", fieldCollation.getFieldIndex());
163  map.put("direction", fieldCollation.getDirection().name());
164  map.put("nulls", fieldCollation.nullDirection.name());
165  list.add(map);
166  }
167  return list;
168  }

+ Here is the caller graph for this function:

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RexFieldCollation  node)
inline

Definition at line 170 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

170  {
171  final Map<String, Object> map = jsonBuilder.map();
172  map.put("field", toJson(node.left));
173  map.put("direction", node.getDirection().name());
174  map.put("nulls", node.getNullDirection().name());
175  return map;
176  }

+ Here is the call graph for this function:

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( AggregateCall  node)
inline

Definition at line 227 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

227  {
228  final Map<String, Object> map = jsonBuilder.map();
229  map.put("agg", toJson(node.getAggregation()));
230  map.put("type", toJson(node.getType()));
231  map.put("distinct", node.isDistinct());
232  map.put("operands", node.getArgList());
233  return map;
234  }

+ Here is the call graph for this function:

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( Object  value)
inlinepackage

Definition at line 236 of file MapDRelJson.java.

References Integer, and org.apache.calcite.rel.externalize.MapDRelJson.toJson().

236  {
237  if (value == null || value instanceof Number || value instanceof String
238  || value instanceof Boolean) {
239  return value;
240  } else if (value instanceof RexNode) {
241  return toJson((RexNode) value);
242  } else if (value instanceof CorrelationId) {
243  return toJson((CorrelationId) value);
244  } else if (value instanceof List) {
245  final List<Object> list = jsonBuilder.list();
246  for (Object o : (List) value) {
247  list.add(toJson(o));
248  }
249  return list;
250  } else if (value instanceof ImmutableBitSet) {
251  final List<Object> list = jsonBuilder.list();
252  for (Integer integer : (ImmutableBitSet) value) {
253  list.add(toJson(integer));
254  }
255  return list;
256  } else if (value instanceof AggregateCall) {
257  return toJson((AggregateCall) value);
258  } else if (value instanceof RelCollationImpl) {
259  return toJson((RelCollationImpl) value);
260  } else if (value instanceof RexFieldCollation) {
261  return toJson((RexFieldCollation) value);
262  } else if (value instanceof RelDataType) {
263  return toJson((RelDataType) value);
264  } else if (value instanceof RelDataTypeField) {
265  return toJson((RelDataTypeField) value);
266  } else if (value instanceof JoinType) {
267  return value.toString();
268  } else if (value instanceof Operation) {
269  return value.toString();
270  } else {
271  throw new UnsupportedOperationException("type not serializable: " + value
272  + " (type " + value.getClass().getCanonicalName() + ")");
273  }
274  }
JoinType
Definition: sqldefs.h:107

+ Here is the call graph for this function:

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RelDataType  node)
inlineprivate

Definition at line 276 of file MapDRelJson.java.

References field(), and org.apache.calcite.rel.externalize.MapDRelJson.toJson().

276  {
277  if (node.isStruct()) {
278  final List<Object> list = jsonBuilder.list();
279  for (RelDataTypeField field : node.getFieldList()) {
280  list.add(toJson(field));
281  }
282  return list;
283  } else {
284  final Map<String, Object> map = jsonBuilder.map();
285  map.put("type", node.getSqlTypeName().name());
286  map.put("nullable", node.isNullable());
287  if (node.getSqlTypeName().allowsPrec()) {
288  map.put("precision", node.getPrecision());
289  }
290  if (node.getSqlTypeName().allowsScale()) {
291  map.put("scale", node.getScale());
292  }
293  return map;
294  }
295  }
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31

+ Here is the call graph for this function:

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RelDataTypeField  node)
inlineprivate

Definition at line 297 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

297  {
298  final Map<String, Object> map = (Map<String, Object>) toJson(node.getType());
299  map.put("name", node.getName());
300  return map;
301  }

+ Here is the call graph for this function:

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( CorrelationId  node)
inlineprivate

Definition at line 303 of file MapDRelJson.java.

303  {
304  return node.getId();
305  }
Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( final RexWindowBound  window_bound)
inlineprivate

Definition at line 307 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

307  {
308  final Map<String, Object> map = jsonBuilder.map();
309  map.put("unbounded", toJson(window_bound.isUnbounded()));
310  map.put("preceding", toJson(window_bound.isPreceding()));
311  map.put("following", toJson(window_bound.isFollowing()));
312  map.put("is_current_row", toJson(window_bound.isCurrentRow()));
313  map.put("offset",
314  window_bound.getOffset() != null ? toJson(window_bound.getOffset()) : null);
315  map.put("order_key", toJson(window_bound.getOrderKey()));
316  return map;
317  }

+ Here is the call graph for this function:

Object org.apache.calcite.rel.externalize.MapDRelJson.toJson ( RexNode  node)
inlineprivate

Definition at line 319 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toJson().

319  {
320  final Map<String, Object> map;
321  switch (node.getKind()) {
322  case FIELD_ACCESS:
323  map = jsonBuilder.map();
324  final RexFieldAccess fieldAccess = (RexFieldAccess) node;
325  map.put("field", fieldAccess.getField().getName());
326  map.put("expr", toJson(fieldAccess.getReferenceExpr()));
327  return map;
328  case LITERAL:
329  final RexLiteral literal = (RexLiteral) node;
330  final Object value2 = literal.getValue2();
331  map = jsonBuilder.map();
332  if (value2 instanceof TimeUnitRange) {
333  map.put("literal", value2.toString());
334  } else {
335  if (value2 instanceof String) {
336  map.put("literal", StringEscapeUtils.escapeJson((String) value2));
337  } else {
338  map.put("literal", value2);
339  }
340  }
341  map.put("type", literal.getTypeName().name());
342  map.put("target_type", literal.getType().getSqlTypeName().toString());
343  final Object value = literal.getValue();
344  if (value instanceof BigDecimal) {
345  map.put("scale", ((BigDecimal) value).scale());
346  map.put("precision", ((BigDecimal) value).precision());
347  } else {
348  map.put("scale", literal.getType().getScale());
349  map.put("precision", literal.getType().getPrecision());
350  }
351  map.put("type_scale", literal.getType().getScale());
352  map.put("type_precision", literal.getType().getPrecision());
353  return map;
354  case INPUT_REF:
355  map = jsonBuilder.map();
356  map.put("input", ((RexInputRef) node).getIndex());
357  return map;
358  case CORREL_VARIABLE:
359  map = jsonBuilder.map();
360  map.put("correl", ((RexCorrelVariable) node).getName());
361  map.put("type", toJson(node.getType()));
362  return map;
363  default:
364  if (node instanceof RexCall) {
365  final RexCall call = (RexCall) node;
366  map = jsonBuilder.map();
367  map.put("op", toJson(call.getOperator()));
368  final List<Object> list = jsonBuilder.list();
369  for (RexNode operand : call.getOperands()) {
370  list.add(toJson(operand));
371  }
372  map.put("operands", list);
373  map.put("type", toJson(node.getType()));
374  if (node instanceof RexSubQuery) {
375  final MapDRelJsonWriter subqueryWriter = new MapDRelJsonWriter();
376  ((RexSubQuery) node).rel.explain(subqueryWriter);
377  map.put("subquery", subqueryWriter.asJsonMap());
378  }
379  if (node instanceof RexOver) {
380  final RexWindow window = ((RexOver) node).getWindow();
381  final List<Object> partitionKeyList = jsonBuilder.list();
382  for (final RexNode partitionKey : window.partitionKeys) {
383  partitionKeyList.add(toJson(partitionKey));
384  }
385  map.put("partition_keys", partitionKeyList);
386  final List<Object> orderKeyList = jsonBuilder.list();
387  for (final RexFieldCollation orderKey : window.orderKeys) {
388  orderKeyList.add(toJson(orderKey));
389  }
390  map.put("order_keys", orderKeyList);
391  RexWindowBound lower_bound = window.getLowerBound();
392  RexWindowBound upper_bound = window.getUpperBound();
393  map.put("lower_bound", toJson(lower_bound));
394  map.put("upper_bound", toJson(upper_bound));
395  map.put("is_rows", toJson(window.isRows()));
396  }
397  if (call.getOperator() instanceof SqlFunction) {
398  switch (((SqlFunction) call.getOperator()).getFunctionType()) {
399  case USER_DEFINED_CONSTRUCTOR:
400  case USER_DEFINED_FUNCTION:
401  case USER_DEFINED_PROCEDURE:
402  case USER_DEFINED_SPECIFIC_FUNCTION:
403  map.put("class", call.getOperator().getClass().getName());
404  }
405  }
406  return map;
407  }
408  throw new UnsupportedOperationException("unknown rex " + node);
409  }
410  }

+ Here is the call graph for this function:

String org.apache.calcite.rel.externalize.MapDRelJson.toJson ( SqlOperator  operator)
inlineprivate

Definition at line 522 of file MapDRelJson.java.

522  {
523  // User-defined operators are not yet handled.
524  return operator.getName();
525  }
SqlOperator org.apache.calcite.rel.externalize.MapDRelJson.toOp ( String  op,
Map< String, Object >  map 
)
inlineprivate

Definition at line 493 of file MapDRelJson.java.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toAggregation(), and org.apache.calcite.rel.externalize.MapDRelJson.toRex().

493  {
494  // TODO: build a map, for more efficient lookup
495  // TODO: look up based on SqlKind
496  final List<SqlOperator> operatorList =
497  SqlStdOperatorTable.instance().getOperatorList();
498  for (SqlOperator operator : operatorList) {
499  if (operator.getName().equals(op)) {
500  return operator;
501  }
502  }
503  String class_ = (String) map.get("class");
504  if (class_ != null) {
505  try {
506  return (SqlOperator) Class.forName(class_).newInstance();
507  } catch (InstantiationException e) {
508  throw new RuntimeException(e);
509  } catch (IllegalAccessException e) {
510  throw new RuntimeException(e);
511  } catch (ClassNotFoundException e) {
512  throw new RuntimeException(e);
513  }
514  }
515  return null;
516  }

+ Here is the caller graph for this function:

RexNode org.apache.calcite.rel.externalize.MapDRelJson.toRex ( RelInput  relInput,
Object  o 
)
inlinepackage

Definition at line 412 of file MapDRelJson.java.

References Double, field(), Float, Integer, org.apache.calcite.rel.externalize.MapDRelJson.toOp(), org.apache.calcite.rel.externalize.MapDRelJson.toRexList(), org.apache.calcite.rel.externalize.MapDRelJson.toType(), and run_benchmark_import.type.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toRexList().

412  {
413  final RelOptCluster cluster = relInput.getCluster();
414  final RexBuilder rexBuilder = cluster.getRexBuilder();
415  if (o == null) {
416  return null;
417  } else if (o instanceof Map) {
418  Map map = (Map) o;
419  final String op = (String) map.get("op");
420  if (op != null) {
421  final List operands = (List) map.get("operands");
422  final Object jsonType = map.get("type");
423  final SqlOperator operator = toOp(op, map);
424  final List<RexNode> rexOperands = toRexList(relInput, operands);
425  RelDataType type;
426  if (jsonType != null) {
427  type = toType(cluster.getTypeFactory(), jsonType);
428  } else {
429  type = rexBuilder.deriveReturnType(operator, rexOperands);
430  }
431  return rexBuilder.makeCall(type, operator, rexOperands);
432  }
433  final Integer input = (Integer) map.get("input");
434  if (input != null) {
435  List<RelNode> inputNodes = relInput.getInputs();
436  int i = input;
437  for (RelNode inputNode : inputNodes) {
438  final RelDataType rowType = inputNode.getRowType();
439  if (i < rowType.getFieldCount()) {
440  final RelDataTypeField field = rowType.getFieldList().get(i);
441  return rexBuilder.makeInputRef(field.getType(), input);
442  }
443  i -= rowType.getFieldCount();
444  }
445  throw new RuntimeException("input field " + input + " is out of range");
446  }
447  final String field = (String) map.get("field");
448  if (field != null) {
449  final Object jsonExpr = map.get("expr");
450  final RexNode expr = toRex(relInput, jsonExpr);
451  return rexBuilder.makeFieldAccess(expr, field, true);
452  }
453  final String correl = (String) map.get("correl");
454  if (correl != null) {
455  final Object jsonType = map.get("type");
456  RelDataType type = toType(cluster.getTypeFactory(), jsonType);
457  return rexBuilder.makeCorrel(type, new CorrelationId(correl));
458  }
459  if (map.containsKey("literal")) {
460  final Object literal = map.get("literal");
461  final SqlTypeName sqlTypeName =
462  Util.enumVal(SqlTypeName.class, (String) map.get("type"));
463  if (literal == null) {
464  return rexBuilder.makeNullLiteral(sqlTypeName);
465  }
466  return toRex(relInput, literal);
467  }
468  throw new UnsupportedOperationException("cannot convert to rex " + o);
469  } else if (o instanceof Boolean) {
470  return rexBuilder.makeLiteral((Boolean) o);
471  } else if (o instanceof String) {
472  return rexBuilder.makeLiteral((String) o);
473  } else if (o instanceof Number) {
474  final Number number = (Number) o;
475  if (number instanceof Double || number instanceof Float) {
476  return rexBuilder.makeApproxLiteral(BigDecimal.valueOf(number.doubleValue()));
477  } else {
478  return rexBuilder.makeExactLiteral(BigDecimal.valueOf(number.longValue()));
479  }
480  } else {
481  throw new UnsupportedOperationException("cannot convert to rex " + o);
482  }
483  }
RexNode toRex(RelInput relInput, Object o)
RelDataType toType(RelDataTypeFactory typeFactory, Object o)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
SqlOperator toOp(String op, Map< String, Object > map)
List< RexNode > toRexList(RelInput relInput, List operands)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

List<RexNode> org.apache.calcite.rel.externalize.MapDRelJson.toRexList ( RelInput  relInput,
List  operands 
)
inlineprivate

Definition at line 485 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.toRex().

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toRex().

485  {
486  final List<RexNode> list = new ArrayList<RexNode>();
487  for (Object operand : operands) {
488  list.add(toRex(relInput, operand));
489  }
490  return list;
491  }
RexNode toRex(RelInput relInput, Object o)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RelDataType org.apache.calcite.rel.externalize.MapDRelJson.toType ( RelDataTypeFactory  typeFactory,
Object  o 
)
inline

Definition at line 199 of file MapDRelJson.java.

References Integer, and run_benchmark_import.type.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.toRex().

199  {
200  if (o instanceof List) {
201  @SuppressWarnings("unchecked")
202  final List<Map<String, Object>> jsonList = (List<Map<String, Object>>) o;
203  final RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
204  for (Map<String, Object> jsonMap : jsonList) {
205  builder.add((String) jsonMap.get("name"), toType(typeFactory, jsonMap));
206  }
207  return builder.build();
208  } else {
209  final Map<String, Object> map = (Map<String, Object>) o;
210  final SqlTypeName sqlTypeName =
211  Util.enumVal(SqlTypeName.class, (String) map.get("type"));
212  final Integer precision = (Integer) map.get("precision");
213  final Integer scale = (Integer) map.get("scale");
214  final RelDataType type;
215  if (precision == null) {
216  type = typeFactory.createSqlType(sqlTypeName);
217  } else if (scale == null) {
218  type = typeFactory.createSqlType(sqlTypeName, precision);
219  } else {
220  type = typeFactory.createSqlType(sqlTypeName, precision, scale);
221  }
222  final boolean nullable = (Boolean) map.get("nullable");
223  return typeFactory.createTypeWithNullability(type, nullable);
224  }
225  }
RelDataType toType(RelDataTypeFactory typeFactory, Object o)

+ Here is the caller graph for this function:

Class org.apache.calcite.rel.externalize.MapDRelJson.typeNameToClass ( String  type)
inline

Converts a type name to a class. E.g.

getClass("LogicalProject")

returns org.apache.calcite.rel.logical.LogicalProject.class.

Definition at line 125 of file MapDRelJson.java.

References org.apache.calcite.rel.externalize.MapDRelJson.PACKAGES, and run_benchmark_import.type.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.getConstructor().

125  {
126  if (!type.contains(".")) {
127  for (String package_ : PACKAGES) {
128  try {
129  return Class.forName(package_ + type);
130  } catch (ClassNotFoundException e) {
131  // ignore
132  }
133  }
134  }
135  try {
136  return Class.forName(type);
137  } catch (ClassNotFoundException e) {
138  throw new RuntimeException("unknown type " + type);
139  }
140  }

+ Here is the caller graph for this function:

Member Data Documentation

final Map<String, Constructor> org.apache.calcite.rel.externalize.MapDRelJson.constructorMap
private
Initial value:
=
new HashMap<String, Constructor>()

Definition at line 74 of file MapDRelJson.java.

final JsonBuilder org.apache.calcite.rel.externalize.MapDRelJson.jsonBuilder
private
final List<String> org.apache.calcite.rel.externalize.MapDRelJson.PACKAGES
static
Initial value:
= ImmutableList.of("org.apache.calcite.rel.",
"org.apache.calcite.rel.core.",
"org.apache.calcite.rel.logical.",
"org.apache.calcite.adapter.jdbc.",
"org.apache.calcite.adapter.enumerable.",
"org.apache.calcite.adapter.jdbc.JdbcRules$")

Definition at line 78 of file MapDRelJson.java.

Referenced by org.apache.calcite.rel.externalize.MapDRelJson.classToTypeName(), and org.apache.calcite.rel.externalize.MapDRelJson.typeNameToClass().


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