kevingurney commented on code in PR #37163:
URL: https://github.com/apache/arrow/pull/37163#discussion_r1293953800


##########
matlab/src/matlab/featherread.m:
##########
@@ -23,64 +23,45 @@
 % specific language governing permissions and limitations
 % under the License.
 
-import arrow.util.*;
-
-% Validate input arguments.
-narginchk(1, 1);
-filename = convertStringsToChars(filename);
-if ~ischar(filename)
-    error('MATLAB:arrow:InvalidFilenameDatatype', ...
-        'Filename must be a character vector or string scalar.');
-end
+    arguments
+        filename(1, 1) string {mustBeNonmissing, mustBeNonzeroLengthText}
+    end
 
-% FOPEN can be used to search for files without an extension on the MATLAB
-% path.
-fid = fopen(filename);
-if fid ~= -1
-    filename = fopen(fid);
-    fclose(fid);
-else
-    error('MATLAB:arrow:UnableToOpenFile', ...
-        'Unable to open file %s.', filename);
-end
+    typesToCast = [arrow.type.ID.UInt8, ...
+                   arrow.type.ID.UInt16, ...
+                   arrow.type.ID.UInt32, ...
+                   arrow.type.ID.UInt64, ...
+                   arrow.type.ID.Int8, ...
+                   arrow.type.ID.Int16, ...
+                   arrow.type.ID.Int32, ...
+                   arrow.type.ID.Int64, ...
+                   arrow.type.ID.Boolean];
 
-% Read table variables and metadata from the given Feather file using
-% libarrow.
-[variables, metadata] = arrow.cpp.call('featherread', filename);
+    reader = arrow.internal.io.feather.Reader(filename);
+    recordBatch = reader.read();
 
-% Make valid MATLAB table variable names out of any of the
-% Feather table column names that are not valid MATLAB table
-% variable names.
-[variableNames, variableDescriptions] = 
makeValidMATLABTableVariableNames({variables.Name});
+    % Convert RecordBatch to a MATLAB table.
+    t = table(recordBatch);
 
-% Iterate over each table variable, handling invalid (null) entries
-% and invalid MATLAB table variable names appropriately.
-% Note: All Arrow arrays can have an associated validity (null) bitmap.
-% The Apache Arrow specification defines 0 (false) to represent an
-% invalid (null) array entry and 1 (true) to represent a valid
-% (non-null) array entry.
-for ii = 1:length(variables)
-    if ~all(variables(ii).Valid)
-        switch variables(ii).Type
-            case {'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16', 
'int32', 'int64'}
-                % MATLAB does not support missing values for integer types, so
-                % cast to double and set missing values to NaN in this case.
-                variables(ii).Data = double(variables(ii).Data);
+    % Cast columns with integer or boolean type containing null values

Review Comment:
   Good point. That sounds clearer.



-- 
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]

Reply via email to