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

Method field

cpp/src/arrow/array/array_nested.cc:1087–1115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1085}
1086
1087std::shared_ptr<Array> StructArray::field(int i) const {
1088 // Atomic ops on std::shared_ptr<T> are deprecated in C++20. They should be
1089 // replaced with std::atomic<std::shared_ptr<T>> but not all C++ standard
1090 // libraries implement it yet. :-/
1091 ARROW_SUPPRESS_DEPRECATION_WARNING
1092 std::shared_ptr<Array> result = std::atomic_load(&impl_->boxed_fields_[i]);
1093 ARROW_UNSUPPRESS_DEPRECATION_WARNING
1094 if (result) {
1095 return result;
1096 }
1097 std::shared_ptr<ArrayData> field_data;
1098 if (data_->offset != 0 || data_->child_data[i]->length != data_->length) {
1099 field_data = data_->child_data[i]->Slice(data_->offset, data_->length);
1100 } else {
1101 field_data = data_->child_data[i];
1102 }
1103 result = MakeArray(field_data);
1104 // Check if some other thread inserted the array in the meantime and return
1105 // that in that case.
1106 std::shared_ptr<Array> expected = nullptr;
1107 ARROW_SUPPRESS_DEPRECATION_WARNING
1108 const bool update_successful =
1109 std::atomic_compare_exchange_strong(&impl_->boxed_fields_[i], &expected, result);
1110 ARROW_UNSUPPRESS_DEPRECATION_WARNING
1111 if (!update_successful) {
1112 result = std::move(expected);
1113 }
1114 return result;
1115}
1116
1117std::shared_ptr<Array> StructArray::GetFieldByName(const std::string& name) const {
1118 int i = struct_type()->GetFieldIndex(name);

Callers 15

VisitMethod · 0.45
PartitionMethod · 0.45
ConvertKeyMethod · 0.45
FormatMethod · 0.45
DoInspectMethod · 0.45
FormatValuesMethod · 0.45
MakeMethod · 0.45

Calls 5

MakeArrayFunction · 0.70
modeFunction · 0.70
SliceMethod · 0.45
sizeMethod · 0.45
CopyMethod · 0.45

Tested by 15

TESTFunction · 0.36
TEST_FFunction · 0.36
VisitMethod · 0.36
GenerateRandomTableFunction · 0.36
TESTFunction · 0.36
RunTestMethod · 0.36
operator()Method · 0.36
ASSERT_OK_AND_ASSIGNFunction · 0.36