From e3d4d7d58837d70903325f294d78c560b88dc0e1 Mon Sep 17 00:00:00 2001 From: davidhcoe <13318837+davidhcoe@users.noreply.github.com> Date: Wed, 11 Oct 2023 09:44:11 -0400 Subject: [PATCH] GH-38153: [C#] expose ArrayDataConcatenator.Concatenate (#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 https://github.com/apache/arrow/issues/38153 * Closes: #38153 Lead-authored-by: David Coe Co-authored-by: davidhcoe <13318837+davidhcoe@users.noreply.github.com> Signed-off-by: David Li --- .../Apache.Arrow/Arrays/ArrayDataConcatenator.cs | 4 ++-- .../ArrayDataConcatenatorTests.cs | 16 +++------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/csharp/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs b/csharp/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs index a3b39923809bb..463ca49e29c94 100644 --- a/csharp/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs +++ b/csharp/src/Apache.Arrow/Arrays/ArrayDataConcatenator.cs @@ -20,9 +20,9 @@ namespace Apache.Arrow { - static class ArrayDataConcatenator + public class ArrayDataConcatenator { - internal static ArrayData Concatenate(IReadOnlyList arrayDataList, MemoryAllocator allocator = default) + public static ArrayData Concatenate(IReadOnlyList arrayDataList, MemoryAllocator allocator = default) { if (arrayDataList == null || arrayDataList.Count == 0) { diff --git a/csharp/test/Apache.Arrow.Tests/ArrayDataConcatenatorTests.cs b/csharp/test/Apache.Arrow.Tests/ArrayDataConcatenatorTests.cs index 9f034b9d0c955..86719f3bef6f4 100644 --- a/csharp/test/Apache.Arrow.Tests/ArrayDataConcatenatorTests.cs +++ b/csharp/test/Apache.Arrow.Tests/ArrayDataConcatenatorTests.cs @@ -26,27 +26,17 @@ public class ArrayDataConcatenatorTests [Fact] public void TestNullOrEmpty() { - Assert.Null(ArrayDataConcatenatorReflector.InvokeConcatenate(null)); - Assert.Null(ArrayDataConcatenatorReflector.InvokeConcatenate(new List())); + Assert.Null(ArrayDataConcatenator.Concatenate(null)); + Assert.Null(ArrayDataConcatenator.Concatenate(new List())); } [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 arrayDataList, MemoryAllocator allocator = default) - { - return s_concatenateInfo.Invoke(null, new object[] { arrayDataList, allocator }) as ArrayData; - } - } } }