Nancy,

   An inline eval will create a constraint in the corresponding node in the network. I.e., if it is an alpha constraint, the eval() will be added to an alpha node, or if it is a beta constraint, it will be added to the beta node.

   If it is an alpha constraint, it will be reevaluated every time the fact type changes (in your example, every time the engine is notified of a change in a User fact). If it is a beta constraint, it will be reevaluated every time the fact changes or a fact matching a previous pattern in the same rule changes.

   Evals are not indexed, so the reevaluation is a bit more costly. It is better to avoid them when possible, but sometimes it is not.

   []s
   Edson

2009/7/28 Nancy Dougherty <nancyhd@stanford.edu>
Hello!

I have a question about how an inline eval function is or isn’t
efficient in the algorithm-  I have many User objects that I am
inserting into Working Memory (in a stateful session), and each User
object has as ArrayList of Messages

The message class has 2 String fields: text and logid

I have custom boolean function user.containsText(String keyword)
function that takes in a string, and searches to see if that keyword
contained in the text field of one of the message entries in the User
message arraylist.  If I use an inline eval statement to implement
this:

$user: User( eval (containsText ( “sample text”) ) )

Will it re-evaluate each time?  Or will Drools cache the result and
remember it/ create a node based on it so the node will have every
user this is true for, and it doesn’t re-evaluate when the users or
rules are modified?  Will it create a "node" in the algorithm for all
the users that this function is true for?

On a similar note, if I use the “matches” comparator in a rule
creation, does it create a node and cache the result? Will it
automatically re-evaluate each time the field its matched against is
modified?

Thanks so much!

Nancy

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com