| 157 | } |
| 158 | |
| 159 | void 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 | |
| 187 | void RecordBatch::getColumnByName(libmexclass::proxy::method::Context& context) { |
| 188 | namespace mda = ::matlab::data; |
nothing calls this directly
no test coverage detected