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

feat: Add C Data integration test shared library #337

Merged
merged 17 commits into from
Dec 19, 2023

Conversation

paleolimbot
Copy link
Member

@paleolimbot paleolimbot commented Dec 13, 2023

This PR adds the shared library target required by the archery integration tetster, based on https://github.com/apache/arrow/blob/main/cpp/src/arrow/integration/c_data_integration_internal.cc .

I haven't tested this via archery because I have no idea how to do so (the implementation names and file locations seem hard-coded?); however, it does add a googletest file with some minimal examples to at least make sure everything is wired up.

@codecov-commenter
Copy link

codecov-commenter commented Dec 13, 2023

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (ef92588) 88.04% compared to head (ee1f9ce) 88.12%.
Report is 1 commits behind head on main.

Files Patch % Lines
src/nanoarrow/integration/c_data_integration.cc 93.91% 7 Missing ⚠️
src/nanoarrow/nanoarrow_testing.hpp 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
+ Coverage   88.04%   88.12%   +0.07%     
==========================================
  Files          72       73       +1     
  Lines       11370    11509     +139     
==========================================
+ Hits        10011    10142     +131     
- Misses       1359     1367       +8     

☔ 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 December 14, 2023 15:29
@paleolimbot paleolimbot requested a review from pitrou December 15, 2023 13:31
@pitrou
Copy link
Member

pitrou commented Dec 18, 2023

I haven't tested this via archery because I have no idea how to do so (the implementation names and file locations seem hard-coded?)

I think you can take a look at what we do for Rust, since it's a similar case of a non-monorepo implementation:
https://github.com/apache/arrow/blob/main/dev/archery/archery/integration/tester_rust.py

(in short: locations can be influenced with an environment variable)


const char* nanoarrow_CDataIntegration_ExportSchemaFromJson(const char* json_path,
ArrowSchema* out) {
ArrowErrorInit(&global_error);
Copy link
Member

Choose a reason for hiding this comment

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

Does this deallocate a previously-initialized error message?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't (it is basically global_error.message[0] = '\0';). The C++ implementation seems to use static std::string which I think is similar?

Copy link
Member

Choose a reason for hiding this comment

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

But does making an error message allocate its storage dynamically?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't (the global error here is a static ArrowError, aka static char[1024]).

static ArrowErrorCode ExportBatchFromJson(const char* json_path, int num_batch,
ArrowArray* out, ArrowError* error) {
MaterializedArrayStream data;
NANOARROW_RETURN_NOT_OK(MaterializeJsonFilePath(json_path, &data, error));
Copy link
Member

Choose a reason for hiding this comment

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

Not very important, but ideally we'd only parse JSON batch num_batch, instead of parsing them all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call! This makes sense (particularly after adding the tracking for bytes allocated).

@paleolimbot paleolimbot merged commit 12be163 into apache:main Dec 19, 2023
27 checks passed
@paleolimbot paleolimbot deleted the integration-test-lib branch December 19, 2023 14:14
@paleolimbot paleolimbot added this to the nanoarrow 0.4.0 milestone Jan 26, 2024
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