This repository has been archived by the owner on May 12, 2021. It is now read-only.
METRON-712: Separate evaluation from parsing in Stellar #473
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
With the current implementation of Stellar, we cannot cache the parse tree and then apply it after the fact. It's just an artifact of how we do the parsing: we actually execute the statement as we parse rather than constructing an AST that can then be evaluated later given a message. Essentially what I'm proposing is that we build the equivalent of Pattern.compile() in Java except for Stellar.
We should for multiple reasons:
In this PR, I have added a google cache that will cache the resulting compiled expression in
BaseStellarProcessor
for 10 minutes (by default). I have also created a microbenchmarking suite and have evaluated this on a few representative expressions.Results:
TO_UPPER('casey')
880.5
15
TO_LOWER(name)
497
3
1 + 2*(3 + int_num) / 10.0
676
4
1.5 + 2*(3 + double_num) / 10.0
634
1
if ('foo' in ['foo']) OR one == very_nearly_one then 'one' else 'two'
616
23
1 + 2*(3 + int_num) / 10.0
601
2
DOMAIN_TO_TLD(domain)
505
16
DOMAIN_REMOVE_SUBDOMAINS(domain)
496
11
Testing Plan
Please refer to the METRON-744 PR testing plan.
In order to streamline the review of the contribution we ask you follow these guidelines and ask you to double check
the following:
For all changes:
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommened that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.