| 143 | |
| 144 | template <class JsonStream> |
| 145 | void ComplexValueWriter<JsonStream>::CollectionElementToJSON(Tuple* item_tuple, |
| 146 | const SlotDescriptor& slot_desc, bool map_key) { |
| 147 | void* element = item_tuple->GetSlot(slot_desc.tuple_offset()); |
| 148 | DCHECK(element != nullptr); |
| 149 | const ColumnType& element_type = slot_desc.type(); |
| 150 | bool element_is_null = item_tuple->IsNull(slot_desc.null_indicator_offset()); |
| 151 | if (element_is_null) { |
| 152 | WriteNull(map_key); |
| 153 | } else if (element_type.IsStructType()) { |
| 154 | DCHECK(!map_key) << "Structs cannot be map keys."; |
| 155 | StructInCollectionToJSON(item_tuple, slot_desc); |
| 156 | } else if (element_type.IsCollectionType()) { |
| 157 | const CollectionValue* nested_collection_val = |
| 158 | reinterpret_cast<CollectionValue*>(element); |
| 159 | const TupleDescriptor* child_item_tuple_desc = |
| 160 | slot_desc.children_tuple_descriptor(); |
| 161 | DCHECK(child_item_tuple_desc != nullptr); |
| 162 | ComplexValueWriter::CollectionValueToJSON(*nested_collection_val, element_type.type, |
| 163 | child_item_tuple_desc); |
| 164 | } else { |
| 165 | PrimitiveValueToJSON(element, element_type, map_key); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | // Gets an array value and writes it in JSON format. |
| 170 | template <class JsonStream> |
nothing calls this directly
no test coverage detected