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

Method field

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

Source from the content-addressed store, hash-verified

1125}
1126
1127std::shared_ptr<Array> StructArray::field(int i) const {
1128 // Atomic ops on std::shared_ptr<T> are deprecated in C++20. They should be
1129 // replaced with std::atomic<std::shared_ptr<T>> but not all C++ standard
1130 // libraries implement it yet. :-/
1131 ARROW_SUPPRESS_DEPRECATION_WARNING
1132 std::shared_ptr<Array> result = std::atomic_load(&impl_->boxed_fields_[i]);
1133 ARROW_UNSUPPRESS_DEPRECATION_WARNING
1134 if (result) {
1135 return result;
1136 }
1137 std::shared_ptr<ArrayData> field_data;
1138 if (data_->offset != 0 || data_->child_data[i]->length != data_->length) {
1139 field_data = data_->child_data[i]->Slice(data_->offset, data_->length);
1140 } else {
1141 field_data = data_->child_data[i];
1142 }
1143 result = MakeArray(field_data);
1144 // Check if some other thread inserted the array in the meantime and return
1145 // that in that case.
1146 std::shared_ptr<Array> expected = nullptr;
1147 ARROW_SUPPRESS_DEPRECATION_WARNING
1148 const bool update_successful =
1149 std::atomic_compare_exchange_strong(&impl_->boxed_fields_[i], &expected, result);
1150 ARROW_UNSUPPRESS_DEPRECATION_WARNING
1151 if (!update_successful) {
1152 result = std::move(expected);
1153 }
1154 return result;
1155}
1156
1157std::shared_ptr<Array> StructArray::GetFieldByName(const std::string& name) const {
1158 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