Skip to content

Commit

Permalink
apacheGH-38153: [C#] expose ArrayDataConcatenator.Concatenate (apache…
Browse files Browse the repository at this point in the history
…#38154)

### Rationale for this change

New C# drivers need the ability to concatenate array data, particularly for metadata calls.

### What changes are included in this PR?

Converts a previously internal class and method to a public class and method.

### Are these changes tested?

Yes

### Are there any user-facing changes?

It exposes previously hidden functionality.

Resolves apache#38153
* Closes: apache#38153

Lead-authored-by: David Coe <[email protected]>
Co-authored-by: davidhcoe <[email protected]>
Signed-off-by: David Li <[email protected]>
  • Loading branch information
davidhcoe authored and dgreiss committed Feb 17, 2024
1 parent fb767a6 commit e3d4d7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
4 changes: 2 additions & 2 deletions csharp/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

namespace Apache.Arrow
{
static class ArrayDataConcatenator
public class ArrayDataConcatenator
{
internal static ArrayData Concatenate(IReadOnlyList<ArrayData> arrayDataList, MemoryAllocator allocator = default)
public static ArrayData Concatenate(IReadOnlyList<ArrayData> arrayDataList, MemoryAllocator allocator = default)
{
if (arrayDataList == null || arrayDataList.Count == 0)
{
Expand Down
16 changes: 3 additions & 13 deletions csharp/test/Apache.Arrow.Tests/ArrayDataConcatenatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,17 @@ public class ArrayDataConcatenatorTests
[Fact]
public void TestNullOrEmpty()
{
Assert.Null(ArrayDataConcatenatorReflector.InvokeConcatenate(null));
Assert.Null(ArrayDataConcatenatorReflector.InvokeConcatenate(new List<ArrayData>()));
Assert.Null(ArrayDataConcatenator.Concatenate(null));
Assert.Null(ArrayDataConcatenator.Concatenate(new List<ArrayData>()));
}

[Fact]
public void TestSingleElement()
{
Int32Array array = new Int32Array.Builder().Append(1).Append(2).Build();
ArrayData actualArray = ArrayDataConcatenatorReflector.InvokeConcatenate(new[] { array.Data });
ArrayData actualArray = ArrayDataConcatenator.Concatenate(new[] { array.Data });
ArrowReaderVerifier.CompareArrays(array, ArrowArrayFactory.BuildArray(actualArray));
}

private static class ArrayDataConcatenatorReflector
{
private static readonly MethodInfo s_concatenateInfo = typeof(ArrayData).Assembly.GetType("Apache.Arrow.ArrayDataConcatenator")
.GetMethod("Concatenate", BindingFlags.Static | BindingFlags.NonPublic);

internal static ArrayData InvokeConcatenate(IReadOnlyList<ArrayData> arrayDataList, MemoryAllocator allocator = default)
{
return s_concatenateInfo.Invoke(null, new object[] { arrayDataList, allocator }) as ArrayData;
}
}
}
}

0 comments on commit e3d4d7d

Please sign in to comment.