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

Method slice

matlab/src/cpp/arrow/matlab/array/proxy/array.cc:148–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void Array::slice(libmexclass::proxy::method::Context& context) {
149 namespace mda = ::matlab::data;
150
151 mda::StructArray opts = context.inputs[0];
152 const mda::TypedArray<int64_t> offset_mda = opts[0]["Offset"];
153 const mda::TypedArray<int64_t> length_mda = opts[0]["Length"];
154
155 const auto matlab_offset = int64_t(offset_mda[0]);
156 MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(
157 arrow::matlab::index::validateSliceOffset(matlab_offset), context,
158 error::ARRAY_SLICE_NON_POSITIVE_OFFSET);
159
160 // Note: MATLAB uses 1-based indexing, so subtract 1.
161 const int64_t offset = matlab_offset - 1;
162 const int64_t length = int64_t(length_mda[0]);
163 MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(arrow::matlab::index::validateSliceLength(length),
164 context, error::ARRAY_SLICE_NEGATIVE_LENGTH);
165
166 auto sliced_array = array->Slice(offset, length);
167 MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(
168 context.outputs[0], arrow::matlab::proxy::wrap_and_manage(sliced_array), context,
169 error::ARRAY_SLICE_FAILED_TO_CREATE_ARRAY_PROXY);
170}
171
172void Array::exportToC(libmexclass::proxy::method::Context& context) {
173 namespace mda = ::matlab::data;

Callers

nothing calls this directly

Calls 4

validateSliceOffsetFunction · 0.85
validateSliceLengthFunction · 0.85
wrap_and_manageFunction · 0.85
SliceMethod · 0.45

Tested by

no test coverage detected