This is an automated email from the ASF dual-hosted git repository.
kevingurney pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 5abdc6e190 GH-37234: [MATLAB] Create an abstract
`arrow.type.TemporalType` class (#37236)
5abdc6e190 is described below
commit 5abdc6e190f8d31ef74869a9269b0e75e993bffe
Author: sgilmore10 <[email protected]>
AuthorDate: Fri Aug 18 09:51:06 2023 -0400
GH-37234: [MATLAB] Create an abstract `arrow.type.TemporalType` class
(#37236)
### Rationale for this change
To simplify the implementation of `Time32Type`, `Time64Type`, `Date32Type`,
and `Date64Type`, it would be helpful to create an abstract
`arrow.type.TemporalType` class that the date and time types can inherit from.
As a first step, we can modify the implementation of `TimestampType` to
inherit from `TemporalType`.
This mimics the class inheritance hierarchy from the C++ libraries.
### What changes are included in this PR?
1. Added a new MATLAB class called `arrow.type.TemporalType`. It inherits
from `arrow.type.FixedWidthType` and defines one read-only property: `TimeUnit`.
2. Modified the MATLAB class `arrow.type.TimestampType` to inherit from
`arrow.type.TemporalType` instead of `arrow.type.FixedWidthType`.
3. Renamed the C++ `proxy::TimestampType` methods `timeUnit()` and
`timeZone()` to `getTimeUnit()` and `getTimeZone()`.
### Are these changes tested?
Yes. The existing tests in `tTimetampType.m` cover these changes.
### Are there any user-facing changes?
No.
### Future Directions
1. Add `arrow.type.Time32Type` (#37231)
2. Add `arrow.type.Time64Type` (#37225)
3. Add `arrow.type.Date32Type` (#37229),
4. Add `arrow.type.Time64Type` (#37230).
5. Add `arrow.array.Time32Array`
6. Add `arrow.array.Time64Array`
7. Add `arrow.array.Date32Array`
8. Add `arrow.array.Date64Array`
* Closes: #37234
Lead-authored-by: Sarah Gilmore <[email protected]>
Co-authored-by: Kevin Gurney <[email protected]>
Signed-off-by: Kevin Gurney <[email protected]>
---
.../cpp/arrow/matlab/type/proxy/timestamp_type.cc | 8 +++---
.../cpp/arrow/matlab/type/proxy/timestamp_type.h | 4 +--
.../+type/{TimestampType.m => TemporalType.m} | 30 +++++++---------------
matlab/src/matlab/+arrow/+type/TimestampType.m | 14 +++-------
4 files changed, 19 insertions(+), 37 deletions(-)
diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.cc
b/matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.cc
index b1d35ee487..9ae5fcde67 100644
--- a/matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.cc
+++ b/matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.cc
@@ -23,8 +23,8 @@
namespace arrow::matlab::type::proxy {
TimestampType::TimestampType(std::shared_ptr<arrow::TimestampType>
timestamp_type) : FixedWidthType(std::move(timestamp_type)) {
- REGISTER_METHOD(TimestampType, timeUnit);
- REGISTER_METHOD(TimestampType, timeZone);
+ REGISTER_METHOD(TimestampType, getTimeUnit);
+ REGISTER_METHOD(TimestampType, getTimeZone);
}
libmexclass::proxy::MakeResult TimestampType::make(const
libmexclass::proxy::FunctionArguments& constructor_arguments) {
@@ -55,7 +55,7 @@ namespace arrow::matlab::type::proxy {
return std::make_shared<TimestampTypeProxy>(std::move(time_type));
}
- void TimestampType::timeZone(libmexclass::proxy::method::Context& context)
{
+ void TimestampType::getTimeZone(libmexclass::proxy::method::Context&
context) {
namespace mda = ::matlab::data;
mda::ArrayFactory factory;
@@ -68,7 +68,7 @@ namespace arrow::matlab::type::proxy {
context.outputs[0] = timezone_mda;
}
- void TimestampType::timeUnit(libmexclass::proxy::method::Context& context)
{
+ void TimestampType::getTimeUnit(libmexclass::proxy::method::Context&
context) {
namespace mda = ::matlab::data;
mda::ArrayFactory factory;
diff --git a/matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.h
b/matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.h
index 71005dc3a9..93a6585311 100644
--- a/matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.h
+++ b/matlab/src/cpp/arrow/matlab/type/proxy/timestamp_type.h
@@ -33,9 +33,9 @@ class TimestampType : public
arrow::matlab::type::proxy::FixedWidthType {
protected:
- void timeZone(libmexclass::proxy::method::Context& context);
+ void getTimeZone(libmexclass::proxy::method::Context& context);
- void timeUnit(libmexclass::proxy::method::Context& context);
+ void getTimeUnit(libmexclass::proxy::method::Context& context);
};
}
diff --git a/matlab/src/matlab/+arrow/+type/TimestampType.m
b/matlab/src/matlab/+arrow/+type/TemporalType.m
similarity index 53%
copy from matlab/src/matlab/+arrow/+type/TimestampType.m
copy to matlab/src/matlab/+arrow/+type/TemporalType.m
index b3d34f31b7..a3d093fb6d 100644
--- a/matlab/src/matlab/+arrow/+type/TimestampType.m
+++ b/matlab/src/matlab/+arrow/+type/TemporalType.m
@@ -1,3 +1,5 @@
+%TEMPORALTYPE Parent class of all temporal types.
+
% 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.
@@ -13,37 +15,23 @@
% implied. See the License for the specific language governing
% permissions and limitations under the License.
-classdef TimestampType < arrow.type.FixedWidthType
-%TIMESTAMPTYPE Type class for timestamp data.
+classdef TemporalType < arrow.type.FixedWidthType
- properties(Dependent, SetAccess=private, GetAccess=public)
- TimeZone
+ properties(Dependent, GetAccess=public, SetAccess=private)
TimeUnit
end
methods
- function obj = TimestampType(proxy)
+ function obj = TemporalType(proxy)
arguments
- proxy(1, 1) libmexclass.proxy.Proxy {validate(proxy,
"arrow.type.proxy.TimestampType")}
+ proxy(1, 1) libmexclass.proxy.Proxy
end
- import arrow.internal.proxy.validate
[email protected](proxy);
end
- function unit = get.TimeUnit(obj)
- val = obj.Proxy.timeUnit();
- unit = arrow.type.TimeUnit(val);
- end
-
- function tz = get.TimeZone(obj)
- tz = obj.Proxy.timeZone();
- end
- end
-
- methods (Access=protected)
- function group = getPropertyGroups(~)
- targets = ["ID" "TimeUnit" "TimeZone"];
- group = matlab.mixin.util.PropertyGroup(targets);
+ function timeUnit = get.TimeUnit(obj)
+ timeUnitValue = obj.Proxy.getTimeUnit();
+ timeUnit = arrow.type.TimeUnit(timeUnitValue);
end
end
end
\ No newline at end of file
diff --git a/matlab/src/matlab/+arrow/+type/TimestampType.m
b/matlab/src/matlab/+arrow/+type/TimestampType.m
index b3d34f31b7..2333818208 100644
--- a/matlab/src/matlab/+arrow/+type/TimestampType.m
+++ b/matlab/src/matlab/+arrow/+type/TimestampType.m
@@ -13,12 +13,11 @@
% implied. See the License for the specific language governing
% permissions and limitations under the License.
-classdef TimestampType < arrow.type.FixedWidthType
+classdef TimestampType < arrow.type.TemporalType
%TIMESTAMPTYPE Type class for timestamp data.
- properties(Dependent, SetAccess=private, GetAccess=public)
+ properties(Dependent, GetAccess=public, SetAccess=private)
TimeZone
- TimeUnit
end
methods
@@ -27,16 +26,11 @@ classdef TimestampType < arrow.type.FixedWidthType
proxy(1, 1) libmexclass.proxy.Proxy {validate(proxy,
"arrow.type.proxy.TimestampType")}
end
import arrow.internal.proxy.validate
- [email protected](proxy);
- end
-
- function unit = get.TimeUnit(obj)
- val = obj.Proxy.timeUnit();
- unit = arrow.type.TimeUnit(val);
+ [email protected](proxy);
end
function tz = get.TimeZone(obj)
- tz = obj.Proxy.timeZone();
+ tz = obj.Proxy.getTimeZone();
end
end