Skip to content
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

fix: Relax comparison strictness such that integration tests pass #399

Merged
merged 16 commits into from
Apr 15, 2024

Conversation

paleolimbot
Copy link
Member

@paleolimbot paleolimbot commented Mar 13, 2024

These changes are the changes required such that apache/arrow#39302 results in passing integration tests for nanoarrow. The changes are mostly related to comparison:

  • We needed an option to allow metadata to be compared on a key/value basis without considering order (for Java, which seems to reorder metadata on read)
  • We needed the ability to treat NULL metadata and zero-size metadata as equivalent (for Go, which always exports zero-length metadata)
  • We needed an option to ignore flags for top-level batches (for C#, which exports nullable structs)
  • We needed to ensure that the last few bits of the validity buffer were zeroed (for C#, although this is now fixed in C# on Arrow main)
  • We needed to ensure that no buffers were NULL (For C#, which leaks the top-level array if it encounters one, at least in the integration tests. This should really be fixed in C#).

@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.80%. Comparing base (a9ef745) to head (aca7b00).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #399      +/-   ##
==========================================
+ Coverage   88.76%   88.80%   +0.03%     
==========================================
  Files          82       82              
  Lines       14633    14685      +52     
==========================================
+ Hits        12989    13041      +52     
  Misses       1644     1644              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@paleolimbot paleolimbot marked this pull request as ready for review April 5, 2024 00:35
ArrowStringView key, value;
while (reader.remaining_keys > 0) {
NANOARROW_RETURN_NOT_OK(ArrowMetadataReaderRead(&reader, &key, &value));
out->insert({std::string(key.data, key.size_bytes),
Copy link

Choose a reason for hiding this comment

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

Just to be sure, can we safely rule out the possibility of duplicate keys by this point?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch! I will workshop this...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok! I now check for duplicate keys, although technically the comparison will just fail if this happens. The real solution is probably to fix the Java implementation to stop reordering metadata and add test cases for this in the archery data generator.

CurtHagenlocher pushed a commit to apache/arrow that referenced this pull request Apr 7, 2024
…e Arrays (#41054)

### Rationale for this change

When implementing integration tests for nanoarrow, it was observed that C# never released arrays where `array->buffers[i]` was `NULL` (including any buffers of any recursive child arrays). This is allowed ( https://arrow.apache.org/docs/format/CDataInterface.html#c.ArrowArray.buffers ); however, every other implementation appears to allocate even for length zero buffers (including nanoarrow after apache/arrow-nanoarrow#399 ).

### What changes are included in this PR?

`AddMemory()` is replaced with `ArrowBuffer.Empty` if the length of the imported buffer would have been 0 bytes. For other buffers (or anywhere I saw dereferencing a buffer pointer), I added a `Debug.Assert` just to be sure.

### Are these changes tested?

I'm not sure what the best way to test them is! They won't be tested in the nanoarrow integration tests since at the point that they run, nanoarrow will no longer export arrays that would trigger this.

### Are there any user-facing changes?

No
* GitHub Issue: #40898

Authored-by: Dewey Dunnington <dewey@fishandwhistle.net>
Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
@paleolimbot paleolimbot merged commit 3a78aa4 into apache:main Apr 15, 2024
31 checks passed
@paleolimbot paleolimbot deleted the integration-fixes branch April 15, 2024 18:53
tolleybot pushed a commit to tmct/arrow that referenced this pull request May 2, 2024
…terface Arrays (apache#41054)

### Rationale for this change

When implementing integration tests for nanoarrow, it was observed that C# never released arrays where `array->buffers[i]` was `NULL` (including any buffers of any recursive child arrays). This is allowed ( https://arrow.apache.org/docs/format/CDataInterface.html#c.ArrowArray.buffers ); however, every other implementation appears to allocate even for length zero buffers (including nanoarrow after apache/arrow-nanoarrow#399 ).

### What changes are included in this PR?

`AddMemory()` is replaced with `ArrowBuffer.Empty` if the length of the imported buffer would have been 0 bytes. For other buffers (or anywhere I saw dereferencing a buffer pointer), I added a `Debug.Assert` just to be sure.

### Are these changes tested?

I'm not sure what the best way to test them is! They won't be tested in the nanoarrow integration tests since at the point that they run, nanoarrow will no longer export arrays that would trigger this.

### Are there any user-facing changes?

No
* GitHub Issue: apache#40898

Authored-by: Dewey Dunnington <dewey@fishandwhistle.net>
Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
@paleolimbot paleolimbot added this to the nanoarrow 0.5.0 milestone May 22, 2024
vibhatha pushed a commit to vibhatha/arrow that referenced this pull request May 25, 2024
…terface Arrays (apache#41054)

### Rationale for this change

When implementing integration tests for nanoarrow, it was observed that C# never released arrays where `array->buffers[i]` was `NULL` (including any buffers of any recursive child arrays). This is allowed ( https://arrow.apache.org/docs/format/CDataInterface.html#c.ArrowArray.buffers ); however, every other implementation appears to allocate even for length zero buffers (including nanoarrow after apache/arrow-nanoarrow#399 ).

### What changes are included in this PR?

`AddMemory()` is replaced with `ArrowBuffer.Empty` if the length of the imported buffer would have been 0 bytes. For other buffers (or anywhere I saw dereferencing a buffer pointer), I added a `Debug.Assert` just to be sure.

### Are these changes tested?

I'm not sure what the best way to test them is! They won't be tested in the nanoarrow integration tests since at the point that they run, nanoarrow will no longer export arrays that would trigger this.

### Are there any user-facing changes?

No
* GitHub Issue: apache#40898

Authored-by: Dewey Dunnington <dewey@fishandwhistle.net>
Signed-off-by: Curt Hagenlocher <curt@hagenlocher.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants