From cd60c0eca5872e3c7df490c18710e0255d6e98e0 Mon Sep 17 00:00:00 2001 From: Curt Hagenlocher Date: Wed, 24 Apr 2024 15:51:22 -0700 Subject: [PATCH] feat(csharp/src/Apache.Arrow.Adbc): Remove AdbcConnection.GetInfo(List) (#1760) Closes #1759 --- .../src/Apache.Arrow.Adbc/AdbcConnection.cs | 20 ++-------------- .../C/CAdbcDriverExporter.cs | 4 ++-- .../C/CAdbcDriverImporter.cs | 23 ++++++++----------- .../Apache/Hive2/HiveServer2Connection.cs | 5 ---- .../Drivers/Apache/Impala/ImpalaConnection.cs | 5 ---- .../Drivers/Apache/Spark/SparkConnection.cs | 2 -- 6 files changed, 13 insertions(+), 46 deletions(-) diff --git a/csharp/src/Apache.Arrow.Adbc/AdbcConnection.cs b/csharp/src/Apache.Arrow.Adbc/AdbcConnection.cs index b33dd5c48b..442b1d3ee2 100644 --- a/csharp/src/Apache.Arrow.Adbc/AdbcConnection.cs +++ b/csharp/src/Apache.Arrow.Adbc/AdbcConnection.cs @@ -70,21 +70,7 @@ public virtual void Dispose() /// The metadata items to fetch. /// /// - /// A statement that can be immediately executed. - /// - public virtual IArrowArrayStream GetInfo(List codes) - { - throw AdbcException.NotImplemented("Connection does not support GetInfo"); - } - - /// - /// Get metadata about the driver/database. - /// - /// - /// The metadata items to fetch. - /// - /// - /// A statement that can be immediately executed. + /// Metadata about the driver and/or database /// /// public virtual IArrowArrayStream GetInfo(List codes) @@ -92,9 +78,7 @@ public virtual IArrowArrayStream GetInfo(List codes) if (codes == null) throw new ArgumentNullException(nameof(codes)); - List codeValues = codes.Select(x => (int)x).ToList(); - - return GetInfo(codeValues); + throw AdbcException.NotImplemented("Connection does not support GetInfo"); } /// diff --git a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverExporter.cs b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverExporter.cs index a8b3089b3d..9be44b3ea5 100644 --- a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverExporter.cs +++ b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverExporter.cs @@ -847,8 +847,8 @@ public unsafe void ReadPartition(byte* serializedPartition, int serialized_lengt public unsafe void GetInfo(int* info_codes, int info_codes_length, CArrowArrayStream* stream) { - int[] infoCodes = new int[info_codes_length]; - fixed (int* infoCodesPtr = infoCodes) + AdbcInfoCode[] infoCodes = new AdbcInfoCode[info_codes_length]; + fixed (AdbcInfoCode* infoCodesPtr = infoCodes) { long length = (long)info_codes_length * sizeof(int); Buffer.MemoryCopy(info_codes, infoCodesPtr, length, length); diff --git a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs index 82b2a8c15f..2d7099b4e7 100644 --- a/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs +++ b/csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs @@ -222,12 +222,7 @@ public unsafe override AdbcStatement CreateStatement() return new AdbcStatementNative(_nativeDriver, nativeStatement); } - public override IArrowArrayStream GetInfo(List codes) - { - return GetInfo(codes.Select(x => (int)x).ToList()); - } - - public override unsafe IArrowArrayStream GetInfo(List codes) + public unsafe override IArrowArrayStream GetInfo(List codes) { CArrowArrayStream* nativeArrayStream = CArrowArrayStream.Create(); @@ -696,28 +691,28 @@ public unsafe void Dispose() } #if NET5_0_OR_GREATER - public unsafe void Call(delegate* unmanaged fn, ref CAdbcConnection connection, List infoCodes, CArrowArrayStream* stream) + public unsafe void Call(delegate* unmanaged fn, ref CAdbcConnection connection, List infoCodes, CArrowArrayStream* stream) { fixed (CAdbcConnection* cn = &connection) fixed (CAdbcError* e = &_error) { - Span span = CollectionsMarshal.AsSpan(infoCodes); - fixed (int* spanPtr = span) + Span span = CollectionsMarshal.AsSpan(infoCodes); + fixed (AdbcInfoCode* spanPtr = span) { - TranslateCode(fn(cn, spanPtr, infoCodes.Count, stream, e)); + TranslateCode(fn(cn, (int*)spanPtr, infoCodes.Count, stream, e)); } } } #else - public unsafe void Call(IntPtr ptr, ref CAdbcConnection connection, List infoCodes, CArrowArrayStream* stream) + public unsafe void Call(IntPtr ptr, ref CAdbcConnection connection, List infoCodes, CArrowArrayStream* stream) { fixed (CAdbcConnection* cn = &connection) fixed (CAdbcError* e = &_error) { - Span span = infoCodes.ToArray().AsSpan(); - fixed (int* spanPtr = span) + Span span = infoCodes.ToArray().AsSpan(); + fixed (AdbcInfoCode* spanPtr = span) { - TranslateCode(Marshal.GetDelegateForFunctionPointer(ptr)(cn, spanPtr, infoCodes.Count, stream, e)); + TranslateCode(Marshal.GetDelegateForFunctionPointer(ptr)(cn, (int*)spanPtr, infoCodes.Count, stream, e)); } } } diff --git a/csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs b/csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs index ae0c47a93c..868d7d65cf 100644 --- a/csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs +++ b/csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs @@ -64,11 +64,6 @@ public override IArrowArrayStream GetObjects(GetObjectsDepth depth, string catal throw new NotImplementedException(); } - public override IArrowArrayStream GetInfo(List codes) - { - throw new NotImplementedException(); - } - public override IArrowArrayStream GetTableTypes() { throw new NotImplementedException(); diff --git a/csharp/src/Drivers/Apache/Impala/ImpalaConnection.cs b/csharp/src/Drivers/Apache/Impala/ImpalaConnection.cs index ec6210c2f3..d08488df5f 100644 --- a/csharp/src/Drivers/Apache/Impala/ImpalaConnection.cs +++ b/csharp/src/Drivers/Apache/Impala/ImpalaConnection.cs @@ -60,11 +60,6 @@ public override AdbcStatement CreateStatement() return new ImpalaStatement(this); } - public override IArrowArrayStream GetInfo(List codes) - { - throw new System.NotImplementedException(); - } - public override IArrowArrayStream GetObjects(GetObjectsDepth depth, string catalogPattern, string dbSchemaPattern, string tableNamePattern, List tableTypes, string columnNamePattern) { throw new System.NotImplementedException(); diff --git a/csharp/src/Drivers/Apache/Spark/SparkConnection.cs b/csharp/src/Drivers/Apache/Spark/SparkConnection.cs index fa1ae62dad..17c369d20f 100644 --- a/csharp/src/Drivers/Apache/Spark/SparkConnection.cs +++ b/csharp/src/Drivers/Apache/Spark/SparkConnection.cs @@ -272,8 +272,6 @@ public override IArrowArrayStream GetInfo(List codes) } - public override IArrowArrayStream GetInfo(List codes) => base.GetInfo(codes); - public override IArrowArrayStream GetTableTypes() { StringArray.Builder tableTypesBuilder = new StringArray.Builder();