This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 0d89741771 GH-37651: [C#] expose ArrowArrayConcatenator.Concatenate
(#37652)
0d89741771 is described below
commit 0d89741771a69ed5ea4ce34a224c26dfca09f26d
Author: davidhcoe <[email protected]>
AuthorDate: Fri Oct 6 10:31:16 2023 -0400
GH-37651: [C#] expose ArrowArrayConcatenator.Concatenate (#37652)
### 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 https://github.com/apache/arrow/issues/37651
* Closes: #37651
Lead-authored-by: David Coe <[email protected]>
Co-authored-by: davidhcoe <[email protected]>
Signed-off-by: David Li <[email protected]>
---
.../src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs | 4 ++--
.../Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs | 19 ++++---------------
2 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/csharp/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs
b/csharp/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs
index cc151210ae..ac8252211e 100644
--- a/csharp/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs
+++ b/csharp/src/Apache.Arrow/Arrays/ArrowArrayConcatenator.cs
@@ -18,9 +18,9 @@ using System.Collections.Generic;
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)
{
diff --git a/csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs
b/csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs
index f1dcbb5d37..6f4c17a959 100644
--- a/csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs
+++ b/csharp/test/Apache.Arrow.Tests/ArrowArrayConcatenatorTests.cs
@@ -30,7 +30,7 @@ namespace Apache.Arrow.Tests
{
foreach ((List<IArrowArray> testTargetArrayList, IArrowArray
expectedArray) in GenerateTestData())
{
- IArrowArray actualArray =
ArrowArrayConcatenatorReflector.InvokeConcatenate(testTargetArrayList);
+ IArrowArray actualArray =
ArrowArrayConcatenator.Concatenate(testTargetArrayList);
ArrowReaderVerifier.CompareArrays(expectedArray, actualArray);
}
}
@@ -38,15 +38,15 @@ namespace Apache.Arrow.Tests
[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);
}
@@ -107,17 +107,6 @@ namespace Apache.Arrow.Tests
}
}
- 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>,