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

Method getFieldNames

matlab/src/cpp/arrow/matlab/array/proxy/struct_array.cc:149–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149void StructArray::getFieldNames(libmexclass::proxy::method::Context& context) {
150 namespace mda = ::matlab::data;
151
152 const auto& fields = array->type()->fields();
153 const auto num_fields = fields.size();
154 std::vector<mda::MATLABString> names;
155 names.reserve(num_fields);
156
157 for (size_t i = 0; i < num_fields; ++i) {
158 auto str_utf8 = fields[i]->name();
159
160 // MATLAB strings are UTF-16 encoded. Must convert UTF-8
161 // encoded field names before returning to MATLAB.
162 MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(auto str_utf16,
163 arrow::util::UTF8StringToUTF16(str_utf8), context,
164 error::UNICODE_CONVERSION_ERROR_ID);
165 const mda::MATLABString matlab_string = mda::MATLABString(std::move(str_utf16));
166 names.push_back(matlab_string);
167 }
168
169 mda::ArrayFactory factory;
170 context.outputs[0] = factory.createArray({1, num_fields}, names.begin(), names.end());
171}
172} // namespace arrow::matlab::array::proxy

Callers

nothing calls this directly

Calls 8

push_backMethod · 0.80
fieldsMethod · 0.45
typeMethod · 0.45
sizeMethod · 0.45
reserveMethod · 0.45
nameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected