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

Method getColumnByIndex

matlab/src/cpp/arrow/matlab/tabular/proxy/record_batch.cc:159–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159void RecordBatch::getColumnByIndex(libmexclass::proxy::method::Context& context) {
160 namespace mda = ::matlab::data;
161
162 mda::StructArray args = context.inputs[0];
163 const mda::TypedArray<int32_t> index_mda = args[0]["Index"];
164 const auto matlab_index = int32_t(index_mda[0]);
165
166 // Note: MATLAB uses 1-based indexing, so subtract 1.
167 // arrow::Schema::field does not do any bounds checking.
168 const int32_t index = matlab_index - 1;
169 const auto num_columns = record_batch->num_columns();
170
171 if (num_columns == 0) {
172 context.error = makeEmptyRecordBatchError();
173 return;
174 }
175
176 if (matlab_index < 1 || matlab_index > num_columns) {
177 context.error = makeInvalidNumericIndexError(matlab_index, num_columns);
178 return;
179 }
180
181 const auto array = record_batch->column(index);
182 MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(context.outputs[0],
183 arrow::matlab::proxy::wrap_and_manage(array),
184 context, error::UNKNOWN_PROXY_FOR_ARRAY_TYPE);
185}
186
187void RecordBatch::getColumnByName(libmexclass::proxy::method::Context& context) {
188 namespace mda = ::matlab::data;

Callers

nothing calls this directly

Calls 5

wrap_and_manageFunction · 0.85
num_columnsMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected