Repository navigation
Java/Janino scripting to replace our interpreter leading to a breaking change of the format #2209
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
Merged
Merged
Changes from all commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
70f3782
basic test with janino passing
karussell 9bf6769
move janino scripting to safe whitelisted approach
karussell 963bcf6
create a class to add encoded values on the fly but limit user input …
karussell bf34c24
compilation unit via overwriting getValue method safely
karussell 3a3779d
minor fix regarding ClassName
karussell 1b18556
ensure it is not called twice
karussell 0948867
separate parsing of condition and number
karussell 6932968
CustomWeighting: ensure Map is ordered (#2162)
karussell 234d210
change expression from factor multiplication to if-then-elseif-else a…
karussell 2f73987
replace catch all with true and make max_speed working
karussell 758eed9
no need to parse value which is always a number
karussell 7228769
use global max speed
karussell a3eb59c
minor cleanup and fix regarding sharedEV
karussell 6c2f77b
found a way to avoid Unparser.unparse
karussell 2b1ec2e
use scripting in CustomWeighting. This revealed: we need if and if-el…
karussell 77f66bc
reduce max speed and fix priority bug
karussell 52fede2
cosmetics
karussell 4af26d6
merged master
karussell 1463e46
minor truck.yml tweaks
karussell 120aa7c
adapt benchmarks
karussell 975f21e
a bit more details in exception
karussell 0ba0f59
see perf with ugly caching hack
karussell 5c9ac65
revert and see bench
karussell 56c2624
workaround bug with import conflict (two imports for enum 'NO')
karussell f544113
inject class for constants, avoid static imports that can easily collide
karussell 802152a
special case of RouteNetwork for bike
karussell 247204e
introduce thread-safe caching; minor restructuring
karussell d32b56f
reduce code duplication in ScriptHelper
karussell d532e32
move code out of ScriptHelper and rename it to ExpressionBuilder
karussell 09b1c8c
merged master
karussell 648a03e
less recursion for more clear protection
karussell 55e6fd5
further cleanup and improved naming
karussell d2e1b75
adapt CustomModel.merge to scripting and throw exception if query-Cus…
karussell d0b8087
improved docs about custom model
karussell e8d69b2
adapted docs to new format
karussell 2ea7f15
removed CustomWeightingOld and all related classes
karussell 2b65279
minor fixes
karussell e634545
make debugging possible; every dynamic class has a different name now…
karussell 83a4758
improve caching: remove oldest accessed entry, instead oldest inserted
karussell 79e15b0
introduce cache to keep certain classes in cache forever
karussell 85c9743
try perf with disabled cache to see CH numbers again
karussell 1744afd
Revert "try perf with disabled cache to see CH numbers again"
karussell df9eff6
merged master
karussell 7dbca99
make it possible to disable dyn cache; clarify about the static cache…
karussell 2998c87
allow multiple first_match and make names of encoded values even stri…
karussell 5a72244
non-shared EncodedValue is too complex due to '.' we should use '$' o…
karussell f40e284
merged master
karussell ea97c53
merged master
karussell 564f342
use non-shared encoded values
karussell 5cb073c
test again without cache
karussell dc4268a
call in-area method only when necessary, improves speed where pre-con…
karussell 8d2e9ee
make area names stricter
karussell f4478bb
already consider parts of the pull request reviews
karussell 591317a
Custom weighting helper cleanup (#2211)
easbar 3762a59
More fine-grained usage of try statement
easbar 49d51ae
revert DEFAULT to true
karussell 63bd616
docs: remove confusing statement
karussell e2d74dc
better name for subclass
karussell 449278b
no need for the extra line in test
karussell 7bf5b21
simple max_speed_fallback handling, still explicit
karussell c40d078
Merge branch 'master' into janino_scripting
karussell 69db7b3
migrate to if-then notation
karussell 97d6be5
fix benchmarks for if-then notation
karussell 0c2eecc
made Clause methods shorter
karussell 2f087cc
introduce different Op
karussell 66bbb9c
merge speed_factor and max_speed into speed via introduced 'multiply …
karussell 43bab56
further simplify custom model: remove max_speed_fallback
karussell 3185010
bug fix
karussell d880afc
docs: adapt to know notation
karussell b8425bd
multiply with -> by
karussell c3fa7c8
minor cleanup
karussell 0f75328
Merge branch 'master' into janino_scripting
karussell 576f2f1
support for StringEncodedValue
karussell 52ca223
UI fixes for new format; make isSharedEncodedValues method private again
karussell 01582a4
bug fix for findMaxSpeed calculation
karussell 3708c22
test perf: disable cache for comparison
karussell 1d90439
test perf: again
karussell bd92b3c
enable cache to permanently store internal Weighting classes
karussell 6bb9fd0
uhm, test perf: without cache but push separately
karussell e8ee463
Revert "uhm, test perf: without cache but push separately"
karussell ac46dad
minor improvements
karussell e7725ca
removed SpeedAndAccessProvider
karussell 1cbfb01
make sure that the internal cache will never be too big
karussell 9759c41
fix package of JaninoCustomWeightingHelperSubclass
karussell a5a497c
rename ExpressionBuilder to CustomModelParser
karussell 46b4c94
made CustomModelParser parser public and move create method to it fro…
karussell f1cc5ec
comment regarding internal cache method
karussell b7fef8b
create -> createWeighting
karussell e090791
move CustomModel to different package to hide useInternalCache methods
karussell 17f764e
merged master
karussell ca6b736
limit size of the whole script, not single expressions
karussell 8c1b25e
Merge branch 'master' into janino_scripting
easbar 4e35826
Rename CustomModelParser#create etc.
easbar a4324f5
Merge branch 'master' into janino_scripting
easbar ee7461e
minor
easbar 30d9cdc
rename internal and throw exception if found in query
karussell 2812d7c
fix contentString
karussell 5cd2762
Improve profiles.md
easbar 0aff1e1
Fix road_surface->surface and else: "" -> else: null
easbar a6853d0
Explain how to use else statement in JSON
easbar b81b1cf
Fix GH maps example
easbar e1cd19d
Warn instead of error in case the edge distance of very long edges di…
easbar 3352262
rename
karussell d6552b2
error message e.g. in case of encoded value wasn't added
karussell c113442
distanceInfluence: use default value only if not initialized
karussell f2292d3
Merge branch 'master' into janino_scripting
karussell 5c2d670
less cryptic error message
karussell 0a0a1db
Merge branch 'master' into janino_scripting
karussell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * Licensed to GraphHopper GmbH under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with this work for | ||
| * additional information regarding copyright ownership. | ||
| * | ||
| * GraphHopper GmbH licenses this file to you under the Apache License, | ||
| * Version 2.0 (the "License"); you may not use this file except in | ||
| * compliance with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.graphhopper.json; | ||
|
|
||
| public class Statement { | ||
| private final Keyword keyword; | ||
| private final String expression; | ||
| private final Op operation; | ||
| private final double value; | ||
|
|
||
| private Statement(Keyword keyword, String expression, Op operation, double value) { | ||
| this.keyword = keyword; | ||
| this.expression = expression; | ||
| this.value = value; | ||
| this.operation = operation; | ||
| } | ||
|
|
||
| public Keyword getKeyword() { | ||
| return keyword; | ||
| } | ||
|
|
||
| public String getExpression() { | ||
| return expression; | ||
| } | ||
|
|
||
| public Op getOperation() { | ||
| return operation; | ||
| } | ||
|
|
||
| public double getValue() { | ||
| return value; | ||
| } | ||
|
|
||
| public enum Keyword { | ||
| IF("if"), ELSEIF("else if"), ELSE("else"); | ||
|
|
||
| String name; | ||
|
|
||
| Keyword(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
| } | ||
|
|
||
| public enum Op { | ||
| MULTIPLY("multiply by"), LIMIT("limit to"); | ||
|
|
||
| String name; | ||
|
|
||
| Op(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public String build(double value) { | ||
| switch (this) { | ||
| case MULTIPLY: | ||
| return "value *= " + value; | ||
| case LIMIT: | ||
| return "value = Math.min(value," + value + ")"; | ||
| default: | ||
| throw new IllegalArgumentException(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return keyword.getName() + ": " + expression + ", " + operation.getName() + ": " + value; | ||
| } | ||
|
|
||
| public static Statement If(String expression, Op op, double value) { | ||
| return new Statement(Keyword.IF, expression, op, value); | ||
| } | ||
|
|
||
| public static Statement ElseIf(String expression, Op op, double value) { | ||
| return new Statement(Keyword.ELSEIF, expression, op, value); | ||
| } | ||
|
|
||
| public static Statement Else(Op op, double value) { | ||
| return new Statement(Keyword.ELSE, null, op, value); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.