X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Farrow%2Fcsharp%2Fsrc%2FApache.Arrow%2FArrays%2FDateArrayBuilder.cs;fp=ceph%2Fsrc%2Farrow%2Fcsharp%2Fsrc%2FApache.Arrow%2FArrays%2FDateArrayBuilder.cs;h=4e69f6fe3e7e1536b1d90f044a413d569e7e61ec;hb=1d09f67e50a235260a0812cca2fb044674d88150;hp=0000000000000000000000000000000000000000;hpb=a653f20b2fb9a1c0c3e465a23074d91f26031b5d;p=ceph.git
diff --git a/ceph/src/arrow/csharp/src/Apache.Arrow/Arrays/DateArrayBuilder.cs b/ceph/src/arrow/csharp/src/Apache.Arrow/Arrays/DateArrayBuilder.cs
new file mode 100644
index 000000000..4e69f6fe3
--- /dev/null
+++ b/ceph/src/arrow/csharp/src/Apache.Arrow/Arrays/DateArrayBuilder.cs
@@ -0,0 +1,209 @@
+// 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.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Apache.Arrow
+{
+ ///
+ /// The class is an abstract array builder that can
+ /// accept dates in the form of or and convert to some
+ /// underlying date representation.
+ ///
+ public abstract class DateArrayBuilder :
+ DelegatingArrayBuilder,
+ IArrowArrayBuilder,
+ IArrowArrayBuilder
+ where TArray : IArrowArray
+ where TBuilder : class, IArrowArrayBuilder
+ {
+ ///
+ /// Construct a new instance of the class.
+ ///
+ /// Inner builder that will produce arrays of type .
+ ///
+ protected DateArrayBuilder(IArrowArrayBuilder> innerBuilder)
+ : base(innerBuilder)
+ { }
+
+ ///
+ /// Append a date in the form of a object to the array.
+ ///
+ ///
+ /// The value of on the input does not have any effect on the behaviour of this
+ /// method.
+ ///
+ /// Date to add.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder Append(DateTime value)
+ {
+ InnerBuilder.Append(Convert(value));
+ return this as TBuilder;
+ }
+
+ ///
+ /// Append a date from a object to the array.
+ ///
+ ///
+ /// Note that to convert the supplied parameter to a date, it is first converted to
+ /// UTC and the date then taken from the UTC date/time. Depending on the value of its
+ /// property, this may not necessarily be the same as the date obtained by
+ /// calling its property.
+ ///
+ /// Date to add.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder Append(DateTimeOffset value)
+ {
+ InnerBuilder.Append(Convert(value));
+ return this as TBuilder;
+ }
+
+ ///
+ /// Append a span of dates in the form of objects to the array.
+ ///
+ ///
+ /// The value of on any of the inputs does not have any effect on the behaviour of
+ /// this method.
+ ///
+ /// Span of dates to add.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder Append(ReadOnlySpan span)
+ {
+ InnerBuilder.Reserve(span.Length);
+ foreach (var item in span)
+ {
+ InnerBuilder.Append(Convert(item));
+ }
+
+ return this as TBuilder;
+ }
+
+ ///
+ /// Append a span of dates in the form of objects to the array.
+ ///
+ ///
+ /// Note that to convert the objects in the parameter to
+ /// dates, they are first converted to UTC and the date then taken from the UTC date/times. Depending on the
+ /// value of each property, this may not necessarily be the same as the
+ /// date obtained by calling the property.
+ ///
+ /// Span of dates to add.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder Append(ReadOnlySpan span)
+ {
+ InnerBuilder.Reserve(span.Length);
+ foreach (var item in span)
+ {
+ InnerBuilder.Append(Convert(item));
+ }
+
+ return this as TBuilder;
+ }
+
+ ///
+ /// Append a null date to the array.
+ ///
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder AppendNull()
+ {
+ InnerBuilder.AppendNull();
+ return this as TBuilder;
+ }
+
+ ///
+ /// Append a collection of dates in the form of objects to the array.
+ ///
+ ///
+ /// The value of on any of the inputs does not have any effect on the behaviour of
+ /// this method.
+ ///
+ /// Collection of dates to add.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder AppendRange(IEnumerable values)
+ {
+ InnerBuilder.AppendRange(values.Select(Convert));
+ return this as TBuilder;
+ }
+
+ ///
+ /// Append a collection of dates in the form of objects to the array.
+ ///
+ ///
+ /// Note that to convert the objects in the parameter to
+ /// dates, they are first converted to UTC and the date then taken from the UTC date/times. Depending on the
+ /// value of each property, this may not necessarily be the same as the
+ /// date obtained by calling the property.
+ ///
+ /// Collection of dates to add.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder AppendRange(IEnumerable values)
+ {
+ InnerBuilder.AppendRange(values.Select(Convert));
+ return this as TBuilder;
+ }
+
+ ///
+ /// Set the value of a date in the form of a object at the specified index.
+ ///
+ ///
+ /// The value of on the input does not have any effect on the behaviour of this
+ /// method.
+ ///
+ /// Index at which to set value.
+ /// Date to set.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder Set(int index, DateTime value)
+ {
+ InnerBuilder.Set(index, Convert(value));
+ return this as TBuilder;
+ }
+
+ ///
+ /// Set the value of a date in the form of a object at the specified index.
+ ///
+ ///
+ /// Note that to convert the supplied parameter to a date, it is first converted to
+ /// UTC and the date then taken from the UTC date/time. Depending on the value of its
+ /// property, this may not necessarily be the same as the date obtained by
+ /// calling its property.
+ ///
+ /// Index at which to set value.
+ /// Date to set.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder Set(int index, DateTimeOffset value)
+ {
+ InnerBuilder.Set(index, Convert(value));
+ return this as TBuilder;
+ }
+
+ ///
+ /// Swap the values of the dates at the specified indices.
+ ///
+ /// First index.
+ /// Second index.
+ /// Returns the builder (for fluent-style composition).
+ public TBuilder Swap(int i, int j)
+ {
+ InnerBuilder.Swap(i, j);
+ return this as TBuilder;
+ }
+
+ protected abstract TUnderlying Convert(DateTime dateTime);
+
+ protected abstract TUnderlying Convert(DateTimeOffset dateTimeOffset);
+ }
+}