| 240 | |
| 241 | template <class JsonStream> |
| 242 | void ComplexValueWriter<JsonStream>::StructValToJSON(const StructVal& struct_val, |
| 243 | const SlotDescriptor& slot_desc) { |
| 244 | const ColumnType& struct_type = slot_desc.type(); |
| 245 | DCHECK(struct_type.type == TYPE_STRUCT); |
| 246 | DCHECK_EQ(struct_val.num_children, struct_type.children.size()); |
| 247 | |
| 248 | const TupleDescriptor* children_item_tuple_desc = slot_desc.children_tuple_descriptor(); |
| 249 | DCHECK(children_item_tuple_desc != nullptr); |
| 250 | const std::vector<SlotDescriptor*>& child_slot_descs = |
| 251 | children_item_tuple_desc->slots(); |
| 252 | DCHECK_EQ(struct_val.num_children, child_slot_descs.size()); |
| 253 | |
| 254 | writer_->StartObject(); |
| 255 | for (int i = 0; i < struct_val.num_children; ++i) { |
| 256 | writer_->String(struct_type.field_names[i].c_str()); |
| 257 | void* child = (void*)(struct_val.ptr[i]); |
| 258 | const SlotDescriptor& child_slot_desc = *child_slot_descs[i]; |
| 259 | const ColumnType& child_type = struct_type.children[i]; |
| 260 | DCHECK_EQ(child_type, child_slot_desc.type()); |
| 261 | if (child == nullptr) { |
| 262 | WriteNull(false); |
| 263 | } else if (child_type.IsStructType()) { |
| 264 | StructValToJSON(*((StructVal*)child), child_slot_desc); |
| 265 | } else if (child_type.IsCollectionType()) { |
| 266 | CollectionValue* collection_child = reinterpret_cast<CollectionValue*>(child); |
| 267 | ComplexValueWriter::CollectionValueToJSON(*collection_child, child_type.type, |
| 268 | child_slot_desc.children_tuple_descriptor()); |
| 269 | } else { |
| 270 | PrimitiveValueToJSON(child, child_type, false); |
| 271 | } |
| 272 | } |
| 273 | writer_->EndObject(); |
| 274 | } |
| 275 | |
| 276 | } // namespace impala |
no test coverage detected