Sessions are cheap to create.
The problem of removing all the facts and then insert new ones is that
depending on you rules, could be much more expensive than throw the old
session and create a new one. And you should also think about globals as
well. Removing a Fact is not just taking it off from a list. There is a lot
of logic involved there.
Is like if you have a populated List and you want to remove all its items
and fill it with new ones (from another List for example).
What would you use?
originalList.clear();
originalList.addAll(anotherList);
or
originalList = new ArrayList(anotherList);
Best Regards,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
- Developer @
http://www.plugtree.com
- Blog @
http://ilesteban.wordpress.com
On Thu, Jan 27, 2011 at 5:45 AM, hyjshanghai <hyjshanghai(a)gmail.com> wrote:
According to Section 3.3.7 "StatelessKnowledgeSession" of
http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/ht...
the Drools document , "the act of calling execute() is a single-shot method
that will internally instantiate a StatefulKnowledgeSession".
Why StatelessKnowledgeSession instantiates a new statefulKnowledgeSession
object on Each execute()?
Instead, can it be implemented as inserting the fact into an existing empty
statefulKnowledgeSession, and retract the fact after
statefulKnowledgeSession.fireAllRules()?
I think the current implementation will cause StatelessKnowledgeSession to
be slower than statefulKnowledgeSession, as opposed to "common sense" that
the former is less complex and should be faster. Any performance benchmark
on Stateless v.s. Stateful Sessions?
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Why-StatelessKnowledg...
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users