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

Method VisitField

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

Source from the content-addressed store, hash-verified

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

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