diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a433287e..da663694 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,3 +35,10 @@ repos: rm -f apache-arrow-dotnet.tar.gz" always_run: true pass_filenames: false + - id: format + name: Format + language: system + entry: | + dotnet format --exclude src/Apache.Arrow/Flatbuf/FlatBuffers/ + always_run: true + pass_filenames: false diff --git a/src/Apache.Arrow.Compression/Lz4CompressionCodec.cs b/src/Apache.Arrow.Compression/Lz4CompressionCodec.cs index ec48d899..972b2a31 100644 --- a/src/Apache.Arrow.Compression/Lz4CompressionCodec.cs +++ b/src/Apache.Arrow.Compression/Lz4CompressionCodec.cs @@ -33,7 +33,7 @@ public Lz4CompressionCodec(int? compressionLevel = null) { _settings = new LZ4EncoderSettings { - CompressionLevel = (LZ4Level) compressionLevel + CompressionLevel = (LZ4Level)compressionLevel }; } else diff --git a/src/Apache.Arrow.Flight.Sql/DoPutResult.cs b/src/Apache.Arrow.Flight.Sql/DoPutResult.cs index 357c7a2b..6e20c401 100644 --- a/src/Apache.Arrow.Flight.Sql/DoPutResult.cs +++ b/src/Apache.Arrow.Flight.Sql/DoPutResult.cs @@ -30,7 +30,7 @@ public DoPutResult(FlightClientRecordBatchStreamWriter writer, IAsyncStreamReade Writer = writer; Reader = reader; } - + /// /// Reads the metadata asynchronously from the reader. /// @@ -43,7 +43,7 @@ public DoPutResult(FlightClientRecordBatchStreamWriter writer, IAsyncStreamReade } throw new RpcException(new Status(StatusCode.Internal, "No metadata available in the response stream.")); } - + /// /// Completes the writer by signaling the end of the writing process. /// diff --git a/src/Apache.Arrow.Flight.Sql/FlightCallOptions.cs b/src/Apache.Arrow.Flight.Sql/FlightCallOptions.cs index 17541b26..f4fe538d 100644 --- a/src/Apache.Arrow.Flight.Sql/FlightCallOptions.cs +++ b/src/Apache.Arrow.Flight.Sql/FlightCallOptions.cs @@ -26,7 +26,7 @@ public FlightCallOptions() { Timeout = TimeSpan.FromSeconds(-1); } - + // Implement any necessary options for RPC calls public Metadata Headers { get; set; } = new(); diff --git a/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs b/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs index a0936eb7..81d48dd4 100644 --- a/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs +++ b/src/Apache.Arrow.Flight.Sql/FlightExtensions.cs @@ -38,4 +38,4 @@ public static int ExtractRowCount(this RecordBatch batch) return length; } -} \ No newline at end of file +} diff --git a/src/Apache.Arrow.Flight.Sql/FlightSqlServer.cs b/src/Apache.Arrow.Flight.Sql/FlightSqlServer.cs index cbccc9da..f2862996 100644 --- a/src/Apache.Arrow.Flight.Sql/FlightSqlServer.cs +++ b/src/Apache.Arrow.Flight.Sql/FlightSqlServer.cs @@ -30,9 +30,9 @@ namespace Apache.Arrow.Flight.Sql; public abstract class FlightSqlServer : FlightServer { private ILogger? Logger { get; } - public static readonly Schema CatalogSchema = new(new List {new("catalog_name", StringType.Default, false)}, null); - public static readonly Schema TableTypesSchema = new(new List {new("table_type", StringType.Default, false)}, null); - public static readonly Schema DbSchemaFlightSchema = new(new List {new("catalog_name", StringType.Default, true), new("db_schema_name", StringType.Default, false)}, null); + public static readonly Schema CatalogSchema = new(new List { new("catalog_name", StringType.Default, false) }, null); + public static readonly Schema TableTypesSchema = new(new List { new("table_type", StringType.Default, false) }, null); + public static readonly Schema DbSchemaFlightSchema = new(new List { new("catalog_name", StringType.Default, true), new("db_schema_name", StringType.Default, false) }, null); public static readonly Schema PrimaryKeysSchema = new(new List { diff --git a/src/Apache.Arrow.Flight.Sql/PreparedStatement.cs b/src/Apache.Arrow.Flight.Sql/PreparedStatement.cs index 0c49d039..b7dd2459 100644 --- a/src/Apache.Arrow.Flight.Sql/PreparedStatement.cs +++ b/src/Apache.Arrow.Flight.Sql/PreparedStatement.cs @@ -230,10 +230,10 @@ public async Task ExecuteAsync(FlightCallOptions? options = default, { PreparedStatementHandle = ByteString.CopyFrom(_handle, Encoding.UTF8), }; - + var descriptor = FlightDescriptor.CreateCommandDescriptor(command.PackAndSerialize()); cancellationToken.ThrowIfCancellationRequested(); - + if (_recordsBatch != null) { await BindParametersAsync(descriptor, _recordsBatch, options, cancellationToken).ConfigureAwait(false); @@ -286,7 +286,7 @@ public async Task ExecuteUpdateAsync( { throw new ArgumentNullException(nameof(parameterBatch), "Parameter batch cannot be null."); } - + var command = new CommandPreparedStatementQuery { PreparedStatementHandle = ByteString.CopyFrom(_handle, Encoding.UTF8), diff --git a/src/Apache.Arrow.Flight.Sql/SchemaExtensions.cs b/src/Apache.Arrow.Flight.Sql/SchemaExtensions.cs index e7347362..6519881d 100644 --- a/src/Apache.Arrow.Flight.Sql/SchemaExtensions.cs +++ b/src/Apache.Arrow.Flight.Sql/SchemaExtensions.cs @@ -35,7 +35,7 @@ public static Schema DeserializeSchema(ReadOnlyMemory serializedSchema) using var reader = new ArrowStreamReader(serializedSchema); return reader.Schema; } - + /// /// Serializes the provided schema to a byte array. /// @@ -43,8 +43,8 @@ public static byte[] SerializeSchema(Schema schema) { using var memoryStream = new MemoryStream(); using var writer = new ArrowStreamWriter(memoryStream, schema); - writer.WriteStart(); + writer.WriteStart(); writer.WriteEnd(); return memoryStream.ToArray(); } -} \ No newline at end of file +} diff --git a/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamReader.cs b/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamReader.cs index 73094338..65eb6b65 100644 --- a/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamReader.cs +++ b/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamReader.cs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Flight.Protocol; using Apache.Arrow.Flight.Internal; +using Apache.Arrow.Flight.Protocol; using Grpc.Core; namespace Apache.Arrow.Flight.Client diff --git a/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamWriter.cs b/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamWriter.cs index e5fa30c9..daf6a004 100644 --- a/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamWriter.cs +++ b/src/Apache.Arrow.Flight/Client/FlightClientRecordBatchStreamWriter.cs @@ -17,8 +17,8 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -using Apache.Arrow.Flight.Protocol; using Apache.Arrow.Flight.Internal; +using Apache.Arrow.Flight.Protocol; using Grpc.Core; namespace Apache.Arrow.Flight.Client diff --git a/src/Apache.Arrow.Flight/Client/FlightRecordBatchExchangeCall.cs b/src/Apache.Arrow.Flight/Client/FlightRecordBatchExchangeCall.cs index 76f0b17e..13059130 100644 --- a/src/Apache.Arrow.Flight/Client/FlightRecordBatchExchangeCall.cs +++ b/src/Apache.Arrow.Flight/Client/FlightRecordBatchExchangeCall.cs @@ -14,8 +14,8 @@ // limitations under the License. using System; -using Grpc.Core; using System.Threading.Tasks; +using Grpc.Core; namespace Apache.Arrow.Flight.Client { diff --git a/src/Apache.Arrow.Flight/Extensions/FlightInfoExtensions.cs b/src/Apache.Arrow.Flight/Extensions/FlightInfoExtensions.cs index 706e092a..3b899635 100644 --- a/src/Apache.Arrow.Flight/Extensions/FlightInfoExtensions.cs +++ b/src/Apache.Arrow.Flight/Extensions/FlightInfoExtensions.cs @@ -21,7 +21,7 @@ namespace Apache.Arrow.Flight.Extensions public static class FlightInfoExtensions { public static ByteString ToByteString(this FlightInfo flightInfo) - { + { return flightInfo.ToProtocol().ToByteString(); } } diff --git a/src/Apache.Arrow.Flight/FlightActionType.cs b/src/Apache.Arrow.Flight/FlightActionType.cs index 8df89394..c52c37c6 100644 --- a/src/Apache.Arrow.Flight/FlightActionType.cs +++ b/src/Apache.Arrow.Flight/FlightActionType.cs @@ -46,7 +46,7 @@ internal Protocol.ActionType ToProtocol() public override bool Equals(object obj) { - if(obj is FlightActionType other) + if (obj is FlightActionType other) { return Equals(_actionType, other._actionType); } diff --git a/src/Apache.Arrow.Flight/FlightDescriptor.cs b/src/Apache.Arrow.Flight/FlightDescriptor.cs index 7d443329..a7c709cb 100644 --- a/src/Apache.Arrow.Flight/FlightDescriptor.cs +++ b/src/Apache.Arrow.Flight/FlightDescriptor.cs @@ -41,7 +41,7 @@ private FlightDescriptor(params string[] paths) Type = Protocol.FlightDescriptor.Types.DescriptorType.Path }; - foreach(var path in paths) + foreach (var path in paths) { _flightDescriptor.Path.Add(path); } @@ -66,7 +66,7 @@ public static FlightDescriptor CreatePathDescriptor(params string[] paths) internal FlightDescriptor(Protocol.FlightDescriptor flightDescriptor) { - if(flightDescriptor.Type != Protocol.FlightDescriptor.Types.DescriptorType.Cmd && flightDescriptor.Type != Protocol.FlightDescriptor.Types.DescriptorType.Path) + if (flightDescriptor.Type != Protocol.FlightDescriptor.Types.DescriptorType.Cmd && flightDescriptor.Type != Protocol.FlightDescriptor.Types.DescriptorType.Path) { throw new NotSupportedException(); } @@ -92,7 +92,7 @@ public override int GetHashCode() public override bool Equals(object obj) { - if(obj is FlightDescriptor other) + if (obj is FlightDescriptor other) { return Equals(_flightDescriptor, other._flightDescriptor); } diff --git a/src/Apache.Arrow.Flight/FlightEndpoint.cs b/src/Apache.Arrow.Flight/FlightEndpoint.cs index ab15fed0..b99f3f37 100644 --- a/src/Apache.Arrow.Flight/FlightEndpoint.cs +++ b/src/Apache.Arrow.Flight/FlightEndpoint.cs @@ -47,7 +47,7 @@ internal Protocol.FlightEndpoint ToProtocol() Ticket = _ticket.ToProtocol() }; - foreach(var location in _locations) + foreach (var location in _locations) { output.Location.Add(location.ToProtocol()); } @@ -56,7 +56,7 @@ internal Protocol.FlightEndpoint ToProtocol() public override bool Equals(object obj) { - if(obj is FlightEndpoint other) + if (obj is FlightEndpoint other) { return Equals(_ticket, other._ticket) && Enumerable.SequenceEqual(_locations, other._locations); diff --git a/src/Apache.Arrow.Flight/FlightHandshakeRequest.cs b/src/Apache.Arrow.Flight/FlightHandshakeRequest.cs index 62db6446..2df96529 100644 --- a/src/Apache.Arrow.Flight/FlightHandshakeRequest.cs +++ b/src/Apache.Arrow.Flight/FlightHandshakeRequest.cs @@ -44,7 +44,7 @@ internal Protocol.HandshakeRequest ToProtocol() public override bool Equals(object obj) { - if(obj is FlightHandshakeRequest other) + if (obj is FlightHandshakeRequest other) { return Equals(_result, other._result); } diff --git a/src/Apache.Arrow.Flight/FlightInfo.cs b/src/Apache.Arrow.Flight/FlightInfo.cs index 22cd219b..1f80ffe1 100644 --- a/src/Apache.Arrow.Flight/FlightInfo.cs +++ b/src/Apache.Arrow.Flight/FlightInfo.cs @@ -30,7 +30,7 @@ internal FlightInfo(Protocol.FlightInfo flightInfo) Descriptor = new FlightDescriptor(flightInfo.FlightDescriptor); var endpoints = new List(); - foreach(var endpoint in flightInfo.Endpoint) + foreach (var endpoint in flightInfo.Endpoint) { endpoints.Add(new FlightEndpoint(endpoint)); } @@ -41,11 +41,11 @@ internal FlightInfo(Protocol.FlightInfo flightInfo) Ordered = flightInfo.Ordered; AppMetadata = flightInfo.AppMetadata; } - public FlightInfo(Schema schema, FlightDescriptor descriptor, IReadOnlyList endpoints, long totalRecords = -1, long totalBytes = -1):this(schema,descriptor,endpoints,totalRecords,totalBytes,false, ByteString.Empty) + public FlightInfo(Schema schema, FlightDescriptor descriptor, IReadOnlyList endpoints, long totalRecords = -1, long totalBytes = -1) : this(schema, descriptor, endpoints, totalRecords, totalBytes, false, ByteString.Empty) { } - public FlightInfo(Schema schema, FlightDescriptor descriptor, IReadOnlyList endpoints, long totalRecords, long totalBytes, bool ordered = false, ByteString appMetadata=null) + public FlightInfo(Schema schema, FlightDescriptor descriptor, IReadOnlyList endpoints, long totalRecords, long totalBytes, bool ordered = false, ByteString appMetadata = null) { Schema = schema; Descriptor = descriptor; @@ -81,7 +81,7 @@ internal Protocol.FlightInfo ToProtocol() TotalBytes = TotalBytes, TotalRecords = TotalRecords, Ordered = Ordered, - AppMetadata = AppMetadata + AppMetadata = AppMetadata }; foreach (var endpoint in Endpoints) diff --git a/src/Apache.Arrow.Flight/FlightLocation.cs b/src/Apache.Arrow.Flight/FlightLocation.cs index 25b9d5d4..641ec048 100644 --- a/src/Apache.Arrow.Flight/FlightLocation.cs +++ b/src/Apache.Arrow.Flight/FlightLocation.cs @@ -44,7 +44,7 @@ internal Protocol.Location ToProtocol() public override bool Equals(object obj) { - if(obj is FlightLocation other) + if (obj is FlightLocation other) { return Equals(_location, other._location); } diff --git a/src/Apache.Arrow.Flight/FlightResult.cs b/src/Apache.Arrow.Flight/FlightResult.cs index 3ddadd4b..8ae1deca 100644 --- a/src/Apache.Arrow.Flight/FlightResult.cs +++ b/src/Apache.Arrow.Flight/FlightResult.cs @@ -56,7 +56,7 @@ internal Protocol.Result ToProtocol() public override bool Equals(object obj) { - if(obj is FlightResult other) + if (obj is FlightResult other) { return Equals(_result, other._result); } diff --git a/src/Apache.Arrow.Flight/FlightTicket.cs b/src/Apache.Arrow.Flight/FlightTicket.cs index 7b3d6dd7..b55af21e 100644 --- a/src/Apache.Arrow.Flight/FlightTicket.cs +++ b/src/Apache.Arrow.Flight/FlightTicket.cs @@ -55,7 +55,7 @@ internal Protocol.Ticket ToProtocol() public override bool Equals(object obj) { - if(obj is FlightTicket other) + if (obj is FlightTicket other) { return Equals(_ticket, other._ticket); } diff --git a/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs b/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs index 7cbbe66f..9c661dee 100644 --- a/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs +++ b/src/Apache.Arrow.Flight/Internal/FlightDataStream.cs @@ -48,7 +48,7 @@ public async Task SendSchema() { _currentFlightData = new Protocol.FlightData(); - if(_flightDescriptor != null) + if (_flightDescriptor != null) { _currentFlightData.FlightDescriptor = _flightDescriptor.ToProtocol(); } @@ -76,7 +76,7 @@ public async Task Write(RecordBatch recordBatch, ByteString applicationMetadata) _currentFlightData = new Protocol.FlightData(); - if(applicationMetadata != null) + if (applicationMetadata != null) { _currentFlightData.AppMetadata = applicationMetadata; } diff --git a/src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs b/src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs index 22d0bd84..e3353e8f 100644 --- a/src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs +++ b/src/Apache.Arrow.Flight/Internal/RecordBatchReaderImplementation.cs @@ -84,7 +84,7 @@ public override async ValueTask ReadSchemaAsync(CancellationToken cancellationTo // AppMetadata will never be null, but length 0 if empty // Those are skipped - if(_flightDataStream.Current.AppMetadata.Length > 0) + if (_flightDataStream.Current.AppMetadata.Length > 0) { _applicationMetadatas.Add(_flightDataStream.Current.AppMetadata); } diff --git a/src/Apache.Arrow.Flight/Internal/SchemaWriter.cs b/src/Apache.Arrow.Flight/Internal/SchemaWriter.cs index be27cb1e..b8e38ed6 100644 --- a/src/Apache.Arrow.Flight/Internal/SchemaWriter.cs +++ b/src/Apache.Arrow.Flight/Internal/SchemaWriter.cs @@ -43,7 +43,7 @@ public void WriteSchema(Schema schema, CancellationToken cancellationToken) public static ByteString SerializeSchema(Schema schema, CancellationToken cancellationToken = default(CancellationToken)) { - using(var memoryStream = new MemoryStream()) + using (var memoryStream = new MemoryStream()) { var writer = new SchemaWriter(memoryStream, schema); writer.WriteSchema(schema, cancellationToken); diff --git a/src/Apache.Arrow/Arrays/ArrayData.cs b/src/Apache.Arrow/Arrays/ArrayData.cs index cdb6ed6b..25cda4d6 100644 --- a/src/Apache.Arrow/Arrays/ArrayData.cs +++ b/src/Apache.Arrow/Arrays/ArrayData.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Linq; +using Apache.Arrow.Memory; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs b/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs index fe2543b7..609ebb92 100644 --- a/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs +++ b/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; +using System.Collections.Generic; using Apache.Arrow.Memory; using Apache.Arrow.Scalars; using Apache.Arrow.Types; -using System; -using System.Collections.Generic; namespace Apache.Arrow { @@ -329,11 +329,11 @@ private ArrowBuffer ConcatenateValidityBuffer() { if (arrayData.NullCount == 0) { - builder.AppendRange(true , length); + builder.AppendRange(true, length); } else if (arrayData.NullCount == length) { - builder.AppendRange(false , length); + builder.AppendRange(false, length); } else { diff --git a/src/Apache.Arrow/Arrays/ArrayDataTypeComparer.cs b/src/Apache.Arrow/Arrays/ArrayDataTypeComparer.cs index 2a5c386e..c51139ce 100644 --- a/src/Apache.Arrow/Arrays/ArrayDataTypeComparer.cs +++ b/src/Apache.Arrow/Arrays/ArrayDataTypeComparer.cs @@ -165,7 +165,7 @@ private static bool CompareNested(NestedType expectedType, NestedType actualType } } - return true; + return true; } public void Visit(IArrowType actualType) diff --git a/src/Apache.Arrow/Arrays/ArrowArrayBuilderFactory.cs b/src/Apache.Arrow/Arrays/ArrowArrayBuilderFactory.cs index 3fb77d2c..4c4586ad 100644 --- a/src/Apache.Arrow/Arrays/ArrowArrayBuilderFactory.cs +++ b/src/Apache.Arrow/Arrays/ArrowArrayBuilderFactory.cs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs b/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs index ac825221..56462e83 100644 --- a/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs +++ b/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs @@ -13,16 +13,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; using System.Collections.Generic; +using Apache.Arrow.Memory; namespace Apache.Arrow { public static class ArrowArrayConcatenator { - public static IArrowArray Concatenate(IReadOnlyList arrowArrayList , MemoryAllocator allocator = default) + public static IArrowArray Concatenate(IReadOnlyList arrowArrayList, MemoryAllocator allocator = default) { - if(arrowArrayList == null || arrowArrayList.Count == 0) + if (arrowArrayList == null || arrowArrayList.Count == 0) { return null; } @@ -34,7 +34,7 @@ public static IArrowArray Concatenate(IReadOnlyList arrowArrayList var arrayDataList = new List(arrowArrayList.Count); - foreach(IArrowArray array in arrowArrayList) + foreach (IArrowArray array in arrowArrayList) { arrayDataList.Add(array.Data); } diff --git a/src/Apache.Arrow/Arrays/ArrowArrayFactory.cs b/src/Apache.Arrow/Arrays/ArrowArrayFactory.cs index 38092a7a..8aaba2d9 100644 --- a/src/Apache.Arrow/Arrays/ArrowArrayFactory.cs +++ b/src/Apache.Arrow/Arrays/ArrowArrayFactory.cs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; using Apache.Arrow.Arrays; using Apache.Arrow.Types; -using System; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/BinaryArray.cs b/src/Apache.Arrow/Arrays/BinaryArray.cs index bd5d9315..feb4b895 100644 --- a/src/Apache.Arrow/Arrays/BinaryArray.cs +++ b/src/Apache.Arrow/Arrays/BinaryArray.cs @@ -13,12 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; +using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using Apache.Arrow.Memory; -using System.Collections; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/BinaryViewArray.cs b/src/Apache.Arrow/Arrays/BinaryViewArray.cs index b7c9b073..f9c8c0e1 100644 --- a/src/Apache.Arrow/Arrays/BinaryViewArray.cs +++ b/src/Apache.Arrow/Arrays/BinaryViewArray.cs @@ -13,13 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; -using Apache.Arrow.Scalars; -using Apache.Arrow.Types; using System; +using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; -using System.Collections; +using Apache.Arrow.Memory; +using Apache.Arrow.Scalars; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/BooleanArray.cs b/src/Apache.Arrow/Arrays/BooleanArray.cs index 19d4d0b7..f87c2ec7 100644 --- a/src/Apache.Arrow/Arrays/BooleanArray.cs +++ b/src/Apache.Arrow/Arrays/BooleanArray.cs @@ -13,15 +13,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; -using Apache.Arrow.Types; using System; using System.Collections; using System.Collections.Generic; +using Apache.Arrow.Memory; +using Apache.Arrow.Types; namespace Apache.Arrow { - public class BooleanArray: Array, IReadOnlyList, ICollection + public class BooleanArray : Array, IReadOnlyList, ICollection { public class Builder : IArrowArrayBuilder { @@ -162,7 +162,7 @@ private void CheckIndex(int index) } public ArrowBuffer ValueBuffer => Data.Buffers[1]; - public ReadOnlySpan Values => ValueBuffer.Span.Slice(0, (int) Math.Ceiling(Length / 8.0)); + public ReadOnlySpan Values => ValueBuffer.Span.Slice(0, (int)Math.Ceiling(Length / 8.0)); public BooleanArray( ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, diff --git a/src/Apache.Arrow/Arrays/Date32Array.cs b/src/Apache.Arrow/Arrays/Date32Array.cs index 55864e89..2fd5bfb8 100644 --- a/src/Apache.Arrow/Arrays/Date32Array.cs +++ b/src/Apache.Arrow/Arrays/Date32Array.cs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/Date64Array.cs b/src/Apache.Arrow/Arrays/Date64Array.cs index bf535745..64d3cf5a 100644 --- a/src/Apache.Arrow/Arrays/Date64Array.cs +++ b/src/Apache.Arrow/Arrays/Date64Array.cs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/DenseUnionArray.cs b/src/Apache.Arrow/Arrays/DenseUnionArray.cs index 79880c89..0b8234a1 100644 --- a/src/Apache.Arrow/Arrays/DenseUnionArray.cs +++ b/src/Apache.Arrow/Arrays/DenseUnionArray.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Linq; +using Apache.Arrow.Types; namespace Apache.Arrow { @@ -41,7 +41,7 @@ public DenseUnionArray( ValidateMode(UnionMode.Dense, Type.Mode); } - public DenseUnionArray(ArrayData data) + public DenseUnionArray(ArrayData data) : base(data) { ValidateMode(UnionMode.Dense, Type.Mode); diff --git a/src/Apache.Arrow/Arrays/FixedSizeBinaryArray.cs b/src/Apache.Arrow/Arrays/FixedSizeBinaryArray.cs index 9d597ef1..3bb0652c 100644 --- a/src/Apache.Arrow/Arrays/FixedSizeBinaryArray.cs +++ b/src/Apache.Arrow/Arrays/FixedSizeBinaryArray.cs @@ -136,7 +136,8 @@ public TBuilder Resize(int length) return Instance; } - public TBuilder Clear() { + public TBuilder Clear() + { ValueBuffer.Clear(); ValidityBuffer.Clear(); @@ -146,7 +147,7 @@ public TBuilder Clear() { public TBuilder Append(byte[] value) { - if(value.Length % ByteWidth != 0) + if (value.Length % ByteWidth != 0) throw new ArgumentOutOfRangeException("Bytes of length: " + value.Length + " do not conform to the fixed size: " + ByteWidth); return Append(value.AsSpan()); } diff --git a/src/Apache.Arrow/Arrays/HalfFloatArray.cs b/src/Apache.Arrow/Arrays/HalfFloatArray.cs index 072629e0..7ab869e9 100644 --- a/src/Apache.Arrow/Arrays/HalfFloatArray.cs +++ b/src/Apache.Arrow/Arrays/HalfFloatArray.cs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/Int16Array.cs b/src/Apache.Arrow/Arrays/Int16Array.cs index 0401865c..cb33a536 100644 --- a/src/Apache.Arrow/Arrays/Int16Array.cs +++ b/src/Apache.Arrow/Arrays/Int16Array.cs @@ -22,7 +22,7 @@ public class Int16Array : PrimitiveArray public class Builder : PrimitiveArrayBuilder { protected override Int16Array Build( - ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, + ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, int length, int nullCount, int offset) => new Int16Array(valueBuffer, nullBitmapBuffer, length, nullCount, offset); } diff --git a/src/Apache.Arrow/Arrays/LargeBinaryArray.cs b/src/Apache.Arrow/Arrays/LargeBinaryArray.cs index 9eddbeda..12194661 100644 --- a/src/Apache.Arrow/Arrays/LargeBinaryArray.cs +++ b/src/Apache.Arrow/Arrays/LargeBinaryArray.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; +using Apache.Arrow.Types; namespace Apache.Arrow; diff --git a/src/Apache.Arrow/Arrays/LargeStringArray.cs b/src/Apache.Arrow/Arrays/LargeStringArray.cs index 2a65b828..e97683f1 100644 --- a/src/Apache.Arrow/Arrays/LargeStringArray.cs +++ b/src/Apache.Arrow/Arrays/LargeStringArray.cs @@ -22,7 +22,7 @@ namespace Apache.Arrow; -public class LargeStringArray: LargeBinaryArray, IReadOnlyList, ICollection +public class LargeStringArray : LargeBinaryArray, IReadOnlyList, ICollection { public static readonly Encoding DefaultEncoding = StringArray.DefaultEncoding; diff --git a/src/Apache.Arrow/Arrays/MapArray.cs b/src/Apache.Arrow/Arrays/MapArray.cs index c1dc9688..341bb241 100644 --- a/src/Apache.Arrow/Arrays/MapArray.cs +++ b/src/Apache.Arrow/Arrays/MapArray.cs @@ -165,7 +165,7 @@ public IEnumerable> GetTuples(int inde } } - public IEnumerable> GetKeyValuePairs(int index, Func getKey, Func getValue) + public IEnumerable> GetKeyValuePairs(int index, Func getKey, Func getValue) where TKeyArray : Array where TValueArray : Array { ReadOnlySpan offsets = ValueOffsets; @@ -178,7 +178,7 @@ public IEnumerable> GetKeyValuePairs(getKey(keyArray, i), getValue(valueArray, i)); + yield return new KeyValuePair(getKey(keyArray, i), getValue(valueArray, i)); } } } diff --git a/src/Apache.Arrow/Arrays/NullArray.cs b/src/Apache.Arrow/Arrays/NullArray.cs index 7f3e1838..4b1c6950 100644 --- a/src/Apache.Arrow/Arrays/NullArray.cs +++ b/src/Apache.Arrow/Arrays/NullArray.cs @@ -14,8 +14,8 @@ // limitations under the License. using System; -using Apache.Arrow.Types; using Apache.Arrow.Memory; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/PrimitiveArrayBuilder.cs b/src/Apache.Arrow/Arrays/PrimitiveArrayBuilder.cs index b3583842..dc6fba2b 100644 --- a/src/Apache.Arrow/Arrays/PrimitiveArrayBuilder.cs +++ b/src/Apache.Arrow/Arrays/PrimitiveArrayBuilder.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; using System; using System.Collections.Generic; using System.Linq; +using Apache.Arrow.Memory; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/SparseUnionArray.cs b/src/Apache.Arrow/Arrays/SparseUnionArray.cs index 5b29489e..5a280906 100644 --- a/src/Apache.Arrow/Arrays/SparseUnionArray.cs +++ b/src/Apache.Arrow/Arrays/SparseUnionArray.cs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System.Collections.Generic; using System.Linq; +using Apache.Arrow.Types; namespace Apache.Arrow { @@ -35,7 +35,7 @@ public SparseUnionArray( ValidateMode(UnionMode.Sparse, Type.Mode); } - public SparseUnionArray(ArrayData data) + public SparseUnionArray(ArrayData data) : base(data) { ValidateMode(UnionMode.Sparse, Type.Mode); diff --git a/src/Apache.Arrow/Arrays/StringArray.cs b/src/Apache.Arrow/Arrays/StringArray.cs index ab44805d..6df10111 100644 --- a/src/Apache.Arrow/Arrays/StringArray.cs +++ b/src/Apache.Arrow/Arrays/StringArray.cs @@ -22,7 +22,7 @@ namespace Apache.Arrow { - public class StringArray: BinaryArray, IReadOnlyList, ICollection + public class StringArray : BinaryArray, IReadOnlyList, ICollection { public static readonly Encoding DefaultEncoding = Encoding.UTF8; diff --git a/src/Apache.Arrow/Arrays/StringViewArray.cs b/src/Apache.Arrow/Arrays/StringViewArray.cs index 88644761..96eeb19a 100644 --- a/src/Apache.Arrow/Arrays/StringViewArray.cs +++ b/src/Apache.Arrow/Arrays/StringViewArray.cs @@ -13,16 +13,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; +using Apache.Arrow.Types; namespace Apache.Arrow { - public class StringViewArray: BinaryViewArray, IReadOnlyList + public class StringViewArray : BinaryViewArray, IReadOnlyList { public static readonly Encoding DefaultEncoding = Encoding.UTF8; diff --git a/src/Apache.Arrow/Arrays/StructArray.cs b/src/Apache.Arrow/Arrays/StructArray.cs index fc1335af..1f0c8e1d 100644 --- a/src/Apache.Arrow/Arrays/StructArray.cs +++ b/src/Apache.Arrow/Arrays/StructArray.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System.Collections.Generic; using System.Linq; using System.Threading; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/Time32Array.cs b/src/Apache.Arrow/Arrays/Time32Array.cs index 63c08989..e546d0fb 100644 --- a/src/Apache.Arrow/Arrays/Time32Array.cs +++ b/src/Apache.Arrow/Arrays/Time32Array.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.IO; +using Apache.Arrow.Types; namespace Apache.Arrow { @@ -104,7 +104,7 @@ public Time32Array(ArrayData data) return null; } - var unit = ((Time32Type) Data.DataType).Unit; + var unit = ((Time32Type)Data.DataType).Unit; return unit switch { TimeUnit.Second => value, diff --git a/src/Apache.Arrow/Arrays/Time64Array.cs b/src/Apache.Arrow/Arrays/Time64Array.cs index 55184629..557cc86f 100644 --- a/src/Apache.Arrow/Arrays/Time64Array.cs +++ b/src/Apache.Arrow/Arrays/Time64Array.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.IO; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Arrays/TimestampArray.cs b/src/Apache.Arrow/Arrays/TimestampArray.cs index b8386058..ffc6471b 100644 --- a/src/Apache.Arrow/Arrays/TimestampArray.cs +++ b/src/Apache.Arrow/Arrays/TimestampArray.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using Apache.Arrow.Types; namespace Apache.Arrow { @@ -25,7 +25,7 @@ public class TimestampArray : PrimitiveArray, IReadOnlyList + public class Builder : PrimitiveArrayBuilder { internal class TimestampBuilder : PrimitiveArrayBuilder { @@ -55,7 +55,7 @@ public Builder(TimeUnit unit = TimeUnit.Millisecond, string timezone = "+00:00") : this(new TimestampType(unit, timezone)) { } public Builder(TimeUnit unit) - : this(new TimestampType(unit, (string) null)) { } + : this(new TimestampType(unit, (string)null)) { } public Builder(TimestampType type) : base(new TimestampBuilder(type)) @@ -95,7 +95,8 @@ public TimestampArray( ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, int length, int nullCount, int offset) : this(new ArrayData(type, length, nullCount, offset, - new[] {nullBitmapBuffer, valueBuffer})) { } + new[] { nullBitmapBuffer, valueBuffer })) + { } public TimestampArray(ArrayData data) : base(data) @@ -109,7 +110,7 @@ public TimestampArray(ArrayData data) public DateTimeOffset GetTimestampUnchecked(int index) { - var type = (TimestampType) Data.DataType; + var type = (TimestampType)Data.DataType; long value = Values[index]; long ticks; diff --git a/src/Apache.Arrow/Arrays/UInt8Array.cs b/src/Apache.Arrow/Arrays/UInt8Array.cs index 5cde7918..f68a5fac 100644 --- a/src/Apache.Arrow/Arrays/UInt8Array.cs +++ b/src/Apache.Arrow/Arrays/UInt8Array.cs @@ -30,8 +30,9 @@ protected override UInt8Array Build( public UInt8Array( ArrowBuffer valueBuffer, ArrowBuffer nullBitmapBuffer, int length, int nullCount, int offset) - : this(new ArrayData(UInt8Type.Default, length, nullCount, offset, - new[] { nullBitmapBuffer, valueBuffer })) { } + : this(new ArrayData(UInt8Type.Default, length, nullCount, offset, + new[] { nullBitmapBuffer, valueBuffer })) + { } public UInt8Array(ArrayData data) : base(data) diff --git a/src/Apache.Arrow/Arrays/UnionArray.cs b/src/Apache.Arrow/Arrays/UnionArray.cs index c1deb9b6..ccaa88df 100644 --- a/src/Apache.Arrow/Arrays/UnionArray.cs +++ b/src/Apache.Arrow/Arrays/UnionArray.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Threading; +using Apache.Arrow.Types; namespace Apache.Arrow { @@ -47,7 +47,7 @@ public abstract class UnionArray : IArrowArray public bool IsNull(int index) => !IsValid(index); - protected UnionArray(ArrayData data) + protected UnionArray(ArrayData data) { Data = data; data.EnsureDataType(ArrowTypeId.Union); diff --git a/src/Apache.Arrow/ArrowBuffer.BitmapBuilder.cs b/src/Apache.Arrow/ArrowBuffer.BitmapBuilder.cs index 6bdd1317..cb1b240c 100644 --- a/src/Apache.Arrow/ArrowBuffer.BitmapBuilder.cs +++ b/src/Apache.Arrow/ArrowBuffer.BitmapBuilder.cs @@ -96,16 +96,16 @@ public BitmapBuilder Append(bool value) /// Number of valid bits in the source span. /// Returns the builder (for fluent-style composition). public BitmapBuilder Append(ReadOnlySpan source, int validBits) - { + { if (!source.IsEmpty && validBits > source.Length * 8) throw new ArgumentException($"Number of valid bits ({validBits}) cannot be greater than the source span length ({source.Length * 8} bits).", nameof(validBits)); - + // Check if memory copy can be used from the source array (performance optimization for byte-aligned coping) if (!source.IsEmpty && Length % 8 == 0) { EnsureAdditionalCapacity(validBits); source.Slice(0, BitUtility.ByteCount(validBits)).CopyTo(Span.Slice(Length / 8)); - + Length += validBits; SetBitCount += BitUtility.CountBits(source, 0, validBits); } diff --git a/src/Apache.Arrow/ArrowBuffer.Builder.cs b/src/Apache.Arrow/ArrowBuffer.Builder.cs index 7c03027f..fad6ab7a 100644 --- a/src/Apache.Arrow/ArrowBuffer.Builder.cs +++ b/src/Apache.Arrow/ArrowBuffer.Builder.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; using System; using System.Buffers; using System.Collections.Generic; using System.Runtime.CompilerServices; +using Apache.Arrow.Memory; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/BitUtility.cs b/src/Apache.Arrow/BitUtility.cs index d9ad2e6d..cf32a459 100644 --- a/src/Apache.Arrow/BitUtility.cs +++ b/src/Apache.Arrow/BitUtility.cs @@ -45,7 +45,7 @@ public static bool GetBit(ReadOnlySpan data, int index) => public static void ClearBit(Span data, int index) { - data[index / 8] &= (byte) ~BitMask[index % 8]; + data[index / 8] &= (byte)~BitMask[index % 8]; } public static void SetBit(Span data, int index) @@ -75,7 +75,7 @@ internal static void SetBits(Span data, int index, int length, bool value) return; int endBitIndex = checked(index + length - 1); - + // Use simpler method if there aren't many values if (length < 20) { @@ -85,13 +85,13 @@ internal static void SetBits(Span data, int index, int length, bool value) } return; } - + // Otherwise do the work to figure out how to copy whole bytes int startByteIndex = index / 8; int startBitOffset = index % 8; int endByteIndex = endBitIndex / 8; int endBitOffset = endBitIndex % 8; - + // If the starting index and ending index are not byte-aligned, // we'll need to set bits the slow way. If they are // byte-aligned, and for all other bytes in the 'middle', we diff --git a/src/Apache.Arrow/C/CArrowArrayExporter.cs b/src/Apache.Arrow/C/CArrowArrayExporter.cs index b241fdfe..d81a67b8 100644 --- a/src/Apache.Arrow/C/CArrowArrayExporter.cs +++ b/src/Apache.Arrow/C/CArrowArrayExporter.cs @@ -239,7 +239,7 @@ private unsafe static void ReleaseArray(CArrowArray* cArray) private unsafe static void DisposePrivateData(void** ptr) { - GCHandle gch = GCHandle.FromIntPtr((IntPtr) (*ptr)); + GCHandle gch = GCHandle.FromIntPtr((IntPtr)(*ptr)); if (!gch.IsAllocated) { return; @@ -247,7 +247,7 @@ private unsafe static void DisposePrivateData(void** ptr) // We can't call IDisposable.Dispose() here as we create multiple // GCHandles to the same object. Instead, refcounting ensures // timely memory deallocation when all GCHandles are freed. - ((ExportedAllocationOwner) gch.Target).DecRef(); + ((ExportedAllocationOwner)gch.Target).DecRef(); gch.Free(); } } diff --git a/src/Apache.Arrow/ChunkedArray.cs b/src/Apache.Arrow/ChunkedArray.cs index 85b3560c..2c238ac5 100644 --- a/src/Apache.Arrow/ChunkedArray.cs +++ b/src/Apache.Arrow/ChunkedArray.cs @@ -93,7 +93,7 @@ public ChunkedArray Slice(long offset) } public override string ToString() => $"{nameof(ChunkedArray)}: Length={Length}, DataType={DataType.Name}"; - + private static IArrowArray[] Cast(IList arrays) { IArrowArray[] arrowArrays = new IArrowArray[arrays.Count]; diff --git a/src/Apache.Arrow/Column.cs b/src/Apache.Arrow/Column.cs index 0709b914..03be51cd 100644 --- a/src/Apache.Arrow/Column.cs +++ b/src/Apache.Arrow/Column.cs @@ -24,7 +24,7 @@ namespace Apache.Arrow /// public class Column { - public Field Field { get; } + public Field Field { get; } public ChunkedArray Data { get; } public Column(Field field, IList arrays) diff --git a/src/Apache.Arrow/DecimalUtility.cs b/src/Apache.Arrow/DecimalUtility.cs index 363f8162..c4e72564 100644 --- a/src/Apache.Arrow/DecimalUtility.cs +++ b/src/Apache.Arrow/DecimalUtility.cs @@ -57,7 +57,7 @@ internal static decimal GetDecimal(in ArrowBuffer valueBuffer, int index, int sc { throw new OverflowException($"Value: {integerPart} of {integerValue} is too big be represented as a decimal"); } - else if (integerPart < _minDecimal) + else if (integerPart < _minDecimal) { throw new OverflowException($"Value: {integerPart} of {integerValue} is too small be represented as a decimal"); } diff --git a/src/Apache.Arrow/Extensions/ArrayDataExtensions.cs b/src/Apache.Arrow/Extensions/ArrayDataExtensions.cs index 2b6742a3..84936a1c 100644 --- a/src/Apache.Arrow/Extensions/ArrayDataExtensions.cs +++ b/src/Apache.Arrow/Extensions/ArrayDataExtensions.cs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Extensions/ArrowTypeExtensions.cs b/src/Apache.Arrow/Extensions/ArrowTypeExtensions.cs index 5b040745..e2ce25ec 100644 --- a/src/Apache.Arrow/Extensions/ArrowTypeExtensions.cs +++ b/src/Apache.Arrow/Extensions/ArrowTypeExtensions.cs @@ -20,7 +20,7 @@ namespace Apache.Arrow { public static class ArrowTypeExtensions { - private static readonly ISet s_integralTypes = + private static readonly ISet s_integralTypes = new HashSet(new[] { ArrowTypeId.Int8, ArrowTypeId.Int16, ArrowTypeId.Int32, ArrowTypeId.Int64, @@ -33,7 +33,7 @@ public static class ArrowTypeExtensions ArrowTypeId.HalfFloat, ArrowTypeId.Float, ArrowTypeId.Double }); - public static bool IsIntegral(this IArrowType type) + public static bool IsIntegral(this IArrowType type) => s_integralTypes.Contains(type.TypeId); public static bool IsFloatingPoint(this IArrowType type) diff --git a/src/Apache.Arrow/Extensions/SpanExtensions.cs b/src/Apache.Arrow/Extensions/SpanExtensions.cs index b759f380..1e994813 100644 --- a/src/Apache.Arrow/Extensions/SpanExtensions.cs +++ b/src/Apache.Arrow/Extensions/SpanExtensions.cs @@ -21,11 +21,11 @@ namespace Apache.Arrow public static class SpanExtensions { public static Span CastTo(this Span span) - where T: struct => + where T : struct => MemoryMarshal.Cast(span); public static ReadOnlySpan CastTo(this ReadOnlySpan span) - where T: struct => + where T : struct => MemoryMarshal.Cast(span); } } diff --git a/src/Apache.Arrow/Extensions/StreamExtensions.cs b/src/Apache.Arrow/Extensions/StreamExtensions.cs index 1767d23e..032cad26 100644 --- a/src/Apache.Arrow/Extensions/StreamExtensions.cs +++ b/src/Apache.Arrow/Extensions/StreamExtensions.cs @@ -27,7 +27,7 @@ public static async ValueTask ReadFullBufferAsync(this Stream stream, Memor int totalBytesRead = 0; do { - int bytesRead = + int bytesRead = await stream.ReadAsync( buffer.Slice(totalBytesRead, buffer.Length - totalBytesRead), cancellationToken) diff --git a/src/Apache.Arrow/Field.Builder.cs b/src/Apache.Arrow/Field.Builder.cs index f7f33383..08513ec5 100644 --- a/src/Apache.Arrow/Field.Builder.cs +++ b/src/Apache.Arrow/Field.Builder.cs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Interfaces/IArrowArrayBuilder.cs b/src/Apache.Arrow/Interfaces/IArrowArrayBuilder.cs index b18ff458..62488663 100644 --- a/src/Apache.Arrow/Interfaces/IArrowArrayBuilder.cs +++ b/src/Apache.Arrow/Interfaces/IArrowArrayBuilder.cs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; using System; using System.Collections.Generic; +using Apache.Arrow.Memory; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Interfaces/IArrowArrayVisitor.cs b/src/Apache.Arrow/Interfaces/IArrowArrayVisitor.cs index c93bbb48..017cc97d 100644 --- a/src/Apache.Arrow/Interfaces/IArrowArrayVisitor.cs +++ b/src/Apache.Arrow/Interfaces/IArrowArrayVisitor.cs @@ -22,8 +22,8 @@ public interface IArrowArrayVisitor void Visit(IArrowArray array); } - public interface IArrowArrayVisitor: IArrowArrayVisitor - where T: IArrowArray + public interface IArrowArrayVisitor : IArrowArrayVisitor + where T : IArrowArray { void Visit(T array); } diff --git a/src/Apache.Arrow/Ipc/ArrowFileReader.cs b/src/Apache.Arrow/Ipc/ArrowFileReader.cs index 935a1e7f..29677ede 100644 --- a/src/Apache.Arrow/Ipc/ArrowFileReader.cs +++ b/src/Apache.Arrow/Ipc/ArrowFileReader.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; using System.IO; using System.Threading; using System.Threading.Tasks; +using Apache.Arrow.Memory; namespace Apache.Arrow.Ipc { diff --git a/src/Apache.Arrow/Ipc/ArrowFileReaderImplementation.cs b/src/Apache.Arrow/Ipc/ArrowFileReaderImplementation.cs index 4b7c5f91..8cedea68 100644 --- a/src/Apache.Arrow/Ipc/ArrowFileReaderImplementation.cs +++ b/src/Apache.Arrow/Ipc/ArrowFileReaderImplementation.cs @@ -13,13 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; using System; using System.Buffers; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Apache.Arrow.Memory; namespace Apache.Arrow.Ipc { diff --git a/src/Apache.Arrow/Ipc/ArrowMemoryReaderImplementation.cs b/src/Apache.Arrow/Ipc/ArrowMemoryReaderImplementation.cs index 842c5682..1a799b01 100644 --- a/src/Apache.Arrow/Ipc/ArrowMemoryReaderImplementation.cs +++ b/src/Apache.Arrow/Ipc/ArrowMemoryReaderImplementation.cs @@ -13,13 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Flatbuf; -using Google.FlatBuffers; using System; using System.Buffers.Binary; using System.IO; using System.Threading; using System.Threading.Tasks; +using Apache.Arrow.Flatbuf; +using Google.FlatBuffers; namespace Apache.Arrow.Ipc { diff --git a/src/Apache.Arrow/Ipc/ArrowReaderImplementation.cs b/src/Apache.Arrow/Ipc/ArrowReaderImplementation.cs index 7e766677..d71478a2 100644 --- a/src/Apache.Arrow/Ipc/ArrowReaderImplementation.cs +++ b/src/Apache.Arrow/Ipc/ArrowReaderImplementation.cs @@ -21,8 +21,8 @@ using System.Threading; using System.Threading.Tasks; using Apache.Arrow.Flatbuf; -using Apache.Arrow.Types; using Apache.Arrow.Memory; +using Apache.Arrow.Types; using Google.FlatBuffers; using Type = System.Type; diff --git a/src/Apache.Arrow/Ipc/ArrowStreamReader.cs b/src/Apache.Arrow/Ipc/ArrowStreamReader.cs index e129da39..dc342b2f 100644 --- a/src/Apache.Arrow/Ipc/ArrowStreamReader.cs +++ b/src/Apache.Arrow/Ipc/ArrowStreamReader.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; using System; using System.IO; using System.Threading; using System.Threading.Tasks; +using Apache.Arrow.Memory; namespace Apache.Arrow.Ipc { diff --git a/src/Apache.Arrow/Ipc/ArrowStreamReaderImplementation.cs b/src/Apache.Arrow/Ipc/ArrowStreamReaderImplementation.cs index 23a14d86..e2bfe4ac 100644 --- a/src/Apache.Arrow/Ipc/ArrowStreamReaderImplementation.cs +++ b/src/Apache.Arrow/Ipc/ArrowStreamReaderImplementation.cs @@ -13,12 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; using System; using System.Buffers; using System.IO; using System.Threading; using System.Threading.Tasks; +using Apache.Arrow.Memory; namespace Apache.Arrow.Ipc { diff --git a/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs b/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs index f3170938..5f180c4a 100644 --- a/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs +++ b/src/Apache.Arrow/Ipc/ArrowStreamWriter.cs @@ -528,7 +528,7 @@ private Buffer CreateBuffer(ArrowBuffer buffer, bool locallyOwned) return CreateBuffer(buffer.Memory, null); } - private Buffer CreateBuffer(IMemoryOwner bufferOwner) + private Buffer CreateBuffer(IMemoryOwner bufferOwner) { return CreateBuffer(bufferOwner.Memory, bufferOwner); } @@ -539,7 +539,7 @@ private Buffer CreateBuffer(ReadOnlyMemory buffer, IDisposable localBuffer const int UncompressedLengthSize = 8; ReadOnlyMemory bufferToWrite; - IMemoryOwner bufferOwner=null; + IMemoryOwner bufferOwner = null; if (_compressionCodec == null) { bufferToWrite = buffer; @@ -560,11 +560,11 @@ private Buffer CreateBuffer(ReadOnlyMemory buffer, IDisposable localBuffer int newBufferLength = UncompressedLengthSize + buffer.Length; bufferOwner = _allocator.Allocate(newBufferLength); - if(TryCompress(buffer, bufferOwner.Memory.Slice(UncompressedLengthSize, buffer.Length), out int bytesWritten)) + if (TryCompress(buffer, bufferOwner.Memory.Slice(UncompressedLengthSize, buffer.Length), out int bytesWritten)) { // Write the uncompressed length to the start of the buffer BinaryPrimitives.WriteInt64LittleEndian(bufferOwner.Memory.Span, buffer.Length); - bufferToWrite = bufferOwner.Memory.Slice(0, bytesWritten+UncompressedLengthSize); + bufferToWrite = bufferOwner.Memory.Slice(0, bytesWritten + UncompressedLengthSize); } else { @@ -587,7 +587,7 @@ private Buffer CreateBuffer(ReadOnlyMemory buffer, IDisposable localBuffer private bool TryCompress(ReadOnlyMemory source, Memory destination, out int bytesWritten) { - if(_compressionCodec is ITryCompressionCodec tryCompressionCodec) + if (_compressionCodec is ITryCompressionCodec tryCompressionCodec) return tryCompressionCodec.TryCompress(source, destination, out bytesWritten); // Fallback to using a memory stream for compression _fallbackCompressionStream.Seek(0, SeekOrigin.Begin); diff --git a/src/Apache.Arrow/Ipc/ArrowTypeFlatbufferBuilder.cs b/src/Apache.Arrow/Ipc/ArrowTypeFlatbufferBuilder.cs index d1fb9216..503680a2 100644 --- a/src/Apache.Arrow/Ipc/ArrowTypeFlatbufferBuilder.cs +++ b/src/Apache.Arrow/Ipc/ArrowTypeFlatbufferBuilder.cs @@ -320,7 +320,7 @@ public void Visit(DictionaryType type) // type in the DictionaryEncoding metadata in the parent field type.ValueType.Accept(this); } - + public void Visit(FixedSizeBinaryType type) { Result = FieldType.Build( diff --git a/src/Apache.Arrow/Ipc/DictionaryMemo.cs b/src/Apache.Arrow/Ipc/DictionaryMemo.cs index b107cc65..680642d0 100644 --- a/src/Apache.Arrow/Ipc/DictionaryMemo.cs +++ b/src/Apache.Arrow/Ipc/DictionaryMemo.cs @@ -110,7 +110,7 @@ public void AddOrReplaceDictionary(long id, IArrowArray dictionary) public void AddDeltaDictionary(long id, IArrowArray deltaDictionary, MemoryAllocator allocator = default) { IArrowArray currentDictionary = _idToDictionary[id]; - IArrowArray dictionary = ArrowArrayConcatenator.Concatenate(new List{ currentDictionary, deltaDictionary }, allocator); + IArrowArray dictionary = ArrowArrayConcatenator.Concatenate(new List { currentDictionary, deltaDictionary }, allocator); AddOrReplaceDictionary(id, dictionary); } } diff --git a/src/Apache.Arrow/Ipc/ReadOnlyMemoryBufferAllocator.cs b/src/Apache.Arrow/Ipc/ReadOnlyMemoryBufferAllocator.cs index 0f968739..31763660 100644 --- a/src/Apache.Arrow/Ipc/ReadOnlyMemoryBufferAllocator.cs +++ b/src/Apache.Arrow/Ipc/ReadOnlyMemoryBufferAllocator.cs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Google.FlatBuffers; using System; +using Google.FlatBuffers; namespace Apache.Arrow.Ipc { diff --git a/src/Apache.Arrow/Memory/ExportedAllocationOwner.cs b/src/Apache.Arrow/Memory/ExportedAllocationOwner.cs index 8084cd24..516e7d7b 100644 --- a/src/Apache.Arrow/Memory/ExportedAllocationOwner.cs +++ b/src/Apache.Arrow/Memory/ExportedAllocationOwner.cs @@ -14,8 +14,8 @@ // limitations under the License. using System; -using System.Diagnostics; using System.Collections.Generic; +using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; diff --git a/src/Apache.Arrow/Memory/NativeMemoryAllocator.cs b/src/Apache.Arrow/Memory/NativeMemoryAllocator.cs index 57f85511..fc4e642e 100644 --- a/src/Apache.Arrow/Memory/NativeMemoryAllocator.cs +++ b/src/Apache.Arrow/Memory/NativeMemoryAllocator.cs @@ -23,7 +23,7 @@ public class NativeMemoryAllocator : MemoryAllocator { internal static readonly INativeAllocationOwner ExclusiveOwner = new NativeAllocationOwner(); - public NativeMemoryAllocator(int alignment = DefaultAlignment) + public NativeMemoryAllocator(int alignment = DefaultAlignment) : base(alignment) { } protected override IMemoryOwner AllocateInternal(int length, out int bytesAllocated) @@ -36,7 +36,7 @@ protected override IMemoryOwner AllocateInternal(int length, out int bytes // TODO: Should the allocation be moved to NativeMemory? int size = length + Alignment; - IntPtr ptr = Marshal.AllocHGlobal(size); + IntPtr ptr = Marshal.AllocHGlobal(size); int offset = (int)(Alignment - (ptr.ToInt64() & (Alignment - 1))); var manager = new NativeMemoryManager(ptr, offset, length); diff --git a/src/Apache.Arrow/Memory/NullMemoryOwner.cs b/src/Apache.Arrow/Memory/NullMemoryOwner.cs index 7415ffc3..390a44a8 100644 --- a/src/Apache.Arrow/Memory/NullMemoryOwner.cs +++ b/src/Apache.Arrow/Memory/NullMemoryOwner.cs @@ -26,4 +26,4 @@ public void Dispose() { } } -} \ No newline at end of file +} diff --git a/src/Apache.Arrow/RecordBatch.Builder.cs b/src/Apache.Arrow/RecordBatch.Builder.cs index e9a84a48..0e881f04 100644 --- a/src/Apache.Arrow/RecordBatch.Builder.cs +++ b/src/Apache.Arrow/RecordBatch.Builder.cs @@ -13,12 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Memory; -using Apache.Arrow.Types; using System; using System.Buffers; using System.Collections.Generic; using System.Linq; +using Apache.Arrow.Memory; +using Apache.Arrow.Types; namespace Apache.Arrow { @@ -82,8 +82,8 @@ public TimestampArray Timestamp(TimeUnit unit, TimeZoneInfo timezone, Action(TArrayBuilder builder, Action action) - where TArray: IArrowArray - where TArrayBuilder: IArrowArrayBuilder + where TArray : IArrowArray + where TArrayBuilder : IArrowArrayBuilder { if (action == null) { @@ -147,7 +147,7 @@ public Builder Append(RecordBatch batch) } public Builder Append(string name, bool nullable, IArrowArrayBuilder builder) - where TArray: IArrowArray + where TArray : IArrowArray { return builder == null ? this @@ -155,7 +155,7 @@ public Builder Append(string name, bool nullable, IArrowArrayBuilder(string name, bool nullable, TArray array) - where TArray: IArrowArray + where TArray : IArrowArray { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException(nameof(name)); if (array == null) return this; @@ -171,7 +171,7 @@ public Builder Append(string name, bool nullable, TArray array) } public Builder Append(string name, bool nullable, Func action) - where TArray: IArrowArray + where TArray : IArrowArray { if (action == null) return this; diff --git a/src/Apache.Arrow/Schema.cs b/src/Apache.Arrow/Schema.cs index 32615e5d..04e0e837 100644 --- a/src/Apache.Arrow/Schema.cs +++ b/src/Apache.Arrow/Schema.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Apache.Arrow.Types; namespace Apache.Arrow { diff --git a/src/Apache.Arrow/Types/ArrowType.cs b/src/Apache.Arrow/Types/ArrowType.cs index c0eca23d..e548cf00 100644 --- a/src/Apache.Arrow/Types/ArrowType.cs +++ b/src/Apache.Arrow/Types/ArrowType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public abstract class ArrowType: IArrowType + public abstract class ArrowType : IArrowType { public abstract ArrowTypeId TypeId { get; } @@ -27,7 +27,7 @@ public abstract class ArrowType: IArrowType public abstract void Accept(IArrowTypeVisitor visitor); internal static void Accept(T type, IArrowTypeVisitor visitor) - where T: class, IArrowType + where T : class, IArrowType { switch (visitor) { diff --git a/src/Apache.Arrow/Types/BinaryType.cs b/src/Apache.Arrow/Types/BinaryType.cs index 6734d93a..74ae61dd 100644 --- a/src/Apache.Arrow/Types/BinaryType.cs +++ b/src/Apache.Arrow/Types/BinaryType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public class BinaryType: ArrowType + public class BinaryType : ArrowType { public static readonly BinaryType Default = new BinaryType(); diff --git a/src/Apache.Arrow/Types/BinaryViewType.cs b/src/Apache.Arrow/Types/BinaryViewType.cs index f5cfc034..8035812b 100644 --- a/src/Apache.Arrow/Types/BinaryViewType.cs +++ b/src/Apache.Arrow/Types/BinaryViewType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public class BinaryViewType: ArrowType + public class BinaryViewType : ArrowType { public static readonly BinaryViewType Default = new BinaryViewType(); diff --git a/src/Apache.Arrow/Types/BooleanType.cs b/src/Apache.Arrow/Types/BooleanType.cs index 3b57414b..2ca1d0e1 100644 --- a/src/Apache.Arrow/Types/BooleanType.cs +++ b/src/Apache.Arrow/Types/BooleanType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public sealed class BooleanType: NumberType + public sealed class BooleanType : NumberType { public static readonly BooleanType Default = new BooleanType(); diff --git a/src/Apache.Arrow/Types/Date32Type.cs b/src/Apache.Arrow/Types/Date32Type.cs index 9673bf62..0eeeef37 100644 --- a/src/Apache.Arrow/Types/Date32Type.cs +++ b/src/Apache.Arrow/Types/Date32Type.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public sealed class Date32Type: DateType + public sealed class Date32Type : DateType { public static readonly Date32Type Default = new Date32Type(); diff --git a/src/Apache.Arrow/Types/DateType.cs b/src/Apache.Arrow/Types/DateType.cs index 8f15b08f..d2e708b9 100644 --- a/src/Apache.Arrow/Types/DateType.cs +++ b/src/Apache.Arrow/Types/DateType.cs @@ -22,7 +22,7 @@ public enum DateUnit Milliseconds = 1 } - public abstract class DateType: FixedWidthType + public abstract class DateType : FixedWidthType { public abstract DateUnit Unit { get; } } diff --git a/src/Apache.Arrow/Types/Decimal256Type.cs b/src/Apache.Arrow/Types/Decimal256Type.cs index b184deb3..707feb6e 100644 --- a/src/Apache.Arrow/Types/Decimal256Type.cs +++ b/src/Apache.Arrow/Types/Decimal256Type.cs @@ -15,7 +15,7 @@ namespace Apache.Arrow.Types { - public sealed class Decimal256Type: FixedSizeBinaryType + public sealed class Decimal256Type : FixedSizeBinaryType { public override ArrowTypeId TypeId => ArrowTypeId.Decimal256; public override string Name => "decimal256"; diff --git a/src/Apache.Arrow/Types/DoubleType.cs b/src/Apache.Arrow/Types/DoubleType.cs index aa6ade65..a9cc79ff 100644 --- a/src/Apache.Arrow/Types/DoubleType.cs +++ b/src/Apache.Arrow/Types/DoubleType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public sealed class DoubleType: FloatingPointType + public sealed class DoubleType : FloatingPointType { public static readonly DoubleType Default = new DoubleType(); diff --git a/src/Apache.Arrow/Types/FixedWidthType.cs b/src/Apache.Arrow/Types/FixedWidthType.cs index d1c9e8c1..9bd97979 100644 --- a/src/Apache.Arrow/Types/FixedWidthType.cs +++ b/src/Apache.Arrow/Types/FixedWidthType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public abstract class FixedWidthType: ArrowType + public abstract class FixedWidthType : ArrowType { public override bool IsFixedWidth => true; diff --git a/src/Apache.Arrow/Types/FloatType.cs b/src/Apache.Arrow/Types/FloatType.cs index a3f7b39b..d8436360 100644 --- a/src/Apache.Arrow/Types/FloatType.cs +++ b/src/Apache.Arrow/Types/FloatType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public sealed class FloatType: FloatingPointType + public sealed class FloatType : FloatingPointType { public static readonly FloatType Default = new FloatType(); diff --git a/src/Apache.Arrow/Types/FloatingPointType.cs b/src/Apache.Arrow/Types/FloatingPointType.cs index 9fbe43a9..f83d8edc 100644 --- a/src/Apache.Arrow/Types/FloatingPointType.cs +++ b/src/Apache.Arrow/Types/FloatingPointType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public abstract class FloatingPointType: NumberType + public abstract class FloatingPointType : NumberType { public enum PrecisionKind { diff --git a/src/Apache.Arrow/Types/HalfFloatType.cs b/src/Apache.Arrow/Types/HalfFloatType.cs index 5bfa232d..ef43196a 100644 --- a/src/Apache.Arrow/Types/HalfFloatType.cs +++ b/src/Apache.Arrow/Types/HalfFloatType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public sealed class HalfFloatType: FloatingPointType + public sealed class HalfFloatType : FloatingPointType { public static readonly HalfFloatType Default = new HalfFloatType(); diff --git a/src/Apache.Arrow/Types/IArrowType.cs b/src/Apache.Arrow/Types/IArrowType.cs index 6020fd41..657b234b 100644 --- a/src/Apache.Arrow/Types/IArrowType.cs +++ b/src/Apache.Arrow/Types/IArrowType.cs @@ -65,10 +65,10 @@ public interface IArrowType ArrowTypeId TypeId { get; } string Name { get; } - + void Accept(IArrowTypeVisitor visitor); bool IsFixedWidth { get; } - + } } diff --git a/src/Apache.Arrow/Types/IArrowTypeVisitor.cs b/src/Apache.Arrow/Types/IArrowTypeVisitor.cs index ce5b114b..9f1c8852 100644 --- a/src/Apache.Arrow/Types/IArrowTypeVisitor.cs +++ b/src/Apache.Arrow/Types/IArrowTypeVisitor.cs @@ -21,8 +21,8 @@ public interface IArrowTypeVisitor void Visit(IArrowType type); } - public interface IArrowTypeVisitor: IArrowTypeVisitor - where T: IArrowType + public interface IArrowTypeVisitor : IArrowTypeVisitor + where T : IArrowType { void Visit(T type); } diff --git a/src/Apache.Arrow/Types/IntegerType.cs b/src/Apache.Arrow/Types/IntegerType.cs index 7a5057c4..06ff55f9 100644 --- a/src/Apache.Arrow/Types/IntegerType.cs +++ b/src/Apache.Arrow/Types/IntegerType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public abstract class IntegerType: NumberType + public abstract class IntegerType : NumberType { } } diff --git a/src/Apache.Arrow/Types/LargeBinaryType.cs b/src/Apache.Arrow/Types/LargeBinaryType.cs index e22c3338..a513065a 100644 --- a/src/Apache.Arrow/Types/LargeBinaryType.cs +++ b/src/Apache.Arrow/Types/LargeBinaryType.cs @@ -15,7 +15,7 @@ namespace Apache.Arrow.Types; -public class LargeBinaryType: ArrowType +public class LargeBinaryType : ArrowType { public static readonly LargeBinaryType Default = new LargeBinaryType(); diff --git a/src/Apache.Arrow/Types/NumberType.cs b/src/Apache.Arrow/Types/NumberType.cs index 04d21bc8..7a49a6be 100644 --- a/src/Apache.Arrow/Types/NumberType.cs +++ b/src/Apache.Arrow/Types/NumberType.cs @@ -16,7 +16,7 @@ namespace Apache.Arrow.Types { - public abstract class NumberType: FixedWidthType + public abstract class NumberType : FixedWidthType { public abstract bool IsSigned { get; } } diff --git a/src/Apache.Arrow/Types/TimeUnit.cs b/src/Apache.Arrow/Types/TimeUnit.cs index ba60fa9b..c97ca28b 100644 --- a/src/Apache.Arrow/Types/TimeUnit.cs +++ b/src/Apache.Arrow/Types/TimeUnit.cs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using System.IO; using System; +using System.IO; namespace Apache.Arrow.Types { diff --git a/test/Apache.Arrow.Benchmarks/ArrowReaderBenchmark.cs b/test/Apache.Arrow.Benchmarks/ArrowReaderBenchmark.cs index cd8198d4..3760d940 100644 --- a/test/Apache.Arrow.Benchmarks/ArrowReaderBenchmark.cs +++ b/test/Apache.Arrow.Benchmarks/ArrowReaderBenchmark.cs @@ -13,15 +13,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System; +using System.IO; +using System.Linq; +using System.Threading.Tasks; using Apache.Arrow.Ipc; using Apache.Arrow.Memory; using Apache.Arrow.Tests; using Apache.Arrow.Types; using BenchmarkDotNet.Attributes; -using System; -using System.IO; -using System.Linq; -using System.Threading.Tasks; namespace Apache.Arrow.Benchmarks { diff --git a/test/Apache.Arrow.Benchmarks/ArrowWriterBenchmark.cs b/test/Apache.Arrow.Benchmarks/ArrowWriterBenchmark.cs index f35c2a5d..36e89219 100644 --- a/test/Apache.Arrow.Benchmarks/ArrowWriterBenchmark.cs +++ b/test/Apache.Arrow.Benchmarks/ArrowWriterBenchmark.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System.IO; +using System.Threading.Tasks; using Apache.Arrow.Ipc; using Apache.Arrow.Tests; using BenchmarkDotNet.Attributes; -using System.IO; -using System.Threading.Tasks; namespace Apache.Arrow.Benchmarks { @@ -26,7 +26,7 @@ namespace Apache.Arrow.Benchmarks public class ArrowWriterBenchmark { [Params(10_000, 1_000_000)] - public int BatchLength{ get; set; } + public int BatchLength { get; set; } //Max column set count is 15 before reaching 2gb limit of memory stream [Params(10, 14)] diff --git a/test/Apache.Arrow.Benchmarks/Program.cs b/test/Apache.Arrow.Benchmarks/Program.cs index 0f1410fc..da4423f4 100644 --- a/test/Apache.Arrow.Benchmarks/Program.cs +++ b/test/Apache.Arrow.Benchmarks/Program.cs @@ -26,4 +26,4 @@ public static void Main(string[] args) .Run(args); } } -} \ No newline at end of file +} diff --git a/test/Apache.Arrow.Compression.Tests/ArrowFileReaderTests.cs b/test/Apache.Arrow.Compression.Tests/ArrowFileReaderTests.cs index 667f25f8..81ff6edd 100644 --- a/test/Apache.Arrow.Compression.Tests/ArrowFileReaderTests.cs +++ b/test/Apache.Arrow.Compression.Tests/ArrowFileReaderTests.cs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Ipc; using System; using System.Reflection; +using Apache.Arrow.Ipc; using Xunit; namespace Apache.Arrow.Compression.Tests @@ -35,8 +35,8 @@ public void CanReadCompressedIpcFile(string fileName) var batch = reader.ReadNextRecordBatch(); - var intArray = (Int32Array) batch.Column("integers"); - var floatArray = (FloatArray) batch.Column("floats"); + var intArray = (Int32Array)batch.Column("integers"); + var floatArray = (FloatArray)batch.Column("floats"); const int numRows = 100; Assert.Equal(numRows, intArray.Length); diff --git a/test/Apache.Arrow.Compression.Tests/ArrowFileWriterTests.cs b/test/Apache.Arrow.Compression.Tests/ArrowFileWriterTests.cs index a237f9c1..d3340a37 100644 --- a/test/Apache.Arrow.Compression.Tests/ArrowFileWriterTests.cs +++ b/test/Apache.Arrow.Compression.Tests/ArrowFileWriterTests.cs @@ -57,7 +57,7 @@ public void CanWriteCompressedIpcFile(CompressionCodecType codec, int? compressi CompressionCodec = codec, CompressionLevel = compressionLevel, }; - TestRoundTripRecordBatches(new [] {batch}, options, codecFactory); + TestRoundTripRecordBatches(new[] { batch }, options, codecFactory); } [Theory] @@ -72,7 +72,7 @@ public async Task CanWriteCompressedIpcFileAsync(CompressionCodecType codec) CompressionCodecFactory = codecFactory, CompressionCodec = codec, }; - await TestRoundTripRecordBatchesAsync(new [] {batch}, options, codecFactory); + await TestRoundTripRecordBatchesAsync(new[] { batch }, options, codecFactory); } private static void TestRoundTripRecordBatches( diff --git a/test/Apache.Arrow.Compression.Tests/ArrowStreamReaderTests.cs b/test/Apache.Arrow.Compression.Tests/ArrowStreamReaderTests.cs index 6f6a26e3..e432e37e 100644 --- a/test/Apache.Arrow.Compression.Tests/ArrowStreamReaderTests.cs +++ b/test/Apache.Arrow.Compression.Tests/ArrowStreamReaderTests.cs @@ -13,9 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Ipc; using System; using System.Reflection; +using Apache.Arrow.Ipc; using Apache.Arrow.Tests; using Xunit; @@ -88,8 +88,8 @@ public void MemoryPoolDisposedOnReadCompressedIpcStream(string fileName) private static void VerifyCompressedIpcFileBatch(RecordBatch batch) { - var intArray = (Int32Array) batch.Column("integers"); - var floatArray = (FloatArray) batch.Column("floats"); + var intArray = (Int32Array)batch.Column("integers"); + var floatArray = (FloatArray)batch.Column("floats"); const int numRows = 100; Assert.Equal(numRows, intArray.Length); diff --git a/test/Apache.Arrow.Compression.Tests/ArrowStreamWriterTests.cs b/test/Apache.Arrow.Compression.Tests/ArrowStreamWriterTests.cs index 1f0f61c1..164de4b6 100644 --- a/test/Apache.Arrow.Compression.Tests/ArrowStreamWriterTests.cs +++ b/test/Apache.Arrow.Compression.Tests/ArrowStreamWriterTests.cs @@ -58,7 +58,7 @@ public void CanWriteCompressedIpcStream(CompressionCodecType codec, int? compres CompressionCodec = codec, CompressionLevel = compressionLevel, }; - TestRoundTripRecordBatches(new [] {batch}, options, codecFactory); + TestRoundTripRecordBatches(new[] { batch }, options, codecFactory); } [Theory] @@ -73,7 +73,7 @@ public async Task CanWriteCompressedIpcStreamAsync(CompressionCodecType codec) CompressionCodecFactory = codecFactory, CompressionCodec = codec, }; - await TestRoundTripRecordBatchesAsync(new [] {batch}, options, codecFactory); + await TestRoundTripRecordBatchesAsync(new[] { batch }, options, codecFactory); } [Fact] @@ -86,7 +86,7 @@ public void CanWriteEmptyBatches() CompressionCodecFactory = codecFactory, CompressionCodec = CompressionCodecType.Lz4Frame, }; - TestRoundTripRecordBatches(new [] {batch}, options, codecFactory); + TestRoundTripRecordBatches(new[] { batch }, options, codecFactory); } [Theory] @@ -120,11 +120,11 @@ public async Task MemoryOwnerDisposal(CompressionCodecType codec) var allocator = new TestMemoryAllocator(); var originalBatch = TestData.CreateSampleRecordBatch(length: 100); var options = new IpcOptions() { CompressionCodecFactory = new CompressionCodecFactory(), CompressionCodec = codec }; - await TestRoundTripRecordBatchesAsync(new List () {originalBatch}, options, options.CompressionCodecFactory, + await TestRoundTripRecordBatchesAsync(new List() { originalBatch }, options, options.CompressionCodecFactory, allocator); Assert.True(allocator.Statistics.Allocations > 0); // make sure all memory allocated by the writer was disposed - Assert.Equal(0,allocator.Rented); + Assert.Equal(0, allocator.Rented); } private static void TestRoundTripRecordBatches( diff --git a/test/Apache.Arrow.Flight.IntegrationTest/Scenarios/JsonTestScenario.cs b/test/Apache.Arrow.Flight.IntegrationTest/Scenarios/JsonTestScenario.cs index 78475104..6b253663 100644 --- a/test/Apache.Arrow.Flight.IntegrationTest/Scenarios/JsonTestScenario.cs +++ b/test/Apache.Arrow.Flight.IntegrationTest/Scenarios/JsonTestScenario.cs @@ -23,8 +23,8 @@ using Apache.Arrow.Tests; using Apache.Arrow.Types; using Google.Protobuf; -using Grpc.Net.Client; using Grpc.Core; +using Grpc.Net.Client; using Grpc.Net.Client.Balancer; using Microsoft.Extensions.DependencyInjection; diff --git a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlClientTests.cs b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlClientTests.cs index 17a5e6f8..38a6fe83 100644 --- a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlClientTests.cs +++ b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlClientTests.cs @@ -139,7 +139,7 @@ public async Task PreparedAsync(string transactionId, bool expectTransaction) PreparedStatement preparedStatement; if (expectTransaction) { - preparedStatement = await _flightSqlClient.PrepareAsync(query, transaction); + preparedStatement = await _flightSqlClient.PrepareAsync(query, transaction); } else { @@ -865,4 +865,4 @@ private void CompareSchemas(Schema expectedSchema, Schema actualSchema) Assert.Equal(expectedField.Metadata, actualField.Metadata); } } -} \ No newline at end of file +} diff --git a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlPreparedStatementTests.cs b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlPreparedStatementTests.cs index 24647bf1..3e402930 100644 --- a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlPreparedStatementTests.cs +++ b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlPreparedStatementTests.cs @@ -68,7 +68,7 @@ private RecordBatch CreateParameterBatch() new Int32Array.Builder().AppendRange(new[] { 32, 255, 1 }).Build() }, 3); } - + [Fact] public async Task ExecuteAsync_ShouldReturnFlightInfo_WhenValidInputsAreProvided() { @@ -184,7 +184,7 @@ public async Task ParseResponseAsync_ShouldThrowException_WhenPreparedStatementH ActionCreatePreparedStatementResult actionResult = string.IsNullOrEmpty(handle) ? new ActionCreatePreparedStatementResult() : new ActionCreatePreparedStatementResult - { PreparedStatementHandle = ByteString.CopyFrom(handle, Encoding.UTF8) }; + { PreparedStatementHandle = ByteString.CopyFrom(handle, Encoding.UTF8) }; var flightData = new FlightData(_flightDescriptor, ByteString.CopyFrom(actionResult.ToByteArray())); var results = GetAsyncEnumerable(new List { flightData }); @@ -223,4 +223,4 @@ public static RecordBatch CreateRecordBatch(int[] values) return new RecordBatch.Builder().Append("field1", true, int32Array).Build(); } } -} \ No newline at end of file +} diff --git a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlServerTests.cs b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlServerTests.cs index e5e64b07..db33da9a 100644 --- a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlServerTests.cs +++ b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlServerTests.cs @@ -43,7 +43,7 @@ public void EnsureGetCommandReturnsTheCorrectResponse(FlightDescriptorType type, if (type == FlightDescriptorType.Command) { descriptor = expectedResult != null ? - FlightDescriptor.CreateCommandDescriptor(((IMessage) Activator.CreateInstance(expectedResult!)!).PackAndSerialize().ToByteArray()) : + FlightDescriptor.CreateCommandDescriptor(((IMessage)Activator.CreateInstance(expectedResult!)!).PackAndSerialize().ToByteArray()) : FlightDescriptor.CreateCommandDescriptor(ByteString.Empty.ToStringUtf8()); } else @@ -74,14 +74,14 @@ public async Task EnsureTheCorrectActionsAreGiven() [Theory] [InlineData(false, - new[] {"catalog_name", "db_schema_name", "table_name", "table_type"}, - new[] {typeof(StringType), typeof(StringType), typeof(StringType), typeof(StringType)}, - new[] {true, true, false, false}) + new[] { "catalog_name", "db_schema_name", "table_name", "table_type" }, + new[] { typeof(StringType), typeof(StringType), typeof(StringType), typeof(StringType) }, + new[] { true, true, false, false }) ] [InlineData(true, - new[] {"catalog_name", "db_schema_name", "table_name", "table_type", "table_schema"}, - new[] {typeof(StringType), typeof(StringType), typeof(StringType), typeof(StringType), typeof(BinaryType)}, - new[] {true, true, false, false, false}) + new[] { "catalog_name", "db_schema_name", "table_name", "table_type", "table_schema" }, + new[] { typeof(StringType), typeof(StringType), typeof(StringType), typeof(StringType), typeof(BinaryType) }, + new[] { true, true, false, false, false }) ] public void EnsureTableSchemaIsCorrectWithoutTableSchema(bool includeTableSchemaField, string[] expectedNames, Type[] expectedTypes, bool[] expectedIsNullable) { @@ -119,7 +119,7 @@ public void EnsureTableSchemaIsCorrectWithoutTableSchema(bool includeTableSchema public async Task EnsureGetFlightInfoIsCorrectlyRoutedForCommand(Type commandType, string expectedResult) { //Given - var command = (IMessage) Activator.CreateInstance(commandType)!; + var command = (IMessage)Activator.CreateInstance(commandType)!; var producer = new TestFlightSqlSever(); var descriptor = FlightDescriptor.CreateCommandDescriptor(command.PackAndSerialize().ToArray()); @@ -180,7 +180,7 @@ public async Task EnsureDoGetIsCorrectlyRoutedForADoGetCommand(Type commandType, { //Given var producer = new TestFlightSqlSever(); - var command = (IMessage) Activator.CreateInstance(commandType)!; + var command = (IMessage)Activator.CreateInstance(commandType)!; var ticket = new FlightTicket(command.PackAndSerialize()); var streamWriter = new MockServerStreamWriter(); @@ -218,7 +218,7 @@ public async Task EnsureDoActionIsCorrectlyRoutedForAnActionRequest(string actio { //Given var producer = new TestFlightSqlSever(); - var actionBody = (IMessage) Activator.CreateInstance(actionBodyType)!; + var actionBody = (IMessage)Activator.CreateInstance(actionBodyType)!; var action = new FlightAction(actionType, actionBody.PackAndSerialize()); var mockStreamWriter = new MockStreamWriter(); @@ -241,7 +241,7 @@ public async Task EnsureDoActionIsCorrectlyRoutedForAnActionRequest(string actio public async Task EnsureDoPutIsCorrectlyRoutedForTheCommand(Type commandType, string expectedResponse, bool isException = false) { //Given - var command = (IMessage) Activator.CreateInstance(commandType)!; + var command = (IMessage)Activator.CreateInstance(commandType)!; var producer = new TestFlightSqlSever(); var descriptor = FlightDescriptor.CreateCommandDescriptor(command.PackAndSerialize().ToArray()); var recordBatch = new RecordBatch(new Schema(new List(), null), System.Array.Empty(), 0); @@ -338,7 +338,7 @@ public static async Task> ToFlightData(this RecordBatch } } -internal class MockStreamReader: IAsyncStreamReader +internal class MockStreamReader : IAsyncStreamReader { private readonly IEnumerator _flightActions; diff --git a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlTestExtensions.cs b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlTestExtensions.cs index c1cd8f2b..f82b3a68 100644 --- a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlTestExtensions.cs +++ b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlTestExtensions.cs @@ -97,13 +97,13 @@ public static RecordBatch CreateRecordBatch(int[] values) return new RecordBatch(schema.Build(), paramsList, values.Length); } - + public static void PrintSchema(this Schema schema) { Console.WriteLine("Schema Fields:"); Console.WriteLine("{0,-20} {1,-20} {2,-20}", "Field Name", "Field Type", "Is Nullable"); Console.WriteLine(new string('-', 60)); - + foreach (var field in schema.FieldsLookup) { string fieldName = field.First().Name; @@ -125,7 +125,7 @@ public static string GetStringValue(IArrowArray array, int index) _ => "Unsupported Type" }; } - + public static void PrintRecordBatch(RecordBatch recordBatch) { int rowCount = recordBatch.Length; @@ -158,7 +158,7 @@ public static RecordBatch CreateRecordBatch(int[] ids, string[] values) return new RecordBatch(schema, [idArrayBuilder.Build(), valueArrayBuilder.Build()], ids.Length); } - + public static RecordBatch CreateRecordBatch(T[] items) { if (items is null || items.Length == 0) @@ -167,7 +167,7 @@ public static RecordBatch CreateRecordBatch(T[] items) } var schema = BuildSchema(typeof(T)); - + var arrays = new List(); foreach (var field in schema.FieldsList) { @@ -176,7 +176,7 @@ public static RecordBatch CreateRecordBatch(T[] items) { throw new InvalidOperationException($"Property {field.Name} not found in type {typeof(T).Name}."); } - + // extract values and build the array var values = items.Select(item => property.GetValue(item, null)).ToArray(); var array = BuildArrowArray(field.DataType, values); @@ -196,7 +196,7 @@ private static Schema BuildSchema(Type type) return builder.Build(); } - + private static IArrowType InferArrowType(Type type) { return type switch @@ -209,7 +209,7 @@ private static IArrowType InferArrowType(Type type) _ => throw new NotSupportedException($"Unsupported type: {type}") }; } - + private static IArrowArray BuildArrowArray(IArrowType dataType, object[] values, MemoryAllocator allocator = default) { allocator ??= MemoryAllocator.Default.Value; @@ -224,7 +224,7 @@ private static IArrowArray BuildArrowArray(IArrowType dataType, object[] values, _ => throw new NotSupportedException($"Unsupported Arrow type: {dataType}") }; } - + private static IArrowArray BuildStringArray(object[] values) { var builder = new StringArray.Builder(); @@ -243,7 +243,7 @@ private static IArrowArray BuildStringArray(object[] values) return builder.Build(); } - + private static IArrowArray BuildArray(object[] values, MemoryAllocator allocator) where TArray : IArrowArray where TBuilder : IArrowArrayBuilder, new() @@ -264,4 +264,4 @@ private static IArrowArray BuildArray(object[] values, Memo return builder.Build(allocator); } -} \ No newline at end of file +} diff --git a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlTestUtils.cs b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlTestUtils.cs index e32cc198..d3f55fd9 100644 --- a/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlTestUtils.cs +++ b/test/Apache.Arrow.Flight.Sql.Tests/FlightSqlTestUtils.cs @@ -30,7 +30,7 @@ public FlightSqlTestUtils(TestFlightSqlWebFactory testWebFactory, FlightStore fl _flightStore = flightStore; } - public RecordBatch CreateTestBatch(int startValue, int length) + public RecordBatch CreateTestBatch(int startValue, int length) { var batchBuilder = new RecordBatch.Builder(); Int32Array.Builder builder = new(); diff --git a/test/Apache.Arrow.Flight.Sql.Tests/Startup.cs b/test/Apache.Arrow.Flight.Sql.Tests/Startup.cs index b99418ce..ec942233 100644 --- a/test/Apache.Arrow.Flight.Sql.Tests/Startup.cs +++ b/test/Apache.Arrow.Flight.Sql.Tests/Startup.cs @@ -54,4 +54,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) }); }); } -} \ No newline at end of file +} diff --git a/test/Apache.Arrow.Flight.Sql.Tests/TestFlightSqlSever.cs b/test/Apache.Arrow.Flight.Sql.Tests/TestFlightSqlSever.cs index 3dca632b..bea8bca2 100644 --- a/test/Apache.Arrow.Flight.Sql.Tests/TestFlightSqlSever.cs +++ b/test/Apache.Arrow.Flight.Sql.Tests/TestFlightSqlSever.cs @@ -83,7 +83,7 @@ public class TestFlightSqlSever : FlightSqlServer private RecordBatch MockRecordBatch(string name) { - var schema = new Schema(new List {new(name, StringType.Default, false)}, System.Array.Empty>()); - return new RecordBatch(schema, new []{ new StringArray.Builder().Append(name).Build() }, 1); + var schema = new Schema(new List { new(name, StringType.Default, false) }, System.Array.Empty>()); + return new RecordBatch(schema, new[] { new StringArray.Builder().Append(name).Build() }, 1); } } diff --git a/test/Apache.Arrow.Flight.Sql.Tests/TestFlightSqlWebFactory.cs b/test/Apache.Arrow.Flight.Sql.Tests/TestFlightSqlWebFactory.cs index 594c5d88..4fb400a1 100644 --- a/test/Apache.Arrow.Flight.Sql.Tests/TestFlightSqlWebFactory.cs +++ b/test/Apache.Arrow.Flight.Sql.Tests/TestFlightSqlWebFactory.cs @@ -79,4 +79,4 @@ public void Dispose() { Stop(); } -} \ No newline at end of file +} diff --git a/test/Apache.Arrow.Flight.TestWeb/FlightHolder.cs b/test/Apache.Arrow.Flight.TestWeb/FlightHolder.cs index b79edc4a..d0c01899 100644 --- a/test/Apache.Arrow.Flight.TestWeb/FlightHolder.cs +++ b/test/Apache.Arrow.Flight.TestWeb/FlightHolder.cs @@ -30,7 +30,7 @@ public class FlightHolder //Not thread safe, but only used in tests private readonly List _recordBatches = new List(); - + public FlightHolder(FlightDescriptor flightDescriptor, Schema schema, string location) { _flightDescriptor = flightDescriptor; @@ -52,7 +52,7 @@ public IEnumerable GetRecordBatches() public FlightInfo GetFlightInfo() { int batchArrayLength = _recordBatches.Sum(rb => rb.RecordBatch.Length); - int batchBytes = _recordBatches.Sum(rb => rb.RecordBatch.Arrays.Sum(arr => arr.Data.Buffers.Sum(b=>b.Length))); + int batchBytes = _recordBatches.Sum(rb => rb.RecordBatch.Arrays.Sum(arr => arr.Data.Buffers.Sum(b => b.Length))); return new FlightInfo(_schema, _flightDescriptor, new List() { new FlightEndpoint(new FlightTicket(GetTicket(_flightDescriptor)), new List(){ @@ -67,7 +67,7 @@ private string GetTicket(FlightDescriptor descriptor) { return descriptor.Paths.FirstOrDefault(); } - + if (descriptor.Command.Length > 0) { return $"{descriptor.Command.ToStringUtf8()}"; @@ -76,4 +76,4 @@ private string GetTicket(FlightDescriptor descriptor) return "default_custom_ticket"; } } -} \ No newline at end of file +} diff --git a/test/Apache.Arrow.Flight.TestWeb/TestFlightServer.cs b/test/Apache.Arrow.Flight.TestWeb/TestFlightServer.cs index 5689b45b..b0d07ba5 100644 --- a/test/Apache.Arrow.Flight.TestWeb/TestFlightServer.cs +++ b/test/Apache.Arrow.Flight.TestWeb/TestFlightServer.cs @@ -49,13 +49,13 @@ public override async Task DoGet(FlightTicket ticket, FlightServerRecordBatchStr { var flightDescriptor = FlightDescriptor.CreatePathDescriptor(ticket.Ticket.ToStringUtf8()); - if(_flightStore.Flights.TryGetValue(flightDescriptor, out var flightHolder)) + if (_flightStore.Flights.TryGetValue(flightDescriptor, out var flightHolder)) { await responseStream.SetupStream(flightHolder.GetFlightInfo().Schema); var batches = flightHolder.GetRecordBatches(); - foreach(var batch in batches) + foreach (var batch in batches) { await responseStream.WriteAsync(batch.RecordBatch, batch.Metadata); } @@ -66,7 +66,7 @@ public override async Task DoPut(FlightServerRecordBatchStreamReader requestStre { var flightDescriptor = await requestStream.FlightDescriptor; - if(!_flightStore.Flights.TryGetValue(flightDescriptor, out var flightHolder)) + if (!_flightStore.Flights.TryGetValue(flightDescriptor, out var flightHolder)) { flightHolder = new FlightHolder(flightDescriptor, await requestStream.Schema, $"grpc+tcp://{context.Host}"); _flightStore.Flights.Add(flightDescriptor, flightHolder); @@ -83,7 +83,7 @@ await responseStream.WriteAsync( public override Task GetFlightInfo(FlightDescriptor request, ServerCallContext context) { - if(_flightStore.Flights.TryGetValue(request, out var flightHolder)) + if (_flightStore.Flights.TryGetValue(request, out var flightHolder)) { return Task.FromResult(flightHolder.GetFlightInfo()); } @@ -107,7 +107,7 @@ public override async Task Handshake(IAsyncStreamReader public override Task GetSchema(FlightDescriptor request, ServerCallContext context) { - if(_flightStore.Flights.TryGetValue(request, out var flightHolder)) + if (_flightStore.Flights.TryGetValue(request, out var flightHolder)) { return Task.FromResult(flightHolder.GetFlightInfo().Schema); } @@ -126,7 +126,7 @@ public override async Task ListFlights(FlightCriteria request, IAsyncStreamWrite { var flightInfos = _flightStore.Flights.Select(x => x.Value.GetFlightInfo()).ToList(); - foreach(var flightInfo in flightInfos) + foreach (var flightInfo in flightInfos) { await responseStream.WriteAsync(flightInfo); } @@ -134,7 +134,7 @@ public override async Task ListFlights(FlightCriteria request, IAsyncStreamWrite public override async Task DoExchange(FlightServerRecordBatchStreamReader requestStream, FlightServerRecordBatchStreamWriter responseStream, ServerCallContext context) { - while(await requestStream.MoveNext().ConfigureAwait(false)) + while (await requestStream.MoveNext().ConfigureAwait(false)) { await responseStream.WriteAsync(requestStream.Current, requestStream.ApplicationMetadata.FirstOrDefault()).ConfigureAwait(false); } diff --git a/test/Apache.Arrow.Flight.TestWeb/TestFlightSqlServer.cs b/test/Apache.Arrow.Flight.TestWeb/TestFlightSqlServer.cs index a7aaad4f..60ece65c 100644 --- a/test/Apache.Arrow.Flight.TestWeb/TestFlightSqlServer.cs +++ b/test/Apache.Arrow.Flight.TestWeb/TestFlightSqlServer.cs @@ -97,7 +97,7 @@ public override async Task DoGet(FlightTicket ticket, FlightServerRecordBatchStr } } } - + public override async Task DoPut(FlightServerRecordBatchStreamReader requestStream, IAsyncStreamWriter responseStream, ServerCallContext context) { var flightDescriptor = await requestStream.FlightDescriptor; @@ -107,7 +107,7 @@ public override async Task DoPut(FlightServerRecordBatchStreamReader requestStre flightHolder = new FlightHolder(flightDescriptor, await requestStream.Schema, $"http://{context.Host}"); _flightStore.Flights.Add(flightDescriptor, flightHolder); } - + int affectedRows = 0; while (await requestStream.MoveNext()) { @@ -129,7 +129,7 @@ public override async Task DoPut(FlightServerRecordBatchStreamReader requestStre var flightPutResult = new FlightPutResult(metadata); await responseStream.WriteAsync(flightPutResult); } - + public override Task GetFlightInfo(FlightDescriptor request, ServerCallContext context) { if (_flightStore.Flights.TryGetValue(request, out var flightHolder)) @@ -144,7 +144,7 @@ public override Task GetFlightInfo(FlightDescriptor request, ServerC throw new RpcException(new Status(StatusCode.NotFound, "Flight not found")); } - + public override Task GetSchema(FlightDescriptor request, ServerCallContext context) { if (_flightStore.Flights.TryGetValue(request, out var flightHolder)) diff --git a/test/Apache.Arrow.Flight.Tests/FlightInfoComparer.cs b/test/Apache.Arrow.Flight.Tests/FlightInfoComparer.cs index 8f3af17d..a55304ac 100644 --- a/test/Apache.Arrow.Flight.Tests/FlightInfoComparer.cs +++ b/test/Apache.Arrow.Flight.Tests/FlightInfoComparer.cs @@ -38,7 +38,7 @@ public static void Compare(FlightInfo expected, FlightInfo actual) Assert.Equal(expected.Ordered, actual.Ordered); Assert.Equal(expected.AppMetadata, actual.AppMetadata); - + } } } diff --git a/test/Apache.Arrow.Flight.Tests/FlightTests.cs b/test/Apache.Arrow.Flight.Tests/FlightTests.cs index acdd8245..b1b52e80 100644 --- a/test/Apache.Arrow.Flight.Tests/FlightTests.cs +++ b/test/Apache.Arrow.Flight.Tests/FlightTests.cs @@ -512,7 +512,7 @@ public async Task EnsureCallRaisesRequestCancelled() { var cts = new CancellationTokenSource(); cts.CancelAfter(1); - + var batch = CreateTestBatch(0, 100); var metadata = new Metadata(); var flightDescriptor = FlightDescriptor.CreatePathDescriptor("raise_cancelled"); diff --git a/test/Apache.Arrow.IntegrationTest/CDataInterface.cs b/test/Apache.Arrow.IntegrationTest/CDataInterface.cs index 2fabae1a..3f701dcb 100644 --- a/test/Apache.Arrow.IntegrationTest/CDataInterface.cs +++ b/test/Apache.Arrow.IntegrationTest/CDataInterface.cs @@ -18,8 +18,8 @@ using System.Data; using System.Diagnostics; using System.IO; -using Apache.Arrow.C; using Apache.Arrow.Arrays; +using Apache.Arrow.C; using Apache.Arrow.Types; namespace Apache.Arrow.IntegrationTest @@ -45,22 +45,22 @@ public static void Initialize() public static unsafe Schema ImportSchema(long ptr) { - return CArrowSchemaImporter.ImportSchema((CArrowSchema*) ptr); + return CArrowSchemaImporter.ImportSchema((CArrowSchema*)ptr); } public static unsafe void ExportSchema(Schema schema, long ptr) { - CArrowSchemaExporter.ExportSchema(schema, (CArrowSchema*) ptr); + CArrowSchemaExporter.ExportSchema(schema, (CArrowSchema*)ptr); } public static unsafe RecordBatch ImportRecordBatch(long ptr, Schema schema) { - return CArrowArrayImporter.ImportRecordBatch((CArrowArray*) ptr, schema); + return CArrowArrayImporter.ImportRecordBatch((CArrowArray*)ptr, schema); } public static unsafe void ExportRecordBatch(RecordBatch batch, long ptr) { - CArrowArrayExporter.ExportRecordBatch(batch, (CArrowArray*) ptr); + CArrowArrayExporter.ExportRecordBatch(batch, (CArrowArray*)ptr); } public static JsonFile ParseJsonFile(string jsonPath) diff --git a/test/Apache.Arrow.IntegrationTest/Program.cs b/test/Apache.Arrow.IntegrationTest/Program.cs index 24326938..8dedd60f 100644 --- a/test/Apache.Arrow.IntegrationTest/Program.cs +++ b/test/Apache.Arrow.IntegrationTest/Program.cs @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.CommandLine; @@ -21,6 +20,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using Apache.Arrow.Types; namespace Apache.Arrow.IntegrationTest { diff --git a/test/Apache.Arrow.Tests/ArrayBuilderTests.cs b/test/Apache.Arrow.Tests/ArrayBuilderTests.cs index f789d6a3..7588c346 100644 --- a/test/Apache.Arrow.Tests/ArrayBuilderTests.cs +++ b/test/Apache.Arrow.Tests/ArrayBuilderTests.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Linq; using System.Numerics; +using Apache.Arrow.Types; using Xunit; namespace Apache.Arrow.Tests diff --git a/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs b/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs index a45a50c4..758c4260 100644 --- a/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs +++ b/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs @@ -257,7 +257,7 @@ public void Visit(BinaryType type) => } else { - builder.Append(new byte[] {(byte)x, (byte)(x + 1)}.AsSpan()); + builder.Append(new byte[] { (byte)x, (byte)(x + 1) }.AsSpan()); } }); @@ -270,7 +270,7 @@ public void Visit(BinaryViewType type) => } else { - builder.Append(new byte[] {(byte)x, (byte)(x + 1)}.AsSpan()); + builder.Append(new byte[] { (byte)x, (byte)(x + 1) }.AsSpan()); } }); @@ -525,7 +525,7 @@ private void GenerateTestData(IArrowType type, Func( - IArrowType type, Action buildAction, Action initAction=null) + IArrowType type, Action buildAction, Action initAction = null) where TArrayBuilder : IArrowArrayBuilder where TArray : IArrowArray { diff --git a/test/Apache.Arrow.Tests/ArrowArrayTests.cs b/test/Apache.Arrow.Tests/ArrowArrayTests.cs index c3c21c41..f96ce7ec 100644 --- a/test/Apache.Arrow.Tests/ArrowArrayTests.cs +++ b/test/Apache.Arrow.Tests/ArrowArrayTests.cs @@ -101,7 +101,7 @@ public void EnumerateArray() { var array = new Int64Array.Builder().Append(1).Append(2).Build(); - foreach(long? foo in array) + foreach (long? foo in array) { Assert.InRange(foo!.Value, 1, 2); } @@ -262,14 +262,14 @@ public void RecursiveArraySlice() var initialValues = Enumerable.Range(0, 100).ToArray(); var array = new Int32Array.Builder().AppendRange(initialValues).Build(); - var sliced = (Int32Array) array.Slice(20, 30); - var slicedAgain = (Int32Array) sliced.Slice(5, 10); + var sliced = (Int32Array)array.Slice(20, 30); + var slicedAgain = (Int32Array)sliced.Slice(5, 10); Assert.Equal(25, slicedAgain.Offset); Assert.Equal(10, slicedAgain.Length); Assert.Equal( - initialValues.Skip(25).Take(10).Select(val => (int?) val).ToArray(), - (IReadOnlyList) slicedAgain); + initialValues.Skip(25).Take(10).Select(val => (int?)val).ToArray(), + (IReadOnlyList)slicedAgain); } #if NET5_0_OR_GREATER @@ -461,7 +461,7 @@ private void ValidateArrays(BooleanArray slicedArray) Assert.True(baseArray.Values.SequenceEqual(slicedArray.Values)); Assert.True( - baseArray.ValueBuffer.Span.Slice(0, (int) Math.Ceiling(slicedArray.Length / 8.0)) + baseArray.ValueBuffer.Span.Slice(0, (int)Math.Ceiling(slicedArray.Length / 8.0)) .SequenceEqual(slicedArray.Values)); Assert.Equal(baseArray.GetValue(slicedArray.Offset), slicedArray.GetValue(0)); diff --git a/test/Apache.Arrow.Tests/ArrowBufferBitmapBuilderTests.cs b/test/Apache.Arrow.Tests/ArrowBufferBitmapBuilderTests.cs index a4e698f5..148ccea0 100644 --- a/test/Apache.Arrow.Tests/ArrowBufferBitmapBuilderTests.cs +++ b/test/Apache.Arrow.Tests/ArrowBufferBitmapBuilderTests.cs @@ -28,8 +28,8 @@ public class ArrowBufferBitmapBuilderTests public class Append { [Theory] - [InlineData(new bool[] {}, false, 1, 0, 1)] - [InlineData(new bool[] {}, true, 1, 1, 0)] + [InlineData(new bool[] { }, false, 1, 0, 1)] + [InlineData(new bool[] { }, true, 1, 1, 0)] [InlineData(new[] { true, false }, true, 3, 2, 1)] [InlineData(new[] { true, false }, false, 3, 1, 2)] public void IncreasesLength( @@ -55,8 +55,8 @@ public void IncreasesLength( } [Theory] - [InlineData(new bool[] {}, false)] - [InlineData(new bool[] {}, true)] + [InlineData(new bool[] { }, false)] + [InlineData(new bool[] { }, true)] [InlineData(new[] { true, false }, true)] [InlineData(new[] { true, false }, false)] public void AfterClearIncreasesLength(bool[] initialContentsToClear, bool valueToAppend) @@ -98,7 +98,7 @@ public void IncreasesCapacityWhenRequired() public class AppendSpan { [Theory] - [InlineData(new byte[] { 0b00000110 }, 4, 4, 2, 2)] + [InlineData(new byte[] { 0b00000110 }, 4, 4, 2, 2)] [InlineData(new byte[] { 0b11111110 }, 4, 4, 3, 1)] [InlineData(new byte[] { 0b11111110, 0b00000001 }, 9, 9, 8, 1)] [InlineData(new byte[] { 0b11111001, 0b00000001 }, 9, 9, 7, 2)] @@ -209,9 +209,9 @@ public void ThrowsWhenLengthIsTooBig() public class AppendRange { [Theory] - [InlineData(new bool[] {}, new bool[] {}, 0, 0, 0)] - [InlineData(new bool[] {}, new[] { true, false }, 2, 1, 1)] - [InlineData(new[] { true, false }, new bool[] {}, 2, 1, 1)] + [InlineData(new bool[] { }, new bool[] { }, 0, 0, 0)] + [InlineData(new bool[] { }, new[] { true, false }, 2, 1, 1)] + [InlineData(new[] { true, false }, new bool[] { }, 2, 1, 1)] [InlineData(new[] { true, false }, new[] { true, false }, 4, 2, 2)] public void AppendingEnumerableIncreasesLength( bool[] initialContents, @@ -311,11 +311,11 @@ public void ClearingSetsBitCountToZero(int numBitsBeforeClear) public class Resize { [Theory] - [InlineData(new bool[] {}, 256, 0, 256)] - [InlineData(new[] { true, true, true, true}, 256, 4, 252)] - [InlineData(new[] { false, false, false, false}, 256, 0, 256)] - [InlineData(new[] { true, true, true, true}, 2, 2, 0)] - [InlineData(new[] { true, true, true, true}, 0, 0, 0)] + [InlineData(new bool[] { }, 256, 0, 256)] + [InlineData(new[] { true, true, true, true }, 256, 4, 252)] + [InlineData(new[] { false, false, false, false }, 256, 0, 256)] + [InlineData(new[] { true, true, true, true }, 2, 2, 0)] + [InlineData(new[] { true, true, true, true }, 0, 0, 0)] public void LengthHasExpectedValueAfterResize( bool[] bits, int newSize, int expectedSetBitCount, int expectedUnsetBitCount) { @@ -383,22 +383,22 @@ public class Set { [Theory] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 2, new byte[] { 0b01010101, 0b00000001 }, 5, 5)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 3, new byte[] { 0b01011101, 0b00000001 }, 6, 4)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 8, new byte[] { 0b01010101, 0b00000001 }, 5, 5)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 9, new byte[] { 0b01010101, 0b00000011 }, 6, 4)] @@ -423,42 +423,42 @@ public void OverloadWithNoValueParameterSetsAsExpected( [Theory] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 2, true, new byte[] { 0b01010101, 0b00000001 }, 5, 5)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 2, false, new byte[] { 0b01010001, 0b00000001 }, 4, 6)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 3, true, new byte[] { 0b01011101, 0b00000001 }, 6, 4)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 3, false, new byte[] { 0b01010101, 0b00000001 }, 5, 5)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 8, true, new byte[] { 0b01010101, 0b00000001 }, 5, 5)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 8, false, new byte[] { 0b01010101, 0b00000000 }, 4, 6)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 9, true, new byte[] { 0b01010101, 0b00000011 }, 6, 4)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 9, false, new byte[] { 0b01010101, 0b00000001 }, 5, 5)] @@ -504,19 +504,19 @@ public class Swap { [Theory] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 0, 2, new byte[] { 0b01010101, 0b00000001 })] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 0, 3, new byte[] { 0b01011100, 0b00000001 })] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 4, 8, new byte[] { 0b01010101, 0b00000001 })] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 4, 9, new byte[] { 0b01000101, 0b00000011 })] public void SwapsAsExpected(bool[] bits, int firstIndex, int secondIndex, byte[] expectedBytes) @@ -565,22 +565,22 @@ public class Toggle { [Theory] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 2, new byte[] { 0b01010001, 0b00000001 }, 4, 6)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 3, new byte[] { 0b01011101, 0b00000001 }, 6, 4)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 8, new byte[] { 0b01010101, 0b00000000 }, 4, 6)] [InlineData( - new[] { true, false, true, false, true, false, true, false, true, false}, + new[] { true, false, true, false, true, false, true, false, true, false }, 9, new byte[] { 0b01010101, 0b00000011 }, 6, 4)] diff --git a/test/Apache.Arrow.Tests/ArrowBufferTests.cs b/test/Apache.Arrow.Tests/ArrowBufferTests.cs index e6fa5256..15ab3d30 100644 --- a/test/Apache.Arrow.Tests/ArrowBufferTests.cs +++ b/test/Apache.Arrow.Tests/ArrowBufferTests.cs @@ -13,16 +13,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Tests.Fixtures; using System; using System.Runtime.InteropServices; +using Apache.Arrow.Tests.Fixtures; using Xunit; namespace Apache.Arrow.Tests { public class ArrowBufferTests { - public class Allocate : + public class Allocate : IClassFixture { private readonly DefaultMemoryAllocatorFixture _memoryPoolFixture; @@ -73,7 +73,7 @@ public unsafe void AllocatesAlignedToMultipleOf64(int size) var buffer = builder.Build(); fixed (byte* ptr = &buffer.Span.GetPinnableReference()) - { + { Assert.True(new IntPtr(ptr).ToInt64() % 64 == 0); } } @@ -85,7 +85,7 @@ public unsafe void AllocatesAlignedToMultipleOf64(int size) public void HasZeroPadding() { var buffer = new ArrowBuffer.Builder(10).Append(0).Build(); - + foreach (var b in buffer.Span) { Assert.Equal(0, b); diff --git a/test/Apache.Arrow.Tests/ArrowFileReaderTests.cs b/test/Apache.Arrow.Tests/ArrowFileReaderTests.cs index 585b1acc..b86e6ec8 100644 --- a/test/Apache.Arrow.Tests/ArrowFileReaderTests.cs +++ b/test/Apache.Arrow.Tests/ArrowFileReaderTests.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Ipc; using System; using System.IO; using System.Reflection; using System.Threading.Tasks; +using Apache.Arrow.Ipc; using Xunit; namespace Apache.Arrow.Tests diff --git a/test/Apache.Arrow.Tests/ArrowFileWriterTests.cs b/test/Apache.Arrow.Tests/ArrowFileWriterTests.cs index 7b259101..60980e28 100644 --- a/test/Apache.Arrow.Tests/ArrowFileWriterTests.cs +++ b/test/Apache.Arrow.Tests/ArrowFileWriterTests.cs @@ -13,12 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Ipc; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; +using Apache.Arrow.Ipc; using Apache.Arrow.Types; using Xunit; diff --git a/test/Apache.Arrow.Tests/ArrowReaderVerifier.cs b/test/Apache.Arrow.Tests/ArrowReaderVerifier.cs index 5977c328..bdbe4bbf 100644 --- a/test/Apache.Arrow.Tests/ArrowReaderVerifier.cs +++ b/test/Apache.Arrow.Tests/ArrowReaderVerifier.cs @@ -13,14 +13,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Ipc; -using Apache.Arrow.Types; using System; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Apache.Arrow.Arrays; +using Apache.Arrow.Ipc; +using Apache.Arrow.Types; using Xunit; -using System.Diagnostics; namespace Apache.Arrow.Tests { diff --git a/test/Apache.Arrow.Tests/ArrowStreamReaderTests.cs b/test/Apache.Arrow.Tests/ArrowStreamReaderTests.cs index c375457f..15dc425c 100644 --- a/test/Apache.Arrow.Tests/ArrowStreamReaderTests.cs +++ b/test/Apache.Arrow.Tests/ArrowStreamReaderTests.cs @@ -13,13 +13,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Ipc; -using Apache.Arrow.Memory; using System; using System.IO; using System.Reflection; using System.Threading; using System.Threading.Tasks; +using Apache.Arrow.Ipc; +using Apache.Arrow.Memory; using Xunit; namespace Apache.Arrow.Tests diff --git a/test/Apache.Arrow.Tests/ArrowStreamWriterTests.cs b/test/Apache.Arrow.Tests/ArrowStreamWriterTests.cs index 570fb03e..42e69dcc 100644 --- a/test/Apache.Arrow.Tests/ArrowStreamWriterTests.cs +++ b/test/Apache.Arrow.Tests/ArrowStreamWriterTests.cs @@ -266,7 +266,7 @@ private static async Task TestRoundTripRecordBatchesAsync(List orig { using (MemoryStream stream = new MemoryStream()) { - using (var writer = new ArrowStreamWriter(stream, originalBatches[0].Schema, leaveOpen: true, options, memoryAllocator ?? new TestMemoryAllocator())) + using (var writer = new ArrowStreamWriter(stream, originalBatches[0].Schema, leaveOpen: true, options, memoryAllocator ?? new TestMemoryAllocator())) { foreach (RecordBatch originalBatch in originalBatches) { @@ -659,7 +659,8 @@ private Tuple CreateListTypeDictionaryArrayTestData(List var listBuilder = new ListArray.Builder(StringType.Default); var valueBuilder = listBuilder.ValueBuilder as StringArray.Builder; - foreach(string data in dictionaryDataBase) { + foreach (string data in dictionaryDataBase) + { listBuilder.Append(); valueBuilder.Append(data); } @@ -730,10 +731,10 @@ public async Task MemoryOwnerDisposalSlicedArray(int sliceOffset, int sliceLengt .ToList(); var slicedBatch = new RecordBatch(originalBatch.Schema, slicedArrays, sliceLength); var allocator = new TestMemoryAllocator(); - await TestRoundTripRecordBatchesAsync(new List () {slicedBatch}, null, false, allocator); - if(sliceOffset % 8 != 0) + await TestRoundTripRecordBatchesAsync(new List() { slicedBatch }, null, false, allocator); + if (sliceOffset % 8 != 0) Assert.True(allocator.Statistics.Allocations > 0); - Assert.Equal(0,allocator.Rented); + Assert.Equal(0, allocator.Rented); } } } diff --git a/test/Apache.Arrow.Tests/BinaryViewArrayTests.cs b/test/Apache.Arrow.Tests/BinaryViewArrayTests.cs index 7c18a49e..707207f6 100644 --- a/test/Apache.Arrow.Tests/BinaryViewArrayTests.cs +++ b/test/Apache.Arrow.Tests/BinaryViewArrayTests.cs @@ -33,8 +33,8 @@ public void SliceBinaryViewArray() var slice = (BinaryViewArray)array.Slice(1, 3); Assert.Equal(3, slice.Length); - Assert.Equal(new byte[] {3, 4}, slice.GetBytes(0).ToArray()); + Assert.Equal(new byte[] { 3, 4 }, slice.GetBytes(0).ToArray()); Assert.True(slice.GetBytes(1).IsEmpty); - Assert.Equal(new byte[] {5, 6}, slice.GetBytes(2).ToArray()); + Assert.Equal(new byte[] { 5, 6 }, slice.GetBytes(2).ToArray()); } } diff --git a/test/Apache.Arrow.Tests/BitUtilityTests.cs b/test/Apache.Arrow.Tests/BitUtilityTests.cs index 528dca1b..3d10bdda 100644 --- a/test/Apache.Arrow.Tests/BitUtilityTests.cs +++ b/test/Apache.Arrow.Tests/BitUtilityTests.cs @@ -58,7 +58,7 @@ public void CountsAllOneBitsFromAnOffset(byte[] data, int offset, int expectedCo Assert.Equal(expectedCount, BitUtility.CountBits(data, offset)); } - + [Theory] [InlineData(new byte[] { 0b11111111 }, 0, 8, 8)] [InlineData(new byte[] { 0b11111111 }, 0, 4, 4)] @@ -159,7 +159,7 @@ public void SetsBitsInRangeOnSmallRanges(byte[] data, int index, int length, boo BitUtility.SetBits(data, index, length, value); Assert.Equal(expectedValue, data); } - + [Fact] public void SetsBitsInRangeOnBigRanges() { diff --git a/test/Apache.Arrow.Tests/BooleanArrayTests.cs b/test/Apache.Arrow.Tests/BooleanArrayTests.cs index efac07db..d2879be3 100644 --- a/test/Apache.Arrow.Tests/BooleanArrayTests.cs +++ b/test/Apache.Arrow.Tests/BooleanArrayTests.cs @@ -134,10 +134,10 @@ public void SwapsExpectedBits() Assert.False(array.GetValue(0).Value); Assert.True(array.GetValue(7).HasValue); Assert.True(array.GetValue(7).Value); - #pragma warning disable CS0618 +#pragma warning disable CS0618 Assert.False(array.GetBoolean(0)); Assert.True(array.GetBoolean(7)); - #pragma warning restore CS0618 +#pragma warning restore CS0618 } [Fact] @@ -200,9 +200,9 @@ public void UnsetBitsAreUnchanged(int index) { Assert.True(array.GetValue(i).HasValue); Assert.False(array.GetValue(i).Value); - #pragma warning disable CS0618 +#pragma warning disable CS0618 Assert.False(array.GetBoolean(i)); - #pragma warning restore CS0618 +#pragma warning restore CS0618 } } } diff --git a/test/Apache.Arrow.Tests/CDataInterfacePythonTests.cs b/test/Apache.Arrow.Tests/CDataInterfacePythonTests.cs index 0ef8eba2..44301f9e 100644 --- a/test/Apache.Arrow.Tests/CDataInterfacePythonTests.cs +++ b/test/Apache.Arrow.Tests/CDataInterfacePythonTests.cs @@ -112,8 +112,8 @@ private static Schema GetTestSchema() .Field(f => f.Name("time64_us").DataType(new Time64Type(TimeUnit.Microsecond)).Nullable(false)) .Field(f => f.Name("time64_ns").DataType(new Time64Type(TimeUnit.Nanosecond)).Nullable(false)) - .Field(f => f.Name("timestamp_ns").DataType(new TimestampType(TimeUnit.Nanosecond, (string) null)).Nullable(false)) - .Field(f => f.Name("timestamp_us").DataType(new TimestampType(TimeUnit.Microsecond, (string) null)).Nullable(false)) + .Field(f => f.Name("timestamp_ns").DataType(new TimestampType(TimeUnit.Nanosecond, (string)null)).Nullable(false)) + .Field(f => f.Name("timestamp_us").DataType(new TimestampType(TimeUnit.Microsecond, (string)null)).Nullable(false)) .Field(f => f.Name("timestamp_us_paris").DataType(new TimestampType(TimeUnit.Microsecond, "Europe/Paris")).Nullable(true)) .Field(f => f.Name("list_string").DataType(new ListType(StringType.Default)).Nullable(false)) @@ -627,7 +627,7 @@ public unsafe void ImportRecordBatch() MapArray col10 = (MapArray)recordBatch.Column("col10"); Assert.Equal(5, col10.Length); - Assert.Equal(new int[] { 0, 0, 1, 2, 4, 10}, col10.ValueOffsets.ToArray()); + Assert.Equal(new int[] { 0, 0, 1, 2, 4, 10 }, col10.ValueOffsets.ToArray()); Assert.Equal(new long?[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, ((Int64Array)col10.Values).ToList().ToArray()); DurationArray col11 = (DurationArray)recordBatch.Column("col11"); diff --git a/test/Apache.Arrow.Tests/ColumnTests.cs b/test/Apache.Arrow.Tests/ColumnTests.cs index 2d867b79..38fce6c5 100644 --- a/test/Apache.Arrow.Tests/ColumnTests.cs +++ b/test/Apache.Arrow.Tests/ColumnTests.cs @@ -46,7 +46,7 @@ public void TestColumn() Assert.Equal(20, column.Length); Assert.Equal(0, column.NullCount); Assert.Equal(field.DataType, column.Type); - + Column slice5 = column.Slice(0, 5); Assert.Equal(5, slice5.Length); Column sliceFull = column.Slice(2); diff --git a/test/Apache.Arrow.Tests/Decimal256ArrayTests.cs b/test/Apache.Arrow.Tests/Decimal256ArrayTests.cs index ba0eb5f0..1c949163 100644 --- a/test/Apache.Arrow.Tests/Decimal256ArrayTests.cs +++ b/test/Apache.Arrow.Tests/Decimal256ArrayTests.cs @@ -54,7 +54,7 @@ public class AppendNull public void AppendThenGetGivesNull() { // Arrange - var builder = new Decimal256Array.Builder(new Decimal256Type(8,2)); + var builder = new Decimal256Array.Builder(new Decimal256Type(8, 2)); // Act @@ -95,7 +95,7 @@ public void AppendDecimal(int count) testData[i] = null; continue; } - decimal rnd = i * (decimal)Math.Round(new Random().NextDouble(),10); + decimal rnd = i * (decimal)Math.Round(new Random().NextDouble(), 10); testData[i] = rnd; builder.Append(rnd); } @@ -178,7 +178,7 @@ public void AppendRangeDecimal() { // Arrange var builder = new Decimal256Array.Builder(new Decimal256Type(24, 8)); - var range = new decimal[] {2.123M, 1.5984M, -0.0000001M, 9878987987987987.1235407M}; + var range = new decimal[] { 2.123M, 1.5984M, -0.0000001M, 9878987987987987.1235407M }; // Act builder.AppendRange(range); @@ -186,13 +186,13 @@ public void AppendRangeDecimal() // Assert var array = builder.Build(); - for(int i = 0; i < range.Length; i ++) + for (int i = 0; i < range.Length; i++) { Assert.Equal(range[i], array.GetValue(i)); Assert.Equal(Convert(range[i]), GetSqlDecimal(array, i)); } - Assert.Null( array.GetValue(range.Length)); + Assert.Null(array.GetValue(range.Length)); } [Fact] @@ -200,7 +200,7 @@ public void AppendClearAppendDecimal() { // Arrange var builder = new Decimal256Array.Builder(new Decimal256Type(24, 8)); - + // Act builder.Append(1); builder.Clear(); @@ -234,7 +234,7 @@ public void SetDecimal() // Arrange var builder = new Decimal256Array.Builder(new Decimal256Type(24, 8)) .Resize(1); - + // Act builder.Set(0, 50.123456M); builder.Set(0, 1.01M); diff --git a/test/Apache.Arrow.Tests/Extensions/DateTimeOffsetExtensions.cs b/test/Apache.Arrow.Tests/Extensions/DateTimeOffsetExtensions.cs index 01809735..0b55363c 100644 --- a/test/Apache.Arrow.Tests/Extensions/DateTimeOffsetExtensions.cs +++ b/test/Apache.Arrow.Tests/Extensions/DateTimeOffsetExtensions.cs @@ -33,6 +33,6 @@ public static DateTimeOffset Truncate(this DateTimeOffset dateTimeOffset, TimeSp return dateTimeOffset.AddTicks(-(dateTimeOffset.Ticks % offset.Ticks)); } - + } } diff --git a/test/Apache.Arrow.Tests/FixedSizeBinaryArrayTests.cs b/test/Apache.Arrow.Tests/FixedSizeBinaryArrayTests.cs index abc66d6c..a33bb433 100644 --- a/test/Apache.Arrow.Tests/FixedSizeBinaryArrayTests.cs +++ b/test/Apache.Arrow.Tests/FixedSizeBinaryArrayTests.cs @@ -39,14 +39,14 @@ public void SliceFixedSizeBinaryArray() .Build(); var arrayData = new ArrayData( new FixedSizeBinaryType(byteWidth), - length, nullCount, 0, new [] {validityBuffer, dataBuffer}); + length, nullCount, 0, new[] { validityBuffer, dataBuffer }); var array = new FixedSizeBinaryArray(arrayData); var slice = (FixedSizeBinaryArray)array.Slice(1, 3); Assert.Equal(3, slice.Length); - Assert.Equal(new byte[] {2, 3}, slice.GetBytes(0).ToArray()); + Assert.Equal(new byte[] { 2, 3 }, slice.GetBytes(0).ToArray()); Assert.True(slice.GetBytes(1).IsEmpty); - Assert.Equal(new byte[] {6, 7}, slice.GetBytes(2).ToArray()); + Assert.Equal(new byte[] { 6, 7 }, slice.GetBytes(2).ToArray()); } } diff --git a/test/Apache.Arrow.Tests/IntervalScalarTests.cs b/test/Apache.Arrow.Tests/IntervalScalarTests.cs index 52c403c5..2cc01271 100644 --- a/test/Apache.Arrow.Tests/IntervalScalarTests.cs +++ b/test/Apache.Arrow.Tests/IntervalScalarTests.cs @@ -145,7 +145,7 @@ public static IEnumerable GetBadDateTimeArithmeticData() public void Equality() { Assert.Equal(new DayTimeInterval(10, -1), new DayTimeInterval(10, -1)); - Assert.NotEqual(new DayTimeInterval(10, 0), new DayTimeInterval(9, 86400*1000)); + Assert.NotEqual(new DayTimeInterval(10, 0), new DayTimeInterval(9, 86400 * 1000)); } [Theory] diff --git a/test/Apache.Arrow.Tests/LargeListArrayTests.cs b/test/Apache.Arrow.Tests/LargeListArrayTests.cs index 1d35a8ff..9b32ab54 100644 --- a/test/Apache.Arrow.Tests/LargeListArrayTests.cs +++ b/test/Apache.Arrow.Tests/LargeListArrayTests.cs @@ -39,7 +39,7 @@ public void GetSlicedValuesReturnsCorrectValues() for (int i = 0; i < values.Length; ++i) { Assert.Equal(values[i] == null, array.IsNull(i)); - var arrayItem = (Int32Array) array.GetSlicedValues(i); + var arrayItem = (Int32Array)array.GetSlicedValues(i); if (values[i] == null) { Assert.Null(arrayItem); diff --git a/test/Apache.Arrow.Tests/SchemaBuilderTests.cs b/test/Apache.Arrow.Tests/SchemaBuilderTests.cs index 19c70398..2691e20d 100644 --- a/test/Apache.Arrow.Tests/SchemaBuilderTests.cs +++ b/test/Apache.Arrow.Tests/SchemaBuilderTests.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Linq; +using Apache.Arrow.Types; using Xunit; using Xunit.Sdk; @@ -279,9 +279,9 @@ public void FieldsHaveExpectedValues(string name, IArrowType type, bool nullable public static IEnumerable SampleSchema1() { - yield return new object[] {"f0", Int32Type.Default, true}; - yield return new object[] {"f1", DoubleType.Default, true}; - yield return new object[] {"f2", Int64Type.Default, false}; + yield return new object[] { "f0", Int32Type.Default, true }; + yield return new object[] { "f1", DoubleType.Default, true }; + yield return new object[] { "f2", Int64Type.Default, false }; } } } diff --git a/test/Apache.Arrow.Tests/StructArrayTests.cs b/test/Apache.Arrow.Tests/StructArrayTests.cs index ff5e8d2a..7cd5da3d 100644 --- a/test/Apache.Arrow.Tests/StructArrayTests.cs +++ b/test/Apache.Arrow.Tests/StructArrayTests.cs @@ -13,11 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Ipc; -using Apache.Arrow.Types; using System.Collections.Generic; using System.IO; using System.Linq; +using Apache.Arrow.Ipc; +using Apache.Arrow.Types; using Xunit; namespace Apache.Arrow.Tests @@ -140,18 +140,18 @@ public void TestSliceStructArray() var nullBitmap = new ArrowBuffer.BitmapBuilder().AppendRange(true, numRows).Build(); var array = new StructArray(new StructType(fields), numRows, arrays, nullBitmap, nullCount: 0); - var slicedArray = (StructArray) array.Slice(3, 4); + var slicedArray = (StructArray)array.Slice(3, 4); Assert.Equal(4, slicedArray.Length); Assert.Equal(2, slicedArray.Fields.Count); var slicedInts = slicedArray.Fields[0]; - var expectedInts = Enumerable.Range(3, 4).Select(val => (int?) val).ToArray(); - Assert.Equal(expectedInts, (IReadOnlyList) slicedInts); + var expectedInts = Enumerable.Range(3, 4).Select(val => (int?)val).ToArray(); + Assert.Equal(expectedInts, (IReadOnlyList)slicedInts); var slicedDoubles = slicedArray.Fields[1]; - var expectedDoubles = Enumerable.Range(3, 4).Select(val => (double?) (val * 0.1)).ToArray(); - Assert.Equal(expectedDoubles, (IReadOnlyList) slicedDoubles); + var expectedDoubles = Enumerable.Range(3, 4).Select(val => (double?)(val * 0.1)).ToArray(); + Assert.Equal(expectedDoubles, (IReadOnlyList)slicedDoubles); } [Fact] @@ -181,24 +181,24 @@ public void TestStructArrayConstructedWithOffset() Assert.Equal(2, array.Fields.Count); var slicedInts = array.Fields[0]; - var expectedInts = Enumerable.Range(3, 4).Select(val => (int?) val).ToArray(); - Assert.Equal(expectedInts, (IReadOnlyList) slicedInts); + var expectedInts = Enumerable.Range(3, 4).Select(val => (int?)val).ToArray(); + Assert.Equal(expectedInts, (IReadOnlyList)slicedInts); var slicedDoubles = array.Fields[1]; - var expectedDoubles = Enumerable.Range(3, 4).Select(val => (double?) (val * 0.1)).ToArray(); - Assert.Equal(expectedDoubles, (IReadOnlyList) slicedDoubles); + var expectedDoubles = Enumerable.Range(3, 4).Select(val => (double?)(val * 0.1)).ToArray(); + Assert.Equal(expectedDoubles, (IReadOnlyList)slicedDoubles); - var subSlice = (StructArray) array.Slice(1, 2); + var subSlice = (StructArray)array.Slice(1, 2); Assert.Equal(2, subSlice.Length); Assert.Equal(2, subSlice.Fields.Count); var subSlicedInts = subSlice.Fields[0]; - var expectedSubSliceInts = Enumerable.Range(4, 2).Select(val => (int?) val).ToArray(); - Assert.Equal(expectedSubSliceInts, (IReadOnlyList) subSlicedInts); + var expectedSubSliceInts = Enumerable.Range(4, 2).Select(val => (int?)val).ToArray(); + Assert.Equal(expectedSubSliceInts, (IReadOnlyList)subSlicedInts); var subSlicedDoubles = subSlice.Fields[1]; - var expectedSubSliceDoubles = Enumerable.Range(4, 2).Select(val => (double?) (val * 0.1)).ToArray(); - Assert.Equal(expectedSubSliceDoubles, (IReadOnlyList) subSlicedDoubles); + var expectedSubSliceDoubles = Enumerable.Range(4, 2).Select(val => (double?)(val * 0.1)).ToArray(); + Assert.Equal(expectedSubSliceDoubles, (IReadOnlyList)subSlicedDoubles); } private static void TestRoundTripRecordBatch(RecordBatch originalBatch) diff --git a/test/Apache.Arrow.Tests/TestData.cs b/test/Apache.Arrow.Tests/TestData.cs index 08ada33d..3eede0a6 100644 --- a/test/Apache.Arrow.Tests/TestData.cs +++ b/test/Apache.Arrow.Tests/TestData.cs @@ -13,12 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Arrays; -using Apache.Arrow.Scalars; -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Linq; +using Apache.Arrow.Arrays; +using Apache.Arrow.Scalars; +using Apache.Arrow.Types; namespace Apache.Arrow.Tests { @@ -757,7 +757,7 @@ public void Visit(IntervalType type) var dayTimeBuilder = new DayTimeIntervalArray.Builder().Reserve(Length); for (var i = 0; i < Length; i++) { - dayTimeBuilder.Append(new DayTimeInterval(100 - 50*i, 100 * i)); + dayTimeBuilder.Append(new DayTimeInterval(100 - 50 * i, 100 * i)); } Array = dayTimeBuilder.Build(); break; @@ -765,7 +765,7 @@ public void Visit(IntervalType type) var monthDayNanoBuilder = new MonthDayNanosecondIntervalArray.Builder().Reserve(Length); for (var i = 0; i < Length; i++) { - monthDayNanoBuilder.Append(new MonthDayNanosecondInterval(i, 5-i, 100*i)); + monthDayNanoBuilder.Append(new MonthDayNanosecondInterval(i, 5 - i, 100 * i)); } Array = monthDayNanoBuilder.Build(); break; diff --git a/test/Apache.Arrow.Tests/TestMemoryAllocator.cs b/test/Apache.Arrow.Tests/TestMemoryAllocator.cs index 0243c395..ab38f744 100644 --- a/test/Apache.Arrow.Tests/TestMemoryAllocator.cs +++ b/test/Apache.Arrow.Tests/TestMemoryAllocator.cs @@ -14,9 +14,9 @@ // limitations under the License. using System; -using Apache.Arrow.Memory; using System.Buffers; using System.Threading; +using Apache.Arrow.Memory; namespace Apache.Arrow.Tests { diff --git a/test/Apache.Arrow.Tests/TypeTests.cs b/test/Apache.Arrow.Tests/TypeTests.cs index c279d698..eea8e92d 100644 --- a/test/Apache.Arrow.Tests/TypeTests.cs +++ b/test/Apache.Arrow.Tests/TypeTests.cs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Apache.Arrow.Types; using System; using System.Collections.Generic; using System.Linq; +using Apache.Arrow.Types; using Xunit; using Xunit.Sdk; diff --git a/test/Apache.Arrow.Tests/UnionArrayTests.cs b/test/Apache.Arrow.Tests/UnionArrayTests.cs index c603ef63..84c3ab08 100644 --- a/test/Apache.Arrow.Tests/UnionArrayTests.cs +++ b/test/Apache.Arrow.Tests/UnionArrayTests.cs @@ -125,7 +125,7 @@ private static void CompareFieldValue(byte typeId, UnionArray origina Assert.Equal(originalValue, sliceValue); } - private static (UnionArray array, bool[] isNull) BuildUnionArray(UnionMode mode, int length, int offset=0) + private static (UnionArray array, bool[] isNull) BuildUnionArray(UnionMode mode, int length, int offset = 0) { var fields = new Field[] {