Skip to content

GH-40870: [C#] Update CompareValidityBuffer() to pass when unspecified final bits are not identical#40873

Merged
paleolimbot merged 4 commits intoapache:mainfrom
paleolimbot:csharp-validity-compare
Mar 28, 2024
Merged

GH-40870: [C#] Update CompareValidityBuffer() to pass when unspecified final bits are not identical#40873
paleolimbot merged 4 commits intoapache:mainfrom
paleolimbot:csharp-validity-compare

Conversation

@paleolimbot
Copy link
Copy Markdown
Member

@paleolimbot paleolimbot commented Mar 28, 2024

Rationale for this change

Before fixing nanoarrow's testing JSON reader to align with other implementations and properly zero out the last few bits, integration tests failed because C#'s CompareValidityBuffer() was comparing the bytes of the validity buffer (including undefined final bits that are maybe not identical due to uninitialized memory or because the arrays are slices).

What changes are included in this PR?

CompareValidityBuffer() now compares the memory for all except the last byte and compares the last byte bitwise.

Are these changes tested?

They should be but I am not sure exactly where to add the test!

Are there any user-facing changes?

No

@github-actions
Copy link
Copy Markdown

⚠️ GitHub issue #40870 has been automatically assigned in GitHub to PR creator.

else if (nullCount != 0 && arrayLength > 0)
{
int validityBitmapByteCount = BitUtility.ByteCount(arrayLength);
ReadOnlySpan<byte> expectedSpan = expectedValidityBuffer.Span.Slice(0, validityBitmapByteCount);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be validityBitmapByteCount - 1?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 (this is the first C# I've ever attempted!)

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Mar 28, 2024
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Mar 28, 2024
@paleolimbot paleolimbot merged commit 683a78b into apache:main Mar 28, 2024
@paleolimbot paleolimbot removed the awaiting change review Awaiting change review label Mar 28, 2024
@paleolimbot paleolimbot deleted the csharp-validity-compare branch March 28, 2024 19:11
@conbench-apache-arrow
Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 683a78b.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

vibhatha pushed a commit to vibhatha/arrow that referenced this pull request May 25, 2024
…ecified final bits are not identical (apache#40873)

### Rationale for this change

Before fixing nanoarrow's testing JSON reader to align with other implementations and properly zero out the last few bits, integration tests failed because C#'s `CompareValidityBuffer()` was comparing the bytes of the validity buffer (including undefined final bits that are maybe not identical due to uninitialized memory or because the arrays are slices).

### What changes are included in this PR?

`CompareValidityBuffer()` now compares the memory for all except the last byte and compares the last byte bitwise.

### Are these changes tested?

They should be but I am not sure exactly where to add the test!

### Are there any user-facing changes?

No
* GitHub Issue: apache#40870

Authored-by: Dewey Dunnington <dewey@fishandwhistle.net>
Signed-off-by: Dewey Dunnington <dewey@voltrondata.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants