Skip to content

Commit

Permalink
Move private local functions in arrow.recordbatch to an internal package
Browse files Browse the repository at this point in the history
  • Loading branch information
sgilmore10 committed Aug 4, 2023
1 parent 76753cf commit ec13989
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 28 deletions.
27 changes: 27 additions & 0 deletions matlab/src/matlab/+arrow/+tabular/+internal/decompose.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
%DECOMPOSE Decompose the input MATLAB table input a cell array of
% equivalent arrow.array.Array instances.

% 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 arrowArrays = decompose(T)
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
26 changes: 26 additions & 0 deletions matlab/src/matlab/+arrow/+tabular/+internal/getArrayProxyIDs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
%GETARRAYPROXYIDS Extract the Proxy IDs underlying a cell array of
% arrow.array.Array instances.

% 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 proxyIDs = getArrayProxyIDs(arrowArrays)
proxyIDs = zeros(1, numel(arrowArrays), "uint64");

% Convert each MATLAB array into a corresponding
% arrow.array.Array.
for ii = 1:numel(arrowArrays)
proxyIDs(ii) = arrowArrays{ii}.Proxy.ID;
end
end
30 changes: 2 additions & 28 deletions matlab/src/matlab/+arrow/recordbatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
T table
end

arrowArrays = decompose(T);
arrayProxyIDs = getArrowProxyIDs(arrowArrays);
arrowArrays = arrow.tabular.internal.decompose(T);
arrayProxyIDs = arrow.tabular.internal.getArrayProxyIDs(arrowArrays);

columnNames = string(T.Properties.VariableNames);
args = struct(ArrayProxyIDs=arrayProxyIDs, ColumnNames=columnNames);
Expand All @@ -29,29 +29,3 @@

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)
% Extract the Proxy IDs underlying a cell array of
% arrow.array.Array instances.
proxyIDs = zeros(1, numel(arrowArrays), "uint64");

% Convert each MATLAB array into a corresponding
% arrow.array.Array.
for ii = 1:numel(arrowArrays)
proxyIDs(ii) = arrowArrays{ii}.Proxy.ID;
end
end

0 comments on commit ec13989

Please sign in to comment.