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

Method getChunk

matlab/src/cpp/arrow/matlab/array/proxy/chunked_array.cc:112–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void ChunkedArray::getChunk(libmexclass::proxy::method::Context& context) {
113 namespace mda = ::matlab::data;
114 mda::ArrayFactory factory;
115
116 mda::StructArray args = context.inputs[0];
117 const mda::TypedArray<int32_t> index_mda = args[0]["Index"];
118 const auto matlab_index = int32_t(index_mda[0]);
119
120 // Note: MATLAB uses 1-based indexing, so subtract 1.
121 // arrow::Schema::field does not do any bounds checking.
122 const int32_t index = matlab_index - 1;
123 const auto num_chunks = chunked_array->num_chunks();
124
125 if (num_chunks == 0) {
126 context.error = makeEmptyChunkedArrayError();
127 return;
128 }
129
130 if (matlab_index < 1 || matlab_index > num_chunks) {
131 context.error = makeInvalidNumericIndexError(matlab_index, num_chunks);
132 return;
133 }
134
135 const auto array = chunked_array->chunk(index);
136 MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(context.outputs[0],
137 arrow::matlab::proxy::wrap_and_manage(array),
138 context, error::UNKNOWN_PROXY_FOR_ARRAY_TYPE);
139}
140
141void ChunkedArray::getType(libmexclass::proxy::method::Context& context) {
142 MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(

Callers

nothing calls this directly

Calls 4

wrap_and_manageFunction · 0.85
num_chunksMethod · 0.45

Tested by

no test coverage detected