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

Make Engine without lifetime. #613

Closed
azoyan opened this issue Dec 20, 2024 · 4 comments · Fixed by #618
Closed

Make Engine without lifetime. #613

azoyan opened this issue Dec 20, 2024 · 4 comments · Fixed by #618
Assignees
Labels
area: library Improvements to the library API quality type: feature New feature or request
Milestone

Comments

@azoyan
Copy link
Contributor

azoyan commented Dec 20, 2024

I need to store compiled once engines in struct

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct RateLimitBodyJsonPath {
    pub engines: Vec<RsonpathEngine>,
}

but engine should keep reference with lifetime to query.

Is it possbile to make special Engine that pass query by value once and compile it to engine, and then use just engine to handle incoming json?

@azoyan azoyan added the type: feature New feature or request label Dec 20, 2024
@github-actions github-actions bot added the acceptance: triage Waiting for owner's input label Dec 20, 2024
Copy link

Tagging @V0ldek for notifications

@V0ldek
Copy link
Member

V0ldek commented Dec 20, 2024

A version of this is actually on my branch for #117 UTF-8 support which is still WIP. I'll try to upstream just the lifetime change sooner without the full #117 feature.

@V0ldek V0ldek added this to the lib v1.0.0 milestone Dec 20, 2024
@github-actions github-actions bot added acceptance: go ahead Reviewed, implementation can start and removed acceptance: triage Waiting for owner's input labels Dec 20, 2024
@V0ldek V0ldek added the area: library Improvements to the library API quality label Dec 20, 2024
V0ldek added a commit that referenced this issue Dec 22, 2024
…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 added a commit that referenced this issue Dec 22, 2024
…g-pattern

Added StringPattern and made Automaton no longer borrow the query
@github-actions github-actions bot removed the acceptance: go ahead Reviewed, implementation can start label Dec 22, 2024
@V0ldek V0ldek moved this from Todo to Merged in Active rq development Dec 22, 2024
@V0ldek V0ldek self-assigned this Dec 22, 2024
@V0ldek V0ldek moved this from Merged to Released in Active rq development Dec 23, 2024
@V0ldek
Copy link
Member

V0ldek commented Dec 23, 2024

This is released in v0.9.2, RsonpathEngine is now lifetimeless.

@azoyan
Copy link
Contributor Author

azoyan commented Dec 23, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: library Improvements to the library API quality type: feature New feature or request
Projects
Status: Released
Development

Successfully merging a pull request may close this issue.

2 participants