| 100 | // tuple. |
| 101 | template <class JsonStream> |
| 102 | void ComplexValueWriter<JsonStream>::StructInCollectionToJSON(Tuple* item_tuple, |
| 103 | const SlotDescriptor& struct_slot_desc) { |
| 104 | const TupleDescriptor* children_tuple_desc = |
| 105 | struct_slot_desc.children_tuple_descriptor(); |
| 106 | DCHECK(children_tuple_desc != nullptr); |
| 107 | |
| 108 | const ColumnType& struct_type = struct_slot_desc.type(); |
| 109 | const std::vector<SlotDescriptor*>& child_slots = children_tuple_desc->slots(); |
| 110 | |
| 111 | DCHECK(struct_type.type == TYPE_STRUCT); |
| 112 | DCHECK_EQ(child_slots.size(), struct_type.children.size()); |
| 113 | |
| 114 | writer_->StartObject(); |
| 115 | for (int i = 0; i < child_slots.size(); ++i) { |
| 116 | writer_->String(struct_type.field_names[i].c_str()); |
| 117 | |
| 118 | const SlotDescriptor& child_slot_desc = *child_slots[i]; |
| 119 | bool element_is_null = item_tuple->IsNull(child_slot_desc.null_indicator_offset()); |
| 120 | if (element_is_null) { |
| 121 | WriteNull(writer_); |
| 122 | continue; |
| 123 | } |
| 124 | |
| 125 | const ColumnType& child_type = child_slot_desc.type(); |
| 126 | void* child = item_tuple->GetSlot(child_slot_desc.tuple_offset()); |
| 127 | if (child_type.IsStructType()) { |
| 128 | StructInCollectionToJSON(item_tuple, child_slot_desc); |
| 129 | } else if (child_type.IsCollectionType()) { |
| 130 | const CollectionValue* nested_collection_val = |
| 131 | reinterpret_cast<CollectionValue*>(child); |
| 132 | const TupleDescriptor* child_item_tuple_desc = |
| 133 | child_slot_desc.children_tuple_descriptor(); |
| 134 | DCHECK(child_item_tuple_desc != nullptr); |
| 135 | CollectionValueToJSON(*nested_collection_val, child_type.type, |
| 136 | child_item_tuple_desc); |
| 137 | } else { |
| 138 | PrimitiveValueToJSON(child, child_type, false); |
| 139 | } |
| 140 | } |
| 141 | writer_->EndObject(); |
| 142 | } |
| 143 | |
| 144 | template <class JsonStream> |
| 145 | void ComplexValueWriter<JsonStream>::CollectionElementToJSON(Tuple* item_tuple, |
nothing calls this directly
no test coverage detected