sgilmore10 commented on code in PR #37806:
URL: https://github.com/apache/arrow/pull/37806#discussion_r1332034692
##########
matlab/src/matlab/+arrow/+type/StructType.m:
##########
@@ -33,14 +33,28 @@
end
methods (Hidden)
- % TODO: Consider using a mixin approach to add this behavior. For
- % example, ChunkedArray's toMATLAB method could check if its
- % Type inherits from a mixin called "Preallocateable" (or something
- % more descriptive). If so, we can call preallocateMATLABArray
- % in the toMATLAB method.
- function preallocateMATLABArray(~)
- error("arrow:type:UnsupportedFunction", ...
- "preallocateMATLABArray is not supported for StructType");
- end
+ function data = preallocateMATLABArray(obj, numElements)
+ import arrow.tabular.internal.*
+
+ fields = obj.Fields;
+
+ % Construct the VariableNames and VariableDimensionNames
+ fieldNames = [fields.Name];
+ validVariableNames = makeValidVariableNames(fieldNames);
+ validDimensionNames = makeValidDimensionNames(validVariableNames);
+
+ % Preallocates each table variable. Uses the child field types
+ % to construct the correct MATLAB type.
+ variableData = cell(1, numel(fields));
+ for ii = 1:numel(fields)
+ type = fields(ii).Type;
Review Comment:
Yup, I added this comment.
--
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]