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


##########
matlab/src/matlab/+arrow/recordbatch.m:
##########
@@ -0,0 +1,57 @@
+%RECORDBATCH Creates an arrow.tabular.RecordBatch from a table.
+
+% Licensed to the Apache Software Foundation (ASF) under one or more
+% contributor license agreements.  See the NOTICE file distributed with
+% this work for additional information regarding copyright ownership.
+% The ASF licenses this file to you under the Apache License, Version
+% 2.0 (the "License"); you may not use this file except in compliance
+% with the License.  You may obtain a copy of the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS,
+% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+% implied.  See the License for the specific language governing
+% permissions and limitations under the License.
+function rb = recordbatch(T)
+    arguments
+        T table
+    end
+
+    arrowArrays = decompose(T);
+    arrayProxyIDs = getArrowProxyIDs(arrowArrays);
+
+    columnNames = string(T.Properties.VariableNames);
+    args = struct(ArrayProxyIDs=arrayProxyIDs, ColumnNames=columnNames);
+    proxyName = "arrow.tabular.proxy.RecordBatch";
+    proxy = arrow.internal.proxy.create(proxyName, args);
+
+    rb = arrow.tabular.RecordBatch(proxy);
+end
+
+function arrowArrays = decompose(T)
+% Decompose the input MATLAB table input a cell array of 
+% equivalent arrow.array.Array instances.
+    
+    numColumns = width(T);
+    arrowArrays = cell(1, numColumns);
+
+    % Convert each MATLAB array into a corresponding
+    % arrow.array.Array.
+    for ii = 1:numColumns
+        arrowArrays{ii} = arrow.array(T{:, ii});
+    end
+end
+
+function proxyIDs = getArrowProxyIDs(arrowArrays)

Review Comment:
   Can we name this `getArrowArrayProxyIDs`?



##########
matlab/src/matlab/+arrow/recordbatch.m:
##########
@@ -0,0 +1,57 @@
+%RECORDBATCH Creates an arrow.tabular.RecordBatch from a table.
+
+% Licensed to the Apache Software Foundation (ASF) under one or more
+% contributor license agreements.  See the NOTICE file distributed with
+% this work for additional information regarding copyright ownership.
+% The ASF licenses this file to you under the Apache License, Version
+% 2.0 (the "License"); you may not use this file except in compliance
+% with the License.  You may obtain a copy of the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS,
+% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+% implied.  See the License for the specific language governing
+% permissions and limitations under the License.
+function rb = recordbatch(T)
+    arguments
+        T table
+    end
+
+    arrowArrays = decompose(T);
+    arrayProxyIDs = getArrowProxyIDs(arrowArrays);
+
+    columnNames = string(T.Properties.VariableNames);
+    args = struct(ArrayProxyIDs=arrayProxyIDs, ColumnNames=columnNames);
+    proxyName = "arrow.tabular.proxy.RecordBatch";
+    proxy = arrow.internal.proxy.create(proxyName, args);
+
+    rb = arrow.tabular.RecordBatch(proxy);
+end
+
+function arrowArrays = decompose(T)
+% Decompose the input MATLAB table input a cell array of 
+% equivalent arrow.array.Array instances.
+    
+    numColumns = width(T);
+    arrowArrays = cell(1, numColumns);
+
+    % Convert each MATLAB array into a corresponding
+    % arrow.array.Array.
+    for ii = 1:numColumns
+        arrowArrays{ii} = arrow.array(T{:, ii});
+    end
+end
+
+function proxyIDs = getArrowProxyIDs(arrowArrays)

Review Comment:
   Actually, it probably makes sense to not include `Arrow` in the name since 
that part is probably implied.



##########
matlab/src/matlab/+arrow/recordbatch.m:
##########
@@ -0,0 +1,57 @@
+%RECORDBATCH Creates an arrow.tabular.RecordBatch from a table.
+
+% Licensed to the Apache Software Foundation (ASF) under one or more
+% contributor license agreements.  See the NOTICE file distributed with
+% this work for additional information regarding copyright ownership.
+% The ASF licenses this file to you under the Apache License, Version
+% 2.0 (the "License"); you may not use this file except in compliance
+% with the License.  You may obtain a copy of the License at
+%
+%   http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS,
+% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+% implied.  See the License for the specific language governing
+% permissions and limitations under the License.
+function rb = recordbatch(T)
+    arguments
+        T table
+    end
+
+    arrowArrays = decompose(T);
+    arrayProxyIDs = getArrowProxyIDs(arrowArrays);
+
+    columnNames = string(T.Properties.VariableNames);
+    args = struct(ArrayProxyIDs=arrayProxyIDs, ColumnNames=columnNames);
+    proxyName = "arrow.tabular.proxy.RecordBatch";
+    proxy = arrow.internal.proxy.create(proxyName, args);
+
+    rb = arrow.tabular.RecordBatch(proxy);
+end
+
+function arrowArrays = decompose(T)

Review Comment:
   Maybe we can move `decompose` and `getArrowProxyIds` into a package 
`arrow.tabular.internal` to keep this file a bit smaller?



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