| 229 | } |
| 230 | |
| 231 | void Table::getColumnByIndex(libmexclass::proxy::method::Context& context) { |
| 232 | using ChunkedArrayProxy = arrow::matlab::array::proxy::ChunkedArray; |
| 233 | namespace mda = ::matlab::data; |
| 234 | using namespace libmexclass::proxy; |
| 235 | mda::ArrayFactory factory; |
| 236 | |
| 237 | mda::StructArray args = context.inputs[0]; |
| 238 | const mda::TypedArray<int32_t> index_mda = args[0]["Index"]; |
| 239 | const auto matlab_index = int32_t(index_mda[0]); |
| 240 | |
| 241 | // Note: MATLAB uses 1-based indexing, so subtract 1. |
| 242 | // arrow::Schema::field does not do any bounds checking. |
| 243 | const int32_t index = matlab_index - 1; |
| 244 | const auto num_columns = table->num_columns(); |
| 245 | |
| 246 | if (num_columns == 0) { |
| 247 | context.error = makeEmptyTableError(); |
| 248 | return; |
| 249 | } |
| 250 | |
| 251 | if (matlab_index < 1 || matlab_index > num_columns) { |
| 252 | context.error = makeInvalidNumericIndexError(matlab_index, num_columns); |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | const auto chunked_array = table->column(index); |
| 257 | const auto chunked_array_proxy = std::make_shared<ChunkedArrayProxy>(chunked_array); |
| 258 | |
| 259 | const auto chunked_array_proxy_id = ProxyManager::manageProxy(chunked_array_proxy); |
| 260 | const auto chunked_array_proxy_id_mda = factory.createScalar(chunked_array_proxy_id); |
| 261 | |
| 262 | context.outputs[0] = chunked_array_proxy_id_mda; |
| 263 | } |
| 264 | |
| 265 | void Table::getColumnByName(libmexclass::proxy::method::Context& context) { |
| 266 | using ChunkedArrayProxy = arrow::matlab::array::proxy::ChunkedArray; |
nothing calls this directly
no test coverage detected