adamreeve commented on issue #40790:
URL: https://github.com/apache/arrow/issues/40790#issuecomment-2019287063
I think this is actually specific to structs. With a `ListArray`, the child
buffer/Array doesn't need to be sliced, the offset just needs to be accounted
for when accessing the value offsets, so slicing a `ListArray` seems to work
fine. Eg. this passes:
```c#
[Fact]
public void TestSliceListArray()
{
const int numRows = 10;
var builder = new ListArray.Builder(new Int32Type());
var valueBuilder = (Int32Array.Builder) builder.ValueBuilder;
for (var rowIdx = 0; rowIdx < numRows; ++rowIdx)
{
builder.Append();
var length = rowIdx % 3;
for (var i = 0; i < length; ++i)
{
valueBuilder.Append(valueBuilder.Length);
}
}
var array = builder.Build();
var slicedArray = (ListArray) array.Slice(2, 4);
Assert.Equal(4, slicedArray.Length);
for (var rowIdx = 0; rowIdx < slicedArray.Length; ++rowIdx)
{
var slicedArrayList =
(IReadOnlyList<int?>)slicedArray.GetSlicedValues(rowIdx);
var sourceArrayList =
(IReadOnlyList<int?>)array.GetSlicedValues(rowIdx + 2);
Assert.Equal(sourceArrayList, slicedArrayList);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]