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

This fixes an NPE when trying to read empty JSON data by adding a new API for missing information #15307

Merged
merged 4 commits into from
Mar 15, 2024

Conversation

revans2
Copy link
Contributor

@revans2 revans2 commented Mar 14, 2024

Description

CUDF cannot create a table with rows and no columns, but that is exactly what we need to be able to read some JSON input. So this adds in a new API that lets us work around this problem if we know how many rows you expect to see. This is not an ideal solutions so it not a fix for #5712 generically. But is is a stop gap, especially for cases when we know how many rows to expect.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

… API for missing information

Signed-off-by: Robert (Bobby) Evans <bobby@apache.org>
@revans2 revans2 added 3 - Ready for Review Ready for review by team Java Affects Java cuDF API. Spark Functionality that helps Spark RAPIDS improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Mar 14, 2024
@revans2 revans2 self-assigned this Mar 14, 2024
@revans2 revans2 requested a review from a team as a code owner March 14, 2024 21:00
Comment on lines 335 to 336
private static final byte[] EMPTY_JSON_DATA_BUFFER = ("{}\n").getBytes(StandardCharsets.UTF_8);
@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Suggested change
private static final byte[] EMPTY_JSON_DATA_BUFFER = ("{}\n").getBytes(StandardCharsets.UTF_8);
@Test
private static final byte[] EMPTY_JSON_DATA_BUFFER = ("{}\n").getBytes(StandardCharsets.UTF_8);
@Test

Comment on lines 358 to 360
private static final byte[] EMPTY_ARRAY_JSON_DATA_BUFFER =
("{'a':[]}\n").getBytes(StandardCharsets.UTF_8);
@Test
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
private static final byte[] EMPTY_ARRAY_JSON_DATA_BUFFER =
("{'a':[]}\n").getBytes(StandardCharsets.UTF_8);
@Test
private static final byte[] EMPTY_ARRAY_JSON_DATA_BUFFER =
("{'a':[]}\n").getBytes(StandardCharsets.UTF_8);
@Test

* @param buffer raw UTF8 formatted bytes.
* @param offset the starting offset into buffer.
* @param len the number of bytes to parse.
* @param emptyRowCount the number of rows to use if no columns were found.
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if there might be a better name for this. Under the circumstances, emptyRowCount is really the best name for this parameter.

@revans2
Copy link
Contributor Author

revans2 commented Mar 15, 2024

/merge

@rapids-bot rapids-bot bot merged commit 610c022 into rapidsai:branch-24.04 Mar 15, 2024
75 checks passed
@revans2 revans2 deleted the fix_jni_json_npe branch March 15, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team improvement Improvement / enhancement to an existing function Java Affects Java cuDF API. non-breaking Non-breaking change Spark Functionality that helps Spark RAPIDS
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants