| 233 | } |
| 234 | |
| 235 | void 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 | |
| 275 | Status AsciiQueryResultSet::AddOneRow(const TResultRow& row) { |
| 276 | int num_col = row.colVals.size(); |
nothing calls this directly
no test coverage detected