OmniSciDB  340b00dbf6
 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)
 
boolean deliverHints (RelNode rel)
 
String explainHints (RelNode rel)
 
List< Object > getList (List< Pair< String, Object >> values, String tag)
 

Private Attributes

final EscapedStringJsonBuilder 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 39 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 234 of file MapDRelJsonWriter.java.

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

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

234  {
235  final Map<String, Object> map = jsonBuilder.map();
236  map.put("rels", relList);
237  return map;
238  }

+ 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 230 of file MapDRelJsonWriter.java.

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

230  {
231  return jsonBuilder.toJsonString(asJsonMap());
232  }

+ Here is the call graph for this function:

boolean org.apache.calcite.rel.externalize.MapDRelJsonWriter.deliverHints ( RelNode  rel)
inlineprivate

Definition at line 118 of file MapDRelJsonWriter.java.

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

118  {
119  if (rel instanceof LogicalTableScan) {
120  LogicalTableScan node = (LogicalTableScan) rel;
121  if (!node.getHints().isEmpty()) {
122  return true;
123  } else {
124  return false;
125  }
126  } else if (rel instanceof LogicalAggregate) {
127  LogicalAggregate node = (LogicalAggregate) rel;
128  if (!node.getHints().isEmpty()) {
129  return true;
130  } else {
131  return false;
132  }
133  } else if (rel instanceof LogicalJoin) {
134  LogicalJoin node = (LogicalJoin) rel;
135  if (!node.getHints().isEmpty()) {
136  return true;
137  } else {
138  return false;
139  }
140  } else if (rel instanceof LogicalProject) {
141  LogicalProject node = (LogicalProject) rel;
142  if (!node.getHints().isEmpty()) {
143  return true;
144  } else {
145  return false;
146  }
147  } else if (rel instanceof LogicalCalc) {
148  LogicalCalc node = (LogicalCalc) rel;
149  if (!node.getHints().isEmpty()) {
150  return true;
151  } else {
152  return false;
153  }
154  }
155  return false;
156  }

+ Here is the caller graph for this function:

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

Definition at line 215 of file MapDRelJsonWriter.java.

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

215  {
216  final List<Pair<String, Object>> valuesCopy = ImmutableList.copyOf(values);
217  values.clear();
218  explain_(node, valuesCopy);
219  return this;
220  }
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 179 of file MapDRelJsonWriter.java.

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

179  {
180  explain_(rel, valueList);
181  }
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 59 of file MapDRelJsonWriter.java.

References org.apache.calcite.rel.externalize.MapDRelJsonWriter.deliverHints(), org.apache.calcite.rel.externalize.MapDRelJsonWriter.explainHints(), org.apache.calcite.rel.externalize.MapDRelJsonWriter.explainInputs(), org.apache.calcite.rel.externalize.MapDRelJsonWriter.previousId, org.apache.calcite.rel.externalize.MapDRelJsonWriter.put(), 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().

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

String org.apache.calcite.rel.externalize.MapDRelJsonWriter.explainHints ( RelNode  rel)
inlineprivate

Definition at line 158 of file MapDRelJsonWriter.java.

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

158  {
159  List<String> explained = new ArrayList<>();
160  if (rel instanceof LogicalTableScan) {
161  LogicalTableScan node = (LogicalTableScan) rel;
162  node.getHints().stream().forEach(s -> explained.add(s.toString().toLowerCase()));
163  } else if (rel instanceof LogicalAggregate) {
164  LogicalAggregate node = (LogicalAggregate) rel;
165  node.getHints().stream().forEach(s -> explained.add(s.toString().toLowerCase()));
166  } else if (rel instanceof LogicalJoin) {
167  LogicalJoin node = (LogicalJoin) rel;
168  node.getHints().stream().forEach(s -> explained.add(s.toString().toLowerCase()));
169  } else if (rel instanceof LogicalProject) {
170  LogicalProject node = (LogicalProject) rel;
171  node.getHints().stream().forEach(s -> explained.add(s.toString().toLowerCase()));
172  } else if (rel instanceof LogicalCalc) {
173  LogicalCalc node = (LogicalCalc) rel;
174  node.getHints().stream().forEach(s -> explained.add(s.toString().toLowerCase()));
175  }
176  return explained.stream().collect(Collectors.joining("|"));
177  }

+ Here is the caller graph for this function:

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

Definition at line 105 of file MapDRelJsonWriter.java.

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

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

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

+ 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 183 of file MapDRelJsonWriter.java.

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

Definition at line 196 of file MapDRelJsonWriter.java.

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

196  {
197  for (Pair<String, Object> value : values) {
198  if (value.left.equals(tag)) {
199  // noinspection unchecked
200  return (List<Object>) value.right;
201  }
202  }
203  final List<Object> list = new ArrayList<Object>();
204  values.add(Pair.of(tag, (Object) list));
205  return list;
206  }
RelWriter org.apache.calcite.rel.externalize.MapDRelJsonWriter.input ( String  term,
RelNode  input 
)
inline

Definition at line 187 of file MapDRelJsonWriter.java.

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

187  {
188  return this;
189  }

+ Here is the caller graph for this function:

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

Definition at line 191 of file MapDRelJsonWriter.java.

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

191  {
192  values.add(Pair.of(term, value));
193  return this;
194  }

+ 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 208 of file MapDRelJsonWriter.java.

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

208  {
209  if (condition) {
210  item(term, value);
211  }
212  return this;
213  }

+ Here is the call graph for this function:

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

Definition at line 222 of file MapDRelJsonWriter.java.

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

Definition at line 101 of file MapDRelJsonWriter.java.

References setup.name.

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

101  {
102  map.put(name, relJson.toJson(value));
103  }
string name
Definition: setup.py:35

+ Here is the caller graph for this function:

Member Data Documentation

final EscapedStringJsonBuilder 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 44 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: