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

Method SetFieldBuilder

cpp/src/arrow/json/parser.cc:838–858  ·  view source on GitHub ↗

\brief helper for Key() functions sets the field builder with name key, or returns false if there is no field with that name

Source from the content-addressed store, hash-verified

836 /// sets the field builder with name key, or returns false if
837 /// there is no field with that name
838 bool SetFieldBuilder(std::string_view key, bool* duplicate_keys) {
839 auto parent = Cast<Kind::kObject>(builder_stack_.back());
840 field_index_ = parent->GetFieldIndex(key);
841 if (ARROW_PREDICT_FALSE(field_index_ == -1)) {
842 return false;
843 }
844 if (field_index_ < absent_fields_stack_.TopSize()) {
845 *duplicate_keys = !absent_fields_stack_[field_index_];
846 } else {
847 // When field_index is beyond the range of absent_fields_stack_ we have a duplicated
848 // field that wasn't declared in schema or previous records.
849 *duplicate_keys = true;
850 }
851 if (*duplicate_keys) {
852 status_ = ParseError("Column(", Path(), ") was specified twice in row ", num_rows_);
853 return false;
854 }
855 builder_ = parent->field_builder(field_index_);
856 absent_fields_stack_[field_index_] = false;
857 return true;
858 }
859
860 Status EndObjectImpl() {
861 auto parent = builder_stack_.back();

Callers

nothing calls this directly

Calls 6

backMethod · 0.80
TopSizeMethod · 0.80
field_builderMethod · 0.80
ParseErrorFunction · 0.70
PathFunction · 0.50
GetFieldIndexMethod · 0.45

Tested by

no test coverage detected