Skip to content

Commit f2add6e

Browse files
author
takashi hashida
committed
Respond to changes of master branch
* Add type check to CompareArrays for ListType * Add ListArray test data to TestData
1 parent bed012b commit f2add6e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

csharp/test/Apache.Arrow.Tests/ArrowReaderVerifier.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ private void CompareArrays(ListArray actualArray)
239239
Assert.IsAssignableFrom<ListArray>(_expectedArray);
240240
ListArray expectedArray = (ListArray)_expectedArray;
241241

242+
_arrayTypeComparer.Visit(actualArray.Data.DataType);
243+
242244
Assert.Equal(expectedArray.Length, actualArray.Length);
243245
Assert.Equal(expectedArray.NullCount, actualArray.NullCount);
244246
Assert.Equal(expectedArray.Offset, actualArray.Offset);

csharp/test/Apache.Arrow.Tests/TestData.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public static RecordBatch CreateSampleRecordBatch(int length, int columnSetCount
5252
//builder.Field(CreateField(StringType.Default));
5353
//builder.Field(CreateField(Time32Type.Default));
5454
//builder.Field(CreateField(Time64Type.Default));
55+
56+
builder.Field(CreateField(new ListType(Int64Type.Default), i));
5557
}
5658

5759
Schema schema = builder.Build();
@@ -102,7 +104,8 @@ private class ArrayCreator :
102104
IArrowTypeVisitor<FloatType>,
103105
IArrowTypeVisitor<DoubleType>,
104106
IArrowTypeVisitor<TimestampType>,
105-
IArrowTypeVisitor<StringType>
107+
IArrowTypeVisitor<StringType>,
108+
IArrowTypeVisitor<ListType>
106109
{
107110
private int Length { get; }
108111
public IArrowArray Array { get; private set; }
@@ -176,6 +179,21 @@ public void Visit(StringType type)
176179
Array = builder.Build();
177180
}
178181

182+
public void Visit(ListType type)
183+
{
184+
//Todo : Use ListArray.Builder
185+
var children = new [] { CreateArray(type.ValueField, Length).Data };
186+
ArrowBuffer.Builder<int> builder = new ArrowBuffer.Builder<int>(Length);
187+
for (int i = 0; i < Length; i++)
188+
{
189+
builder.Append(i);
190+
}
191+
192+
var valueOffsetsBuffer = builder.Build();
193+
Array = new ListArray(new ArrayData(type, Length, 0, 0,
194+
new[] { ArrowBuffer.Empty, valueOffsetsBuffer }, children));
195+
}
196+
179197
private void GenerateArray<T, TArray, TArrayBuilder>(IArrowArrayBuilder<T, TArray, TArrayBuilder> builder, Func<int, T> generator)
180198
where TArrayBuilder : IArrowArrayBuilder<T, TArray, TArrayBuilder>
181199
where TArray : IArrowArray

0 commit comments

Comments
 (0)