Optimizing BizVR Collection Processing Using Pattern Matching and Iteration - Gnorion/BizVR GitHub Wiki
Optimizing BizVR Collection Processing
Iteration may be used when the actions of the rules do none of the following
- modify a variable that is tested in the conditions
- delete an item from collection currently being processed
- add an item to the collection currently being processed
Otherwise, pattern matching is probably necessary
Single Collection
In the rulesheet
{x in COLLECTION}
if x.age>18 then x.eligible=true
Implementated in Aion
var X is &COLLECTION
for COLLECTION,x
if x.age>18 then x.eligible=true end
end
Two Independent Collections
In the rulesheet
{x in COLLECTION}
if x.age>18 then x.eligible=true
{item in CART}
if item.type=’fresh’ then item.tax=0
Implementated in Aion
var X is &COLLECTION
for COLLECTION,x
if x.age>18 then x.eligible=true end
end
var item is &CART
for CART,item
If item.type=’fresh’ then item.tax=0 end
end
One Collection two bind variables (Cartesian product)
Where DIGIT={1,2,3,4,5}
{x,y in DIGIT}
If x>3 and y<x then message
var x,y is &DIGIT
for DIGIT,x // the independent loop
if x>3 then // condition that applies only to x
for DIGIT, y // the dependent loop
if y<x then message end // condition that applies to y and x
end
end
end
- Every bind variable becomes a loop
- Multiple bindings in one statement will become nested loops
- The order of the loops will be determined as follows
- Any bind variables with no constraints can come first
- Each new loop added should be immediately followed by all the conditions it’s tested against (as long as the bind vars are available in the higher loops)
- if they aren’t then we have to wait until after the appropriate bind loop has been added
- If “distinct “ was specified then we need to add the extra conditions for distinctness
- Breakif stop condition needs to be added unless the user wants to process all bindings
Something along these lines anyway.