MCPcopy Create free account
hub / github.com/apache/arrow / VisitField

Method VisitField

cpp/src/arrow/integration/json_internal.cc:195–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193 }
194
195 Status VisitField(const std::shared_ptr<Field>& field, FieldPosition field_pos) {
196 writer_->StartObject();
197
198 writer_->Key("name");
199 writer_->String(field->name().c_str());
200
201 writer_->Key("nullable");
202 writer_->Bool(field->nullable());
203
204 const DataType* type = field->type().get();
205 std::vector<std::pair<std::string, std::string>> additional_metadata;
206 if (type->id() == Type::EXTENSION) {
207 const auto& ext_type = checked_cast<const ExtensionType&>(*type);
208 type = ext_type.storage_type().get();
209 additional_metadata.emplace_back(kExtensionTypeKeyName, ext_type.extension_name());
210 additional_metadata.emplace_back(kExtensionMetadataKeyName, ext_type.Serialize());
211 }
212
213 // Visit the type
214 writer_->Key("type");
215 writer_->StartObject();
216 RETURN_NOT_OK(VisitType(*type));
217 writer_->EndObject();
218
219 if (type->id() == Type::DICTIONARY) {
220 const auto& dict_type = checked_cast<const DictionaryType&>(*type);
221 // Ensure we visit child fields first so that, in the case of nested
222 // dictionaries, inner dictionaries get a smaller id than outer dictionaries.
223 RETURN_NOT_OK(WriteChildren(dict_type.value_type()->fields(), field_pos));
224 ARROW_ASSIGN_OR_RAISE(const int64_t dictionary_id,
225 mapper_.GetFieldId(field_pos.path()));
226 RETURN_NOT_OK(WriteDictionaryMetadata(dictionary_id, dict_type));
227 } else {
228 RETURN_NOT_OK(WriteChildren(type->fields(), field_pos));
229 }
230
231 WriteKeyValueMetadata(field->metadata(), additional_metadata);
232 writer_->EndObject();
233
234 return Status::OK();
235 }
236
237 Status VisitType(const DataType& type);
238

Callers

nothing calls this directly

Calls 15

nullableMethod · 0.80
storage_typeMethod · 0.80
emplace_backMethod · 0.80
VisitTypeFunction · 0.50
OKFunction · 0.50
StartObjectMethod · 0.45
KeyMethod · 0.45
StringMethod · 0.45
nameMethod · 0.45
BoolMethod · 0.45
getMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected