From 290d33a6de55a6bfd365208d92b3812f7917a603 Mon Sep 17 00:00:00 2001 From: kronic Date: Sat, 4 Jul 2026 20:48:56 +0300 Subject: [PATCH 1/4] Update DurationType.cs --- src/Apache.Arrow/Types/DurationType.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Apache.Arrow/Types/DurationType.cs b/src/Apache.Arrow/Types/DurationType.cs index 7e937a6e..ee86f693 100644 --- a/src/Apache.Arrow/Types/DurationType.cs +++ b/src/Apache.Arrow/Types/DurationType.cs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; + namespace Apache.Arrow.Types { public sealed class DurationType : TimeBasedType @@ -21,7 +23,6 @@ public sealed class DurationType : TimeBasedType public static readonly DurationType Millisecond = new DurationType(TimeUnit.Millisecond); public static readonly DurationType Microsecond = new DurationType(TimeUnit.Microsecond); public static readonly DurationType Nanosecond = new DurationType(TimeUnit.Nanosecond); - private static readonly DurationType[] _types = new DurationType[] { Second, Millisecond, Microsecond, Nanosecond }; private DurationType(TimeUnit unit) : base(unit) @@ -34,7 +35,14 @@ private DurationType(TimeUnit unit) public static DurationType FromTimeUnit(TimeUnit unit) { - return _types[(int)unit]; + switch (unit) + { + case TimeUnit.Second: return Second; + case TimeUnit.Millisecond: return Millisecond; + case TimeUnit.Microsecond: return Microsecond; + case TimeUnit.Nanosecond: return Nanosecond; + default: throw new ArgumentOutOfRangeException(nameof(unit), unit); + } } public override void Accept(IArrowTypeVisitor visitor) => Accept(this, visitor); From cbce7ab4694689cf56497d30a1bba7879cdde09f Mon Sep 17 00:00:00 2001 From: kronic Date: Sun, 5 Jul 2026 06:52:56 +0300 Subject: [PATCH 2/4] Update DurationType.cs --- src/Apache.Arrow/Types/DurationType.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Apache.Arrow/Types/DurationType.cs b/src/Apache.Arrow/Types/DurationType.cs index ee86f693..9a725fb7 100644 --- a/src/Apache.Arrow/Types/DurationType.cs +++ b/src/Apache.Arrow/Types/DurationType.cs @@ -33,17 +33,14 @@ private DurationType(TimeUnit unit) public override string Name => "duration"; public override int BitWidth => 64; - public static DurationType FromTimeUnit(TimeUnit unit) + public static DurationType FromTimeUnit(TimeUnit unit) => unit switch { - switch (unit) - { - case TimeUnit.Second: return Second; - case TimeUnit.Millisecond: return Millisecond; - case TimeUnit.Microsecond: return Microsecond; - case TimeUnit.Nanosecond: return Nanosecond; - default: throw new ArgumentOutOfRangeException(nameof(unit), unit); - } - } + TimeUnit.Second => Second, + TimeUnit.Millisecond => Millisecond, + TimeUnit.Microsecond => Microsecond, + TimeUnit.Nanosecond => Nanosecond, + _ => throw new ArgumentOutOfRangeException(nameof(unit), unit, @"Unsupported time unit.") + }; public override void Accept(IArrowTypeVisitor visitor) => Accept(this, visitor); } From e3e606692c3c2b7884c876a661c76e9da10a5bb1 Mon Sep 17 00:00:00 2001 From: kronic Date: Sun, 5 Jul 2026 06:53:42 +0300 Subject: [PATCH 3/4] Update IntervalType.cs --- src/Apache.Arrow/Types/IntervalType.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Apache.Arrow/Types/IntervalType.cs b/src/Apache.Arrow/Types/IntervalType.cs index b8e1fdea..14bf61f1 100644 --- a/src/Apache.Arrow/Types/IntervalType.cs +++ b/src/Apache.Arrow/Types/IntervalType.cs @@ -22,7 +22,6 @@ public sealed class IntervalType : FixedWidthType public static readonly IntervalType YearMonth = new IntervalType(IntervalUnit.YearMonth); public static readonly IntervalType DayTime = new IntervalType(IntervalUnit.DayTime); public static readonly IntervalType MonthDayNanosecond = new IntervalType(IntervalUnit.MonthDayNanosecond); - private static readonly IntervalType[] _types = new IntervalType[] { YearMonth, DayTime, MonthDayNanosecond }; public override ArrowTypeId TypeId => ArrowTypeId.Interval; public override string Name => "interval"; @@ -43,9 +42,12 @@ public IntervalType(IntervalUnit unit = IntervalUnit.YearMonth) public override void Accept(IArrowTypeVisitor visitor) => Accept(this, visitor); - public static IntervalType FromIntervalUnit(IntervalUnit unit) + public static IntervalType FromIntervalUnit(IntervalUnit unit) => unit switch { - return _types[(int)unit]; - } + IntervalUnit.YearMonth => YearMonth, + IntervalUnit.DayTime => DayTime, + IntervalUnit.MonthDayNanosecond => MonthDayNanosecond, + _ => throw new ArgumentOutOfRangeException(nameof(unit), unit, @"Unsupported interval unit") + }; } } From 7945362d20e4eff0e004b64cba15cb79eff16fba Mon Sep 17 00:00:00 2001 From: kronic Date: Sun, 5 Jul 2026 06:54:13 +0300 Subject: [PATCH 4/4] Update TimeType.cs --- src/Apache.Arrow/Types/TimeType.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Apache.Arrow/Types/TimeType.cs b/src/Apache.Arrow/Types/TimeType.cs index b317df26..2ca612cc 100644 --- a/src/Apache.Arrow/Types/TimeType.cs +++ b/src/Apache.Arrow/Types/TimeType.cs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; + namespace Apache.Arrow.Types { public abstract class TimeType : TimeBasedType @@ -21,16 +23,19 @@ public abstract class TimeType : TimeBasedType public static readonly Time32Type Millisecond = new Time32Type(TimeUnit.Millisecond); public static readonly Time64Type Microsecond = new Time64Type(TimeUnit.Microsecond); public static readonly Time64Type Nanosecond = new Time64Type(TimeUnit.Nanosecond); - private static readonly TimeType[] _types = new TimeType[] { Second, Millisecond, Microsecond, Nanosecond }; protected TimeType(TimeUnit unit) : base(unit) { } - public static TimeType FromTimeUnit(TimeUnit unit) + public static TimeType FromTimeUnit(TimeUnit unit) => unit switch { - return _types[(int)unit]; - } + TimeUnit.Second => Second, + TimeUnit.Millisecond => Millisecond, + TimeUnit.Microsecond => Microsecond, + TimeUnit.Nanosecond => Nanosecond, + _ => throw new ArgumentOutOfRangeException(nameof(unit), unit, @"Unsupported time unit") + }; } }