Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions matlab/src/cpp/arrow/matlab/array/proxy/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ namespace arrow::matlab::array::proxy {
Array::Array(const libmexclass::proxy::FunctionArguments& constructor_arguments) {

// Register Proxy methods.
REGISTER_METHOD(Array, ToString);
REGISTER_METHOD(Array, ToMatlab);
REGISTER_METHOD(Array, Length);
REGISTER_METHOD(Array, toString);
REGISTER_METHOD(Array, toMATLAB);
REGISTER_METHOD(Array, length);
}

void Array::ToString(libmexclass::proxy::method::Context& context) {
void Array::toString(libmexclass::proxy::method::Context& context) {
::matlab::data::ArrayFactory factory;

// TODO: handle non-ascii characters
auto str_mda = factory.createScalar(array->ToString());
context.outputs[0] = str_mda;
}

void Array::Length(libmexclass::proxy::method::Context& context) {
void Array::length(libmexclass::proxy::method::Context& context) {
::matlab::data::ArrayFactory factory;
auto length_mda = factory.createScalar(array->length());
context.outputs[0] = length_mda;
Expand Down
6 changes: 3 additions & 3 deletions matlab/src/cpp/arrow/matlab/array/proxy/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class Array : public libmexclass::proxy::Proxy {

protected:

void ToString(libmexclass::proxy::method::Context& context);
void toString(libmexclass::proxy::method::Context& context);

void Length(libmexclass::proxy::method::Context& context);
void length(libmexclass::proxy::method::Context& context);

virtual void ToMatlab(libmexclass::proxy::method::Context& context) = 0;
virtual void toMATLAB(libmexclass::proxy::method::Context& context) = 0;

std::shared_ptr<arrow::Array> array;
};
Expand Down
2 changes: 1 addition & 1 deletion matlab/src/cpp/arrow/matlab/array/proxy/numeric_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class NumericArray : public arrow::matlab::array::proxy::Array {
}

protected:
void ToMatlab(libmexclass::proxy::method::Context& context) override {
void toMATLAB(libmexclass::proxy::method::Context& context) override {
using ArrowArrayType = typename arrow::CTypeTraits<CType>::ArrayType;

const auto num_elements = static_cast<size_t>(array->length());
Expand Down
12 changes: 8 additions & 4 deletions matlab/src/matlab/+arrow/+array/Array.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@
end

function numElements = get.Length(obj)
numElements = obj.Proxy.Length();
numElements = obj.Proxy.length();
end

function matlabArray = toMATLAB(obj)
matlabArray = obj.Proxy.toMATLAB();
end
end

methods (Access = private)
function str = ToString(obj)
str = obj.Proxy.ToString();
function str = toString(obj)
str = obj.Proxy.toString();
end
end

methods (Access=protected)
function displayScalarObject(obj)
disp(obj.ToString());
disp(obj.toString());
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion matlab/src/matlab/+arrow/+array/Float32Array.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
end

function data = single(obj)
data = obj.Proxy.ToMatlab();
data = obj.Proxy.toMATLAB();
end
end
end
2 changes: 1 addition & 1 deletion matlab/src/matlab/+arrow/+array/Float64Array.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
end

function data = double(obj)
data = obj.Proxy.ToMatlab();
data = obj.Proxy.toMATLAB();
end
end
end
6 changes: 6 additions & 0 deletions matlab/test/arrow/array/tFloat32Array.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,11 @@ function ErrorIfComplex(testCase, MakeDeepCopy)
fcn = @() arrow.array.Float32Array(single([10 + 1i, 4]), DeepCopy=MakeDeepCopy);
testCase.verifyError(fcn, "MATLAB:expectedReal");
end

function toMATLAB(testCase, MakeDeepCopy)
A1 = arrow.array.Float32Array(single(100), DeepCopy=MakeDeepCopy);
data = toMATLAB(A1);
testCase.verifyEqual(data, single(100));
end
end
end
6 changes: 6 additions & 0 deletions matlab/test/arrow/array/tFloat64Array.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ function Length(testCase, MakeDeepCopy)
A = arrow.array.Float64Array(1:100, DeepCopy=MakeDeepCopy);
expectedLength = int64(100);
testCase.verifyEqual(A.Length, expectedLength);
end

function toMATLAB(testCase, MakeDeepCopy)
A1 = arrow.array.Float64Array(100, DeepCopy=MakeDeepCopy);
data = toMATLAB(A1);
testCase.verifyEqual(data, 100);
end
end
end