-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-36795: [C#] Implement support for dense and sparse unions #36797
Merged
Merged
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
dc253c7
Initial changes for Union support
CurtHagenlocher 1bb1417
Union-related fixes
CurtHagenlocher 56df33a
Merge branch 'apache:main' into Union
CurtHagenlocher 6b3ff65
Fixed IPC to work correctly for unions
CurtHagenlocher 01eb95b
Merge branch 'Union' of https://github.com/CurtHagenlocher/arrow into…
CurtHagenlocher c576eca
Implement Archery support for C# unions
CurtHagenlocher a113a80
Better backwards compatibility
CurtHagenlocher bfc26ee
Merge branch 'main' of https://github.com/apache/arrow into Union
CurtHagenlocher 2bd6f3d
Merge branch 'main' of https://github.com/apache/arrow into Union
CurtHagenlocher f892aba
Merge from main
CurtHagenlocher b77d04c
Merge from main and resolve conflicts
CurtHagenlocher 039ec9e
Fix deserialization of fixed-size list
CurtHagenlocher 0327be2
Fix bug in ctor
CurtHagenlocher 832f7cb
PR feedback
CurtHagenlocher 6591b81
Merge branch 'main' of https://github.com/CurtHagenlocher/arrow into …
CurtHagenlocher 0de1117
Merge from main
CurtHagenlocher a29e1c1
Merge branch 'main' of https://github.com/CurtHagenlocher/arrow into …
CurtHagenlocher 5ebefcf
Increment metadata version to V5 and add handling for V4 unions.
CurtHagenlocher ddac4d3
Merge branch 'main' into Union
CurtHagenlocher 143a469
Correctly skip buffer in pre-V5 metadata
CurtHagenlocher 3ef09de
Merge branch 'Union' of https://github.com/CurtHagenlocher/arrow into…
CurtHagenlocher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); // TODO: | ||
} | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe link this TODO to a new issue? (and what is the TODO about, given SparseUnionArray lacks one?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heck if I can remember... . Will just remove the TODO.