Skip to content

Commit

Permalink
[55335] Fixes maximum calculation example in tutorial
Browse files Browse the repository at this point in the history
Change-Id: I431c6b3ca96ea0650a8a84b69b54e0a0a76f862b
Signed-off-by: Zoltan Ujhelyi <[email protected]>
  • Loading branch information
ujhelyiz committed Feb 23, 2020
1 parent 6c2dee1 commit 19c88e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pattern reachableState(sm :StateMachine, state: State){
// tag::maximumNumberOfInstances[]
pattern maximumNumberOfInstances(at : ApplicationType, max : java Integer) {
max == max find sumNumberOfInstances(at, #);
find sumNumberOfInstances(applicationType, max);
}

pattern sumNumberOfInstances(at : ApplicationType, n : java Integer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ This section introduces a set of more complex queries, useful for both introduci

It is possible to find the Application Type that has the most instances defined in the model by combining a _counting_ of the values of the related feature and a _max_ function. The `sumNumberOfInstances` helper pattern uses a `count` call of the `ApplicationType.instances` feature (note the omission of the `find` keyword there). This feature is available starting with VIATRA 2.0, and allows reducing the number of trivial helper patterns, like the pattern `hostIpAddress` introduced earlier in this tutorial.

After the counts are available in the match set of a pattern, it is easy to calculate the maximum value using the `max find` construct.
After the counts are available in the match set of a pattern, it is possible to calculate the maximum value using the `max find` construct. However, it is important that calculating the maximum does not connect the ApplicationType instances to their maximum, that needs to be done with an additional constraint.

[[vql-maximumNumberOfInstances]]
[source,vql,indent=0]
Expand Down

0 comments on commit 19c88e0

Please sign in to comment.