kevingurney commented on code in PR #38531:
URL: https://github.com/apache/arrow/pull/38531#discussion_r1377992976
##########
matlab/src/cpp/arrow/matlab/array/proxy/list_array.cc:
##########
@@ -100,4 +102,38 @@ namespace arrow::matlab::array::proxy {
mda::ArrayFactory factory;
context.outputs[0] =
factory.createScalar(offsets_int32_array_proxy_id);
}
+
+ void ListArray::validate(libmexclass::proxy::method::Context& context) {
+ namespace mda = ::matlab::data;
+ mda::StructArray args = context.inputs[0];
+ const mda::TypedArray<std::uint8_t> validation_mode_mda =
args[0]["ValidationMode"];
+ const auto validation_mode_integer = uint8_t(validation_mode_mda[0]);
+ // Convert integer representation to ValidationMode enum.
+ const auto validation_mode =
static_cast<ValidationMode>(validation_mode_integer);
+ switch (validation_mode) {
+ case ValidationMode::None: {
+ // Do nothing.
+ break;
+ }
+ case ValidationMode::Minimal: {
+ MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(array->Validate(),
+ context,
+ error::ARRAY_VALIDATE_MINIMAL_FAILED);
+ break;
+ }
+ case ValidationMode::Full: {
+ MATLAB_ERROR_IF_NOT_OK_WITH_CONTEXT(array->ValidateFull(),
+ context,
+ error::ARRAY_VALIDATE_FULL_FAILED);
+ break;
+ }
+ default: {
+ // Throw an error if an unsupported enumeration value is
provided.
+ const auto msg = "Unsupported ValidationMode enumeration
value: " + std::to_string(validation_mode_integer);
+ context.error =
libmexclass::error::Error{error::ARRAY_VALIDATE_UNSUPPORTED_ENUM, msg};
+ return;
Review Comment:
Yeah, I considered using `break`. The only argument I have in favor of
`return` over `break` is that, if someone were to edit this code and add code
below this `switch` statement in the future for some reason, then that code
might unintentionally get executed if we put a `break` here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]