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

Method MapValueToJSON

be/src/runtime/complex-value-writer.inline.h:195–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193// Gets a map value and writes it in JSON format.
194template <class JsonStream>
195void ComplexValueWriter<JsonStream>::MapValueToJSON(const CollectionValue& map_value,
196 const TupleDescriptor* item_tuple_desc) {
197 DCHECK(item_tuple_desc != nullptr);
198
199 const int item_byte_size = item_tuple_desc->byte_size();
200 const vector<SlotDescriptor*>& slot_descs = item_tuple_desc->slots();
201
202 DCHECK(slot_descs.size() == 2);
203 DCHECK(slot_descs[0] != nullptr);
204 DCHECK(slot_descs[1] != nullptr);
205
206 writer_->StartObject();
207
208 for (int i = 0; i < map_value.num_tuples; ++i) {
209 Tuple* item_tuple = reinterpret_cast<Tuple*>(
210 map_value.ptr + i * item_byte_size);
211 // Print key.
212 const SlotDescriptor& key_slot_desc = *slot_descs[0];
213 CollectionElementToJSON(item_tuple, key_slot_desc, true);
214
215 // Print the value.
216 const SlotDescriptor& value_slot_desc = *slot_descs[1];
217 CollectionElementToJSON(item_tuple, value_slot_desc, false);
218 }
219
220 writer_->EndObject();
221}
222
223template <class JsonStream>
224ComplexValueWriter<JsonStream>::ComplexValueWriter(rapidjson::Writer<JsonStream>* writer,

Callers

nothing calls this directly

Calls 4

byte_sizeMethod · 0.45
sizeMethod · 0.45
StartObjectMethod · 0.45
EndObjectMethod · 0.45

Tested by

no test coverage detected