MCPcopy Create free account
hub / github.com/apache/impala / PrintComplexValue

Method PrintComplexValue

be/src/service/query-result-set.cc:235–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void QueryResultSet::PrintComplexValue(ScalarExprEvaluator* expr_eval,
236 const TupleRow* row, stringstream *stream, const ColumnType& type,
237 bool stringify_map_keys) {
238 DCHECK(type.IsComplexType());
239 const ScalarExpr& scalar_expr = expr_eval->root();
240 // Currently scalar_expr can be only a slot ref as no functions return complex types.
241 DCHECK(scalar_expr.IsSlotRef());
242 void* value = expr_eval->GetValue(row);
243
244 if (value == nullptr) {
245 (*stream) << RawValue::NullLiteral(/*top-level*/ true);
246 return;
247 }
248
249 rapidjson::BasicOStreamWrapper<stringstream> wrapped_stream(*stream);
250 rapidjson::Writer<rapidjson::BasicOStreamWrapper<stringstream>> writer(wrapped_stream);
251
252 if (type.IsCollectionType()) {
253 const CollectionValue* collection_val = static_cast<const CollectionValue*>(value);
254 const TupleDescriptor* item_tuple_desc = scalar_expr.GetCollectionTupleDesc();
255 DCHECK(item_tuple_desc != nullptr);
256
257 ComplexValueWriter<rapidjson::BasicOStreamWrapper<stringstream>>
258 complex_value_writer(&writer, stringify_map_keys);
259 complex_value_writer.CollectionValueToJSON(*collection_val, type.type,
260 item_tuple_desc);
261 } else {
262 DCHECK(type.IsStructType());
263 const StructVal* struct_val = static_cast<const StructVal*>(value);
264 const SlotDescriptor* slot_desc =
265 static_cast<const SlotRef&>(scalar_expr).GetSlotDescriptor();
266 DCHECK(slot_desc != nullptr);
267 DCHECK_EQ(type, slot_desc->type());
268
269 ComplexValueWriter<rapidjson::BasicOStreamWrapper<stringstream>>
270 complex_value_writer(&writer, stringify_map_keys);
271 complex_value_writer.StructValToJSON(*struct_val, *slot_desc);
272 }
273}
274
275Status AsciiQueryResultSet::AddOneRow(const TResultRow& row) {
276 int num_col = row.colVals.size();

Callers

nothing calls this directly

Calls 12

IsComplexTypeMethod · 0.80
rootMethod · 0.80
IsCollectionTypeMethod · 0.80
CollectionValueToJSONMethod · 0.80
IsStructTypeMethod · 0.80
StructValToJSONMethod · 0.80
NullLiteralClass · 0.50
IsSlotRefMethod · 0.45
GetValueMethod · 0.45
GetSlotDescriptorMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected