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

Added StringPattern and made Automaton no longer borrow the query #618

Merged
merged 4 commits into from
Dec 22, 2024

Conversation

V0ldek
Copy link
Member

@V0ldek V0ldek commented Dec 22, 2024

Short description

The Automaton struct borrowed the source query, which also caused the
Engine to carry the query's lifetime with it. The actual data being borrowed
were the JsonString values for member transitions.
In preparation for #117 we remove the borrowed JsonString and replace it
with StringPattern. For UTF-8 the StringPattern will be a more complex
struct that precomputes some stuff for efficient matching later.
For now, it's a thin wrapper over a JsonString.

During construction we may create many transitions over the same pattern.
To reduce the size of the automaton we cache the patterns and put them
into an Rc. This may get optimised later to instead use some kind of
inline storage, but it's unlikely to actually matter. I ran the benchmarks
and saw no measurable difference between the previous version and this one.

Issue

Resolves: #613

Checklist

All of these should be ticked off before you submit the PR.

  • I ran just verify locally and it succeeded.
  • Issue was given go ahead and is linked above OR I have included justification for a minor change.
  • Unit tests for my changes are included OR no functionality was changed.

After removing `gradle-wrapper.jar` from being tracked in the repo
you need to regenerate it manually when you clone the repo.
To do that, you need `gradle` actually installed and then to run `gradle wrapper`
in the correct directory. This was added to the README and to the benchmarks' `just init`.

Additionally updated the root Justfile to also perform that during `init`.
…query

The `Automaton` struct borrowed the source query, which also caused the
Engine to carry the query's lifetime with it. The actual data being borrowed
were the `JsonString` values for member transitions.
In preparation for #117 we remove the borrowed `JsonString` and replace it
with `StringPattern`. For UTF-8 the `StringPattern` will be a more complex
struct that precomputes some stuff for efficient matching later.
For now, it's a thin wrapper over a `JsonString`.

During construction we may create many transitions over the same pattern.
To reduce the size of the automaton we cache the patterns and put them
into an `Rc`. This may get optimised later to instead use some kind of
inline storage, but it's unlikely to actually matter. I ran the benchmarks
and saw no measurable difference between the previous version and this one.

Refs: #117 #613
@V0ldek V0ldek merged commit 62d336f into main Dec 22, 2024
50 checks passed
@V0ldek V0ldek deleted the v0ldek/#613-non-borrowed-string-pattern branch December 22, 2024 21:15
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.

Make Engine without lifetime.
1 participant