-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### What changes are included in this PR? Support dense and sparse unions in the C# implementation. Adds Archery support for C# unions. ### Are these changes tested? Yes ### Are there any user-facing changes? Unions are now supported in the C# implementation. **This PR includes breaking changes to public APIs.** The public APIs for the UnionArray and UnionType were changed fairly substantially. As these were previously not implemented properly, the impact of the changes ought to be minimal. The ChunkedArray and Column classes were changed to hold IArrowArrays instead of Arrays. To accomodate this, a constructor was added which may introduce ambiguity in calling code. This could be avoided by changing the overloaded constructor to instead be a factory method. This didn't seem worthwhile but could be reconsidered. The metadata version was finally increased to V5. * Closes: #36795 Authored-by: Curt Hagenlocher <[email protected]> Signed-off-by: David Li <[email protected]>
- Loading branch information
1 parent
64acef8
commit e55f912
Showing
32 changed files
with
797 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to You under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Apache.Arrow.Types; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Apache.Arrow | ||
{ | ||
public class DenseUnionArray : UnionArray | ||
{ | ||
public ArrowBuffer ValueOffsetBuffer => Data.Buffers[1]; | ||
|
||
public ReadOnlySpan<int> ValueOffsets => ValueOffsetBuffer.Span.CastTo<int>(); | ||
|
||
public DenseUnionArray( | ||
IArrowType dataType, | ||
int length, | ||
IEnumerable<IArrowArray> children, | ||
ArrowBuffer typeIds, | ||
ArrowBuffer valuesOffsetBuffer, | ||
int nullCount = 0, | ||
int offset = 0) | ||
: base(new ArrayData( | ||
dataType, length, nullCount, offset, new[] { typeIds, valuesOffsetBuffer }, | ||
children.Select(child => child.Data))) | ||
{ | ||
_fields = children.ToArray(); | ||
ValidateMode(UnionMode.Dense, Type.Mode); | ||
} | ||
|
||
public DenseUnionArray(ArrayData data) | ||
: base(data) | ||
{ | ||
ValidateMode(UnionMode.Dense, Type.Mode); | ||
data.EnsureBufferCount(2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one or more | ||
// contributor license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright ownership. | ||
// The ASF licenses this file to You under the Apache License, Version 2.0 | ||
// (the "License"); you may not use this file except in compliance with | ||
// the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using Apache.Arrow.Types; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Apache.Arrow | ||
{ | ||
public class SparseUnionArray : UnionArray | ||
{ | ||
public SparseUnionArray( | ||
IArrowType dataType, | ||
int length, | ||
IEnumerable<IArrowArray> children, | ||
ArrowBuffer typeIds, | ||
int nullCount = 0, | ||
int offset = 0) | ||
: base(new ArrayData( | ||
dataType, length, nullCount, offset, new[] { typeIds }, | ||
children.Select(child => child.Data))) | ||
{ | ||
_fields = children.ToArray(); | ||
ValidateMode(UnionMode.Sparse, Type.Mode); | ||
} | ||
|
||
public SparseUnionArray(ArrayData data) | ||
: base(data) | ||
{ | ||
ValidateMode(UnionMode.Sparse, Type.Mode); | ||
data.EnsureBufferCount(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.