eerhardt commented on code in PR #13279: URL: https://github.com/apache/arrow/pull/13279#discussion_r889599530
########## csharp/src/Apache.Arrow/Arrays/Time64Array.cs: ########## @@ -0,0 +1,172 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time64Array"/> class holds an array of longs, where each value is + /// stored as the number of seconds/ milliseconds (depending on the Time64Type) since midnight. Review Comment: ```suggestion /// stored as the number of microseconds/nanoseconds (depending on the Time64Type) since midnight. ``` ########## csharp/src/Apache.Arrow/Arrays/Time32Array.cs: ########## @@ -0,0 +1,118 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time32Array"/> class holds an array of ints, where each value is Review Comment: ```suggestion /// The <see cref="Time32Array"/> class holds an array of <see cref="Int32" />, where each value is ``` "int" and "long" are C# specific, but the xml doc is for all languages (VB, F#), so we don't use C# specific keywords in xml doc. ########## csharp/src/Apache.Arrow/Arrays/Time64Array.cs: ########## @@ -0,0 +1,172 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time64Array"/> class holds an array of longs, where each value is + /// stored as the number of seconds/ milliseconds (depending on the Time64Type) since midnight. + /// </summary> + public class Time64Array : PrimitiveArray<long> + { + /// <summary> + /// The <see cref="Builder"/> class can be used to fluently build <see cref="Time64Array"/> objects. + /// </summary> + public class Builder : PrimitiveArrayBuilder<long, Time64Array, Builder> + { + protected override Time64Array Build( + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) => + new Time64Array(DataType, valueBuffer, nullBitmapBuffer, length, nullCount, offset); + + protected Time64Type DataType { get; } + + public Builder() + : this(Time64Type.Default) { } + + public Builder(TimeUnit unit) + : this(new Time64Type(unit)) { } + + /// <summary> + /// Construct a new instance of the <see cref="Builder"/> class. + /// </summary> + public Builder(Time64Type type) + : base() + { + DataType = type; + } + } + + public Time64Array( + Time64Type type, + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) + : this(new ArrayData(type, length, nullCount, offset, + new[] { nullBitmapBuffer, valueBuffer })) + { } + + public Time64Array(ArrayData data) + : base(data) + { + data.EnsureDataType(ArrowTypeId.Time64); + } + + public override void Accept(IArrowArrayVisitor visitor) => Accept(this, visitor); + + Review Comment: ```suggestion ``` extra blank space. ########## csharp/src/Apache.Arrow/Arrays/Time32Array.cs: ########## @@ -0,0 +1,118 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time32Array"/> class holds an array of ints, where each value is + /// stored as the number of seconds/ milliseconds (depending on the Time32Type) since midnight. + /// </summary> + public class Time32Array : PrimitiveArray<int> + { + /// <summary> + /// The <see cref="Builder"/> class can be used to fluently build <see cref="Time32Array"/> objects. + /// </summary> + public class Builder : PrimitiveArrayBuilder<int, Time32Array, Builder> + { + protected override Time32Array Build( + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) => + new Time32Array(DataType, valueBuffer, nullBitmapBuffer, length, nullCount, offset); + + protected Time32Type DataType { get; } + + public Builder() + : this(Time32Type.Default) { } + + public Builder(TimeUnit unit) + : this(new Time32Type(unit)) { } + + /// <summary> + /// Construct a new instance of the <see cref="Builder"/> class. + /// </summary> + public Builder(Time32Type type) + : base() + { + DataType = type; + } + } + + public Time32Array( + Time32Type type, + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) + : this(new ArrayData(type, length, nullCount, offset, + new[] { nullBitmapBuffer, valueBuffer })) + { } + + public Time32Array(ArrayData data) + : base(data) + { + data.EnsureDataType(ArrowTypeId.Time32); + } + + public override void Accept(IArrowArrayVisitor visitor) => Accept(this, visitor); + + + /// <summary> + /// Get the time at the specified index as seconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns an int, or <c>null</c> if there is no object at that index. + /// </returns> + public int? GetSeconds(int index) + { + int? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time32Type) Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value, + TimeUnit.Millisecond => value / 1_000, + _ => throw new InvalidDataException($"Unsupported time unit for Time32Type: {unit}") + }; + } + + /// <summary> + /// Get the time at the specified index as milliseconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns an int, or <c>null</c> if there is no object at that index. + /// </returns> + public int? GetMilliSeconds(int index) Review Comment: One thought I have is that we could add some helper methods for .net 6+ that gets a `TimeOnly` value at each index. This doesn't need to be done in this PR, but I just wanted to get your thoughts on it. ########## csharp/src/Apache.Arrow/Arrays/Time64Array.cs: ########## @@ -0,0 +1,172 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time64Array"/> class holds an array of longs, where each value is + /// stored as the number of seconds/ milliseconds (depending on the Time64Type) since midnight. + /// </summary> + public class Time64Array : PrimitiveArray<long> + { + /// <summary> + /// The <see cref="Builder"/> class can be used to fluently build <see cref="Time64Array"/> objects. + /// </summary> + public class Builder : PrimitiveArrayBuilder<long, Time64Array, Builder> + { + protected override Time64Array Build( + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) => + new Time64Array(DataType, valueBuffer, nullBitmapBuffer, length, nullCount, offset); + + protected Time64Type DataType { get; } + + public Builder() + : this(Time64Type.Default) { } + + public Builder(TimeUnit unit) + : this(new Time64Type(unit)) { } + + /// <summary> + /// Construct a new instance of the <see cref="Builder"/> class. + /// </summary> + public Builder(Time64Type type) + : base() + { + DataType = type; + } + } + + public Time64Array( + Time64Type type, + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) + : this(new ArrayData(type, length, nullCount, offset, + new[] { nullBitmapBuffer, valueBuffer })) + { } + + public Time64Array(ArrayData data) + : base(data) + { + data.EnsureDataType(ArrowTypeId.Time64); + } + + public override void Accept(IArrowArrayVisitor visitor) => Accept(this, visitor); + + + /// <summary> + /// Get the time at the specified index as seconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type) Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value, + TimeUnit.Millisecond => value / 1_000, + TimeUnit.Microsecond => value / 1_000_000, + TimeUnit.Nanosecond => value / 1_000_000_000, + _ => throw new InvalidDataException($"Unsupported time unit for Time64Type: {unit}") + }; + } + + /// <summary> + /// Get the time at the specified index as milliseconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetMilliSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type)Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value * 1_000, + TimeUnit.Millisecond => value, + TimeUnit.Microsecond => value / 1_000, + TimeUnit.Nanosecond => value / 1_000_000, + _ => throw new InvalidDataException($"Unsupported time unit for Time64Type: {unit}") + }; + } + + /// <summary> + /// Get the time at the specified index as microseconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetMicroSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type)Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value * 1_000_000, + TimeUnit.Millisecond => value * 1_000, Review Comment: ```suggestion ``` According to https://github.com/apache/arrow/blob/25e0dd488ab60417f8f453f648e6ecfeb058f01e/format/Schema.fbs#L218-L220 Time64 only supports micro and nano seconds ########## csharp/src/Apache.Arrow/Arrays/Time64Array.cs: ########## @@ -0,0 +1,172 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time64Array"/> class holds an array of longs, where each value is + /// stored as the number of seconds/ milliseconds (depending on the Time64Type) since midnight. + /// </summary> + public class Time64Array : PrimitiveArray<long> + { + /// <summary> + /// The <see cref="Builder"/> class can be used to fluently build <see cref="Time64Array"/> objects. + /// </summary> + public class Builder : PrimitiveArrayBuilder<long, Time64Array, Builder> + { + protected override Time64Array Build( + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) => + new Time64Array(DataType, valueBuffer, nullBitmapBuffer, length, nullCount, offset); + + protected Time64Type DataType { get; } + + public Builder() + : this(Time64Type.Default) { } + + public Builder(TimeUnit unit) + : this(new Time64Type(unit)) { } + + /// <summary> + /// Construct a new instance of the <see cref="Builder"/> class. + /// </summary> + public Builder(Time64Type type) + : base() + { + DataType = type; + } + } + + public Time64Array( + Time64Type type, + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) + : this(new ArrayData(type, length, nullCount, offset, + new[] { nullBitmapBuffer, valueBuffer })) + { } + + public Time64Array(ArrayData data) + : base(data) + { + data.EnsureDataType(ArrowTypeId.Time64); + } + + public override void Accept(IArrowArrayVisitor visitor) => Accept(this, visitor); + + + /// <summary> + /// Get the time at the specified index as seconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type) Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value, + TimeUnit.Millisecond => value / 1_000, + TimeUnit.Microsecond => value / 1_000_000, + TimeUnit.Nanosecond => value / 1_000_000_000, + _ => throw new InvalidDataException($"Unsupported time unit for Time64Type: {unit}") + }; + } + + /// <summary> + /// Get the time at the specified index as milliseconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetMilliSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type)Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value * 1_000, + TimeUnit.Millisecond => value, + TimeUnit.Microsecond => value / 1_000, + TimeUnit.Nanosecond => value / 1_000_000, + _ => throw new InvalidDataException($"Unsupported time unit for Time64Type: {unit}") + }; + } + + /// <summary> + /// Get the time at the specified index as microseconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> Review Comment: ```suggestion /// <param name="index">Index at which to get the time.</param> ``` ########## csharp/src/Apache.Arrow/Arrays/Time32Array.cs: ########## @@ -0,0 +1,118 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time32Array"/> class holds an array of ints, where each value is + /// stored as the number of seconds/ milliseconds (depending on the Time32Type) since midnight. + /// </summary> + public class Time32Array : PrimitiveArray<int> + { + /// <summary> + /// The <see cref="Builder"/> class can be used to fluently build <see cref="Time32Array"/> objects. + /// </summary> + public class Builder : PrimitiveArrayBuilder<int, Time32Array, Builder> + { + protected override Time32Array Build( + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) => + new Time32Array(DataType, valueBuffer, nullBitmapBuffer, length, nullCount, offset); + + protected Time32Type DataType { get; } + + public Builder() + : this(Time32Type.Default) { } + + public Builder(TimeUnit unit) + : this(new Time32Type(unit)) { } + + /// <summary> + /// Construct a new instance of the <see cref="Builder"/> class. + /// </summary> + public Builder(Time32Type type) + : base() + { + DataType = type; + } + } + + public Time32Array( + Time32Type type, + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) + : this(new ArrayData(type, length, nullCount, offset, + new[] { nullBitmapBuffer, valueBuffer })) + { } + + public Time32Array(ArrayData data) + : base(data) + { + data.EnsureDataType(ArrowTypeId.Time32); + } + + public override void Accept(IArrowArrayVisitor visitor) => Accept(this, visitor); + + Review Comment: ```suggestion ``` extra blank line ########## csharp/src/Apache.Arrow/Arrays/Time64Array.cs: ########## @@ -0,0 +1,172 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time64Array"/> class holds an array of longs, where each value is + /// stored as the number of seconds/ milliseconds (depending on the Time64Type) since midnight. + /// </summary> + public class Time64Array : PrimitiveArray<long> + { + /// <summary> + /// The <see cref="Builder"/> class can be used to fluently build <see cref="Time64Array"/> objects. + /// </summary> + public class Builder : PrimitiveArrayBuilder<long, Time64Array, Builder> + { + protected override Time64Array Build( + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) => + new Time64Array(DataType, valueBuffer, nullBitmapBuffer, length, nullCount, offset); + + protected Time64Type DataType { get; } + + public Builder() + : this(Time64Type.Default) { } + + public Builder(TimeUnit unit) + : this(new Time64Type(unit)) { } + + /// <summary> + /// Construct a new instance of the <see cref="Builder"/> class. + /// </summary> + public Builder(Time64Type type) + : base() + { + DataType = type; + } + } + + public Time64Array( + Time64Type type, + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) + : this(new ArrayData(type, length, nullCount, offset, + new[] { nullBitmapBuffer, valueBuffer })) + { } + + public Time64Array(ArrayData data) + : base(data) + { + data.EnsureDataType(ArrowTypeId.Time64); + } + + public override void Accept(IArrowArrayVisitor visitor) => Accept(this, visitor); + + + /// <summary> + /// Get the time at the specified index as seconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> Review Comment: ```suggestion /// <param name="index">Index at which to get the time.</param> ``` ########## csharp/src/Apache.Arrow/Arrays/Time64Array.cs: ########## @@ -0,0 +1,172 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time64Array"/> class holds an array of longs, where each value is + /// stored as the number of seconds/ milliseconds (depending on the Time64Type) since midnight. + /// </summary> + public class Time64Array : PrimitiveArray<long> + { + /// <summary> + /// The <see cref="Builder"/> class can be used to fluently build <see cref="Time64Array"/> objects. + /// </summary> + public class Builder : PrimitiveArrayBuilder<long, Time64Array, Builder> + { + protected override Time64Array Build( + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) => + new Time64Array(DataType, valueBuffer, nullBitmapBuffer, length, nullCount, offset); + + protected Time64Type DataType { get; } + + public Builder() + : this(Time64Type.Default) { } + + public Builder(TimeUnit unit) + : this(new Time64Type(unit)) { } + + /// <summary> + /// Construct a new instance of the <see cref="Builder"/> class. + /// </summary> + public Builder(Time64Type type) + : base() + { + DataType = type; + } + } + + public Time64Array( + Time64Type type, + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + int length, int nullCount, int offset) + : this(new ArrayData(type, length, nullCount, offset, + new[] { nullBitmapBuffer, valueBuffer })) + { } + + public Time64Array(ArrayData data) + : base(data) + { + data.EnsureDataType(ArrowTypeId.Time64); + } + + public override void Accept(IArrowArrayVisitor visitor) => Accept(this, visitor); + + + /// <summary> + /// Get the time at the specified index as seconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type) Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value, + TimeUnit.Millisecond => value / 1_000, + TimeUnit.Microsecond => value / 1_000_000, + TimeUnit.Nanosecond => value / 1_000_000_000, + _ => throw new InvalidDataException($"Unsupported time unit for Time64Type: {unit}") + }; + } + + /// <summary> + /// Get the time at the specified index as milliseconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetMilliSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type)Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value * 1_000, + TimeUnit.Millisecond => value, + TimeUnit.Microsecond => value / 1_000, + TimeUnit.Nanosecond => value / 1_000_000, + _ => throw new InvalidDataException($"Unsupported time unit for Time64Type: {unit}") + }; + } + + /// <summary> + /// Get the time at the specified index as microseconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetMicroSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type)Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value * 1_000_000, + TimeUnit.Millisecond => value * 1_000, + TimeUnit.Microsecond => value, + TimeUnit.Nanosecond => value / 1_000, + _ => throw new InvalidDataException($"Unsupported time unit for Time64Type: {unit}") + }; + } + + /// <summary> + /// Get the time at the specified index as nanoseconds + /// </summary> + /// <param name="index">Index at which to get the date.</param> + /// <returns>Returns a long, or <c>null</c> if there is no object at that index. + /// </returns> + public long? GetNanoSeconds(int index) + { + long? value = GetValue(index); + if (value == null) + { + return null; + } + + var unit = ((Time64Type)Data.DataType).Unit; + return unit switch + { + TimeUnit.Second => value * 1_000_000_000, + TimeUnit.Millisecond => value * 1_000_000, Review Comment: ```suggestion ``` According to https://github.com/apache/arrow/blob/25e0dd488ab60417f8f453f648e6ecfeb058f01e/format/Schema.fbs#L218-L220 Time64 only supports micro and nano seconds ########## csharp/src/Apache.Arrow/Arrays/Time64Array.cs: ########## @@ -0,0 +1,172 @@ +// Licensed to the Apache Software Foundation (ASF) under one or moreDate32Array +// 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. + +using Apache.Arrow.Types; +using System.IO; + +namespace Apache.Arrow +{ + /// <summary> + /// The <see cref="Time64Array"/> class holds an array of longs, where each value is Review Comment: ```suggestion /// The <see cref="Time64Array"/> class holds an array of <see cref="Int64" />, where each value is ``` -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org