[
https://issues.apache.org/jira/browse/UNOMI-188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Serge Huber updated UNOMI-188:
------------------------------
Fix Version/s: (was: 1.5.0)
2.0.0
> Optimize rule engine by associating rules with event types directly
> -------------------------------------------------------------------
>
> Key: UNOMI-188
> URL: https://issues.apache.org/jira/browse/UNOMI-188
> Project: Apache Unomi
> Issue Type: Sub-task
> Components: core
> Affects Versions: 1.3.0-incubating
> Reporter: Romain Gauthier
> Priority: Major
> Fix For: 2.0.0
>
>
> Hello,
> Here is an improvement that we identified:
> When analyzing the performance of Apache Unomi, we noticed that the
> executions of the condition evaluators to determine if a rule should be
> executed for a particular event were being called million of times.
> A way to avoid all these condition calls, and since each rule is always
> related to an event processing, we could simply associated a rule with an
> eventTypeId or multiple types (if they correspond to multiple types).
> We will also need to handle the migration of existing rules to use this,
> which will require analyzing the existing conditions to extract the
> conditions that match with a specific event type.
> For example a rule such as :
> {code:java}
> {
> "metadata": {
> "id": "_ynqbd6g4t_incrementInterests",
> "name": "Increment profile interests",
> "description": "Evaluate segments when a profile is modified"
> },
> "raiseEventOnlyOnceForSession": true,
> "condition": {
> "parameterValues": {
> "subConditions": [
> {
> "type": "pageViewEventCondition",
> "parameterValues": {
> }
> },
> {
> "type": "eventPropertyCondition",
> "parameterValues": {
> "propertyName": "target.properties.interests",
> "comparisonOperator": "exists"
> }
> }
> ],
> "operator": "and"
> },
> "type": "booleanCondition"
> },
> "actions": [
> {
> "parameterValues": {
> "setPropertyName": "properties.interests",
> "setPropertyValue": "script::r = profile.properties['interests'];
> foreach(interest : event.target.properties['interests'].entrySet()) { if (r
> == null) { r = [interest.key: interest.value] } else if (r[interest.key] !=
> null) { r[interest.key] = r[interest.key] + interest.value } else {
> r[interest.key] = interest.value } } r",
> "storeInSession": false
> },
> "type": "setPropertyAction"
> }
> ]
> }
> {code}
> Would become :
> {code:java}
> {
> "metadata": {
> "id": "_ynqbd6g4t_incrementInterests",
> "name": "Increment profile interests",
> "description": "Evaluate segments when a profile is modified"
> },
> "raiseEventOnlyOnceForSession": true,
> *"eventTypes" : [ "view" ]*
> "condition": {
> "parameterValues": {
> "subConditions": [
> {
> "type": "eventPropertyCondition",
> "parameterValues": {
> "propertyName": "target.properties.interests",
> "comparisonOperator": "exists"
> }
> }
> ],
> "operator": "and"
> },
> "type": "booleanCondition"
> },
> "actions": [
> {
> "parameterValues": {
> "setPropertyName": "properties.interests",
> "setPropertyValue": "script::r = profile.properties['interests'];
> foreach(interest : event.target.properties['interests'].entrySet()) { if (r
> == null) { r = [interest.key: interest.value] } else if (r[interest.key] !=
> null) { r[interest.key] = r[interest.key] + interest.value } else {
> r[interest.key] = interest.value } } r",
> "storeInSession": false
> },
> "type": "setPropertyAction"
> }
> ]
> }
> {code}
> In the above example we have replaced the pageViewEventCondition with the
> restrictions on the "view" eventTypeId.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)