Skip to content

Commit

Permalink
GH-37651: [C#] expose ArrowArrayConcatenator.Concatenate (#37652)
Browse files Browse the repository at this point in the history
### Rationale for this change

New C# drivers need the ability to concatenate arrays, 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?

No substantive product changes were made. All tests still pass.

### Are there any user-facing changes?

It exposes previously hidden functionality. 

Resolves #37651 

* Closes: #37651

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 Oct 6, 2023
1 parent fdecb6a commit 0d89741
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
4 changes: 2 additions & 2 deletions csharp/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

namespace Apache.Arrow
{
static class ArrowArrayConcatenator
public static class ArrowArrayConcatenator
{
internal static IArrowArray Concatenate(IReadOnlyList<IArrowArray> arrowArrayList , MemoryAllocator allocator = default)
public static IArrowArray Concatenate(IReadOnlyList<IArrowArray> arrowArrayList , MemoryAllocator allocator = default)
{
if(arrowArrayList == null || arrowArrayList.Count == 0)
{
Expand Down
19 changes: 4 additions & 15 deletions csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ public void TestStandardCases()
{
foreach ((List<IArrowArray> testTargetArrayList, IArrowArray expectedArray) in GenerateTestData())
{
IArrowArray actualArray = ArrowArrayConcatenatorReflector.InvokeConcatenate(testTargetArrayList);
IArrowArray actualArray = ArrowArrayConcatenator.Concatenate(testTargetArrayList);
ArrowReaderVerifier.CompareArrays(expectedArray, actualArray);
}
}

[Fact]
public void TestNullOrEmpty()
{
Assert.Null(ArrowArrayConcatenatorReflector.InvokeConcatenate(null));
Assert.Null(ArrowArrayConcatenatorReflector.InvokeConcatenate(new List<IArrowArray>()));
Assert.Null(ArrowArrayConcatenator.Concatenate(null));
Assert.Null(ArrowArrayConcatenator.Concatenate(new List<IArrowArray>()));
}

[Fact]
public void TestSingleElement()
{
Int32Array array = new Int32Array.Builder().Append(1).Append(2).Build();
IArrowArray actualArray = ArrowArrayConcatenatorReflector.InvokeConcatenate(new[] { array });
IArrowArray actualArray = ArrowArrayConcatenator.Concatenate(new[] { array });
ArrowReaderVerifier.CompareArrays(array, actualArray);
}

Expand Down Expand Up @@ -107,17 +107,6 @@ private static IEnumerable<Tuple<List<IArrowArray>, IArrowArray>> GenerateTestDa
}
}

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

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

private class TestDataGenerator :
IArrowTypeVisitor<BooleanType>,
IArrowTypeVisitor<Int8Type>,
Expand Down

0 comments on commit 0d89741

Please sign in to comment.