Skip to content

Add JNI for strings::code_points - #14533

Merged
rapids-bot[bot] merged 5 commits into
NVIDIA:branch-24.02from
thirtiseven:code_points_jni
Dec 12, 2023
Merged

Add JNI for strings::code_points#14533
rapids-bot[bot] merged 5 commits into
NVIDIA:branch-24.02from
thirtiseven:code_points_jni

Conversation

@thirtiseven

Copy link
Copy Markdown
Contributor

Description

This implements JNI work for strings::code_points to expose the API to Java usage.

It will be useful for NVIDIA/cudf-spark#9585

Checklist

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

Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
@thirtiseven
thirtiseven requested a review from a team as a code owner November 30, 2023 09:34
@copy-pr-bot

copy-pr-bot Bot commented Nov 30, 2023

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the Java Affects Java cuDF API. label Nov 30, 2023
@davidwendt davidwendt added 3 - Ready for Review Ready for review by team improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Nov 30, 2023
@davidwendt

Copy link
Copy Markdown
Contributor

/ok to test

Comment thread java/src/main/native/src/ColumnViewJni.cpp Outdated

@jlowe jlowe left a comment

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.

Not very excited to add this API since it seems problematic to use in general. However it can be useful for a very specific case (once we pre-process input accordingly for it).

}

/**
* Get the code point values (integers) for each character of each string.

@jlowe jlowe Nov 30, 2023

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.

This API seems very problematic in light of the effort to move to large strings. A strings column will soon support more than 2^31 characters. Calling this API on such a column will crash since it cannot manifest an INT32 column with more than 2^31 entries.

It also seems problematic from a usability point of view. Since it returns only a column of INT32 instead of LIST(INT32), it's not straightforward to figure out where the code points of one string stops and another starts. We can't use the offset column of the original string, since that's byte offsets instead of character offsets. I guess one would need to get the character lengths of the original string (converting nulls to zereoes) and then do a prefix scan to compute the code point offsets to know where one string's codepoints are in the result.

It also seems very wasteful for what NVIDIA/cudf-spark#9585 needs if called directly, since it will explode the memory of many string columns by 4X. We should first slice the original string column to only select the first character of each string. That would work around the large strings issue, the "where does a string start" issue, as well as the waste, since we only need the codepoint of the first character for that Spark feature.

@thirtiseven thirtiseven Dec 1, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review and analysis! I'm trying the 'only select the first character' way in the plugin.

Another problem with the spark issue is that the results of Latin-1 Supplement chars are mismatched between spark and code_points. For example é is 50089 for code_points and utf-8, and 233 for spark and Unicode (and Latin-1 and utf-16?), I'm trying to work around it but it is possible that we need a custom kernel for ascii.

thirtiseven and others added 2 commits December 1, 2023 17:51
@res-life

Copy link
Copy Markdown
Contributor

/merge

@res-life

Copy link
Copy Markdown
Contributor

/ok to test

Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
@res-life

Copy link
Copy Markdown
Contributor

/ok to test

@rapids-bot
rapids-bot Bot merged commit f8e891f into NVIDIA:branch-24.02 Dec 12, 2023
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants