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

Add precise start and end offset byte values for Pattern #134

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

dabico
Copy link
Member

@dabico dabico commented Feb 14, 2024

This PR introduces the ability to determine the exact location of a Pattern within a Query. For this to work properly, all user-submitted queries have to be normalized to a minimal, but human-readable format.

We were already extracting this information when building out `Query`
instances, but for some reason, we did not include it in the `Pattern`
objects that we constructed. This is no longer the case, and the same
objects now clearly state the starting offset with respect to the
`Query` they reside in.
It's not possible to set the field value because we copy all pattern
characters (extra trailing whitespaces included) into the `Pattern` that
we are constructing. To get around this, we can simply `trim` the value
passed from the JNI when constructing the object. Then we can use the
total string length of the value to calculate the end offset.
This still allows for a great deal of flexibility on the user end while
still normalizing the resulting query `Pattern` values in a consistent
(minimal, but legible) format.
Add new parametrized test, and extend `BaseTest` directly
@dabico dabico merged commit 64b872c into master Feb 14, 2024
2 checks passed
@dabico dabico deleted the feature/offset branch February 14, 2024 20:13
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.

1 participant