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

Public Member Functions

 MapDRelJsonWriter ()
 
final void explain (RelNode rel, List< Pair< String, Object >> valueList)
 
SqlExplainLevel getDetailLevel ()
 
RelWriter input (String term, RelNode input)
 
RelWriter item (String term, Object value)
 
RelWriter itemIf (String term, Object value, boolean condition)
 
RelWriter done (RelNode node)
 
boolean nest ()
 
String asString ()
 
Map< String, Object > asJsonMap ()
 

Protected Member Functions

void explain_ (RelNode rel, List< Pair< String, Object >> values)
 

Private Member Functions

void put (Map< String, Object > map, String name, Object value)
 
List< Object > explainInputs (List< RelNode > inputs)
 
List< Object > getList (List< Pair< String, Object >> values, String tag)
 

Private Attributes

final JsonBuilder jsonBuilder
 
final MapDRelJson relJson
 
final Map< RelNode, String > relIdMap = new IdentityHashMap<RelNode, String>()
 
final List< Object > relList
 
final List< Pair< String,
Object > > 
values = new ArrayList<Pair<String, Object>>()
 
String previousId
 

Detailed Description

Callback for a relational expression to dump itself as JSON.

See Also
RelJsonReader

Definition at line 42 of file MapDRelJsonWriter.java.

Constructor & Destructor Documentation

org.apache.calcite.rel.externalize.MapDRelJsonWriter.MapDRelJsonWriter ( )
inline

Member Function Documentation

Map<String, Object> org.apache.calcite.rel.externalize.MapDRelJsonWriter.asJsonMap ( )
inline

Definition at line 171 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.relList.

Referenced by org.apache.calcite.rel.externalize.MapDRelJsonWriter.asString().

171  {
172  final Map<String, Object> map = jsonBuilder.map();
173  map.put("rels", relList);
174  return map;
175  }

+ Here is the caller graph for this function:

String org.apache.calcite.rel.externalize.MapDRelJsonWriter.asString ( )
inline

Returns a JSON string describing the relational expressions that were just explained.

Definition at line 167 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.asJsonMap().

167  {
168  return jsonBuilder.toJsonString(asJsonMap());
169  }

+ Here is the call graph for this function:

RelWriter org.apache.calcite.rel.externalize.MapDRelJsonWriter.done ( RelNode  node)
inline

Definition at line 152 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.explain_(), and org.apache.calcite.rel.externalize.MapDRelJsonWriter.values.

152  {
153  final List<Pair<String, Object>> valuesCopy = ImmutableList.copyOf(values);
154  values.clear();
155  explain_(node, valuesCopy);
156  return this;
157  }
void explain_(RelNode rel, List< Pair< String, Object >> values)

+ Here is the call graph for this function:

final void org.apache.calcite.rel.externalize.MapDRelJsonWriter.explain ( RelNode  rel,
List< Pair< String, Object >>  valueList 
)
inline

Definition at line 116 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.explain_().

116  {
117  explain_(rel, valueList);
118  }
void explain_(RelNode rel, List< Pair< String, Object >> values)

+ Here is the call graph for this function:

void org.apache.calcite.rel.externalize.MapDRelJsonWriter.explain_ ( RelNode  rel,
List< Pair< String, Object >>  values 
)
inlineprotected

Definition at line 62 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.explainInputs(), org.apache.calcite.rel.externalize.MapDRelJsonWriter.previousId, org.apache.calcite.rel.externalize.MapDRelJsonWriter.put(), Experimental.String, and org.apache.calcite.rel.externalize.MapDRelJsonWriter.values.

Referenced by org.apache.calcite.rel.externalize.MapDRelJsonWriter.done(), and org.apache.calcite.rel.externalize.MapDRelJsonWriter.explain().

62  {
63  final Map<String, Object> map = jsonBuilder.map();
64 
65  map.put("id", null); // ensure that id is the first attribute
66  map.put("relOp", relJson.classToTypeName(rel.getClass()));
67  if (rel instanceof EnumerableTableScan) {
68  RelDataType row_type = ((EnumerableTableScan) rel).getTable().getRowType();
69  List<String> field_names = row_type.getFieldNames();
70  map.put("fieldNames", field_names);
71  }
72  if (rel instanceof LogicalAggregate) {
73  map.put("fields", rel.getRowType().getFieldNames());
74  }
75  if (rel instanceof LogicalTableModify) {
76  // FIX-ME: What goes here?
77  }
78 
79  for (Pair<String, Object> value : values) {
80  if (value.right instanceof RelNode) {
81  continue;
82  }
83  put(map, value.left, value.right);
84  }
85  // omit 'inputs: ["3"]' if "3" is the preceding rel
86  final List<Object> list = explainInputs(rel.getInputs());
87  if (list.size() != 1 || !list.get(0).equals(previousId)) {
88  map.put("inputs", list);
89  }
90 
91  final String id = Integer.toString(relIdMap.size());
92  relIdMap.put(rel, id);
93  map.put("id", id);
94 
95  relList.add(map);
96  previousId = id;
97  }
List< Object > explainInputs(List< RelNode > inputs)
void put(Map< String, Object > map, String name, Object value)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

List<Object> org.apache.calcite.rel.externalize.MapDRelJsonWriter.explainInputs ( List< RelNode >  inputs)
inlineprivate

Definition at line 103 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.input(), org.apache.calcite.rel.externalize.MapDRelJsonWriter.previousId, and Experimental.String.

Referenced by org.apache.calcite.rel.externalize.MapDRelJsonWriter.explain_().

103  {
104  final List<Object> list = jsonBuilder.list();
105  for (RelNode input : inputs) {
106  String id = relIdMap.get(input);
107  if (id == null) {
108  input.explain(this);
109  id = previousId;
110  }
111  list.add(id);
112  }
113  return list;
114  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SqlExplainLevel org.apache.calcite.rel.externalize.MapDRelJsonWriter.getDetailLevel ( )
inline

Definition at line 120 of file MapDRelJsonWriter.java.

120  {
121  return SqlExplainLevel.ALL_ATTRIBUTES;
122  }
List<Object> org.apache.calcite.rel.externalize.MapDRelJsonWriter.getList ( List< Pair< String, Object >>  values,
String  tag 
)
inlineprivate

Definition at line 133 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.values.

133  {
134  for (Pair<String, Object> value : values) {
135  if (value.left.equals(tag)) {
136  // noinspection unchecked
137  return (List<Object>) value.right;
138  }
139  }
140  final List<Object> list = new ArrayList<Object>();
141  values.add(Pair.of(tag, (Object) list));
142  return list;
143  }
RelWriter org.apache.calcite.rel.externalize.MapDRelJsonWriter.input ( String  term,
RelNode  input 
)
inline

Definition at line 124 of file MapDRelJsonWriter.java.

Referenced by org.apache.calcite.rel.externalize.MapDRelJsonWriter.explainInputs().

124  {
125  return this;
126  }

+ Here is the caller graph for this function:

RelWriter org.apache.calcite.rel.externalize.MapDRelJsonWriter.item ( String  term,
Object  value 
)
inline

Definition at line 128 of file MapDRelJsonWriter.java.

Referenced by org.apache.calcite.rel.externalize.MapDRelJsonWriter.itemIf().

128  {
129  values.add(Pair.of(term, value));
130  return this;
131  }

+ Here is the caller graph for this function:

RelWriter org.apache.calcite.rel.externalize.MapDRelJsonWriter.itemIf ( String  term,
Object  value,
boolean  condition 
)
inline

Definition at line 145 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.item().

145  {
146  if (condition) {
147  item(term, value);
148  }
149  return this;
150  }

+ Here is the call graph for this function:

boolean org.apache.calcite.rel.externalize.MapDRelJsonWriter.nest ( )
inline

Definition at line 159 of file MapDRelJsonWriter.java.

159  {
160  return true;
161  }
void org.apache.calcite.rel.externalize.MapDRelJsonWriter.put ( Map< String, Object >  map,
String  name,
Object  value 
)
inlineprivate

Definition at line 99 of file MapDRelJsonWriter.java.

Referenced by org.apache.calcite.rel.externalize.MapDRelJsonWriter.explain_().

99  {
100  map.put(name, relJson.toJson(value));
101  }

+ Here is the caller graph for this function:

Member Data Documentation

final JsonBuilder org.apache.calcite.rel.externalize.MapDRelJsonWriter.jsonBuilder
private
String org.apache.calcite.rel.externalize.MapDRelJsonWriter.previousId
private
final Map<RelNode, String> org.apache.calcite.rel.externalize.MapDRelJsonWriter.relIdMap = new IdentityHashMap<RelNode, String>()
private

Definition at line 47 of file MapDRelJsonWriter.java.

final MapDRelJson org.apache.calcite.rel.externalize.MapDRelJsonWriter.relJson
private
final List<Object> org.apache.calcite.rel.externalize.MapDRelJsonWriter.relList
private
final List<Pair<String, Object> > org.apache.calcite.rel.externalize.MapDRelJsonWriter.values = new ArrayList<Pair<String, Object>>()
private

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