Skip to content

Commit

Permalink
feat(csharp/src/Apache.Arrow.Adbc): Remove AdbcConnection.GetInfo(Lis…
Browse files Browse the repository at this point in the history
…t<int>) (#1760)

Closes #1759
  • Loading branch information
CurtHagenlocher authored Apr 24, 2024
1 parent 9287e9a commit cd60c0e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 46 deletions.
20 changes: 2 additions & 18 deletions csharp/src/Apache.Arrow.Adbc/AdbcConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,15 @@ public virtual void Dispose()
/// The metadata items to fetch.
/// </param>
/// <returns>
/// A statement that can be immediately executed.
/// </returns>
public virtual IArrowArrayStream GetInfo(List<int> codes)
{
throw AdbcException.NotImplemented("Connection does not support GetInfo");
}

/// <summary>
/// Get metadata about the driver/database.
/// </summary>
/// <param name="codes">
/// The metadata items to fetch.
/// </param>
/// <returns>
/// A statement that can be immediately executed.
/// Metadata about the driver and/or database
/// </returns>
/// <exception cref="ArgumentNullException"></exception>
public virtual IArrowArrayStream GetInfo(List<AdbcInfoCode> codes)
{
if (codes == null)
throw new ArgumentNullException(nameof(codes));

List<int> codeValues = codes.Select(x => (int)x).ToList();

return GetInfo(codeValues);
throw AdbcException.NotImplemented("Connection does not support GetInfo");
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 9 additions & 14 deletions csharp/src/Apache.Arrow.Adbc/C/CAdbcDriverImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,7 @@ public unsafe override AdbcStatement CreateStatement()
return new AdbcStatementNative(_nativeDriver, nativeStatement);
}

public override IArrowArrayStream GetInfo(List<AdbcInfoCode> codes)
{
return GetInfo(codes.Select(x => (int)x).ToList<int>());
}

public override unsafe IArrowArrayStream GetInfo(List<int> codes)
public unsafe override IArrowArrayStream GetInfo(List<AdbcInfoCode> codes)
{
CArrowArrayStream* nativeArrayStream = CArrowArrayStream.Create();

Expand Down Expand Up @@ -696,28 +691,28 @@ public unsafe void Dispose()
}

#if NET5_0_OR_GREATER
public unsafe void Call(delegate* unmanaged<CAdbcConnection*, int*, int, CArrowArrayStream*, CAdbcError*, AdbcStatusCode> fn, ref CAdbcConnection connection, List<int> infoCodes, CArrowArrayStream* stream)
public unsafe void Call(delegate* unmanaged<CAdbcConnection*, int*, int, CArrowArrayStream*, CAdbcError*, AdbcStatusCode> fn, ref CAdbcConnection connection, List<AdbcInfoCode> infoCodes, CArrowArrayStream* stream)
{
fixed (CAdbcConnection* cn = &connection)
fixed (CAdbcError* e = &_error)
{
Span<int> span = CollectionsMarshal.AsSpan(infoCodes);
fixed (int* spanPtr = span)
Span<AdbcInfoCode> 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<int> infoCodes, CArrowArrayStream* stream)
public unsafe void Call(IntPtr ptr, ref CAdbcConnection connection, List<AdbcInfoCode> infoCodes, CArrowArrayStream* stream)
{
fixed (CAdbcConnection* cn = &connection)
fixed (CAdbcError* e = &_error)
{
Span<int> span = infoCodes.ToArray().AsSpan();
fixed (int* spanPtr = span)
Span<AdbcInfoCode> span = infoCodes.ToArray().AsSpan();
fixed (AdbcInfoCode* spanPtr = span)
{
TranslateCode(Marshal.GetDelegateForFunctionPointer<CAdbcDriverExporter.ConnectionGetInfo>(ptr)(cn, spanPtr, infoCodes.Count, stream, e));
TranslateCode(Marshal.GetDelegateForFunctionPointer<CAdbcDriverExporter.ConnectionGetInfo>(ptr)(cn, (int*)spanPtr, infoCodes.Count, stream, e));
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions csharp/src/Drivers/Apache/Hive2/HiveServer2Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ public override IArrowArrayStream GetObjects(GetObjectsDepth depth, string catal
throw new NotImplementedException();
}

public override IArrowArrayStream GetInfo(List<int> codes)
{
throw new NotImplementedException();
}

public override IArrowArrayStream GetTableTypes()
{
throw new NotImplementedException();
Expand Down
5 changes: 0 additions & 5 deletions csharp/src/Drivers/Apache/Impala/ImpalaConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ public override AdbcStatement CreateStatement()
return new ImpalaStatement(this);
}

public override IArrowArrayStream GetInfo(List<int> codes)
{
throw new System.NotImplementedException();
}

public override IArrowArrayStream GetObjects(GetObjectsDepth depth, string catalogPattern, string dbSchemaPattern, string tableNamePattern, List<string> tableTypes, string columnNamePattern)
{
throw new System.NotImplementedException();
Expand Down
2 changes: 0 additions & 2 deletions csharp/src/Drivers/Apache/Spark/SparkConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ public override IArrowArrayStream GetInfo(List<AdbcInfoCode> codes)

}

public override IArrowArrayStream GetInfo(List<int> codes) => base.GetInfo(codes);

public override IArrowArrayStream GetTableTypes()
{
StringArray.Builder tableTypesBuilder = new StringArray.Builder();
Expand Down

0 comments on commit cd60c0e

Please sign in to comment.